Skip to content

Commit

Permalink
docs: add example on how to import schema from ./schemas/ folder
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ42 committed Jan 22, 2024
1 parent c54a370 commit ab8af39
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
26 changes: 23 additions & 3 deletions docs/schemas.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,29 @@ _A quick reference for keys used in schema definitions can be seen below_

## Standard LSP Schemas

The most common schemas of [LUKSO Standard Proposals](https://github.com/lukso-network/LIPs/tree/main/LSPs) are available under the [`schemas/`](https://github.com/ERC725Alliance/erc725.js/tree/develop/schemas) folder.
The most common schemas of [LUKSO Standard Proposals](https://github.com/lukso-network/LIPs/tree/main/LSPs) are available to import. These are typed automatically with the Typescript type `ERC725JSONSchema[]` for when instantiating `new ERC725(...)` from Typescript projects.

Current provided LSPs are:
```ts
import {
LSP1Schema,
LSP3Schema,
LSP4Schema,
LSP4LegacySchema,
LSP5Schema,
LSP6Schema,
LSP8Schema,
LSP9Schema,
LSP10Schema,
LSP12Schema,
LSP17Schema,
} from '@erc725/erc725.js/schemas';

const erc725js = new ERC725(LSP12Schema);
```

The raw JSON schemas are also available for import from the [`schemas/`](https://github.com/ERC725Alliance/erc725.js/tree/develop/schemas) folder.

Current provided LSPs JSON schemas are:

```
LSP1UniversalReceiverDelegate.json
Expand All @@ -38,7 +58,7 @@ LSP12IssuedAssets.json
LSP17ContractExtension.json
```

You can import them from:
You can import the raw JSON as follow:

```js
import LSP3 from '@erc725/erc725.js/schemas/LSP3ProfileMetadata.json';
Expand Down
15 changes: 15 additions & 0 deletions src/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,18 @@ export const LSP9Schema: schemaType = LSP9JSONSchema as schemaType;
export const LSP10Schema: schemaType = LSP10JSONSchema as schemaType;
export const LSP12Schema: schemaType = LSP12JSONSchema as schemaType;
export const LSP17Schema: schemaType = LSP17JSONSchema as schemaType;

const AllSchemas = LSP1Schema.concat(
LSP3Schema,
LSP4Schema,
LSP4LegacySchema,
LSP5Schema,
LSP6Schema,
LSP8Schema,
LSP9Schema,
LSP10Schema,
LSP12Schema,
LSP17Schema,
);

export default AllSchemas;

0 comments on commit ab8af39

Please sign in to comment.