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 143ea7c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/lib/classes/lsp8-identifiable-digital-asset.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { lsp4DigitalAsset } from '../../../test/lsp4-digital-asset.mock';
import { JSONURL_KNOWN_HASH_FUNCTIONS } from '../helpers/config.helper';

import { ProxyDeployer } from './proxy-deployer';
import ERC725 from '@erc725/erc725.js';

jest.setTimeout(30000);
jest.useRealTimers();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/classes/proxy-deployer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ethers, SignerWithAddress } from 'hardhat';
import { hexlify, randomBytes } from 'ethers/lib/utils';
import { ethers, SignerWithAddress } from 'hardhat';

import { ProxyDeployer } from './proxy-deployer';

Expand Down
7 changes: 3 additions & 4 deletions src/lib/services/universal-profile.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe('LSP3Account Service', () => {
});

describe('prepareSetDataParameters', () => {
let abiCoder;
let universalProfile, universalReceiverDelegate;

beforeAll(async () => {
Expand All @@ -42,7 +41,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 +79,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 +120,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
2 changes: 1 addition & 1 deletion test/digital-asset.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export async function testDeployWithSpecifiedCreators(
digitalAsset: LSP7Mintable | LSP8Mintable,
creators: string[]
) {
const [creatorArrayLength] = await digitalAsset.getData(
const creatorArrayLength = await digitalAsset.getData(
ERC725YDataKeys.LSP4['LSP4Creators[]'].length
);

Expand Down

0 comments on commit 143ea7c

Please sign in to comment.