]> git.codecow.com Git - libnemo.git/commitdiff
Fix sign calls when refreshing accounts. Remove unused account index variables.
authorChris Duncan <chris@zoso.dev>
Fri, 1 May 2026 05:02:50 +0000 (22:02 -0700)
committerChris Duncan <chris@zoso.dev>
Fri, 1 May 2026 05:02:50 +0000 (22:02 -0700)
src/lib/account/refresh.ts
src/lib/wallet/refresh.ts
src/lib/wallet/unopened.ts
test/test.ledger.mjs

index 6fd7a98a28e4bd61649be5374fd2c9fbcd0cc11f..c87e76725b6839a887b3f48ea28c4c0c272e22f3 100644 (file)
@@ -35,7 +35,7 @@ export async function _refresh (account: Account, rpc: unknown): Promise<void> {
        if (typeof confirmedFrontierBlock[confirmedFrontierSubtype] !== 'function') {
                throw new TypeError('Unknown subtype of confirmed frontier block', { cause: confirmedFrontierSubtype })
        }
-       confirmedFrontierBlock[confirmedFrontierSubtype](confirmedFrontierContents.link, 0).sign(confirmedFrontierContents.signature)
+       confirmedFrontierBlock[confirmedFrontierSubtype](confirmedFrontierContents.link, 0).signature = confirmedFrontierContents.signature
        account.confirmed_frontier_block = confirmedFrontierBlock
 
        const reqFrontier = {
@@ -47,6 +47,6 @@ export async function _refresh (account: Account, rpc: unknown): Promise<void> {
        if (typeof frontierBlock[frontierSubtype] !== 'function') {
                throw new TypeError('Unknown subtype of frontier block', { cause: frontierSubtype })
        }
-       frontierBlock[frontierSubtype](frontierContents.link, 0).sign(frontierContents.signature)
+       frontierBlock[frontierSubtype](frontierContents.link, 0).signature = frontierContents.signature
        account.frontier_block = frontierBlock
 }
index f154e506e930c1e1b0012fcf3236649479702f74..13308f4e56963048a80faaff7956432607c286f8 100644 (file)
@@ -33,7 +33,7 @@ export async function _refresh (wallet: Wallet, rpc: unknown, from: unknown, to:
                if (from > to) [from as number, to as number] = [to, from]
                const accounts = await wallet.accounts(from, to)
                const addresses = []
-               for (const [index, account] of accounts) {
+               for (const account of accounts.values()) {
                        addresses.push(account.address)
                }
                const data = {
@@ -44,7 +44,7 @@ export async function _refresh (wallet: Wallet, rpc: unknown, from: unknown, to:
                const { frontiers } = await rpc.post('accounts_frontiers', data) as { frontiers: { [address: string]: string } }
                const { representatives } = await rpc.post('accounts_representatives', data) as { representatives: { [address: string]: string } }
                const { blocks } = await rpc.post('blocks_info', { json_block: true, hashes: Object.values(frontiers) }) as BlockInfo
-               for (const [index, account] of accounts) {
+               for (const account of accounts.values()) {
                        account.balance = balances[account.address]?.balance
                        account.receivable = balances[account.address]?.receivable
                        account.representative = representatives?.[account.address]
@@ -56,7 +56,7 @@ export async function _refresh (wallet: Wallet, rpc: unknown, from: unknown, to:
                                if (typeof frontierBlock[subtype] !== 'function') {
                                        throw new TypeError('Unknown frontier block subtype', { cause: subtype })
                                }
-                               frontierBlock[subtype](link, 0).sign(signature)
+                               frontierBlock[subtype](link, 0).signature = signature
                                account.frontier_block = frontierBlock
                        }
                }
index d9499082d93d0fe0e7d526a1e60109e7f4e72b54..14b40f0bdfbe3f4802061ca41af656c4a247a8a0 100644 (file)
@@ -19,7 +19,7 @@ export async function _unopened (wallet: Wallet, rpc: unknown, batchSize: unknow
        const to = from + batchSize
        const accounts = await wallet.accounts(from, to - 1)
        const addresses = []
-       for (const [index, account] of accounts) {
+       for (const account of accounts.values()) {
                addresses.push(account.address)
        }
        const data = {
index 31891642b134314ba88db9efb4e78e69c3da13d1..e90957c715076a4baa6ad80fab137cf1279fa633 100644 (file)
@@ -215,7 +215,7 @@ await Promise.all([
 
                        assert.exists(accounts)
                        assert.equal(accounts.size, 2)
-                       for (const [index, account] of accounts) {
+                       for (const account of accounts.values()) {
                                assert.ok(account instanceof Account)
                                assert.exists(account.address)
                                assert.exists(account.publicKey)
@@ -227,7 +227,7 @@ await Promise.all([
                        const accounts = await wallet.refresh(rpc, 0, 2)
 
                        assert.exists(accounts)
-                       for (const [index, account] of accounts) {
+                       for (const account of accounts.values()) {
                                assert.ok(account instanceof Account)
                                assert.exists(account.address)
                                assert.exists(account.publicKey)