From: Chris Duncan Date: Thu, 7 Aug 2025 18:36:45 +0000 (-0700) Subject: Allow number type for balance. X-Git-Tag: v0.10.5~43^2~57 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=6a257db4b60338f9e52d517d974e31063a64377a;p=libnemo.git Allow number type for balance. --- diff --git a/src/lib/block.ts b/src/lib/block.ts index 45de7a3..797b302 100644 --- a/src/lib/block.ts +++ b/src/lib/block.ts @@ -71,7 +71,7 @@ export class Block { signature?: string work?: string - constructor (account: string | Account, balance?: bigint | string, previous?: string, representative?: string | Account, signature?: string) + constructor (account: string | Account, balance?: bigint | number | string, previous?: string, representative?: string | Account, signature?: string) constructor (account: unknown, balance: unknown, previous: unknown, representative: unknown, signature: unknown) { try { if (typeof account === 'string') { @@ -86,7 +86,7 @@ export class Block { balance ??= account.balance previous ??= account.frontier representative ??= account.representative - if (typeof balance !== 'bigint' && typeof balance !== 'string') { + if (typeof balance !== 'bigint' && typeof balance !== 'number' && typeof balance !== 'string') { throw new TypeError('Account balance is unknown') } if (typeof previous !== 'string') {