From: Chris Duncan Date: Sun, 3 May 2026 15:48:17 +0000 (-0700) Subject: Fix wallet account usage docs. X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=e0454b30eeb75b12999bd1f12f2d00cea3c2a8fb;p=libnemo.git Fix wallet account usage docs. --- diff --git a/README.md b/README.md index 6ca67b2..6feed19 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ address can be considered correct for Nano protocol purposes. Wallet accounts are cached in an array-like numerically-indexed Map. This means that deriving an account any time after the first will be faster, and it also means that deriving a range of accounts will return an object that can be -treated somewhat like a [sparse array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays). +treated somewhat like a [sparse array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Indexed_collections#sparse_arrays) using the `get/set` syntax of Map objects. ```javascript try { @@ -102,9 +102,13 @@ try { const firstAccount = await wallet.account(); const secondAccount = await wallet.account(1); +const { address, publicKey } = secondAccount; + const multipleAccounts = await wallet.accounts(2, 3); -const thirdAccount = multipleAccounts[2]; -const { address, publicKey } = firstAccount; +const thirdAccount = multipleAccounts.get(2); +for (const [i, a] of multipleAccounts) { + console.log(`Index ${i} returns account ${a.address}`); +} const nodeUrl = "https://nano-node.example.com/"; await firstAccount.refresh(nodeUrl); // online