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

docs: use toggles to display better examples of encoding #300

Merged
merged 2 commits into from
Aug 3, 2023
Merged
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
44 changes: 32 additions & 12 deletions docs/classes/ERC725.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ An array of extra [LSP-2 ERC725YJSONSchema] objects that can be used to find the

:::

#### Single-Key Example
### Single-Key Example

```javascript title="Decoding an object with one key"
myErc725.decodeData([
Expand Down Expand Up @@ -95,7 +95,7 @@ myErc725.decodeData({
*/
```

#### Multi-Key Example
### Multi-Key Example

```javascript title="Decoding an object with multiple keys"
myErc725.decodeData([
Expand Down Expand Up @@ -146,7 +146,7 @@ myErc725.decodeData([
*/
```

#### Dynamic-Key Example
### Dynamic-Key Example

```javascript title="Decoding an object with dynamic key and a custom schema"
const schemas = [
Expand Down Expand Up @@ -322,6 +322,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>

```javascript title="Encode a JSONURL with JSON and uploaded URL"
myErc725.encodeData([
{
Expand Down Expand Up @@ -389,6 +392,11 @@ myErc725.encodeData([
*/
```

</details>

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

```javascript title="Encode a JSONURL with hash function, hash and uploaded URL"
myErc725.encodeData([
{
Expand All @@ -408,6 +416,11 @@ myErc725.encodeData([
*/
```

</details>

<details>
<summary>Encode dynamic keys</summary>

```javascript title="Encode dynamic keys"
const schemas = [
{
Expand Down Expand Up @@ -464,6 +477,11 @@ myErc725.encodeData(
*/
```

</details>

<details>
<summary>Encode multiple keys at once</summary>

```javascript title="Encode multiple keys at once"
myErc725.encodeData([
{
Expand Down Expand Up @@ -506,6 +524,8 @@ myErc725.encodeData([
*/
```

</details>

---

## encodeKeyName
Expand Down Expand Up @@ -779,7 +799,7 @@ The name(s) (or the encoded name(s) as schema key) of the element(s) in the smar

:::

#### All-Keys Example
### All-Keys Example

```javascript title="Receiving all keys from the schema"
await myErc725.fetchData();
Expand Down Expand Up @@ -820,7 +840,7 @@ await myErc725.fetchData();
*/
```

#### Single-Key Example
### Single-Key Example

```javascript title="Receiving one key from the schema"
await myErc725.fetchData('LSP3Profile');
Expand All @@ -843,7 +863,7 @@ await myErc725.fetchData(['LSP1UniversalReceiverDelegate']);
*/
```

#### Multi-Keys / Dynamic-Keys Example
### Multi-Keys / Dynamic-Keys Example

```javascript title="Receiving multiple keys from the schema"
await myErc725.fetchData(['LSP3Profile', 'LSP1UniversalReceiverDelegate']);
Expand Down Expand Up @@ -928,7 +948,7 @@ The name(s) (or the encoded name(s) as schema key) of the element(s) in the smar

:::

#### All-Keys Example
### All-Keys Example

```javascript title="Receiving all keys from the schema"
await myErc725.getData();
Expand Down Expand Up @@ -973,7 +993,7 @@ await myErc725.getData();
*/
```

#### Single-Key Example
### Single-Key Example

```javascript title="Receiving one key from the schema"
await myErc725.getData('LSP3Profile');
Expand Down Expand Up @@ -1014,7 +1034,7 @@ await myErc725.getData('LSP1UniversalReceiverDelegate');
*/
```

#### Multi-Key Example
### Multi-Key Example

```javascript title="Receiving multiple keys from the schema"
await myErc725.getData(['LSP3Profile', 'LSP1UniversalReceiverDelegate']);
Expand All @@ -1038,7 +1058,7 @@ await myErc725.getData(['LSP3Profile', 'LSP1UniversalReceiverDelegate']);
*/
```

#### Dynamic-Key Example
### Dynamic-Key Example

```javascript title="Receiving dynamic keys from the schema"
await myErc725.getData({
Expand Down Expand Up @@ -1170,7 +1190,7 @@ An array of extra [LSP-2 ERC725YJSONSchema] objects that can be used to find the
| `result` | Record string | If the parameter `keys` is a string[&nbsp;] and the schema was found. |
| `result` | null | If the schema was not found. |

#### Example using a predefined LSP3 schema
### Example using a predefined LSP3 schema

```javascript title="Parsing the hashed key from the LSP3 schema"
myErc725.getSchema(
Expand Down Expand Up @@ -1209,7 +1229,7 @@ myErc725.getSchema([
*/
```

#### Example using a custom schema
### Example using a custom schema

```javascript title="Parsing the hashed key from a custom schema"
myErc725.getSchema(
Expand Down
Loading