Skip to content

Commit

Permalink
Fix getExtensionsArray() method when address hash starts with 00
Browse files Browse the repository at this point in the history
Co-authored-by: Dmytro Polunin <[email protected]>
  • Loading branch information
Skydev0h and p0lunin committed Jun 14, 2024
1 parent 1f9b0a3 commit a210caa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions tests/wallet-v5-get.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,27 @@ 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<bigint, bigint> = Dictionary.empty(
Dictionary.Keys.BigUint(256),
Dictionary.Values.BigInt(8)
);
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 () => {
Expand Down
2 changes: 1 addition & 1 deletion wrappers/wallet-v5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')}`);
});
}
}

0 comments on commit a210caa

Please sign in to comment.