import { Account } from '.'
import { Block } from '../block'
-import { SCHEMA } from '../constants'
-import { Rpc } from '../rpc'
+import { Rpc, Schema } from '../rpc'
export async function _refresh (account: Account, rpc: Rpc | string | URL): Promise<void>
export async function _refresh (account: Account, rpc: unknown): Promise<void> {
throw new Error('Account not found')
}
for (const [k, v] of Object.entries(accountInfo)) {
- if (SCHEMA.account_info.fields.includes(k) && typeof v === 'string') {
+ if (Schema.account_info.fields.includes(k) && typeof v === 'string') {
account[k] = v
}
}
}
const confirmedFrontierContents: Record<string, string> = {}
for (const [k, v] of Object.entries(resConfirmedFrontierBlockInfo.contents)) {
- if (SCHEMA.block_info.contents.fields.includes(k) && typeof v === 'string') {
+ if (Schema.block_info.contents.fields.includes(k) && typeof v === 'string') {
confirmedFrontierContents[k] = v
}
}
}
const frontierContents: Record<string, string> = {}
for (const [k, v] of Object.entries(resFrontierBlockInfo.contents)) {
- if (SCHEMA.block_info.contents.fields.includes(k) && typeof v === 'string') {
+ if (Schema.block_info.contents.fields.includes(k) && typeof v === 'string') {
frontierContents[k] = v
}
}
block.subtype = 'receive'
unit ??= 'RAW'
- if (typeof unit !== 'string' || typeof UNITS[unit] !== 'number') {
+ if (typeof unit !== 'string' || typeof UNITS[unit as keyof typeof UNITS] !== 'number') {
throw new TypeError('Invalid unit')
}
block.subtype = 'send'
unit ??= 'RAW'
- if (typeof unit !== 'string' || typeof UNITS[unit] !== 'number') {
+ if (typeof unit !== 'string' || typeof UNITS[unit as keyof typeof UNITS] !== 'number') {
throw new TypeError('Invalid unit', { cause: unit })
}
import { Block } from '../block'
import { BIP44_COIN_NANO, BIP44_PURPOSE, HARDENED_OFFSET } from '../constants'
import { dec } from '../convert'
-import { Rpc } from '../rpc'
-import { SCHEMA } from '../rpc/schema'
+import { Rpc, Schema } from '../rpc'
import { _account } from './account'
import { _cache } from './cache'
import { _close } from './close'
}
const contents = {} as Record<string, string>
for (const [k, v] of Object.entries(blockInfo.contents)) {
- if (SCHEMA.block_info.fields.includes(k)) {
+ if (Schema.block_info.fields.includes(k)) {
contents[k] = v
}
}
//! SPDX-FileCopyrightText: 2025 Chris Duncan <chris@codecow.com>
//! SPDX-License-Identifier: GPL-3.0-or-later
-import { SCHEMA } from './schema'
+import { Schema } from './schema'
+
+export { Schema }
/**
* Represents a Nano network node. It primarily consists of a URL which will
if (!/^[A-Za-z]+(_[A-Za-z]+)*$/.test(action)) {
throw new TypeError('RPC action contains invalid characters')
}
- if (!(action in SCHEMA)) {
+ if (!(action in Schema)) {
throw new TypeError('Unknown RPC action')
}
}
import { account_info } from './account_info'
import { block_info } from './block_info'
-export const SCHEMA = Object.freeze({
+export const Schema = Object.freeze({
account_info,
block_info,
})