Skip to content

Commit

Permalink
fix: encode LSP2 array length as 16 bytes long
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ42 committed Oct 19, 2023
1 parent 136c268 commit 97ce334
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/lib/services/universal-profile.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('LSP3Account Service', () => {
// AddressPermissions[] array length should be 1
const totalPermissionsSet =
valuesToSet[keysToSet.indexOf(ERC725YDataKeys.LSP6['AddressPermissions[]'].length)];
const expectedLength = abiCoder.encode(['uint256'], [2]);
const expectedLength = ethers.utils.hexZeroPad(2, 16);
expect(totalPermissionsSet).toEqual(expectedLength);

// controller address should have default permissions set
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('LSP3Account Service', () => {
// AddressPermissions[] array length should be 2
const totalPermissionsSet =
valuesToSet[keysToSet.indexOf(ERC725YDataKeys.LSP6['AddressPermissions[]'].length)];
const expectedLength = abiCoder.encode(['uint256'], [controllerAddresses.length + 1]);
const expectedLength = ethers.utils.hexZeroPad(controllerAddresses.length + 1, 16);
expect(totalPermissionsSet).toEqual(expectedLength);

for (let index = 0; index < controllerAddresses.length; index++) {
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('LSP3Account Service', () => {
// AddressPermissions[] array length should be 11 (including Universal Receiver Delegate address)
const totalPermissionsSet =
valuesToSet[keysToSet.indexOf(ERC725YDataKeys.LSP6['AddressPermissions[]'].length)];
const expectedLength = abiCoder.encode(['uint256'], [controllerAddresses.length + 1]);
const expectedLength = ethers.utils.hexZeroPad(controllerAddresses.length + 1, 16);
expect(totalPermissionsSet).toEqual(expectedLength);

for (let index = 0; index < controllerAddresses.length; index++) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/services/universal-profile.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ export async function prepareSetDataParameters(
const valuesToSet = [
universalReceiverDelegateAddress,
ERC725.encodePermissions({ SUPER_SETDATA: true, REENTRANCY: true }),
ethers.utils.defaultAbiCoder.encode(['uint256'], [controllerPermissions.length + 1]),
ethers.utils.hexZeroPad(ethers.utils.hexlify(controllerAddresses.length + 1), 16),
...controllerAddresses,
...controllerPermissions,
universalReceiverDelegateAddress,
Expand Down

0 comments on commit 97ce334

Please sign in to comment.