From ab8af3951b1b4f85fda57abebc6895ac81b29b0b Mon Sep 17 00:00:00 2001 From: CJ42 Date: Mon, 22 Jan 2024 16:45:00 +0000 Subject: [PATCH] docs: add example on how to import schema from `./schemas/` folder --- docs/schemas.md | 26 +++++++++++++++++++++++--- src/schemas/index.ts | 15 +++++++++++++++ 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/docs/schemas.md b/docs/schemas.md index 42ecde81..2f7f0b21 100644 --- a/docs/schemas.md +++ b/docs/schemas.md @@ -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 @@ -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'; diff --git a/src/schemas/index.ts b/src/schemas/index.ts index 2cfbfdfd..0011630c 100644 --- a/src/schemas/index.ts +++ b/src/schemas/index.ts @@ -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;