From 239bbf0417a66e6d1862479252faa317a11d6ea3 Mon Sep 17 00:00:00 2001 From: Jean Cvllr <31145285+CJ42@users.noreply.github.com> Date: Thu, 3 Aug 2023 10:45:17 +0100 Subject: [PATCH] docs: use toggles to display better examples of encoding (#300) * docs: show examples in details toggle for readability * docs: improve subheadings to display on sidebar --- docs/classes/ERC725.md | 44 ++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/docs/classes/ERC725.md b/docs/classes/ERC725.md index 06ca8d4d..ac065183 100644 --- a/docs/classes/ERC725.md +++ b/docs/classes/ERC725.md @@ -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([ @@ -95,7 +95,7 @@ myErc725.decodeData({ */ ``` -#### Multi-Key Example +### Multi-Key Example ```javascript title="Decoding an object with multiple keys" myErc725.decodeData([ @@ -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 = [ @@ -322,6 +322,9 @@ After the `data` is encoded, the object is ready to be stored in smart contracts #### Examples +
+ Encode a JSONURL with JSON and uploaded URL + ```javascript title="Encode a JSONURL with JSON and uploaded URL" myErc725.encodeData([ { @@ -389,6 +392,11 @@ myErc725.encodeData([ */ ``` +
+ +
+ Encode a JSONURL with hash function, hash and uploaded URL + ```javascript title="Encode a JSONURL with hash function, hash and uploaded URL" myErc725.encodeData([ { @@ -408,6 +416,11 @@ myErc725.encodeData([ */ ``` +
+ +
+ Encode dynamic keys + ```javascript title="Encode dynamic keys" const schemas = [ { @@ -464,6 +477,11 @@ myErc725.encodeData( */ ``` +
+ +
+ Encode multiple keys at once + ```javascript title="Encode multiple keys at once" myErc725.encodeData([ { @@ -506,6 +524,8 @@ myErc725.encodeData([ */ ``` +
+ --- ## encodeKeyName @@ -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(); @@ -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'); @@ -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']); @@ -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(); @@ -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'); @@ -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']); @@ -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({ @@ -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[ ] 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( @@ -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(