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

Sync main #318

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -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)
43 changes: 22 additions & 21 deletions src/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
8 changes: 8 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,7 @@ describe('Running @erc725/erc725.js tests...', () => {
ENCRYPT: true,
DECRYPT: true,
SIGN: true,
EXECUTE_RELAY_CALL: false,
},
hex: '0x00000000000000000000000000000000000000000000000000000000003f3f7f',
},
Expand Down Expand Up @@ -1087,6 +1088,7 @@ describe('Running @erc725/erc725.js tests...', () => {
ENCRYPT: false,
DECRYPT: false,
SIGN: false,
EXECUTE_RELAY_CALL: false,
},
hex: '0x0000000000000000000000000000000000000000000000000000000000000000',
},
Expand Down Expand Up @@ -1114,6 +1116,7 @@ describe('Running @erc725/erc725.js tests...', () => {
ENCRYPT: false,
DECRYPT: false,
SIGN: true,
EXECUTE_RELAY_CALL: false,
},
hex: '0x0000000000000000000000000000000000000000000000000000000000200a00',
},
Expand Down Expand Up @@ -1141,6 +1144,7 @@ describe('Running @erc725/erc725.js tests...', () => {
ENCRYPT: false,
DECRYPT: false,
SIGN: false,
EXECUTE_RELAY_CALL: false,
},
hex: '0x0000000000000000000000000000000000000000000000000000000000040800',
},
Expand Down Expand Up @@ -1168,6 +1172,7 @@ describe('Running @erc725/erc725.js tests...', () => {
ENCRYPT: false,
DECRYPT: false,
SIGN: false,
EXECUTE_RELAY_CALL: false,
},
hex: '0x0000000000000000000000000000000000000000000000000000000000040004',
},
Expand Down Expand Up @@ -1195,6 +1200,7 @@ describe('Running @erc725/erc725.js tests...', () => {
ENCRYPT: false,
DECRYPT: false,
SIGN: false,
EXECUTE_RELAY_CALL: false,
},
hex: '0x0000000000000000000000000000000000000000000000000000000000000a00',
},
Expand Down Expand Up @@ -1275,6 +1281,7 @@ describe('Running @erc725/erc725.js tests...', () => {
ENCRYPT: true,
DECRYPT: true,
SIGN: true,
EXECUTE_RELAY_CALL: true,
},
);
assert.deepStrictEqual(
Expand Down Expand Up @@ -1304,6 +1311,7 @@ describe('Running @erc725/erc725.js tests...', () => {
ENCRYPT: true,
DECRYPT: true,
SIGN: true,
EXECUTE_RELAY_CALL: true,
},
);
});
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -477,6 +477,7 @@ export class ERC725 {
ENCRYPT: false,
DECRYPT: false,
SIGN: false,
EXECUTE_RELAY_CALL: 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 {
ENCRYPT?: boolean;
DECRYPT?: boolean;
SIGN?: boolean;
EXECUTE_RELAY_CALL?: boolean;
}
Loading