]> git.codecow.com Git - libnemo.git/commitdiff
Specify account info data types.
authorChris Duncan <chris@zoso.dev>
Tue, 19 Aug 2025 14:49:12 +0000 (07:49 -0700)
committerChris Duncan <chris@zoso.dev>
Tue, 19 Aug 2025 14:49:12 +0000 (07:49 -0700)
src/lib/account.ts

index f58c7a5f5e9d23456a9df89b38b3023071e9197c..294d8e888cb998952060fe033bf9376d16210999 100644 (file)
@@ -26,20 +26,20 @@ export class Account {
        #representative?: Account\r
        #weight?: bigint\r
 \r
-       get address () { return `${PREFIX}${this.#address}` }\r
-       get index () { return this.#index }\r
-       get publicKey () { return bytes.toHex(this.#publicKey) }\r
+       get address (): string { return `${PREFIX}${this.#address}` }\r
+       get index (): number | undefined { return this.#index }\r
+       get publicKey (): string { return bytes.toHex(this.#publicKey) }\r
 \r
-       get balance () { return this.#balance }\r
-       get frontier () { return this.#frontier }\r
-       get receivable () { return this.#receivable }\r
-       get representative () { return this.#representative }\r
-       get weight () { return this.#weight }\r
+       get balance (): bigint | undefined { return this.#balance }\r
+       get frontier (): string | undefined { return this.#frontier }\r
+       get receivable (): bigint | undefined { return this.#receivable }\r
+       get representative (): Account | undefined { return this.#representative }\r
+       get weight (): bigint | undefined { return this.#weight }\r
 \r
-       set balance (v) { this.#balance = v ? BigInt(v) : undefined }\r
-       set frontier (v) { this.#frontier = v }\r
-       set receivable (v) { this.#receivable = v ? BigInt(v) : undefined }\r
-       set representative (v) {\r
+       set balance (v: bigint | number | string) { this.#balance = BigInt(v) }\r
+       set frontier (v: string | undefined) { this.#frontier = v }\r
+       set receivable (v: bigint | number | string) { this.#receivable = BigInt(v) }\r
+       set representative (v: unknown) {\r
                if (v instanceof Account) {\r
                        this.#representative = v\r
                } else if (typeof v === 'string') {\r
@@ -48,7 +48,7 @@ export class Account {
                        throw new TypeError(`Invalid argument for account representative: ${v}`)\r
                }\r
        }\r
-       set weight (v) { this.#weight = v ? BigInt(v) : undefined }\r
+       set weight (v: bigint | number | string) { this.#weight = BigInt(v) }\r
 \r
        private constructor (address: string, publicKey: Key, index?: number) {\r
                if (!Account.#isInternal) {\r