diff --git a/examples/README.md b/examples/README.md index 4315d205..0dc1743f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,25 +1,33 @@ # Examples ## fetchData + ``` npm run fetchData ``` + [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/erc725js-fetch-data?devtoolsheight=66&file=index.js) ## getData + ``` npm run getData ``` + [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/erc725js-get-data?devtoolsheight=66&file=package.json) ## encodeData + ``` npm run encodeData ``` + [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/erc725js-encode-data?devtoolsheight=66&file=index.js) ## decodeData + ``` npm run decodeData ``` + [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/erc725js-decode-data?devtoolsheight=66) diff --git a/src/constants/constants.ts b/src/constants/constants.ts index 1c71a5c0..b2e02f1e 100644 --- a/src/constants/constants.ts +++ b/src/constants/constants.ts @@ -155,27 +155,28 @@ export const HASH_FUNCTIONS: { // prettier-ignore export const LSP6_DEFAULT_PERMISSIONS = { CHANGEOWNER :"0x0000000000000000000000000000000000000000000000000000000000000001", - ADDCONTROLLER :"0x0000000000000000000000000000000000000000000000000000000000000002", - EDITPERMISSIONS :"0x0000000000000000000000000000000000000000000000000000000000000004", - ADDEXTENSIONS :"0x0000000000000000000000000000000000000000000000000000000000000008", - CHANGEEXTENSIONS :"0x0000000000000000000000000000000000000000000000000000000000000010", - ADDUNIVERSALRECEIVERDELEGATE :"0x0000000000000000000000000000000000000000000000000000000000000020", - CHANGEUNIVERSALRECEIVERDELEGATE :"0x0000000000000000000000000000000000000000000000000000000000000040", - REENTRANCY :"0x0000000000000000000000000000000000000000000000000000000000000080", - SUPER_TRANSFERVALUE :"0x0000000000000000000000000000000000000000000000000000000000000100", - TRANSFERVALUE :"0x0000000000000000000000000000000000000000000000000000000000000200", - SUPER_CALL :"0x0000000000000000000000000000000000000000000000000000000000000400", - CALL :"0x0000000000000000000000000000000000000000000000000000000000000800", - SUPER_STATICCALL :"0x0000000000000000000000000000000000000000000000000000000000001000", - STATICCALL :"0x0000000000000000000000000000000000000000000000000000000000002000", - SUPER_DELEGATECALL :"0x0000000000000000000000000000000000000000000000000000000000004000", - DELEGATECALL :"0x0000000000000000000000000000000000000000000000000000000000008000", - DEPLOY :"0x0000000000000000000000000000000000000000000000000000000000010000", - SUPER_SETDATA :"0x0000000000000000000000000000000000000000000000000000000000020000", - SETDATA :"0x0000000000000000000000000000000000000000000000000000000000040000", - ENCRYPT :"0x0000000000000000000000000000000000000000000000000000000000080000", - DECRYPT :"0x0000000000000000000000000000000000000000000000000000000000100000", - SIGN :"0x0000000000000000000000000000000000000000000000000000000000200000", + ADDCONTROLLER :"0x0000000000000000000000000000000000000000000000000000000000000002", + EDITPERMISSIONS :"0x0000000000000000000000000000000000000000000000000000000000000004", + ADDEXTENSIONS :"0x0000000000000000000000000000000000000000000000000000000000000008", + CHANGEEXTENSIONS :"0x0000000000000000000000000000000000000000000000000000000000000010", + ADDUNIVERSALRECEIVERDELEGATE :"0x0000000000000000000000000000000000000000000000000000000000000020", + CHANGEUNIVERSALRECEIVERDELEGATE :"0x0000000000000000000000000000000000000000000000000000000000000040", + REENTRANCY :"0x0000000000000000000000000000000000000000000000000000000000000080", + SUPER_TRANSFERVALUE :"0x0000000000000000000000000000000000000000000000000000000000000100", + TRANSFERVALUE :"0x0000000000000000000000000000000000000000000000000000000000000200", + SUPER_CALL :"0x0000000000000000000000000000000000000000000000000000000000000400", + CALL :"0x0000000000000000000000000000000000000000000000000000000000000800", + SUPER_STATICCALL :"0x0000000000000000000000000000000000000000000000000000000000001000", + STATICCALL :"0x0000000000000000000000000000000000000000000000000000000000002000", + SUPER_DELEGATECALL :"0x0000000000000000000000000000000000000000000000000000000000004000", + DELEGATECALL :"0x0000000000000000000000000000000000000000000000000000000000008000", + DEPLOY :"0x0000000000000000000000000000000000000000000000000000000000010000", + SUPER_SETDATA :"0x0000000000000000000000000000000000000000000000000000000000020000", + SETDATA :"0x0000000000000000000000000000000000000000000000000000000000040000", + ENCRYPT :"0x0000000000000000000000000000000000000000000000000000000000080000", + DECRYPT :"0x0000000000000000000000000000000000000000000000000000000000100000", + SIGN :"0x0000000000000000000000000000000000000000000000000000000000200000", + EXECUTE_RELAY_CALL :"0x00000000000000000000000000000000000000000000000000000000004400000", }; export const LSP6_ALL_PERMISSIONS = diff --git a/src/index.test.ts b/src/index.test.ts index 568d2dc5..36d077e4 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -1060,6 +1060,7 @@ describe('Running @erc725/erc725.js tests...', () => { ENCRYPT: true, DECRYPT: true, SIGN: true, + EXECUTE_RELAY_CALL: false, }, hex: '0x00000000000000000000000000000000000000000000000000000000003f3f7f', }, @@ -1087,6 +1088,7 @@ describe('Running @erc725/erc725.js tests...', () => { ENCRYPT: false, DECRYPT: false, SIGN: false, + EXECUTE_RELAY_CALL: false, }, hex: '0x0000000000000000000000000000000000000000000000000000000000000000', }, @@ -1114,6 +1116,7 @@ describe('Running @erc725/erc725.js tests...', () => { ENCRYPT: false, DECRYPT: false, SIGN: true, + EXECUTE_RELAY_CALL: false, }, hex: '0x0000000000000000000000000000000000000000000000000000000000200a00', }, @@ -1141,6 +1144,7 @@ describe('Running @erc725/erc725.js tests...', () => { ENCRYPT: false, DECRYPT: false, SIGN: false, + EXECUTE_RELAY_CALL: false, }, hex: '0x0000000000000000000000000000000000000000000000000000000000040800', }, @@ -1168,6 +1172,7 @@ describe('Running @erc725/erc725.js tests...', () => { ENCRYPT: false, DECRYPT: false, SIGN: false, + EXECUTE_RELAY_CALL: false, }, hex: '0x0000000000000000000000000000000000000000000000000000000000040004', }, @@ -1195,6 +1200,7 @@ describe('Running @erc725/erc725.js tests...', () => { ENCRYPT: false, DECRYPT: false, SIGN: false, + EXECUTE_RELAY_CALL: false, }, hex: '0x0000000000000000000000000000000000000000000000000000000000000a00', }, @@ -1275,6 +1281,7 @@ describe('Running @erc725/erc725.js tests...', () => { ENCRYPT: true, DECRYPT: true, SIGN: true, + EXECUTE_RELAY_CALL: true, }, ); assert.deepStrictEqual( @@ -1304,6 +1311,7 @@ describe('Running @erc725/erc725.js tests...', () => { ENCRYPT: true, DECRYPT: true, SIGN: true, + EXECUTE_RELAY_CALL: true, }, ); }); diff --git a/src/index.ts b/src/index.ts index 2acbb8d1..6a07e404 100644 --- a/src/index.ts +++ b/src/index.ts @@ -428,7 +428,7 @@ export class ERC725 { static encodePermissions(permissions: Permissions): string { const result = Object.keys(permissions).reduce((previous, key) => { return permissions[key] - ? previous + Number(hexToNumber(LSP6_DEFAULT_PERMISSIONS[key])) + ? previous | Number(hexToNumber(LSP6_DEFAULT_PERMISSIONS[key])) : previous; }, 0); @@ -477,6 +477,7 @@ export class ERC725 { ENCRYPT: false, DECRYPT: false, SIGN: false, + EXECUTE_RELAY_CALL: false, }; const permissionsToTest = Object.keys(LSP6_DEFAULT_PERMISSIONS); diff --git a/src/types/Method.ts b/src/types/Method.ts index 658bde75..e28b49ab 100644 --- a/src/types/Method.ts +++ b/src/types/Method.ts @@ -48,4 +48,5 @@ export interface Permissions { ENCRYPT?: boolean; DECRYPT?: boolean; SIGN?: boolean; + EXECUTE_RELAY_CALL?: boolean; }