Skip to content

Commit

Permalink
docs: update README and examples and docs for VerifiableURI
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugoo committed Dec 14, 2023
1 parent 44315cc commit 2e22522
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 45 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const schema = [
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
keyType: 'Singleton',
valueContent: 'JSONURL',
valueContent: 'VerifiableURI',
valueType: 'bytes',
},
{
Expand Down
31 changes: 15 additions & 16 deletions docs/classes/ERC725.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ const schemas = [
key: '0x...',
keyType: 'Singleton',
valueType: 'bytes',
valueContent: 'JSONURL',
valueContent: 'VerifiableURI',
},
];

Expand All @@ -251,7 +251,7 @@ myErc725.decodeData(
'true',
],
value:
'0x6f357c6a820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361696670733a2f2f516d597231564a4c776572673670456f73636468564775676f3339706136727963455a4c6a7452504466573834554178',
'0x00006f357c6a0020820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361696670733a2f2f516d597231564a4c776572673670456f73636468564775676f3339706136727963455a4c6a7452504466573834554178',
},
],
schemas,
Expand Down Expand Up @@ -469,9 +469,9 @@ After the `data` is encoded, the object is ready to be stored in smart contracts
#### Examples
<details>
<summary>Encode a <code>JSONURL</code> with JSON and uploaded URL</summary>
<summary>Encode a <code>VerifiableURI</code> with JSON and uploaded URL</summary>
```javascript title="Encode a JSONURL with JSON and uploaded URL"
```javascript title="Encode a VerifiableURI with JSON and uploaded URL"
myErc725.encodeData([
{
keyName: 'LSP3Profile',
Expand Down Expand Up @@ -541,9 +541,9 @@ myErc725.encodeData([
</details>

<details>
<summary>Encode a <code>JSONURL</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 JSONURL with hash function, hash and uploaded URL"
```javascript title="Encode a VerifiableURI with hash function, hash and uploaded URL"
myErc725.encodeData([
{
keyName: 'LSP3Profile',
Expand Down Expand Up @@ -1005,7 +1005,7 @@ myErc725.decodeMappingKey(
myErc725.fetchData([keys]);
```

The `fetchData` function fetches smart contract data and can additionally return [`JSONURL`](https://github.com/lukso-network/LIPs/blob/master/LSPs/LSP-2-ERC725YJSONSchema.md#jsonurl) or [`ASSETURL`](https://github.com/lukso-network/LIPs/blob/master/LSPs/LSP-2-ERC725YJSONSchema.md#asseturl) data from IPFS, HTTP, or HTTPS endpoints.
The `fetchData` function fetches smart contract data and can additionally return [`VerifiableURI`](https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md#verifiableuri) data from IPFS, HTTP, or HTTPS endpoints.

:::info

Expand All @@ -1032,9 +1032,9 @@ The name(s) (or the encoded name(s) as schema key) of the element(s) in the smar

#### Returns

| Name | Type | Description |
| :--- | :------------------------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| data | `Promise<Array>` or <br/> `Promise<Object>` | An array with same objects as for [`decodeData()`](./ERC725#decodedata) function but with the value being remplaced by the actual file for `JSONURL` and `ASSETURL` valueContent. If there is a hash mismatch, the value will be `null`. |
| Name | Type | Description |
| :--- | :------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| data | `Promise<Array>` or <br/> `Promise<Object>` | An array with same objects as for [`decodeData()`](./ERC725#decodedata) function but with the value being remplaced by the actual file for `VerifiableURI` valueContent. If there is a hash mismatch, the value will be `null`. |

:::info

Expand Down Expand Up @@ -1162,8 +1162,7 @@ When omitting the `keys` parameter, it will give back every key (as per `ERC725J

:::caution

- Data returned by this function does not contain external data of [`JSONURL`](https://github.com/lukso-network/LIPs/blob/master/LSPs/LSP-2-ERC725YJSONSchema.md#jsonurl)
or [`ASSETURL`](https://github.com/lukso-network/LIPs/blob/master/LSPs/LSP-2-ERC725YJSONSchema.md#asseturl) schema elements.
- Data returned by this function does not contain external data of [`VerifiableURI`](https://github.com/lukso-network/LIPs/blob/main/LSPs/LSP-2-ERC725YJSONSchema.md#verifiableuri) schema elements.
- If you would like to receive everything in one go, you can use [`fetchData`](ERC725.md#fetchdata).

:::
Expand Down Expand Up @@ -1455,7 +1454,7 @@ myErc725.getSchema(
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
keyType: 'Singleton',
valueContent: 'JSONURL',
valueContent: 'VerifiableURI',
valueType: 'bytes'
}
*/
Expand All @@ -1469,7 +1468,7 @@ myErc725.getSchema([
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
keyType: 'Singleton',
valueContent: 'JSONURL',
valueContent: 'VerifiableURI',
valueType: 'bytes'
},
'0x3a47ab5bd3a594c3a8995f8fa58d087600000000000000000000000000000001': {
Expand All @@ -1493,7 +1492,7 @@ myErc725.getSchema(
name: 'ParameterSchema',
key: '0x777f55baf2e0c9f73d3bb456dfb8dbf6e609bf557969e3184c17ff925b3c402c',
keyType: 'Singleton',
valueContent: 'JSONURL',
valueContent: 'VerifiableURI',
valueType: 'bytes',
},
],
Expand All @@ -1503,7 +1502,7 @@ myErc725.getSchema(
name: 'ParameterSchema',
key: '0x777f55baf2e0c9f73d3bb456dfb8dbf6e609bf557969e3184c17ff925b3c402c',
keyType: 'Singleton',
valueContent: 'JSONURL',
valueContent: 'VerifiableURI',
valueType: 'bytes',
}
*/
Expand Down
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const schemas = [
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
keyType: 'Singleton',
valueType: 'bytes',
valueContent: 'JSONURL',
valueContent: 'VerifiableURI',
},
{
name: 'LSP1UniversalReceiverDelegate',
Expand Down
27 changes: 0 additions & 27 deletions examples/src/decodeData.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,6 @@ const decodedDataOneKey = myERC725.decodeData([
]
*/

const decodedDataOneKeyOld = myERC725.decodeData([
{
keyName: 'LSP3Profile',
value:
'0x6f357c6a820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361697066733a2f2f516d597231564a4c776572673670456f73636468564775676f3339706136727963455a4c6a7452504466573834554178',
},
]);
/**
[
{
name: 'LSP3Profile',
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value: {
verification: {
method: 'keccak256(utf8)',
data: '0x820464ddfac1bec070cc14a8daf04129871d458f2ca94368aae8391311af6361',
},
url: 'ipfs://QmYr1VJLwerg6pEoscdhVGugo39pa6rycEZLjtRPDfW84UAx'
}
}
]
*/

const decodedDataManyKeys = myERC725.decodeData([
{
keyName: 'LSP3Profile',
Expand Down Expand Up @@ -103,10 +80,6 @@ console.log('/* decodeData - one key (VerifiableURI) /*');
console.log('/*--------------------------------------------/*');
console.log(decodedDataOneKey);
console.log('/*--------------------------------------------/*');
console.log('/* decodeData - one key (JSONURL) /*');
console.log('/*--------------------------------------------/*');
console.log(decodedDataOneKeyOld);
console.log('/*--------------------------------------------/*');
console.log('/* decodeData - many keys /*');
console.log('/*--------------------------------------------/*');
console.log(decodedDataManyKeys);

0 comments on commit 2e22522

Please sign in to comment.