return true\r
}\r
\r
+ /**\r
+ * Refreshes the account from its current state on the network.\r
+ *\r
+ * A successful response sets the balance, frontier, and representative\r
+ * properties.\r
+ *\r
+ * @param {Rpc|string|URL} rpc - RPC node information required to call `account_info`\r
+ */\r
+ async refresh (rpc: Rpc | string | URL): Promise<void> {\r
+ if (typeof rpc === 'string' || rpc.constructor === URL) {\r
+ rpc = new Rpc(rpc)\r
+ }\r
+ if (rpc.constructor !== Rpc) {\r
+ throw new TypeError('RPC must be a valid node')\r
+ }\r
+ const data = {\r
+ account: this.address,\r
+ receivable: true,\r
+ representative: true,\r
+ weight: true\r
+ }\r
+ const { balance, frontier, receivable, representative, weight } = await rpc.call('account_info', data)\r
+ if (frontier == null) {\r
+ throw new Error('Account not found')\r
+ }\r
+ this.#balance = BigInt(balance)\r
+ this.#frontier = frontier\r
+ this.#receivable = BigInt(receivable)\r
+ this.#representative = Account.fromAddress(representative)\r
+ this.#weight = BigInt(weight)\r
+ }\r
+\r
/**\r
* Unlocks the account using the same password as used prior to lock it.\r
*\r
}\r
}\r
\r
- /**\r
- * Refreshes the account from its current state on the network.\r
- *\r
- * A successful response sets the balance, frontier, and representative\r
- * properties.\r
- *\r
- * @param {Rpc|string|URL} rpc - RPC node information required to call `account_info`\r
- */\r
- async refresh (rpc: Rpc | string | URL): Promise<void> {\r
- if (typeof rpc === 'string' || rpc.constructor === URL) {\r
- rpc = new Rpc(rpc)\r
- }\r
- if (rpc.constructor !== Rpc) {\r
- throw new TypeError('RPC must be a valid node')\r
- }\r
- const data = {\r
- account: this.address,\r
- receivable: true,\r
- representative: true,\r
- weight: true\r
- }\r
- const { balance, frontier, receivable, representative, weight } = await rpc.call('account_info', data)\r
- if (frontier == null) {\r
- throw new Error('Account not found')\r
- }\r
- this.#balance = BigInt(balance)\r
- this.#frontier = frontier\r
- this.#receivable = BigInt(receivable)\r
- this.#representative = Account.fromAddress(representative)\r
- this.#weight = BigInt(weight)\r
- }\r
-\r
static #addressToKey (v: string): string {\r
const publicKeyBytes = base32.toBytes(v.slice(-60, -8))\r
const checksumBytes = base32.toBytes(v.slice(-8))\r