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

rebase: Merge develop to main #468

Merged
merged 19 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7613e2a
docs: add missing code sandbox from docs.lukso.tech
CJ42 Jun 5, 2024
2a3f80f
Merge pull request #454 from ERC725Alliance/docs/codesandbox
Hugoo Jun 17, 2024
a443fe2
Revert "refactor: improve code for `Literal` hex for `valueContent`" …
CJ42 Jun 22, 2024
8396676
Merge pull request #458 from ERC725Alliance/revert/decode-value-conte…
CJ42 Jun 24, 2024
db52578
docs: add descriptions for encoding / decoding tuples
CJ42 Jun 25, 2024
efa426e
chore: remove `.only` and `console.log`
CJ42 Jun 27, 2024
1bfd9e8
Merge pull request #460 from ERC725Alliance/docs/encode-decode-tuple
Hugoo Jun 27, 2024
9e7c807
Merge pull request #383 from ERC725Alliance/fix/upgrade-modules
richtera Mar 29, 2024
239c98c
fix: Some cleanup, remove global-agent, some new minor upgrades
richtera Jun 24, 2024
036f73f
Update src/lib/encodeKeyName.ts
richtera Jun 28, 2024
95dabb2
fix: Normalize tests and add name as a constant in the schema. Add no…
richtera Jul 1, 2024
cef4e15
fix: Repair tests and 0x prefix for dynamic fields in some places.
richtera Jul 2, 2024
2874516
fix: Repair and use dynamicName and dynamicKeyParts.
richtera Jul 9, 2024
b0ffa5b
fix: Repair limitation
richtera Jul 9, 2024
a99f8c5
Merge pull request #462 from ERC725Alliance/feat/tests
richtera Jul 9, 2024
8a397ef
Merge pull request #459 from ERC725Alliance/feat/upgrades
CJ42 Jul 9, 2024
3eef9bf
build: fix package-lock
CJ42 Jul 9, 2024
c7458c1
Merge pull request #467 from ERC725Alliance/fix/package-lock
CJ42 Jul 9, 2024
57fbc2a
Merge branch 'develop'
richtera Jul 9, 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
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
Loading