From a210caabc58b737d4c2fbe6e3676020b5c88dda3 Mon Sep 17 00:00:00 2001 From: Skydev0h Date: Fri, 14 Jun 2024 19:38:39 +0300 Subject: [PATCH] Fix `getExtensionsArray()` method when address hash starts with `00` Co-authored-by: Dmytro Polunin --- tests/wallet-v5-get.spec.ts | 11 ++++++++--- wrappers/wallet-v5.ts | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/wallet-v5-get.spec.ts b/tests/wallet-v5-get.spec.ts index c6bca5e..cb36bea 100644 --- a/tests/wallet-v5-get.spec.ts +++ b/tests/wallet-v5-get.spec.ts @@ -127,8 +127,11 @@ describe('Wallet V5 get methods', () => { }); it('Get extensions array', async () => { - const plugin1 = Address.parse('EQAvDfWFG0oYX19jwNDNBBL1rKNT9XfaGP9HyTb5nb2Eml6y'); - const plugin2 = Address.parse('EQA2pT4d8T7TyRsjW2BpGpGYga-lMA4JjQb4D2tc1PXMX5Bf'); + const plugin1 = Address.parse( + '0:0000F5851B4A185F5F63C0D0CD0412F5ACA353F577DA18FF47C936F99DBD0000' + ); + const plugin2 = Address.parse('EQAvDfWFG0oYX19jwNDNBBL1rKNT9XfaGP9HyTb5nb2Eml6y'); + const plugin3 = Address.parse('EQA2pT4d8T7TyRsjW2BpGpGYga-lMA4JjQb4D2tc1PXMX5Bf'); const extensions: Dictionary = Dictionary.empty( Dictionary.Keys.BigUint(256), @@ -136,13 +139,15 @@ describe('Wallet V5 get methods', () => { ); extensions.set(packAddress(plugin1), BigInt(plugin1.workChain)); extensions.set(packAddress(plugin2), BigInt(plugin2.workChain)); + extensions.set(packAddress(plugin3), BigInt(plugin3.workChain)); await deploy({ extensions }); const actual = await walletV5.getExtensionsArray(); - expect(actual.length).toBe(2); + expect(actual.length).toBe(3); expect(actual[0].equals(plugin1)).toBeTruthy(); expect(actual[1].equals(plugin2)).toBeTruthy(); + expect(actual[2].equals(plugin3)).toBeTruthy(); }); it('Get empty extensions array', async () => { diff --git a/wrappers/wallet-v5.ts b/wrappers/wallet-v5.ts index 3d5fd45..b62870e 100644 --- a/wrappers/wallet-v5.ts +++ b/wrappers/wallet-v5.ts @@ -235,7 +235,7 @@ export class WalletV5 implements Contract { return dict.keys().map(key => { const wc = dict.get(key)!; const addressHex = key; - return Address.parseRaw(`${wc}:${addressHex.toString(16)}`); + return Address.parseRaw(`${wc}:${addressHex.toString(16).padStart(64, '0')}`); }); } }