Skip to content

Commit

Permalink
docs: improve code snippets with import
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ42 committed May 15, 2024
1 parent de846cd commit 758730c
Showing 1 changed file with 44 additions and 3 deletions.
47 changes: 44 additions & 3 deletions docs/classes/fetching-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ The name(s) (or the encoded name(s) as schema key) of the element(s) in the smar
### All-Keys Example

```javascript title="Receiving all keys from the schema"
import ERC725 from '@erc725/erc725.js';
import LSP3Schemas from '@erc725/erc725.js/schemas/LSP3ProfileMetadata.sjon';
const universalProfileAddress = '0x0F4180da178ed1C71398a57ca8Cb177F69591f1f';

const myErc725 = new ERC725(LSP3Schemas, universalProfileAddress);
await myErc725.fetchData();
/**
[
Expand Down Expand Up @@ -88,6 +93,12 @@ await myErc725.fetchData();
### Single-Key Example

```javascript title="Receiving one key from the schema"
import ERC725 from '@erc725/erc725.js';
import LSP3Schemas from '@erc725/erc725.js/schemas/LSP3ProfileMetadata.sjon';
const universalProfileAddress = '0x0F4180da178ed1C71398a57ca8Cb177F69591f1f';

const myErc725 = new ERC725(LSP3Schemas, universalProfileAddress);

await myErc725.fetchData('LSP3Profile');
/**
{
Expand All @@ -111,6 +122,12 @@ await myErc725.fetchData(['LSP1UniversalReceiverDelegate']);
### Multi-Keys / Dynamic-Keys Example

```javascript title="Receiving multiple keys from the schema"
import ERC725 from '@erc725/erc725.js';
import LSP3Schemas from '@erc725/erc725.js/schemas/LSP3ProfileMetadata.sjon';
const universalProfileAddress = '0x0F4180da178ed1C71398a57ca8Cb177F69591f1f';

const myErc725 = new ERC725(LSP3Schemas, universalProfileAddress);

await myErc725.fetchData(['LSP3Profile', 'LSP1UniversalReceiverDelegate']);
/**
[
Expand Down Expand Up @@ -195,6 +212,12 @@ The name(s) (or the encoded name(s) as schema key) of the element(s) in the smar
### All-Keys Example

```javascript title="Receiving all keys from the schema"
import ERC725 from '@erc725/erc725.js';
import LSP3Schemas from '@erc725/erc725.js/schemas/LSP3ProfileMetadata.sjon';
const universalProfileAddress = '0x0F4180da178ed1C71398a57ca8Cb177F69591f1f';

const myErc725 = new ERC725(LSP3Schemas, universalProfileAddress);

await myErc725.getData();
/**
[
Expand Down Expand Up @@ -242,6 +265,12 @@ await myErc725.getData();
### Single-Key Example

```javascript title="Receiving one key from the schema"
import ERC725 from '@erc725/erc725.js';
import LSP3Schemas from '@erc725/erc725.js/schemas/LSP3ProfileMetadata.sjon';
const universalProfileAddress = '0x0F4180da178ed1C71398a57ca8Cb177F69591f1f';

const myErc725 = new ERC725(LSP3Schemas, universalProfileAddress);

await myErc725.getData('LSP3Profile');
/**
{
Expand Down Expand Up @@ -287,6 +316,12 @@ await myErc725.getData('LSP1UniversalReceiverDelegate');
### Multi-Key Example

```javascript title="Receiving multiple keys from the schema"
import ERC725 from '@erc725/erc725.js';
import LSP3Schemas from '@erc725/erc725.js/schemas/LSP3ProfileMetadata.sjon';
const universalProfileAddress = '0x0F4180da178ed1C71398a57ca8Cb177F69591f1f';

const myErc725 = new ERC725(LSP3Schemas, universalProfileAddress);

await myErc725.getData(['LSP3Profile', 'LSP1UniversalReceiverDelegate']);
/**
[
Expand All @@ -313,14 +348,20 @@ await myErc725.getData(['LSP3Profile', 'LSP1UniversalReceiverDelegate']);
### Dynamic-Key Example

```javascript title="Receiving dynamic keys from the schema"
import ERC725 from '@erc725/erc725.js';
import LSP3Schemas from '@erc725/erc725.js/schemas/LSP3ProfileMetadata.sjon';
const luksoUniversalProfile = '0x8363Cfe6c787218f0ADA0A4aBC289A8d9dfc2453';

const myErc725 = new ERC725(LSP3Schemas, luksoUniversalProfile);

await myErc725.getData({
keyName: 'LSP12IssuedAssetsMap:<address>',
dynamicKeyParts: '0xcafecafecafecafecafecafecafecafecafecafe',
dynamicKeyParts: '0x592dCACb0A0d4b85eea0975992E42Bc543207F74', // asset address (KidSuper World Arts Path)
});
/**
{
name: 'LSP12IssuedAssetsMap:cafecafecafecafecafecafecafecafecafecafe',
key: '0x74ac2555c10b9349e78f0000cafecafecafecafecafecafecafecafecafecafe',
name: 'LSP12IssuedAssetsMap:592dCACb0A0d4b85eea0975992E42Bc543207F74',
key: '0x74ac2555c10b9349e78f0000592dCACb0A0d4b85eea0975992E42Bc543207F74',
value: '0x6b175474e89094c44da98b954eedeac495271d0f',
}
*/
Expand Down

0 comments on commit 758730c

Please sign in to comment.