Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
richtera committed Jul 9, 2024
2 parents ea64bdf + c7458c1 commit 57fbc2a
Show file tree
Hide file tree
Showing 45 changed files with 17,329 additions and 13,127 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: ⚙️ Setup Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
node-version: '20.x'
cache: 'npm'

- name: 🧰 Install
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
with:
fetch-depth: 0

- name: ⚙️ Setup Node.js v16
- name: ⚙️ Setup Node.js 20.x
uses: actions/setup-node@v2
with:
node-version: '16.x'
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
scope: '@erc725'
cache: 'npm'
Expand Down
2 changes: 2 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
node = "20"
6 changes: 5 additions & 1 deletion .mocharc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"extension": ["ts"],
"spec": "src/**/*.test.ts",
"require": "ts-node/register",
"timeout": 20000
"timeout": 20000,
"node-option": [
"experimental-specifier-resolution=node",
"loader=ts-node/esm"
]
}
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.19.0
20.5.1
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 20.x
141 changes: 111 additions & 30 deletions docs/methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ sidebar_position: 1
title: 'Methods'
---

import CodeSandbox from "../../../src/components/CodeSandbox";

<CodeSandbox />

## Encoding

### encodeData
Expand Down Expand Up @@ -92,6 +96,40 @@ After the `data` is encoded, the object is ready to be stored in smart contracts

#### Examples

<details>
<summary>**Encode** a <code>Singleton</code> data key</summary>

```javascript title="encode a Singleton data key of valueContent Address"
import ERC725 from '@erc725/erc725.js';

const schemas = [
{
name: 'LSP1UniversalReceiverDelegate',
key: '0x0cfc51aec37c55a4d0b1a65c6255c4bf2fbdf6277f3cc0730c45b828b6db8b47',
keyType: 'Singleton',
valueType: 'address',
valueContent: 'Address',
},
];

const myErc725 = new ERC725(schemas);

myErc725.encodeData([
{
keyName: 'LSP1UniversalReceiverDelegate',
value: '0x1183790f29BE3cDfD0A102862fEA1a4a30b3AdAb',
},
]);
/**
{
keys: ['0x0cfc51aec37c55a4d0b1a65c6255c4bf2fbdf6277f3cc0730c45b828b6db8b47'],
values: ['0x1183790f29be3cdfd0a102862fea1a4a30b3adab'],
}
*/
```

</details>

<details>
<summary>Encode a <code>VerifiableURI</code> with JSON and uploaded URL</summary>

Expand Down Expand Up @@ -162,39 +200,10 @@ myErc725.encodeData([
*/
```

```javascript title="encode a Singleton data key of valueContent Address"
import ERC725 from '@erc725/erc725.js';

const schemas = [
{
name: 'LSP1UniversalReceiverDelegate',
key: '0x0cfc51aec37c55a4d0b1a65c6255c4bf2fbdf6277f3cc0730c45b828b6db8b47',
keyType: 'Singleton',
valueType: 'address',
valueContent: 'Address',
},
];

const myErc725 = new ERC725(schemas);

myErc725.encodeData([
{
keyName: 'LSP1UniversalReceiverDelegate',
value: '0x1183790f29BE3cDfD0A102862fEA1a4a30b3AdAb',
},
]);
/**
{
keys: ['0x0cfc51aec37c55a4d0b1a65c6255c4bf2fbdf6277f3cc0730c45b828b6db8b47'],
values: ['0x1183790f29be3cdfd0a102862fea1a4a30b3adab'],
}
*/
```

</details>

<details>
<summary>Encode a <code>VerifiableURI</code> with hash function, hash and uploaded URL</summary>
<summary>**Encode** a <code>VerifiableURI</code> with hash function, hash and uploaded URL</summary>

```javascript title="Encode a VerifiableURI with hash function, hash and uploaded URL"
import ERC725 from '@erc725/erc725.js';
Expand Down Expand Up @@ -459,6 +468,46 @@ myErc725.encodeData(

</details>

<details>
<summary>Encode a tuple for <code>valueType</code> / <code>valueContent</code></summary>

```javascript title="Encode a tuple for valueType / valueContent"
import ERC725 from '@erc725/erc725.js';

const schemas = [
{
name: 'LSP4CreatorsMap:<address>',
key: '0x6de85eaf5d982b4e5da00000<address>',
keyType: 'Mapping',
valueType: '(bytes4,uint128)',
valueContent: '(Bytes4,Number)',
},
];

ERC725.encodeData(
[
{
keyName: 'LSP4CreatorsMap:<address>',
dynamicKeyParts: "0xcafecafecafecafecafecafecafecafecafecafe"
value: ['0x24871b3d', '11'],
},
],
schemas,
);
/**
{
keys: [
'0xdf30dba06db6a30e65354d9a64c609861f089545ca58c6b4dbe31a5f338cb0e3', // -> data key for `LSP4CreatorsMap:0xcafecafecafecafecafecafecafecafecafecafe`
],
values: [
'0x24871b3d0000000000000000000000000000000b', // (bytes4,uint128)
],
}
*/
```

</details>

---

### encodeKeyName
Expand Down Expand Up @@ -884,6 +933,38 @@ myErc725.decodeData(

---

#### Tuple Example

```javascript title="Decode a key with tuple as valueType / valueContent"
import ERC725 from '@erc725/erc725.js';

const schemas = [
{
name: 'LSP4CreatorsMap:<address>',
key: '0x6de85eaf5d982b4e5da00000<address>',
keyType: 'Mapping',
valueType: '(bytes4,uint128)',
valueContent: '(Bytes4,Number)',
},
];

ERC725.decodeData(
{
keyName: 'LSP4CreatorsMap:<address>',
dynamicKeyParts: "0xcafecafecafecafecafecafecafecafecafecafe"
value: "0x24871b3d0000000000000000000000000000000b",
},
schemas,
);
/**
{
key: '0x6de85eaf5d982b4e5da00000cafecafecafecafecafecafecafecafecafecafe',
name: 'LSP4CreatorsMap:cafecafecafecafecafecafecafecafecafecafe',
value: ['0x24871b3d', 11]
}
*/
```

### decodeValueType

```js
Expand Down
Loading

0 comments on commit 57fbc2a

Please sign in to comment.