Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ALL_PERMISSIONS flag to encoding #384

Merged
merged 57 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
8a518eb
Merge pull request #72 from ERC725Alliance/develop
frozeman Jan 5, 2022
ff19b0e
Merge pull request #81 from ERC725Alliance/develop
Hugoo Jan 5, 2022
a63b82d
Merge pull request #88 from ERC725Alliance/develop
frozeman Jan 6, 2022
8ecbc25
Merge pull request #102 from ERC725Alliance/develop
Hugoo Feb 2, 2022
dfdd027
Merge pull request #112 from ERC725Alliance/develop
frozeman Mar 3, 2022
3bd4b93
Merge pull request #115 from ERC725Alliance/develop
frozeman Mar 16, 2022
0b7a93b
improved example titles encodeData
frozeman Mar 30, 2022
b050aeb
Merge pull request #128 from ERC725Alliance/develop
Hugoo Apr 6, 2022
269a540
Merge pull request #131 from ERC725Alliance/develop
Hugoo Apr 6, 2022
ebea7f5
Merge pull request #144 from ERC725Alliance/develop
Hugoo May 20, 2022
0c75f63
Merge pull request #170 from ERC725Alliance/develop
Hugoo Jun 2, 2022
4401e62
Merge pull request #177 from ERC725Alliance/develop
Hugoo Jun 9, 2022
22c5e1a
Merge pull request #186 from ERC725Alliance/develop
Hugoo Jun 14, 2022
303720a
Merge pull request #190 from ERC725Alliance/develop
Hugoo Jun 15, 2022
714495f
Merge pull request #198 from ERC725Alliance/develop
Hugoo Jun 24, 2022
44ab226
Merge pull request #211 from ERC725Alliance/develop
Hugoo Jul 7, 2022
0d0064d
Merge pull request #218 from ERC725Alliance/develop
Hugoo Jul 25, 2022
6ef86bc
Merge pull request #226 from ERC725Alliance/develop
CallumGrindle Sep 14, 2022
ed3522b
Merge pull request #250 from ERC725Alliance/develop
Hugoo Oct 28, 2022
fbca5c4
Merge pull request #273 from ERC725Alliance/develop
Hugoo Feb 7, 2023
88b0e03
Merge pull request #276 from ERC725Alliance/develop
Hugoo Feb 8, 2023
3ec90bf
Merge pull request #284 from ERC725Alliance/develop
Hugoo Mar 14, 2023
866ba2c
chore(release): 0.18.0
Hugoo Aug 3, 2023
b3027c6
Merge pull request #305 from ERC725Alliance/release-v0.18.0
Hugoo Aug 3, 2023
89c41e5
Merge pull request #314 from ERC725Alliance/develop
CallumGrindle Oct 5, 2023
100d42b
chore(main): release 0.19.0
github-actions[bot] Oct 5, 2023
20198f4
Merge pull request #315 from ERC725Alliance/release-please--branches-…
CallumGrindle Oct 13, 2023
2aaeeb1
Update schemas.md
frozeman Oct 18, 2023
e4c09c7
Merge pull request #318 from ERC725Alliance/develop
CallumGrindle Oct 18, 2023
4c5860d
chore(main): release 0.20.0
github-actions[bot] Oct 18, 2023
d9e647c
Merge pull request #322 from ERC725Alliance/develop
CallumGrindle Oct 18, 2023
42e105e
Merge pull request #320 from ERC725Alliance/release-please--branches-…
CallumGrindle Oct 18, 2023
6982b23
Merge pull request #329 from ERC725Alliance/develop
CJ42 Oct 30, 2023
4635125
chore(main): release 0.20.1
github-actions[bot] Oct 30, 2023
51c29c5
Merge pull request #330 from ERC725Alliance/release-please--branches-…
CJ42 Oct 30, 2023
3b688a9
Merge pull request #334 from ERC725Alliance/develop
CallumGrindle Nov 2, 2023
3a2d725
chore(main): release 0.21.0
github-actions[bot] Nov 2, 2023
9b80d75
Merge pull request #338 from ERC725Alliance/release-please--branches-…
CJ42 Nov 2, 2023
fc0ee1a
Merge pull request #340 from ERC725Alliance/develop
CallumGrindle Nov 6, 2023
636d4c9
chore(main): release 0.21.1
github-actions[bot] Nov 6, 2023
489a9e7
Merge pull request #341 from ERC725Alliance/release-please--branches-…
CallumGrindle Nov 6, 2023
de6452e
Merge pull request #344 from ERC725Alliance/develop
CallumGrindle Nov 7, 2023
9d08111
chore(main): release 0.21.2
github-actions[bot] Nov 7, 2023
b1bb164
Merge pull request #346 from ERC725Alliance/release-please--branches-…
CallumGrindle Nov 7, 2023
1562a9d
Merge pull request #348 from ERC725Alliance/develop
CallumGrindle Nov 9, 2023
4cda9b9
Merge pull request #358 from ERC725Alliance/develop
Hugoo Nov 29, 2023
120d5ee
Merge pull request #362 from ERC725Alliance/develop
Hugoo Nov 29, 2023
86301ca
chore(main): release 0.21.3
github-actions[bot] Nov 29, 2023
90f735c
Merge pull request #349 from ERC725Alliance/release-please--branches-…
Hugoo Nov 29, 2023
3720b17
Merge pull request #369 from ERC725Alliance/develop
Hugoo Dec 15, 2023
330cb7d
chore(main): release 0.22.0
github-actions[bot] Dec 15, 2023
3994b72
Merge pull request #370 from ERC725Alliance/release-please--branches-…
Hugoo Dec 15, 2023
1dd59bf
Merge pull request #376 from ERC725Alliance/develop
richtera Jan 22, 2024
9cda880
chore(main): release 0.23.0
github-actions[bot] Jan 22, 2024
b35001f
Merge pull request #382 from ERC725Alliance/release-please--branches-…
richtera Jan 22, 2024
8adad51
feat: add ALL_PERMISSIONS flag to encoding
skimaharvey Feb 22, 2024
53c1a51
Merge remote-tracking branch 'upstream/main' into encode_all_permissions
skimaharvey Mar 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,52 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [0.23.0](https://github.com/ERC725Alliance/erc725.js/compare/v0.22.0...v0.23.0) (2024-01-22)


### Features

* add permission related to 4337 ([e7fd19b](https://github.com/ERC725Alliance/erc725.js/commit/e7fd19bc27aa89fae410b9633ef5ccdf13f33f0e))
* allow to load typed schemas from `schemas/` folder ([c54a370](https://github.com/ERC725Alliance/erc725.js/commit/c54a370c1e4f8d71ba6bb7e62122b89069f521e6))


### Bug Fixes

* Add workaround to read (bytes4,URI), repair none vs unknown signature. ([204409d](https://github.com/ERC725Alliance/erc725.js/commit/204409df544825041a586865cfb6bb124288e48f))
* Additional PR repair ([2a18f2b](https://github.com/ERC725Alliance/erc725.js/commit/2a18f2bf1a24547e71cad6953f5144761aa2cc9a))
* BodyInit should be just string or buffer and not already Uint8Array ([08e0177](https://github.com/ERC725Alliance/erc725.js/commit/08e017778fa42ade5386b8d9e85255225a7f3195))
* Cleanup ([038d975](https://github.com/ERC725Alliance/erc725.js/commit/038d97584075c89f93f51227666074cf11973a29))
* Cleanup a bit with comments. ([3d6a5a6](https://github.com/ERC725Alliance/erc725.js/commit/3d6a5a65db5049b678d0d54149e9b11ea2479999))
* Cleanup and handle situation where one of many keys fails. Return null. ([cdf4583](https://github.com/ERC725Alliance/erc725.js/commit/cdf4583c159d8c8e52a832bfe5af6b650d8945fa))
* Cleanup error handler inside of getDataFromExternalSources ([fde2e0f](https://github.com/ERC725Alliance/erc725.js/commit/fde2e0f41df3ecee90a4dfd8248dd9c2a7a72965))
* Debug and repair test scripts. Implement detecting of JSON inside of Uint8Array ([74c0526](https://github.com/ERC725Alliance/erc725.js/commit/74c0526e3f544400ced78f02ff4fed64bd048bfa))
* Missing commit ([a3dd604](https://github.com/ERC725Alliance/erc725.js/commit/a3dd604964c9c9221ff421fe668faa8fd363101a))
* More fixes ([620b606](https://github.com/ERC725Alliance/erc725.js/commit/620b60632e50ca59abedae9935f8b75d188278e0))
* Remove .only call for testing. ([d5ef3c9](https://github.com/ERC725Alliance/erc725.js/commit/d5ef3c9965e2c5ad343f88a9c30a6281e9fa169b))
* Remove console debugging. ([e349d57](https://github.com/ERC725Alliance/erc725.js/commit/e349d5715c7779c1eeb8d6e08c3ae3bf17eedd9e))
* Remove unnecessary special case for 0x00000000 ([cd6152a](https://github.com/ERC725Alliance/erc725.js/commit/cd6152a88ca7a1c98184799b6fdc6982ff8a1cd6))
* Repair and enhance test scripts ([224eb9e](https://github.com/ERC725Alliance/erc725.js/commit/224eb9ecb1b16f373f2ad17ee9d3efab08dda53b))
* Repair as per PR review ([0a52452](https://github.com/ERC725Alliance/erc725.js/commit/0a5245230455324e9911e4e14992c50e6f645ba2))
* Repair console.log and expand types of URLs (ar://, ipfs://, https\?://, data:) ([5c8f228](https://github.com/ERC725Alliance/erc725.js/commit/5c8f2285d2d23c59ef9707a54e419b55d25e4136))
* Repair problems with IPFS, fetch and VerifiableURI ([44834b8](https://github.com/ERC725Alliance/erc725.js/commit/44834b8ed517e869ad99920b2853e30213a8d7b5))
* Repair to not throw errors when data is not authentica or not accessible withing getDataFromExternalSources. ([25756d0](https://github.com/ERC725Alliance/erc725.js/commit/25756d09cecfec5d13d6e4fb6ed842c4e3d77734))
* Repair tuples containing numeric types uintX/intX, add Number to output data type. ([01cceea](https://github.com/ERC725Alliance/erc725.js/commit/01cceeac03f719df6eb8be8c238aca4483e7a3e8))
* Simplify buffer to string conversion. ([0bd1349](https://github.com/ERC725Alliance/erc725.js/commit/0bd1349f863283cf16cc6808bef48990ec118361))
* Simplify creation of key to detect JSON. ([df2580d](https://github.com/ERC725Alliance/erc725.js/commit/df2580d9434dc386480f7eec2cd6e94a5b4ca7c1))
* Use a single keccak function since ethereumjs converts it to a Buffer no matter what. ([cdc6c0a](https://github.com/ERC725Alliance/erc725.js/commit/cdc6c0a0f749209352d620db6d60865a276e072c))

## [0.22.0](https://github.com/ERC725Alliance/erc725.js/compare/v0.21.3...v0.22.0) (2023-12-15)


### ⚠ BREAKING CHANGES

* update new LSP7/8 interface IDs ([#367](https://github.com/ERC725Alliance/erc725.js/issues/367))
* `JSONURL` and `AssetURL` are now deprecated and have been replaced by `VerifiableURI`. The decoding is backward compatible but if you try to encode `JSONURL` and `AssetURL` value, they will be encoded as [`VerifiableURI`](https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md#verifiableuri). ([9aa87e5](https://github.com/ERC725Alliance/erc725.js/commit/9aa87e5ccc0fb1caac1f3291387370b3a980324b))

### Bug Fixes

* Rename JSONURLDataToEncode ([808f1b3](https://github.com/ERC725Alliance/erc725.js/commit/808f1b362bd2275424cf93ac6333049cde90216e))

## [0.21.3](https://github.com/ERC725Alliance/erc725.js/compare/v0.21.2...v0.21.3) (2023-11-29)


Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@erc725/erc725.js",
"version": "0.21.3",
"version": "0.23.0",
"description": "Library to interact with ERC725 smart contracts",
"main": "build/main/src/index.js",
"typings": "build/main/src/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ export const LSP6_DEFAULT_PERMISSIONS = {
DECRYPT : "0x0000000000000000000000000000000000000000000000000000000000100000",
SIGN : "0x0000000000000000000000000000000000000000000000000000000000200000",
EXECUTE_RELAY_CALL : "0x0000000000000000000000000000000000000000000000000000000000400000",
ERC4337_PERMISSION : "0x0000000000000000000000000000000000000000000000000000000000800000"
ERC4337_PERMISSION : "0x0000000000000000000000000000000000000000000000000000000000800000",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest adding a comment that this is not a standard permission defined in LSP6, but used for integration of ERC4337 standard.

Otherwise, people might look into the LSP6 specs to understand what this is used for, but will not find it.

Do we have a link in our docs or a guide that mentions this permission? Maybe worth adding it here.

@Hugoo @skimaharvey wdyt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree that this is confusing. I am not sure if the confusion starts at the lib level but imo more at the LIPs level and probably we should fix it there first

ALL_PERMISSIONS : "0x00000000000000000000000000000000000000000000000000000000007f3f7f" // lsp6 v0.14.0
};

export const LSP6_ALL_PERMISSIONS =
Expand Down
116 changes: 116 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import 'isomorphic-fetch';

import {
ERC725Y_INTERFACE_IDS,
LSP6_DEFAULT_PERMISSIONS,
SUPPORTED_VERIFICATION_METHOD_STRINGS,
} from './constants/constants';
import { decodeKey } from './lib/decodeData';
Expand Down Expand Up @@ -1192,6 +1193,7 @@ describe('Running @erc725/erc725.js tests...', () => {
SIGN: true,
EXECUTE_RELAY_CALL: false,
ERC4337_PERMISSION: false,
ALL_PERMISSIONS: false,
},
hex: '0x00000000000000000000000000000000000000000000000000000000003f3f7f',
},
Expand Down Expand Up @@ -1221,6 +1223,7 @@ describe('Running @erc725/erc725.js tests...', () => {
SIGN: false,
EXECUTE_RELAY_CALL: false,
ERC4337_PERMISSION: false,
ALL_PERMISSIONS: false,
},
hex: '0x0000000000000000000000000000000000000000000000000000000000000000',
},
Expand Down Expand Up @@ -1250,6 +1253,7 @@ describe('Running @erc725/erc725.js tests...', () => {
SIGN: true,
EXECUTE_RELAY_CALL: false,
ERC4337_PERMISSION: false,
ALL_PERMISSIONS: false,
},
hex: '0x0000000000000000000000000000000000000000000000000000000000200a00',
},
Expand Down Expand Up @@ -1279,6 +1283,7 @@ describe('Running @erc725/erc725.js tests...', () => {
SIGN: false,
EXECUTE_RELAY_CALL: false,
ERC4337_PERMISSION: false,
ALL_PERMISSIONS: false,
},
hex: '0x0000000000000000000000000000000000000000000000000000000000040800',
},
Expand Down Expand Up @@ -1308,6 +1313,7 @@ describe('Running @erc725/erc725.js tests...', () => {
SIGN: false,
EXECUTE_RELAY_CALL: false,
ERC4337_PERMISSION: false,
ALL_PERMISSIONS: false,
},
hex: '0x0000000000000000000000000000000000000000000000000000000000040004',
},
Expand Down Expand Up @@ -1337,6 +1343,7 @@ describe('Running @erc725/erc725.js tests...', () => {
SIGN: false,
EXECUTE_RELAY_CALL: false,
ERC4337_PERMISSION: false,
ALL_PERMISSIONS: false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth adding some extra tests to tests that when all permission is set and others are set to false, it removes them, etc... More cases

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes ideally we can randomize them like i did for some tests i added. I find it not efficient to do one test at a time. Will think about it

},
hex: '0x0000000000000000000000000000000000000000000000000000000000000a00',
},
Expand Down Expand Up @@ -1376,13 +1383,120 @@ describe('Running @erc725/erc725.js tests...', () => {
});
});

describe('Randomized Permissions Encoding', () => {
function convertToPermissionBits(permissions: { [key: string]: string }) {
const permissionBits = {};
Object.entries(permissions).forEach(([key, hexValue]) => {
// Convert hex to binary, then find the position of the '1' bit
const bitPosition = BigInt(hexValue).toString(2).length - 1;
permissionBits[key] = bitPosition;
});
return permissionBits;
}

// remove LSP6_DEFAULT_PERMISSIONS.ALL_PERMISSIONS from LSP6_DEFAULT_PERMISSIONS
const ALL_PERMISSIONS_WITHOUT_ALL_PERMISSIONS = Object.keys(
LSP6_DEFAULT_PERMISSIONS,
).reduce((acc, key) => {
if (key !== 'ALL_PERMISSIONS') {
acc[key] = LSP6_DEFAULT_PERMISSIONS[key];
}
return acc;
}, {});

// Use the function to generate permissionBits
const permissionBits = convertToPermissionBits(
ALL_PERMISSIONS_WITHOUT_ALL_PERMISSIONS,
);

// Function to generate a random permissions object
const generateRandomPermissions = () => {
return Object.keys(permissionBits).reduce((acc, key) => {
// Randomly assign true or false
acc[key] = Math.random() < 0.5;
return acc;
}, {});
};

// Function to calculate expected hex based on permissions
const calculateExpectedHex = (permissions) => {
let basePermissions = BigInt(0);
Object.entries(permissions).forEach(([key, value]) => {
if (value) {
const bitPosition = permissionBits[key];
basePermissions |= BigInt(1) << BigInt(bitPosition);
}
});
// Convert to hex string, properly padded
return `0x${basePermissions.toString(16).padStart(64, '0')}`;
};

// Run the randomized test multiple times
const numberOfTests = 100; // Number of random tests
for (let i = 0; i < numberOfTests; i++) {
it(`Randomized test #${i + 1}`, () => {
const randomPermissions = generateRandomPermissions();
const encoded = ERC725.encodePermissions(randomPermissions);
const expectedHex = calculateExpectedHex(randomPermissions);
assert.strictEqual(
encoded,
expectedHex,
`Failed at randomized test #${i + 1}`,
);
});
}
});

describe('all permissions', () => {
it('should encode ALL_PERMISSIONS correctly', () => {
const permissions = { ALL_PERMISSIONS: true };
const encoded = ERC725.encodePermissions(permissions);

assert.strictEqual(
encoded,
LSP6_DEFAULT_PERMISSIONS.ALL_PERMISSIONS,
'Encoded permissions do not match expected value for ALL_PERMISSIONS',
);
});

it('should ignore individual permissions when ALL_PERMISSIONS is set', () => {
const permissions = {
ALL_PERMISSIONS: true,
CHANGEOWNER: true,
};
const encoded = ERC725.encodePermissions(permissions);
assert.strictEqual(
encoded,
LSP6_DEFAULT_PERMISSIONS.ALL_PERMISSIONS,
'ALL_PERMISSIONS did not correctly encode with additional permissions',
);
});
it('should be able to disable permissions that are part of ALL_PERMISSIONS', () => {
const permissions = {
ALL_PERMISSIONS: true,
CHANGEOWNER: false, // Explicitly disable CHANGEOWNER
};

const encoded = ERC725.encodePermissions(permissions);
const decodedPermissions = ERC725.decodePermissions(encoded);

// check that the permission is disabled
assert.strictEqual(
decodedPermissions.CHANGEOWNER,
false,
'CHANGEOWNER permission was not correctly disabled',
);
});
});

describe('decodePermissions', () => {
testCases.forEach((testCase) => {
it(`Decodes ${testCase.hex} permission correctly`, () => {
assert.deepStrictEqual(
ERC725.decodePermissions(testCase.hex),
testCase.permissions,
);

assert.deepStrictEqual(
erc725Instance.decodePermissions(testCase.hex),
testCase.permissions,
Expand Down Expand Up @@ -1419,6 +1533,7 @@ describe('Running @erc725/erc725.js tests...', () => {
SIGN: true,
EXECUTE_RELAY_CALL: true,
ERC4337_PERMISSION: true,
ALL_PERMISSIONS: true,
},
);
assert.deepStrictEqual(
Expand Down Expand Up @@ -1450,6 +1565,7 @@ describe('Running @erc725/erc725.js tests...', () => {
SIGN: true,
EXECUTE_RELAY_CALL: true,
ERC4337_PERMISSION: true,
ALL_PERMISSIONS: true,
},
);
});
Expand Down
53 changes: 47 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,53 @@ export class ERC725 {
* @returns {*} The permissions encoded as a hexadecimal string as defined by the LSP6 Standard.
*/
static encodePermissions(permissions: Permissions): string {
const result = Object.keys(permissions).reduce((previous, key) => {
return permissions[key]
? previous | Number(hexToNumber(LSP6_DEFAULT_PERMISSIONS[key]))
: previous;
}, 0);
let basePermissions = BigInt(0);

return leftPad(toHex(result), 64);
// If ALL_PERMISSIONS is requested, start with that as the base
if (permissions.ALL_PERMISSIONS) {
basePermissions = BigInt(
hexToNumber(LSP6_DEFAULT_PERMISSIONS.ALL_PERMISSIONS),
);
}

// Explicitly add REENTRANCY, DELEGATECALL, and SUPER_DELEGATECALL if requested (they are not included in ALL_PERMISSIONS)
const additionalPermissions = [
LSP6_DEFAULT_PERMISSIONS.REENTRANCY,
LSP6_DEFAULT_PERMISSIONS.DELEGATECALL,
LSP6_DEFAULT_PERMISSIONS.SUPER_DELEGATECALL,
];
additionalPermissions.forEach((permission) => {
if (permissions[permission]) {
basePermissions |= BigInt(
hexToNumber(LSP6_DEFAULT_PERMISSIONS[permission]),
);
}
});

// Process each permission to potentially switch off permissions included in ALL_PERMISSIONS
Object.keys(permissions).forEach((key) => {
const permissionValue = BigInt(
hexToNumber(LSP6_DEFAULT_PERMISSIONS[key]),
);

if (permissions[key]) {
// If not dealing with ALL_PERMISSIONS or additional permissions, ensure they are added
if (
!additionalPermissions.includes(key) &&
key !== LSP6_DEFAULT_PERMISSIONS.ALL_PERMISSIONS
) {
basePermissions |= permissionValue;
}
} else if (
LSP6_DEFAULT_PERMISSIONS[key] !==
LSP6_DEFAULT_PERMISSIONS.ALL_PERMISSIONS
) {
// If permission is set to false, remove it from the basePermissions
basePermissions &= ~permissionValue;
}
});
// Convert the final BigInt permission value back to a hex string, properly padded
return leftPad(toHex(basePermissions.toString()), 64);
}

/**
Expand Down Expand Up @@ -503,6 +543,7 @@ export class ERC725 {
SIGN: false,
EXECUTE_RELAY_CALL: false,
ERC4337_PERMISSION: false,
ALL_PERMISSIONS: false,
};

const permissionsToTest = Object.keys(LSP6_DEFAULT_PERMISSIONS);
Expand Down
1 change: 1 addition & 0 deletions src/types/Method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ export interface Permissions {
SIGN?: boolean;
EXECUTE_RELAY_CALL?: boolean;
ERC4337_PERMISSION?: boolean;
ALL_PERMISSIONS?: boolean;
}
18 changes: 18 additions & 0 deletions test/testHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,21 @@ export function generateAllResults(schemas) {
};
});
}

export function hexToBitPositions(hexString) {
const binaryString = BigInt(hexString).toString(2);

const bitPositions: number[] = [];

for (let i = binaryString.length - 1; i >= 0; i--) {
// The current bit is set to 1
if (binaryString[i] === '1') {
// Calculate the bit position. We subtract from the string's length to start counting from 0
const bitPosition = binaryString.length - 1 - i;
bitPositions.push(bitPosition);
}
}

// Return the array of bit positions
return bitPositions;
}
Loading