]> git.codecow.com Git - libnemo.git/commitdiff
Allow number type for balance.
authorChris Duncan <chris@zoso.dev>
Thu, 7 Aug 2025 18:36:45 +0000 (11:36 -0700)
committerChris Duncan <chris@zoso.dev>
Thu, 7 Aug 2025 18:36:45 +0000 (11:36 -0700)
src/lib/block.ts

index 45de7a317e3a351e17c646f73eb20c927b454583..797b30220c9d7ab17b6443332770ffc519b8d58f 100644 (file)
@@ -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') {