From 964cd6b293a715d5d208ec8a38085eeb49a2f73f Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Tue, 19 Aug 2025 07:49:12 -0700 Subject: [PATCH] Specify account info data types. --- src/lib/account.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/lib/account.ts b/src/lib/account.ts index f58c7a5..294d8e8 100644 --- a/src/lib/account.ts +++ b/src/lib/account.ts @@ -26,20 +26,20 @@ export class Account { #representative?: Account #weight?: bigint - get address () { return `${PREFIX}${this.#address}` } - get index () { return this.#index } - get publicKey () { return bytes.toHex(this.#publicKey) } + get address (): string { return `${PREFIX}${this.#address}` } + get index (): number | undefined { return this.#index } + get publicKey (): string { return bytes.toHex(this.#publicKey) } - get balance () { return this.#balance } - get frontier () { return this.#frontier } - get receivable () { return this.#receivable } - get representative () { return this.#representative } - get weight () { return this.#weight } + get balance (): bigint | undefined { return this.#balance } + get frontier (): string | undefined { return this.#frontier } + get receivable (): bigint | undefined { return this.#receivable } + get representative (): Account | undefined { return this.#representative } + get weight (): bigint | undefined { return this.#weight } - set balance (v) { this.#balance = v ? BigInt(v) : undefined } - set frontier (v) { this.#frontier = v } - set receivable (v) { this.#receivable = v ? BigInt(v) : undefined } - set representative (v) { + set balance (v: bigint | number | string) { this.#balance = BigInt(v) } + set frontier (v: string | undefined) { this.#frontier = v } + set receivable (v: bigint | number | string) { this.#receivable = BigInt(v) } + set representative (v: unknown) { if (v instanceof Account) { this.#representative = v } else if (typeof v === 'string') { @@ -48,7 +48,7 @@ export class Account { throw new TypeError(`Invalid argument for account representative: ${v}`) } } - set weight (v) { this.#weight = v ? BigInt(v) : undefined } + set weight (v: bigint | number | string) { this.#weight = BigInt(v) } private constructor (address: string, publicKey: Key, index?: number) { if (!Account.#isInternal) { -- 2.47.3