From 231c097bbcfceca7ed80ebdb921d4dd05c4a73e8 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Tue, 3 May 2022 14:02:36 -0700 Subject: [PATCH 1/2] cleanup docs --- docs/sdk.smartcontract.md | 10 +- docs/sdk.smartcontract.metadata.md | 111 +----------- docs/sdk.smartcontract.platformfees.md | 2 +- docs/sdk.smartcontract.roles.md | 2 +- docs/sdk.smartcontract.royalties.md | 111 +----------- docs/sdk.smartcontract.sales.md | 2 +- etc/sdk.api.md | 240 +------------------------ src/constants/contract-features.ts | 13 +- src/constants/thirdweb-features.ts | 36 ++++ src/contracts/edition-drop.ts | 4 +- src/contracts/edition.ts | 12 +- src/contracts/nft-collection.ts | 18 +- src/contracts/nft-drop.ts | 12 +- src/contracts/smart-contract.ts | 29 +-- src/contracts/token.ts | 8 +- src/core/classes/contract-royalty.ts | 1 + 16 files changed, 111 insertions(+), 500 deletions(-) create mode 100644 src/constants/thirdweb-features.ts diff --git a/docs/sdk.smartcontract.md b/docs/sdk.smartcontract.md index 70a688662..9945bf715 100644 --- a/docs/sdk.smartcontract.md +++ b/docs/sdk.smartcontract.md @@ -55,13 +55,13 @@ const tx = await contract.nft.mint.to("0x...", { | [events](./sdk.smartcontract.events.md) | | [ContractEvents](./sdk.contractevents.md)<TContract> | (BETA) | | [functions](./sdk.smartcontract.functions.md) | | any | (BETA) Call any function in this contract using the function signature ex: contract.functions.mint(address, quantity) | | [interceptor](./sdk.smartcontract.interceptor.md) | | ContractInterceptor<TContract> | (BETA) | -| [metadata](./sdk.smartcontract.metadata.md) | | [ContractMetadata](./sdk.contractmetadata.md)<TContract, { deploy: import("zod").ZodObject<import("zod").extendShape<import("zod").extendShape<{ name: import("zod").ZodString; description: import("zod").ZodOptional<import("zod").ZodString>; image: import("zod").ZodOptional<import("zod").ZodUnion<\[import("zod").ZodTypeAny, import("zod").ZodString\]>>; external\_link: import("zod").ZodOptional<import("zod").ZodString>; }, { merkle: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>>; seller\_fee\_basis\_points: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>; fee\_recipient: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodEffects<import("zod").ZodString, string, string>>>; symbol: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>>; }>, { primary\_sale\_recipient: import("zod").ZodOptional<import("zod").ZodEffects<import("zod").ZodString, string, string>>; platform\_fee\_basis\_points: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>; platform\_fee\_recipient: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodEffects<import("zod").ZodString, string, string>>>; trusted\_forwarders: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodEffects<import("zod").ZodString, string, string>, "many">>>; }>, "strip", import("zod").ZodLazy<import("zod").ZodType<import("../core").[Json](./sdk.json.md), import("zod").ZodTypeDef, import("../core").[Json](./sdk.json.md)>>, { \[x: string\]: import("../core").[Json](./sdk.json.md); symbol?: string \| undefined; merkle?: Record<string, string> \| undefined; description?: string \| undefined; image?: any; external\_link?: string \| undefined; seller\_fee\_basis\_points?: number \| undefined; fee\_recipient?: string \| undefined; primary\_sale\_recipient?: string \| undefined; platform\_fee\_basis\_points?: number \| undefined; platform\_fee\_recipient?: string \| undefined; trusted\_forwarders?: string\[\] \| undefined; name: string; }, { \[x: string\]: import("../core").[Json](./sdk.json.md); symbol?: string \| undefined; merkle?: Record<string, string> \| undefined; description?: string \| undefined; image?: any; external\_link?: string \| undefined; seller\_fee\_basis\_points?: number \| undefined; fee\_recipient?: string \| undefined; primary\_sale\_recipient?: string \| undefined; platform\_fee\_basis\_points?: number \| undefined; platform\_fee\_recipient?: string \| undefined; trusted\_forwarders?: string\[\] \| undefined; name: string; }>; output: import("zod").ZodObject<import("zod").extendShape<import("zod").extendShape<{ name: import("zod").ZodString; description: import("zod").ZodOptional<import("zod").ZodString>; image: import("zod").ZodOptional<import("zod").ZodUnion<\[import("zod").ZodTypeAny, import("zod").ZodString\]>>; external\_link: import("zod").ZodOptional<import("zod").ZodString>; }, { image: import("zod").ZodOptional<import("zod").ZodString>; }>, { merkle: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>>; seller\_fee\_basis\_points: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>; fee\_recipient: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodEffects<import("zod").ZodString, string, string>>>; symbol: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>>; }>, "strip", import("zod").ZodLazy<import("zod").ZodType<import("../core").[Json](./sdk.json.md), import("zod").ZodTypeDef, import("../core").[Json](./sdk.json.md)>>, { \[x: string\]: import("../core").[Json](./sdk.json.md); symbol?: string \| undefined; merkle?: Record<string, string> \| undefined; description?: string \| undefined; image?: string \| undefined; external\_link?: string \| undefined; seller\_fee\_basis\_points?: number \| undefined; fee\_recipient?: string \| undefined; name: string; }, { \[x: string\]: import("../core").[Json](./sdk.json.md); symbol?: string \| undefined; merkle?: Record<string, string> \| undefined; description?: string \| undefined; image?: string \| undefined; external\_link?: string \| undefined; seller\_fee\_basis\_points?: number \| undefined; fee\_recipient?: string \| undefined; name: string; }>; input: import("zod").ZodObject<import("zod").extendShape<{ name: import("zod").ZodString; description: import("zod").ZodOptional<import("zod").ZodString>; image: import("zod").ZodOptional<import("zod").ZodUnion<\[import("zod").ZodTypeAny, import("zod").ZodString\]>>; external\_link: import("zod").ZodOptional<import("zod").ZodString>; }, { merkle: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>>; seller\_fee\_basis\_points: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>; fee\_recipient: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodEffects<import("zod").ZodString, string, string>>>; symbol: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>>; }>, "strip", import("zod").ZodLazy<import("zod").ZodType<import("../core").[Json](./sdk.json.md), import("zod").ZodTypeDef, import("../core").[Json](./sdk.json.md)>>, { \[x: string\]: import("../core").[Json](./sdk.json.md); symbol?: string \| undefined; merkle?: Record<string, string> \| undefined; description?: string \| undefined; image?: any; external\_link?: string \| undefined; seller\_fee\_basis\_points?: number \| undefined; fee\_recipient?: string \| undefined; name: string; }, { \[x: string\]: import("../core").[Json](./sdk.json.md); symbol?: string \| undefined; merkle?: Record<string, string> \| undefined; description?: string \| undefined; image?: any; external\_link?: string \| undefined; seller\_fee\_basis\_points?: number \| undefined; fee\_recipient?: string \| undefined; name: string; }>; }> | (BETA) | +| [metadata](./sdk.smartcontract.metadata.md) | | [ContractMetadata](./sdk.contractmetadata.md)<ThirdwebContract, any> \| undefined | (BETA) | | [nft](./sdk.smartcontract.nft.md) | | [Erc721](./sdk.erc721.md)<BaseERC721> \| undefined | (BETA) Auto-detects ERC721 standard functions. | -| [platformFees](./sdk.smartcontract.platformfees.md) | | [ContractPlatformFee](./sdk.contractplatformfee.md)<TContract & IThirdwebPlatformFee> \| undefined | (BETA) | +| [platformFees](./sdk.smartcontract.platformfees.md) | | [ContractPlatformFee](./sdk.contractplatformfee.md)<IThirdwebPlatformFee> \| undefined | (BETA) | | [publishedMetadata](./sdk.smartcontract.publishedmetadata.md) | | ContractPublishedMetadata<TContract> | (BETA) | -| [roles](./sdk.smartcontract.roles.md) | | [ContractRoles](./sdk.contractroles.md)<TContract & AccessControlEnumerable, "transfer" \| "lister" \| "minter" \| "admin" \| "pauser" \| "editor" \| "asset"> \| undefined | (BETA) | -| [royalties](./sdk.smartcontract.royalties.md) | | [ContractRoyalty](./sdk.contractroyalty.md)<TContract & IThirdwebContract & IThirdwebRoyalty, { deploy: import("zod").ZodObject<import("zod").extendShape<import("zod").extendShape<{ name: import("zod").ZodString; description: import("zod").ZodOptional<import("zod").ZodString>; image: import("zod").ZodOptional<import("zod").ZodUnion<\[import("zod").ZodTypeAny, import("zod").ZodString\]>>; external\_link: import("zod").ZodOptional<import("zod").ZodString>; }, { merkle: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>>; seller\_fee\_basis\_points: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>; fee\_recipient: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodEffects<import("zod").ZodString, string, string>>>; symbol: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>>; }>, { primary\_sale\_recipient: import("zod").ZodOptional<import("zod").ZodEffects<import("zod").ZodString, string, string>>; platform\_fee\_basis\_points: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>; platform\_fee\_recipient: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodEffects<import("zod").ZodString, string, string>>>; trusted\_forwarders: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodEffects<import("zod").ZodString, string, string>, "many">>>; }>, "strip", import("zod").ZodLazy<import("zod").ZodType<import("../core").[Json](./sdk.json.md), import("zod").ZodTypeDef, import("../core").[Json](./sdk.json.md)>>, { \[x: string\]: import("../core").[Json](./sdk.json.md); symbol?: string \| undefined; merkle?: Record<string, string> \| undefined; description?: string \| undefined; image?: any; external\_link?: string \| undefined; seller\_fee\_basis\_points?: number \| undefined; fee\_recipient?: string \| undefined; primary\_sale\_recipient?: string \| undefined; platform\_fee\_basis\_points?: number \| undefined; platform\_fee\_recipient?: string \| undefined; trusted\_forwarders?: string\[\] \| undefined; name: string; }, { \[x: string\]: import("../core").[Json](./sdk.json.md); symbol?: string \| undefined; merkle?: Record<string, string> \| undefined; description?: string \| undefined; image?: any; external\_link?: string \| undefined; seller\_fee\_basis\_points?: number \| undefined; fee\_recipient?: string \| undefined; primary\_sale\_recipient?: string \| undefined; platform\_fee\_basis\_points?: number \| undefined; platform\_fee\_recipient?: string \| undefined; trusted\_forwarders?: string\[\] \| undefined; name: string; }>; output: import("zod").ZodObject<import("zod").extendShape<import("zod").extendShape<{ name: import("zod").ZodString; description: import("zod").ZodOptional<import("zod").ZodString>; image: import("zod").ZodOptional<import("zod").ZodUnion<\[import("zod").ZodTypeAny, import("zod").ZodString\]>>; external\_link: import("zod").ZodOptional<import("zod").ZodString>; }, { image: import("zod").ZodOptional<import("zod").ZodString>; }>, { merkle: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>>; seller\_fee\_basis\_points: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>; fee\_recipient: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodEffects<import("zod").ZodString, string, string>>>; symbol: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>>; }>, "strip", import("zod").ZodLazy<import("zod").ZodType<import("../core").[Json](./sdk.json.md), import("zod").ZodTypeDef, import("../core").[Json](./sdk.json.md)>>, { \[x: string\]: import("../core").[Json](./sdk.json.md); symbol?: string \| undefined; merkle?: Record<string, string> \| undefined; description?: string \| undefined; image?: string \| undefined; external\_link?: string \| undefined; seller\_fee\_basis\_points?: number \| undefined; fee\_recipient?: string \| undefined; name: string; }, { \[x: string\]: import("../core").[Json](./sdk.json.md); symbol?: string \| undefined; merkle?: Record<string, string> \| undefined; description?: string \| undefined; image?: string \| undefined; external\_link?: string \| undefined; seller\_fee\_basis\_points?: number \| undefined; fee\_recipient?: string \| undefined; name: string; }>; input: import("zod").ZodObject<import("zod").extendShape<{ name: import("zod").ZodString; description: import("zod").ZodOptional<import("zod").ZodString>; image: import("zod").ZodOptional<import("zod").ZodUnion<\[import("zod").ZodTypeAny, import("zod").ZodString\]>>; external\_link: import("zod").ZodOptional<import("zod").ZodString>; }, { merkle: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>>; seller\_fee\_basis\_points: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodNumber>>; fee\_recipient: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodEffects<import("zod").ZodString, string, string>>>; symbol: import("zod").ZodOptional<import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodString>>>; }>, "strip", import("zod").ZodLazy<import("zod").ZodType<import("../core").[Json](./sdk.json.md), import("zod").ZodTypeDef, import("../core").[Json](./sdk.json.md)>>, { \[x: string\]: import("../core").[Json](./sdk.json.md); symbol?: string \| undefined; merkle?: Record<string, string> \| undefined; description?: string \| undefined; image?: any; external\_link?: string \| undefined; seller\_fee\_basis\_points?: number \| undefined; fee\_recipient?: string \| undefined; name: string; }, { \[x: string\]: import("../core").[Json](./sdk.json.md); symbol?: string \| undefined; merkle?: Record<string, string> \| undefined; description?: string \| undefined; image?: any; external\_link?: string \| undefined; seller\_fee\_basis\_points?: number \| undefined; fee\_recipient?: string \| undefined; name: string; }>; }> \| undefined | (BETA) | -| [sales](./sdk.smartcontract.sales.md) | | [ContractPrimarySale](./sdk.contractprimarysale.md)<TContract & IThirdwebPrimarySale> \| undefined | (BETA) | +| [roles](./sdk.smartcontract.roles.md) | | [ContractRoles](./sdk.contractroles.md)<AccessControlEnumerable, any> \| undefined | (BETA) | +| [royalties](./sdk.smartcontract.royalties.md) | | [ContractRoyalty](./sdk.contractroyalty.md)<IThirdwebRoyalty & IThirdwebContract, any> \| undefined | (BETA) | +| [sales](./sdk.smartcontract.sales.md) | | [ContractPrimarySale](./sdk.contractprimarysale.md)<IThirdwebPrimarySale> \| undefined | (BETA) | | [token](./sdk.smartcontract.token.md) | | [Erc20](./sdk.erc20.md)<BaseERC20> \| undefined | (BETA) Auto-detects ERC20 standard functions. | ## Methods diff --git a/docs/sdk.smartcontract.metadata.md b/docs/sdk.smartcontract.metadata.md index 2322f3af9..dd7cd111a 100644 --- a/docs/sdk.smartcontract.metadata.md +++ b/docs/sdk.smartcontract.metadata.md @@ -10,114 +10,5 @@ Signature: ```typescript -metadata: ContractMetadata; - image: import("zod").ZodOptional>; - external_link: import("zod").ZodOptional; - }, { - merkle: import("zod").ZodOptional>>; - seller_fee_basis_points: import("zod").ZodOptional>; - fee_recipient: import("zod").ZodOptional>>; - symbol: import("zod").ZodOptional>>; - }>, { - primary_sale_recipient: import("zod").ZodOptional>; - platform_fee_basis_points: import("zod").ZodOptional>; - platform_fee_recipient: import("zod").ZodOptional>>; - trusted_forwarders: import("zod").ZodOptional, "many">>>; - }>, "strip", import("zod").ZodLazy>, { - [x: string]: import("../core").Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - primary_sale_recipient?: string | undefined; - platform_fee_basis_points?: number | undefined; - platform_fee_recipient?: string | undefined; - trusted_forwarders?: string[] | undefined; - name: string; - }, { - [x: string]: import("../core").Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - primary_sale_recipient?: string | undefined; - platform_fee_basis_points?: number | undefined; - platform_fee_recipient?: string | undefined; - trusted_forwarders?: string[] | undefined; - name: string; - }>; - output: import("zod").ZodObject; - image: import("zod").ZodOptional>; - external_link: import("zod").ZodOptional; - }, { - image: import("zod").ZodOptional; - }>, { - merkle: import("zod").ZodOptional>>; - seller_fee_basis_points: import("zod").ZodOptional>; - fee_recipient: import("zod").ZodOptional>>; - symbol: import("zod").ZodOptional>>; - }>, "strip", import("zod").ZodLazy>, { - [x: string]: import("../core").Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: string | undefined; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }, { - [x: string]: import("../core").Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: string | undefined; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }>; - input: import("zod").ZodObject; - image: import("zod").ZodOptional>; - external_link: import("zod").ZodOptional; - }, { - merkle: import("zod").ZodOptional>>; - seller_fee_basis_points: import("zod").ZodOptional>; - fee_recipient: import("zod").ZodOptional>>; - symbol: import("zod").ZodOptional>>; - }>, "strip", import("zod").ZodLazy>, { - [x: string]: import("../core").Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }, { - [x: string]: import("../core").Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }>; - }>; +metadata: ContractMetadata | undefined; ``` diff --git a/docs/sdk.smartcontract.platformfees.md b/docs/sdk.smartcontract.platformfees.md index e0ac5c016..7c000c22a 100644 --- a/docs/sdk.smartcontract.platformfees.md +++ b/docs/sdk.smartcontract.platformfees.md @@ -10,5 +10,5 @@ Signature: ```typescript -platformFees: ContractPlatformFee | undefined; +platformFees: ContractPlatformFee | undefined; ``` diff --git a/docs/sdk.smartcontract.roles.md b/docs/sdk.smartcontract.roles.md index 995cacccf..7e4b9de1f 100644 --- a/docs/sdk.smartcontract.roles.md +++ b/docs/sdk.smartcontract.roles.md @@ -10,5 +10,5 @@ Signature: ```typescript -roles: ContractRoles | undefined; +roles: ContractRoles | undefined; ``` diff --git a/docs/sdk.smartcontract.royalties.md b/docs/sdk.smartcontract.royalties.md index d498bd577..695762ce2 100644 --- a/docs/sdk.smartcontract.royalties.md +++ b/docs/sdk.smartcontract.royalties.md @@ -10,114 +10,5 @@ Signature: ```typescript -royalties: ContractRoyalty; - image: import("zod").ZodOptional>; - external_link: import("zod").ZodOptional; - }, { - merkle: import("zod").ZodOptional>>; - seller_fee_basis_points: import("zod").ZodOptional>; - fee_recipient: import("zod").ZodOptional>>; - symbol: import("zod").ZodOptional>>; - }>, { - primary_sale_recipient: import("zod").ZodOptional>; - platform_fee_basis_points: import("zod").ZodOptional>; - platform_fee_recipient: import("zod").ZodOptional>>; - trusted_forwarders: import("zod").ZodOptional, "many">>>; - }>, "strip", import("zod").ZodLazy>, { - [x: string]: import("../core").Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - primary_sale_recipient?: string | undefined; - platform_fee_basis_points?: number | undefined; - platform_fee_recipient?: string | undefined; - trusted_forwarders?: string[] | undefined; - name: string; - }, { - [x: string]: import("../core").Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - primary_sale_recipient?: string | undefined; - platform_fee_basis_points?: number | undefined; - platform_fee_recipient?: string | undefined; - trusted_forwarders?: string[] | undefined; - name: string; - }>; - output: import("zod").ZodObject; - image: import("zod").ZodOptional>; - external_link: import("zod").ZodOptional; - }, { - image: import("zod").ZodOptional; - }>, { - merkle: import("zod").ZodOptional>>; - seller_fee_basis_points: import("zod").ZodOptional>; - fee_recipient: import("zod").ZodOptional>>; - symbol: import("zod").ZodOptional>>; - }>, "strip", import("zod").ZodLazy>, { - [x: string]: import("../core").Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: string | undefined; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }, { - [x: string]: import("../core").Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: string | undefined; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }>; - input: import("zod").ZodObject; - image: import("zod").ZodOptional>; - external_link: import("zod").ZodOptional; - }, { - merkle: import("zod").ZodOptional>>; - seller_fee_basis_points: import("zod").ZodOptional>; - fee_recipient: import("zod").ZodOptional>>; - symbol: import("zod").ZodOptional>>; - }>, "strip", import("zod").ZodLazy>, { - [x: string]: import("../core").Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }, { - [x: string]: import("../core").Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }>; - }> | undefined; +royalties: ContractRoyalty | undefined; ``` diff --git a/docs/sdk.smartcontract.sales.md b/docs/sdk.smartcontract.sales.md index fe338f193..399eeca2d 100644 --- a/docs/sdk.smartcontract.sales.md +++ b/docs/sdk.smartcontract.sales.md @@ -10,5 +10,5 @@ Signature: ```typescript -sales: ContractPrimarySale | undefined; +sales: ContractPrimarySale | undefined; ``` diff --git a/etc/sdk.api.md b/etc/sdk.api.md index 1c073e454..ac85328dc 100644 --- a/etc/sdk.api.md +++ b/etc/sdk.api.md @@ -2262,9 +2262,7 @@ export class NFTCollection extends Erc721 { seller_fee_basis_points: ZodDefault; fee_recipient: ZodDefault>; }>, { - symbol: ZodDefault>; /** - * @internal - */ + symbol: ZodDefault>; }>, { platform_fee_basis_points: ZodDefault; platform_fee_recipient: ZodDefault>; @@ -2308,9 +2306,7 @@ export class NFTCollection extends Erc721 { seller_fee_basis_points: ZodDefault; fee_recipient: ZodDefault>; }>, { - symbol: ZodDefault>; /** - * @internal - */ + symbol: ZodDefault>; }>, "strip", ZodLazy>, { [x: string]: Json; description?: string | undefined; @@ -2339,9 +2335,7 @@ export class NFTCollection extends Erc721 { seller_fee_basis_points: ZodDefault; fee_recipient: ZodDefault>; }>, { - symbol: ZodDefault>; /** - * @internal - */ + symbol: ZodDefault>; }>, "strip", ZodTypeAny, { description?: string | undefined; image?: any; @@ -3647,240 +3641,22 @@ export class SmartContract; // (undocumented) - metadata: ContractMetadata; - image: ZodOptional>; - external_link: ZodOptional; - }, { - merkle: ZodOptional>>; - seller_fee_basis_points: ZodOptional>; - fee_recipient: ZodOptional>>; - symbol: ZodOptional>>; - }>, { - primary_sale_recipient: ZodOptional>; - platform_fee_basis_points: ZodOptional>; - platform_fee_recipient: ZodOptional>>; - trusted_forwarders: ZodOptional, "many">>>; - }>, "strip", ZodLazy>, { - [x: string]: Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - primary_sale_recipient?: string | undefined; - platform_fee_basis_points?: number | undefined; - platform_fee_recipient?: string | undefined; - trusted_forwarders?: string[] | undefined; - name: string; - }, { - [x: string]: Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - primary_sale_recipient?: string | undefined; - platform_fee_basis_points?: number | undefined; - platform_fee_recipient?: string | undefined; - trusted_forwarders?: string[] | undefined; - name: string; - }>; - output: ZodObject; - image: ZodOptional>; - external_link: ZodOptional; - }, { - image: ZodOptional; - }>, { - merkle: ZodOptional>>; - seller_fee_basis_points: ZodOptional>; - fee_recipient: ZodOptional>>; - symbol: ZodOptional>>; - }>, "strip", ZodLazy>, { - [x: string]: Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: string | undefined; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }, { - [x: string]: Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: string | undefined; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }>; - input: ZodObject; - image: ZodOptional>; - external_link: ZodOptional; - }, { - merkle: ZodOptional>>; - seller_fee_basis_points: ZodOptional>; - fee_recipient: ZodOptional>>; - symbol: ZodOptional>>; - }>, "strip", ZodLazy>, { - [x: string]: Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }, { - [x: string]: Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }>; - }>; + metadata: ContractMetadata | undefined; nft: Erc721 | undefined; // (undocumented) onNetworkUpdated(network: NetworkOrSignerOrProvider): void; // (undocumented) - platformFees: ContractPlatformFee | undefined; + platformFees: ContractPlatformFee | undefined; // Warning: (ae-incompatible-release-tags) The symbol "publishedMetadata" is marked as @beta, but its signature references "ContractPublishedMetadata" which is marked as @internal // // (undocumented) publishedMetadata: ContractPublishedMetadata; // (undocumented) - roles: ContractRoles | undefined; + roles: ContractRoles | undefined; // (undocumented) - royalties: ContractRoyalty; - image: ZodOptional>; - external_link: ZodOptional; - }, { - merkle: ZodOptional>>; - seller_fee_basis_points: ZodOptional>; - fee_recipient: ZodOptional>>; - symbol: ZodOptional>>; - }>, { - primary_sale_recipient: ZodOptional>; - platform_fee_basis_points: ZodOptional>; - platform_fee_recipient: ZodOptional>>; - trusted_forwarders: ZodOptional, "many">>>; - }>, "strip", ZodLazy>, { - [x: string]: Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - primary_sale_recipient?: string | undefined; - platform_fee_basis_points?: number | undefined; - platform_fee_recipient?: string | undefined; - trusted_forwarders?: string[] | undefined; - name: string; - }, { - [x: string]: Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - primary_sale_recipient?: string | undefined; - platform_fee_basis_points?: number | undefined; - platform_fee_recipient?: string | undefined; - trusted_forwarders?: string[] | undefined; - name: string; - }>; - output: ZodObject; - image: ZodOptional>; - external_link: ZodOptional; - }, { - image: ZodOptional; - }>, { - merkle: ZodOptional>>; - seller_fee_basis_points: ZodOptional>; - fee_recipient: ZodOptional>>; - symbol: ZodOptional>>; - }>, "strip", ZodLazy>, { - [x: string]: Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: string | undefined; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }, { - [x: string]: Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: string | undefined; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }>; - input: ZodObject; - image: ZodOptional>; - external_link: ZodOptional; - }, { - merkle: ZodOptional>>; - seller_fee_basis_points: ZodOptional>; - fee_recipient: ZodOptional>>; - symbol: ZodOptional>>; - }>, "strip", ZodLazy>, { - [x: string]: Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }, { - [x: string]: Json; - symbol?: string | undefined; - merkle?: Record | undefined; - description?: string | undefined; - image?: any; - external_link?: string | undefined; - seller_fee_basis_points?: number | undefined; - fee_recipient?: string | undefined; - name: string; - }>; - }> | undefined; + royalties: ContractRoyalty | undefined; // (undocumented) - sales: ContractPrimarySale | undefined; + sales: ContractPrimarySale | undefined; // @internal (undocumented) static schema: { deploy: ZodObject = { [FEATURE_TOKEN.name]: FEATURE_TOKEN, [FEATURE_NFT.name]: FEATURE_NFT, [FEATURE_EDITION.name]: FEATURE_EDITION, + [FEATURE_ROYALTY.name]: FEATURE_ROYALTY, + [FEATURE_PLATFORM_FEE.name]: FEATURE_PLATFORM_FEE, + [FEATURE_PRIMARY_SALE.name]: FEATURE_PRIMARY_SALE, }; diff --git a/src/constants/thirdweb-features.ts b/src/constants/thirdweb-features.ts new file mode 100644 index 000000000..50d1f0072 --- /dev/null +++ b/src/constants/thirdweb-features.ts @@ -0,0 +1,36 @@ +import IThirdwebPrimarySaleAbi from "../../abis/IThirdwebPrimarySale.json"; +import IThirdwebPlatformFeeAbi from "../../abis/IThirdwebPlatformFee.json"; +import IThirdwebRoyaltyAbi from "../../abis/IThirdwebRoyalty.json"; + +export const FEATURE_ROYALTY = { + name: "Royalty", + namespace: "sales", + docLinks: { + sdk: "sdk.contractroyalty", + contracts: "IThirdwebPrimarySale", + }, + abi: IThirdwebRoyaltyAbi, + features: {}, +} as const; + +export const FEATURE_PRIMARY_SALE = { + name: "PrimarySale", + namespace: "sales", + docLinks: { + sdk: "sdk.contractprimarysale", + contracts: "IThirdwebPrimarySale", + }, + abi: IThirdwebPrimarySaleAbi, + features: {}, +} as const; + +export const FEATURE_PLATFORM_FEE = { + name: "PlatformFee", + namespace: "platformFee", + docLinks: { + sdk: "sdk.platformfee", + contracts: "IThirdwebPlatformFee", + }, + abi: IThirdwebPlatformFeeAbi, + features: {}, +} as const; diff --git a/src/contracts/edition-drop.ts b/src/contracts/edition-drop.ts index 9b933ea0f..a7b75873d 100644 --- a/src/contracts/edition-drop.ts +++ b/src/contracts/edition-drop.ts @@ -5,6 +5,7 @@ import { ContractRoles } from "../core/classes/contract-roles"; import { ContractRoyalty } from "../core/classes/contract-royalty"; import { ContractPrimarySale } from "../core/classes/contract-sales"; import { + Erc1155Enumerable, IStorage, NetworkOrSignerOrProvider, TransactionResult, @@ -59,8 +60,7 @@ export class EditionDrop extends Erc1155 { */ static schema = DropErc1155ContractSchema; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - private _query = this.query!; + private _query = this.query as Erc1155Enumerable; public primarySale: ContractPrimarySale; public platformFee: ContractPlatformFee; diff --git a/src/contracts/edition.ts b/src/contracts/edition.ts index 59fddc635..9b5f61e28 100644 --- a/src/contracts/edition.ts +++ b/src/contracts/edition.ts @@ -5,6 +5,7 @@ import { ContractRoles } from "../core/classes/contract-roles"; import { ContractRoyalty } from "../core/classes/contract-royalty"; import { ContractPrimarySale } from "../core/classes/contract-sales"; import { + Erc1155Enumerable, IStorage, NetworkOrSignerOrProvider, TransactionResult, @@ -30,6 +31,8 @@ import { GasCostEstimator } from "../core/classes/gas-cost-estimator"; import { getRoleHash } from "../common"; import { AddressZero } from "@ethersproject/constants"; import { QueryAllParams } from "../types"; +import { Erc1155Mintable } from "../core/classes/erc-1155-mintable"; +import { Erc1155BatchMintable } from "../core/classes/erc-1155-batch-mintable"; /** * Create a collection of NFTs that lets you mint multiple copies of each NFT. @@ -52,12 +55,9 @@ export class Edition extends Erc1155 { static contractRoles = ["admin", "minter", "transfer"] as const; static contractAbi = require("../../abis/TokenERC1155.json"); - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - private _query = this.query!; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - private _mint = this.mint!; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - private _batchMint = this.mint!.batch!; + private _query = this.query as Erc1155Enumerable; + private _mint = this.mint as Erc1155Mintable; + private _batchMint = this._mint.batch as Erc1155BatchMintable; /** * @internal */ diff --git a/src/contracts/nft-collection.ts b/src/contracts/nft-collection.ts index 6661e1c92..8c1481f70 100644 --- a/src/contracts/nft-collection.ts +++ b/src/contracts/nft-collection.ts @@ -4,6 +4,12 @@ import type { TransactionResult, TransactionResultWithId, } from "../core"; +import { + Erc721BatchMintable, + Erc721Enumerable, + Erc721Mintable, + Erc721Supply, +} from "../core"; import { TokenErc721ContractSchema } from "../schema/contracts/token-erc721"; import { ContractWrapper } from "../core/classes/contract-wrapper"; import { TokenERC721 } from "contracts"; @@ -97,14 +103,10 @@ export class NFTCollection extends Erc721 { */ public interceptor: ContractInterceptor; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - private _mint = this.mint!; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - private _batchMint = this.mint!.batch!; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - private _query = this.query!; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - private _owned = this.query!.owned!; + private _mint = this.mint as Erc721Mintable; + private _batchMint = this._mint.batch as Erc721BatchMintable; + private _query = this.query as Erc721Supply; + private _owned = this._query.owned as Erc721Enumerable; constructor( network: NetworkOrSignerOrProvider, diff --git a/src/contracts/nft-drop.ts b/src/contracts/nft-drop.ts index c22e0c68f..65dd65e03 100644 --- a/src/contracts/nft-drop.ts +++ b/src/contracts/nft-drop.ts @@ -26,7 +26,11 @@ import { ContractPrimarySale } from "../core/classes/contract-sales"; import { prepareClaim } from "../common/claim-conditions"; import { ContractEncoder } from "../core/classes/contract-encoder"; import { DelayedReveal } from "../core/classes/delayed-reveal"; -import { GasCostEstimator } from "../core/classes"; +import { + Erc721Enumerable, + Erc721Supply, + GasCostEstimator, +} from "../core/classes"; import { ClaimVerification } from "../types"; import { ContractEvents } from "../core/classes/contract-events"; import { ContractPlatformFee } from "../core/classes/contract-platform-fee"; @@ -148,10 +152,8 @@ export class NFTDrop extends Erc721 { */ public revealer: DelayedReveal; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - private _query = this.query!; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - private _owned = this.query!.owned!; + private _query = this.query as Erc721Supply; + private _owned = this._query.owned as Erc721Enumerable; constructor( network: NetworkOrSignerOrProvider, diff --git a/src/contracts/smart-contract.ts b/src/contracts/smart-contract.ts index 9cd31e49f..181ba7eec 100644 --- a/src/contracts/smart-contract.ts +++ b/src/contracts/smart-contract.ts @@ -19,11 +19,8 @@ import { AccessControlEnumerable__factory, IThirdwebContract, IThirdwebPlatformFee, - IThirdwebPlatformFee__factory, IThirdwebPrimarySale, - IThirdwebPrimarySale__factory, IThirdwebRoyalty, - IThirdwebRoyalty__factory, ThirdwebContract, } from "contracts"; import { CustomContractSchema } from "../schema/contracts/custom"; @@ -90,11 +87,13 @@ export class SmartContract< public publishedMetadata: ContractPublishedMetadata; // features - public metadata; - public royalties; - public roles; - public sales; - public platformFees; + public metadata: ContractMetadata | undefined; + public royalties: + | ContractRoyalty + | undefined; // TODO (byoc) change to ThirdwebContract + public roles: ContractRoles | undefined; // TODO (byoc) change to IPermission + public sales: ContractPrimarySale | undefined; + public platformFees: ContractPlatformFee | undefined; /** * Auto-detects ERC20 standard functions. */ @@ -167,10 +166,11 @@ export class SmartContract< * ********************/ private detectRoyalties() { + // TODO (byoc) change to ThirdwebContract if ( - implementsInterface( + detectContractFeature( this.contractWrapper, - IThirdwebRoyalty__factory.createInterface(), + "Royalty", ) ) { // ContractMetadata is stateless, it's fine to create a new one here @@ -186,6 +186,7 @@ export class SmartContract< } private detectRoles() { + // TODO IThirdwebPermissions if ( implementsInterface( this.contractWrapper, @@ -199,9 +200,9 @@ export class SmartContract< private detectPrimarySales() { if ( - implementsInterface( + detectContractFeature( this.contractWrapper, - IThirdwebPrimarySale__factory.createInterface(), + "PrimarySale", ) ) { return new ContractPrimarySale(this.contractWrapper); @@ -211,9 +212,9 @@ export class SmartContract< private detectPlatformFees() { if ( - implementsInterface( + detectContractFeature( this.contractWrapper, - IThirdwebPlatformFee__factory.createInterface(), + "PlatformFee", ) ) { return new ContractPlatformFee(this.contractWrapper); diff --git a/src/contracts/token.ts b/src/contracts/token.ts index 1e2b090fa..c80265857 100644 --- a/src/contracts/token.ts +++ b/src/contracts/token.ts @@ -23,6 +23,8 @@ import { TokenERC20History } from "../core/classes/erc-20-history"; import { Erc20SignatureMinting } from "../core/classes/erc-20-signature-minting"; import { getRoleHash } from "../common"; import { AddressZero } from "@ethersproject/constants"; +import { Erc20Mintable } from "../core/classes/erc-20-mintable"; +import { Erc20BatchMintable } from "../core/classes/erc-20-batch-mintable"; /** * Create a standard crypto token or cryptocurrency. @@ -49,10 +51,8 @@ export class Token extends Erc20 { */ static schema = TokenErc20ContractSchema; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - private _mint = this.mint!; - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - private _batchMint = this.mint!.batch!; + private _mint = this.mint as Erc20Mintable; + private _batchMint = this._mint.batch as Erc20BatchMintable; public metadata: ContractMetadata; public roles: ContractRoles; diff --git a/src/core/classes/contract-royalty.ts b/src/core/classes/contract-royalty.ts index 9447bf278..d12a19e0c 100644 --- a/src/core/classes/contract-royalty.ts +++ b/src/core/classes/contract-royalty.ts @@ -10,6 +10,7 @@ import { BigNumberish } from "ethers"; * Handles Contract royalties * @public */ +// TODO (byoc) change to ThirdwebContract export class ContractRoyalty< TContract extends IThirdwebRoyalty & IThirdwebContract, TSchema extends IGenericSchemaType, From 7d88db6ebaba07cca2c9773577c137e6de6c9211 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Tue, 3 May 2022 14:29:07 -0700 Subject: [PATCH 2/2] update README --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 203909e63..4bc3bf34d 100644 --- a/README.md +++ b/README.md @@ -88,12 +88,17 @@ const sdk = new ThirdwebSDK( ) ); +// deploy contracts +const deployedAddress = sdk.deployer.deployNFTCollection({ + name: "My NFT Collection", +}) + // access your deployed contracts -const nftCollection = sdk.getNFTCollection("0x..."); +const nftCollection = sdk.getNFTCollection(deployedAddress); // Execute transactions on your contracts from the connected wallet const walletAddress = "0x..."; -await nftCollection.mint.to(walletAddress, { +await nftCollection.mintTo(walletAddress, { name: "Cool NFT", description: "Minted NFT from code!", image: fs.readFileSync("path/to/image.png"), // This can be an image url or file