From: Chris Duncan Date: Mon, 7 Jul 2025 13:14:47 +0000 (-0700) Subject: Alphabetize function declaration order. X-Git-Tag: v0.10.5~99 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=e8240ff93e41a8193df5b920069aef71f8b417bf;p=libnemo.git Alphabetize function declaration order. --- diff --git a/src/lib/account.ts b/src/lib/account.ts index e235481..c304535 100644 --- a/src/lib/account.ts +++ b/src/lib/account.ts @@ -186,6 +186,38 @@ export class Account { return true } + /** + * Refreshes the account from its current state on the network. + * + * A successful response sets the balance, frontier, and representative + * properties. + * + * @param {Rpc|string|URL} rpc - RPC node information required to call `account_info` + */ + async refresh (rpc: Rpc | string | URL): Promise { + if (typeof rpc === 'string' || rpc.constructor === URL) { + rpc = new Rpc(rpc) + } + if (rpc.constructor !== Rpc) { + throw new TypeError('RPC must be a valid node') + } + const data = { + account: this.address, + receivable: true, + representative: true, + weight: true + } + const { balance, frontier, receivable, representative, weight } = await rpc.call('account_info', data) + if (frontier == null) { + throw new Error('Account not found') + } + this.#balance = BigInt(balance) + this.#frontier = frontier + this.#receivable = BigInt(receivable) + this.#representative = Account.fromAddress(representative) + this.#weight = BigInt(weight) + } + /** * Unlocks the account using the same password as used prior to lock it. * @@ -249,38 +281,6 @@ export class Account { } } - /** - * Refreshes the account from its current state on the network. - * - * A successful response sets the balance, frontier, and representative - * properties. - * - * @param {Rpc|string|URL} rpc - RPC node information required to call `account_info` - */ - async refresh (rpc: Rpc | string | URL): Promise { - if (typeof rpc === 'string' || rpc.constructor === URL) { - rpc = new Rpc(rpc) - } - if (rpc.constructor !== Rpc) { - throw new TypeError('RPC must be a valid node') - } - const data = { - account: this.address, - receivable: true, - representative: true, - weight: true - } - const { balance, frontier, receivable, representative, weight } = await rpc.call('account_info', data) - if (frontier == null) { - throw new Error('Account not found') - } - this.#balance = BigInt(balance) - this.#frontier = frontier - this.#receivable = BigInt(receivable) - this.#representative = Account.fromAddress(representative) - this.#weight = BigInt(weight) - } - static #addressToKey (v: string): string { const publicKeyBytes = base32.toBytes(v.slice(-60, -8)) const checksumBytes = base32.toBytes(v.slice(-8))