From 75d3f698f4d91831ca1dc12e1758a37cd4adaf04 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 13:28:27 -0700 Subject: [PATCH 01/15] add DectectableFeature interface --- src/core/classes/erc-1155-batch-mintable.ts | 5 ++++- src/core/classes/erc-1155-enumerable.ts | 5 ++++- src/core/classes/erc-1155-mintable.ts | 5 ++++- src/core/classes/erc-1155.ts | 5 ++++- src/core/classes/erc-20-batch-mintable.ts | 5 ++++- src/core/classes/erc-20-mintable.ts | 5 ++++- src/core/classes/erc-20.ts | 5 ++++- src/core/classes/erc-721-batch-mintable.ts | 5 ++++- src/core/classes/erc-721-enumerable.ts | 5 ++++- src/core/classes/erc-721-mintable.ts | 5 ++++- src/core/classes/erc-721-supply.ts | 5 ++++- src/core/classes/erc-721.ts | 5 ++++- src/core/interfaces/DetectableFeature.ts | 5 +++++ 13 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 src/core/interfaces/DetectableFeature.ts diff --git a/src/core/classes/erc-1155-batch-mintable.ts b/src/core/classes/erc-1155-batch-mintable.ts index ed73e79d8..721513d1f 100644 --- a/src/core/classes/erc-1155-batch-mintable.ts +++ b/src/core/classes/erc-1155-batch-mintable.ts @@ -8,8 +8,11 @@ import { uploadOrExtractURIs } from "../../common/nft"; import { ethers } from "ethers"; import { TokensMintedEvent } from "contracts/TokenERC1155"; import { IStorage } from "../interfaces"; +import { FEATURE_EDITION_BATCH_MINTABLE } from "../../constants/erc1155-features"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; -export class Erc1155BatchMintable { +export class Erc1155BatchMintable implements DetectableFeature { + featureName = FEATURE_EDITION_BATCH_MINTABLE.name; private contractWrapper: ContractWrapper; private erc1155: Erc1155; private storage: IStorage; diff --git a/src/core/classes/erc-1155-enumerable.ts b/src/core/classes/erc-1155-enumerable.ts index 97e323892..86f678492 100644 --- a/src/core/classes/erc-1155-enumerable.ts +++ b/src/core/classes/erc-1155-enumerable.ts @@ -5,8 +5,11 @@ import { DEFAULT_QUERY_ALL_COUNT, QueryAllParams } from "../../types"; import { EditionMetadata, EditionMetadataOwner } from "../../schema"; import { Erc1155 } from "./erc-1155"; import { BaseERC1155 } from "../../types/eips"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; +import { FEATURE_EDITION_ENUMERABLE } from "../../constants/erc1155-features"; -export class Erc1155Enumerable { +export class Erc1155Enumerable implements DetectableFeature { + featureName = FEATURE_EDITION_ENUMERABLE.name; private contractWrapper: ContractWrapper; private erc1155: Erc1155; diff --git a/src/core/classes/erc-1155-mintable.ts b/src/core/classes/erc-1155-mintable.ts index 23f823757..a1a68fcaa 100644 --- a/src/core/classes/erc-1155-mintable.ts +++ b/src/core/classes/erc-1155-mintable.ts @@ -10,8 +10,11 @@ import { uploadOrExtractURI } from "../../common/nft"; import { BigNumber, BigNumberish, ethers } from "ethers"; import { TokensMintedEvent } from "contracts/TokenERC1155"; import { IStorage } from "../interfaces"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; +import { FEATURE_EDITION_MINTABLE } from "../../constants/erc1155-features"; -export class Erc1155Mintable { +export class Erc1155Mintable implements DetectableFeature { + featureName = FEATURE_EDITION_MINTABLE.name; private contractWrapper: ContractWrapper; private erc1155: Erc1155; private storage: IStorage; diff --git a/src/core/classes/erc-1155.ts b/src/core/classes/erc-1155.ts index 071c87945..1d73c303e 100644 --- a/src/core/classes/erc-1155.ts +++ b/src/core/classes/erc-1155.ts @@ -22,14 +22,17 @@ import { AirdropInputSchema } from "../../schema/contracts/common/airdrop"; import { BaseERC1155 } from "../../types/eips"; import { Erc1155Enumerable } from "./erc-1155-enumerable"; import { Erc1155Mintable } from "./erc-1155-mintable"; +import { FEATURE_EDITION } from "../../constants/erc1155-features"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; /** * Standard ERC1155 functions * @public */ export class Erc1155 - implements UpdateableNetwork + implements UpdateableNetwork, DetectableFeature { + featureName = FEATURE_EDITION.name; protected contractWrapper: ContractWrapper; protected storage: IStorage; protected options: SDKOptions; diff --git a/src/core/classes/erc-20-batch-mintable.ts b/src/core/classes/erc-20-batch-mintable.ts index c99af6b80..8365d4a3c 100644 --- a/src/core/classes/erc-20-batch-mintable.ts +++ b/src/core/classes/erc-20-batch-mintable.ts @@ -4,8 +4,11 @@ import { Erc20 } from "./erc-20"; import { BaseERC20 } from "../../types/eips"; import { TokenMintInput } from "../../schema"; import { TransactionResult } from "../types"; +import { FEATURE_TOKEN_BATCH_MINTABLE } from "../../constants/erc20-features"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; -export class Erc20BatchMintable { +export class Erc20BatchMintable implements DetectableFeature { + featureName = FEATURE_TOKEN_BATCH_MINTABLE.name; private contractWrapper: ContractWrapper; private erc20: Erc20; diff --git a/src/core/classes/erc-20-mintable.ts b/src/core/classes/erc-20-mintable.ts index e6c3a5cec..6e5854f8d 100644 --- a/src/core/classes/erc-20-mintable.ts +++ b/src/core/classes/erc-20-mintable.ts @@ -6,8 +6,11 @@ import { BaseERC20 } from "../../types/eips"; import { Erc20 } from "./erc-20"; import { Amount } from "../../types"; import { Erc20BatchMintable } from "./erc-20-batch-mintable"; +import { FEATURE_TOKEN_MINTABLE } from "../../constants/erc20-features"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; -export class Erc20Mintable { +export class Erc20Mintable implements DetectableFeature { + featureName = FEATURE_TOKEN_MINTABLE.name; private contractWrapper: ContractWrapper; private erc20: Erc20; diff --git a/src/core/classes/erc-20.ts b/src/core/classes/erc-20.ts index b7194e2c0..a71d22ca9 100644 --- a/src/core/classes/erc-20.ts +++ b/src/core/classes/erc-20.ts @@ -15,14 +15,17 @@ import { PriceSchema } from "../../schema"; import { BaseERC20 } from "../../types/eips"; import { detectContractFeature } from "../../common"; import { Erc20Mintable } from "./erc-20-mintable"; +import { FEATURE_TOKEN } from "../../constants/erc20-features"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; /** * Standard ERC20 functions * @public */ export class Erc20 - implements UpdateableNetwork + implements UpdateableNetwork, DetectableFeature { + featureName = FEATURE_TOKEN.name; protected contractWrapper: ContractWrapper; protected storage: IStorage; protected options: SDKOptions; diff --git a/src/core/classes/erc-721-batch-mintable.ts b/src/core/classes/erc-721-batch-mintable.ts index 7a7ccdb61..06853c1ed 100644 --- a/src/core/classes/erc-721-batch-mintable.ts +++ b/src/core/classes/erc-721-batch-mintable.ts @@ -7,8 +7,11 @@ import { IStorage } from "../interfaces"; import { Erc721 } from "./erc-721"; import { TokensMintedEvent } from "contracts/IMintableERC721"; import { BaseERC721 } from "../../types/eips"; +import { FEATURE_NFT_BATCH_MINTABLE } from "../../constants/erc721-features"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; -export class Erc721BatchMintable { +export class Erc721BatchMintable implements DetectableFeature { + featureName = FEATURE_NFT_BATCH_MINTABLE.name; private contractWrapper: ContractWrapper; private storage: IStorage; private erc721: Erc721; diff --git a/src/core/classes/erc-721-enumerable.ts b/src/core/classes/erc-721-enumerable.ts index ffaaaedc1..80c1d623c 100644 --- a/src/core/classes/erc-721-enumerable.ts +++ b/src/core/classes/erc-721-enumerable.ts @@ -4,8 +4,11 @@ import { BigNumber } from "ethers"; import { NFTMetadataOwner } from "../../schema"; import { Erc721 } from "./erc-721"; import { BaseERC721 } from "../../types/eips"; +import { FEATURE_NFT_ENUMERABLE } from "../../constants/erc721-features"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; -export class Erc721Enumerable { +export class Erc721Enumerable implements DetectableFeature { + featureName = FEATURE_NFT_ENUMERABLE.name; private contractWrapper: ContractWrapper; private erc721: Erc721; diff --git a/src/core/classes/erc-721-mintable.ts b/src/core/classes/erc-721-mintable.ts index 8b6da37ec..cf04b5eca 100644 --- a/src/core/classes/erc-721-mintable.ts +++ b/src/core/classes/erc-721-mintable.ts @@ -9,8 +9,11 @@ import { TokensMintedEvent } from "contracts/IMintableERC721"; import { Erc721BatchMintable } from "./erc-721-batch-mintable"; import { detectContractFeature } from "../../common"; import { BaseERC721 } from "../../types/eips"; +import { FEATURE_NFT_MINTABLE } from "../../constants/erc721-features"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; -export class Erc721Mintable { +export class Erc721Mintable implements DetectableFeature { + featureName = FEATURE_NFT_MINTABLE.name; private contractWrapper: ContractWrapper; private storage: IStorage; private erc721: Erc721; diff --git a/src/core/classes/erc-721-supply.ts b/src/core/classes/erc-721-supply.ts index 2dc474f64..ab3274746 100644 --- a/src/core/classes/erc-721-supply.ts +++ b/src/core/classes/erc-721-supply.ts @@ -7,8 +7,11 @@ import { Erc721 } from "./erc-721"; import { BaseERC721 } from "../../types/eips"; import { detectContractFeature } from "../../common"; import { Erc721Enumerable } from "./erc-721-enumerable"; +import { FEATURE_NFT_SUPPLY } from "../../constants/erc721-features"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; -export class Erc721Supply { +export class Erc721Supply implements DetectableFeature { + featureName = FEATURE_NFT_SUPPLY.name; private contractWrapper: ContractWrapper; private erc721: Erc721; diff --git a/src/core/classes/erc-721.ts b/src/core/classes/erc-721.ts index e37678150..a54413336 100644 --- a/src/core/classes/erc-721.ts +++ b/src/core/classes/erc-721.ts @@ -17,14 +17,17 @@ import { import { Erc721Supply } from "./erc-721-supply"; import { Erc721Mintable } from "./erc-721-mintable"; import { BaseERC721 } from "../../types/eips"; +import { FEATURE_NFT } from "../../constants/erc721-features"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; /** * Standard ERC721 functions * @public */ export class Erc721 - implements UpdateableNetwork + implements UpdateableNetwork, DetectableFeature { + featureName = FEATURE_NFT.name; protected contractWrapper: ContractWrapper; protected storage: IStorage; protected options: SDKOptions; diff --git a/src/core/interfaces/DetectableFeature.ts b/src/core/interfaces/DetectableFeature.ts new file mode 100644 index 000000000..d2654bbfe --- /dev/null +++ b/src/core/interfaces/DetectableFeature.ts @@ -0,0 +1,5 @@ +import { FeatureName } from "../../constants/contract-features"; + +export interface DetectableFeature { + featureName: FeatureName; +} From 1d53a31d94a91c0b2d83562f32e398e085a2cf91 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 15:59:20 -0700 Subject: [PATCH 02/15] generate feature code snippets --- docs/feature_snippets.json | 280 ++++++++++++++++++++ docs/sdk.erc1155.featurename.md | 11 + docs/sdk.erc1155.md | 5 +- docs/sdk.erc1155enumerable.featurename.md | 11 + docs/sdk.erc1155enumerable.md | 9 +- docs/sdk.erc20.featurename.md | 11 + docs/sdk.erc20.md | 5 +- docs/sdk.erc721.featurename.md | 11 + docs/sdk.erc721.md | 5 +- docs/sdk.erc721batchmintable.featurename.md | 11 + docs/sdk.erc721batchmintable.md | 9 +- docs/sdk.erc721enumerable.featurename.md | 11 + docs/sdk.erc721enumerable.md | 9 +- docs/sdk.erc721mintable.featurename.md | 11 + docs/sdk.erc721mintable.md | 4 +- docs/sdk.erc721supply.featurename.md | 11 + docs/sdk.erc721supply.md | 4 +- etc/sdk.api.md | 33 ++- scripts/generate-feature-snippets.mjs | 143 ++++++++++ 19 files changed, 575 insertions(+), 19 deletions(-) create mode 100644 docs/feature_snippets.json create mode 100644 docs/sdk.erc1155.featurename.md create mode 100644 docs/sdk.erc1155enumerable.featurename.md create mode 100644 docs/sdk.erc20.featurename.md create mode 100644 docs/sdk.erc721.featurename.md create mode 100644 docs/sdk.erc721batchmintable.featurename.md create mode 100644 docs/sdk.erc721enumerable.featurename.md create mode 100644 docs/sdk.erc721mintable.featurename.md create mode 100644 docs/sdk.erc721supply.featurename.md create mode 100644 scripts/generate-feature-snippets.mjs diff --git a/docs/feature_snippets.json b/docs/feature_snippets.json new file mode 100644 index 000000000..2e6fb96a8 --- /dev/null +++ b/docs/feature_snippets.json @@ -0,0 +1,280 @@ +{ + "ERC1155": { + "name": "Erc1155", + "summary": "Standard ERC1155 functions\n\n\n", + "remarks": null, + "examples": {}, + "methods": [ + { + "name": "airdrop", + "summary": "Airdrop multiple NFTs\n\n", + "remarks": "\n\nAirdrop one or multiple NFTs to the provided wallet addresses.\n\n", + "examples": { + "javascript": "// Array of objects of addresses and quantities to airdrop NFTs to\nconst addresses = [\n {\n address: \"0x...\",\n quantity: 2,\n },\n {\n address: \"0x...\",\n quantity: 3,\n },\n];\nconst tokenId = \"0\";\nawait contract.airdrop(addresses, tokenId);\n\n// You can also pass an array of addresses, it will airdrop 1 NFT per address\nconst addresses = [\n \"0x...\", \"0x...\", \"0x...\",\n]\nconst tokenId = \"0\";\nawait contract.airdrop(addresses, tokenId);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.airdrop" + }, + { + "name": "balanceOf", + "summary": "Get NFT Balance\n\n", + "remarks": "\n\nGet a wallets NFT balance (number of NFTs in this contract owned by the wallet).\n\n", + "examples": { + "javascript": "// Address of the wallet to check NFT balance\nconst address = \"{{wallet_address}}\";\n// Id of the NFT to check\nconst tokenId = 0;\n\nconst balance = await contract.balanceOf(address, tokenId);\nconsole.log(balance);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.balanceOf" + }, + { + "name": "get", + "summary": "Get a single NFT Metadata\n\n", + "remarks": null, + "examples": { + "javascript": "const nft = await contract.get(\"0\");\nconsole.log(nft);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.get" + }, + { + "name": "transfer", + "summary": "Transfer a single NFT\n\n", + "remarks": "\n\nTransfer an NFT from the connected wallet to another wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet you want to send the NFT to\nconst toAddress = \"{{wallet_address}}\";\n\n// The token ID of the NFT you want to send\nconst tokenId = \"0\";\n// How many copies of the NFTs to transfer\nconst amount = 3;\n\nawait contract.transfer(toAddress, tokenId, amount);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.transfer" + } + ], + "properties": [], + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155" + }, + "ERC1155Enumerable": { + "name": "Erc1155Enumerable", + "summary": "", + "remarks": null, + "examples": {}, + "methods": [ + { + "name": "all", + "summary": "Get All NFTs\n\n", + "remarks": "\n\nGet all the data associated with every NFT in this contract.\n\nBy default, returns the first 100 NFTs, use queryParams to fetch more.\n\n", + "examples": { + "javascript": "const nfts = await contract.getAll();\nconsole.log(nfts);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155Enumerable.all" + }, + { + "name": "owned", + "summary": "Get Owned NFTs\n\n", + "remarks": "\n\nGet all the data associated with the NFTs owned by a specific wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet to get the NFTs of\nconst address = \"{{wallet_address}}\";\nconst nfts = await contract.getOwned(address);\nconsole.log(nfts);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155Enumerable.owned" + } + ], + "properties": [], + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155Enumerable" + }, + "ERC20": { + "name": "Erc20", + "summary": "Standard ERC20 functions\n\n\n", + "remarks": null, + "examples": {}, + "methods": [ + { + "name": "allowance", + "summary": "Get Token Allowance\n\n", + "remarks": "\n\nGet the allowance of a 'spender' wallet over the connected wallet's funds - the allowance of a different address for a token is the amount of tokens that the `spender` wallet is allowed to spend on behalf of the connected wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet to check token allowance\nconst spenderAddress = \"0x...\";\n\nconst allowance = await contract.allowanceOf(otherAddress);\nconsole.log(allowance);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.allowance" + }, + { + "name": "allowanceOf", + "summary": "Get Token Allowance\n\n", + "remarks": "\n\nGet the allowance of one wallet over another wallet's funds - the allowance of a different address for a token is the amount of tokens that the wallet is allowed to spend on behalf of the specified wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet who owns the funds\nconst address = \"{{wallet_address}}\";\n\n// Address of the wallet to check token allowance\nconst spenderAddress = \"0x...\";\n\nconst allowance = await contract.allowanceOf(address, spenderAddress);\nconsole.log(allowance);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.allowanceOf" + }, + { + "name": "balance", + "summary": "Get Token Balance for the currently connected wallet\n\n", + "remarks": "\n\nGet a wallets token balance.\n\n", + "examples": { + "javascript": "const balance = await contract.balance();\nconsole.log(balance);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.balance" + }, + { + "name": "balanceOf", + "summary": "Get Token Balance\n\n", + "remarks": "\n\nGet a wallets token balance.\n\n", + "examples": { + "javascript": "// Address of the wallet to check token balance\nconst address = \"{{wallet_address}}\";\n\nconst balance = await contract.balanceOf(address);\nconsole.log(balance);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.balanceOf" + }, + { + "name": "get", + "summary": "Get the token Metadata (name, symbol, etc...)\n\n", + "remarks": null, + "examples": { + "javascript": "const token = await contract.get();\nconsole.log(token);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.get" + }, + { + "name": "setAllowance", + "summary": "Allows the specified `spender` wallet to transfer the given `amount` of tokens to another wallet\n\n", + "remarks": null, + "examples": { + "javascript": "// Address of the wallet to allow transfers from\nconst spenderAddress = \"0x...\";\n\n// The number of tokens to give as allowance\nconst amount = 100\n\nawait contract.setAllowance(spenderAddress, amount);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.setAllowance" + }, + { + "name": "transfer", + "summary": "Transfer Tokens\n\n", + "remarks": "\n\nTransfer tokens from the connected wallet to another wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet you want to send the tokens to\nconst toAddress = \"0x...\";\n\n// The amount of tokens you want to send\nconst amount = 0.1;\n\nawait contract.transfer(toAddress, amount);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.transfer" + }, + { + "name": "transferBatch", + "summary": "Transfer Tokens To Many Wallets\n\n", + "remarks": "\n\nMint tokens from the connected wallet to many wallets\n\n", + "examples": { + "javascript": "// Data of the tokens you want to mint\nconst data = [\n {\n toAddress: \"{{wallet_address}}\", // Address to mint tokens to\n amount: 100, // How many tokens to mint to specified address\n },\n {\n toAddress: \"0x...\",\n amount: 100,\n }\n]\n\nawait contract.transferBatch(data);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.transferBatch" + }, + { + "name": "transferFrom", + "summary": "Transfer Tokens From Address\n\n", + "remarks": "\n\nTransfer tokens from one wallet to another\n\n", + "examples": { + "javascript": "// Address of the wallet sending the tokens\nconst fromAddress = \"{{wallet_address}}\";\n\n// Address of the wallet you want to send the tokens to\nconst toAddress = \"0x...\";\n\n// The number of tokens you want to send\nconst amount = 1.2\n\n// Note that the connected wallet must have approval to transfer the tokens of the fromAddress\nawait contract.transferFrom(fromAddress, toAddress, amount);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.transferFrom" + } + ], + "properties": [], + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20" + }, + "ERC721": { + "name": "Erc721", + "summary": "Standard ERC721 functions\n\n\n", + "remarks": null, + "examples": {}, + "methods": [ + { + "name": "balanceOf", + "summary": "Get NFT Balance\n\n", + "remarks": "\n\nGet a wallets NFT balance (number of NFTs in this contract owned by the wallet).\n\n", + "examples": { + "javascript": "// Address of the wallet to check NFT balance\nconst address = \"{{wallet_address}}\";\n\nconst balance = await contract.balanceOf(address);\nconsole.log(balance);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.balanceOf" + }, + { + "name": "get", + "summary": "Get a single NFT Metadata\n\n", + "remarks": null, + "examples": { + "javascript": "const nft = await contract.get(\"0\");\nconsole.log(nft);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.get" + }, + { + "name": "transfer", + "summary": "Transfer a single NFT\n\n", + "remarks": "\n\nTransfer an NFT from the connected wallet to another wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet you want to send the NFT to\nconst toAddress = \"{{wallet_address}}\";\n\n// The token ID of the NFT you want to send\nconst tokenId = \"0\";\n\nawait contract.transfer(toAddress, tokenId);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.transfer" + } + ], + "properties": [], + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721" + }, + "ERC721BatchMintable": { + "name": "Erc721BatchMintable", + "summary": "", + "remarks": null, + "examples": {}, + "methods": [ + { + "name": "to", + "summary": "Mint Many unique NFTs\n\n", + "remarks": "\n\nMint many unique NFTs at once to a specified wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet you want to mint the NFT to\nconst walletAddress = \"{{wallet_address}}\";\n\n// Custom metadata of the NFTs you want to mint.\nconst metadatas = [{\n name: \"Cool NFT #1\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/image.png\"), // This can be an image url or file\n}, {\n name: \"Cool NFT #2\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/other/image.png\"),\n}];\n\nconst tx = await contract.mintBatchTo(walletAddress, metadatas);\nconst receipt = tx[0].receipt; // same transaction receipt for all minted NFTs\nconst firstTokenId = tx[0].id; // token id of the first minted NFT\nconst firstNFT = await tx[0].data(); // (optional) fetch details of the first minted NFT" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721BatchMintable.to" + } + ], + "properties": [], + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721BatchMintable" + }, + "ERC721Enumerable": { + "name": "Erc721Enumerable", + "summary": "", + "remarks": null, + "examples": {}, + "methods": [ + { + "name": "all", + "summary": "Get Owned NFTs\n\n", + "remarks": "\n\nGet all the data associated with the NFTs owned by a specific wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet to get the NFTs of\nconst address = \"{{wallet_address}}\";\nconst nfts = await contract.query.owned.all(address);\nconsole.log(nfts);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721Enumerable.all" + } + ], + "properties": [], + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721Enumerable" + }, + "ERC721Mintable": { + "name": "Erc721Mintable", + "summary": "", + "remarks": null, + "examples": {}, + "methods": [ + { + "name": "to", + "summary": "Mint a unique NFT\n\n", + "remarks": "\n\nMint a unique NFT to a specified wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet you want to mint the NFT to\nconst walletAddress = \"{{wallet_address}}\";\n\n// Custom metadata of the NFT, note that you can fully customize this metadata with other properties.\nconst metadata = {\n name: \"Cool NFT\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/image.png\"), // This can be an image url or file\n};\n\nconst tx = await contract.mintTo(walletAddress, metadata);\nconst receipt = tx.receipt; // the transaction receipt\nconst tokenId = tx.id; // the id of the NFT minted\nconst nft = await tx.data(); // (optional) fetch details of minted NFT" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721Mintable.to" + } + ], + "properties": [], + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721Mintable" + }, + "ERC721Supply": { + "name": "Erc721Supply", + "summary": "", + "remarks": null, + "examples": {}, + "methods": [ + { + "name": "all", + "summary": "Get All Minted NFTs\n\n", + "remarks": "\n\nGet all the data associated with every NFT in this contract.\n\nBy default, returns the first 100 NFTs, use queryParams to fetch more.\n\n", + "examples": { + "javascript": "const nfts = await contract.query.all();\nconsole.log(nfts);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721Supply.all" + } + ], + "properties": [], + "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721Supply" + } +} \ No newline at end of file diff --git a/docs/sdk.erc1155.featurename.md b/docs/sdk.erc1155.featurename.md new file mode 100644 index 000000000..af0c7dfcd --- /dev/null +++ b/docs/sdk.erc1155.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155](./sdk.erc1155.md) > [featureName](./sdk.erc1155.featurename.md) + +## Erc1155.featureName property + +Signature: + +```typescript +featureName: "ERC1155"; +``` diff --git a/docs/sdk.erc1155.md b/docs/sdk.erc1155.md index fde88a00c..6c1493a53 100644 --- a/docs/sdk.erc1155.md +++ b/docs/sdk.erc1155.md @@ -9,9 +9,9 @@ Standard ERC1155 functions Signature: ```typescript -export declare class Erc1155 implements UpdateableNetwork +export declare class Erc1155 implements UpdateableNetwork, DetectableFeature ``` -Implements: UpdateableNetwork +Implements: UpdateableNetwork, DetectableFeature ## Constructors @@ -24,6 +24,7 @@ export declare class Erc1155 | Property | Modifiers | Type | Description | | --- | --- | --- | --- | | [contractWrapper](./sdk.erc1155.contractwrapper.md) | | ContractWrapper<T> | | +| [featureName](./sdk.erc1155.featurename.md) | | "ERC1155" | | | [mint](./sdk.erc1155.mint.md) | | Erc1155Mintable \| undefined | | | [options](./sdk.erc1155.options.md) | | [SDKOptions](./sdk.sdkoptions.md) | | | [query](./sdk.erc1155.query.md) | | [Erc1155Enumerable](./sdk.erc1155enumerable.md) \| undefined | | diff --git a/docs/sdk.erc1155enumerable.featurename.md b/docs/sdk.erc1155enumerable.featurename.md new file mode 100644 index 000000000..ae951feb3 --- /dev/null +++ b/docs/sdk.erc1155enumerable.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155Enumerable](./sdk.erc1155enumerable.md) > [featureName](./sdk.erc1155enumerable.featurename.md) + +## Erc1155Enumerable.featureName property + +Signature: + +```typescript +featureName: "ERC1155Enumerable"; +``` diff --git a/docs/sdk.erc1155enumerable.md b/docs/sdk.erc1155enumerable.md index 20cfbf732..aa551195c 100644 --- a/docs/sdk.erc1155enumerable.md +++ b/docs/sdk.erc1155enumerable.md @@ -7,8 +7,9 @@ Signature: ```typescript -export declare class Erc1155Enumerable +export declare class Erc1155Enumerable implements DetectableFeature ``` +Implements: DetectableFeature ## Constructors @@ -16,6 +17,12 @@ export declare class Erc1155Enumerable | --- | --- | --- | | [(constructor)(erc1155, contractWrapper)](./sdk.erc1155enumerable._constructor_.md) | | Constructs a new instance of the Erc1155Enumerable class | +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [featureName](./sdk.erc1155enumerable.featurename.md) | | "ERC1155Enumerable" | | + ## Methods | Method | Modifiers | Description | diff --git a/docs/sdk.erc20.featurename.md b/docs/sdk.erc20.featurename.md new file mode 100644 index 000000000..5705d18ee --- /dev/null +++ b/docs/sdk.erc20.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc20](./sdk.erc20.md) > [featureName](./sdk.erc20.featurename.md) + +## Erc20.featureName property + +Signature: + +```typescript +featureName: "ERC20"; +``` diff --git a/docs/sdk.erc20.md b/docs/sdk.erc20.md index 41fa3395a..74279bf5b 100644 --- a/docs/sdk.erc20.md +++ b/docs/sdk.erc20.md @@ -9,9 +9,9 @@ Standard ERC20 functions Signature: ```typescript -export declare class Erc20 implements UpdateableNetwork +export declare class Erc20 implements UpdateableNetwork, DetectableFeature ``` -Implements: UpdateableNetwork +Implements: UpdateableNetwork, DetectableFeature ## Constructors @@ -24,6 +24,7 @@ export declare class Erc20 impleme | Property | Modifiers | Type | Description | | --- | --- | --- | --- | | [contractWrapper](./sdk.erc20.contractwrapper.md) | | ContractWrapper<T> | | +| [featureName](./sdk.erc20.featurename.md) | | "ERC20" | | | [mint](./sdk.erc20.mint.md) | | Erc20Mintable \| undefined | Mint tokens | | [options](./sdk.erc20.options.md) | | [SDKOptions](./sdk.sdkoptions.md) | | | [storage](./sdk.erc20.storage.md) | | [IStorage](./sdk.istorage.md) | | diff --git a/docs/sdk.erc721.featurename.md b/docs/sdk.erc721.featurename.md new file mode 100644 index 000000000..d2129a4b6 --- /dev/null +++ b/docs/sdk.erc721.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc721](./sdk.erc721.md) > [featureName](./sdk.erc721.featurename.md) + +## Erc721.featureName property + +Signature: + +```typescript +featureName: "ERC721"; +``` diff --git a/docs/sdk.erc721.md b/docs/sdk.erc721.md index 4013a9f91..2c2d5c1f3 100644 --- a/docs/sdk.erc721.md +++ b/docs/sdk.erc721.md @@ -9,9 +9,9 @@ Standard ERC721 functions Signature: ```typescript -export declare class Erc721 implements UpdateableNetwork +export declare class Erc721 implements UpdateableNetwork, DetectableFeature ``` -Implements: UpdateableNetwork +Implements: UpdateableNetwork, DetectableFeature ## Constructors @@ -24,6 +24,7 @@ export declare class Erc721 imp | Property | Modifiers | Type | Description | | --- | --- | --- | --- | | [contractWrapper](./sdk.erc721.contractwrapper.md) | | ContractWrapper<T> | | +| [featureName](./sdk.erc721.featurename.md) | | "ERC721" | | | [mint](./sdk.erc721.mint.md) | | [Erc721Mintable](./sdk.erc721mintable.md) \| undefined | | | [options](./sdk.erc721.options.md) | | [SDKOptions](./sdk.sdkoptions.md) | | | [query](./sdk.erc721.query.md) | | [Erc721Supply](./sdk.erc721supply.md) \| undefined | | diff --git a/docs/sdk.erc721batchmintable.featurename.md b/docs/sdk.erc721batchmintable.featurename.md new file mode 100644 index 000000000..5df4fa13f --- /dev/null +++ b/docs/sdk.erc721batchmintable.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc721BatchMintable](./sdk.erc721batchmintable.md) > [featureName](./sdk.erc721batchmintable.featurename.md) + +## Erc721BatchMintable.featureName property + +Signature: + +```typescript +featureName: "ERC721BatchMintable"; +``` diff --git a/docs/sdk.erc721batchmintable.md b/docs/sdk.erc721batchmintable.md index 5d518a649..90b7c5045 100644 --- a/docs/sdk.erc721batchmintable.md +++ b/docs/sdk.erc721batchmintable.md @@ -7,8 +7,9 @@ Signature: ```typescript -export declare class Erc721BatchMintable +export declare class Erc721BatchMintable implements DetectableFeature ``` +Implements: DetectableFeature ## Constructors @@ -16,6 +17,12 @@ export declare class Erc721BatchMintable | --- | --- | --- | | [(constructor)(erc721, contractWrapper, storage)](./sdk.erc721batchmintable._constructor_.md) | | Constructs a new instance of the Erc721BatchMintable class | +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [featureName](./sdk.erc721batchmintable.featurename.md) | | "ERC721BatchMintable" | | + ## Methods | Method | Modifiers | Description | diff --git a/docs/sdk.erc721enumerable.featurename.md b/docs/sdk.erc721enumerable.featurename.md new file mode 100644 index 000000000..fb1e264bc --- /dev/null +++ b/docs/sdk.erc721enumerable.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc721Enumerable](./sdk.erc721enumerable.md) > [featureName](./sdk.erc721enumerable.featurename.md) + +## Erc721Enumerable.featureName property + +Signature: + +```typescript +featureName: "ERC721Enumerable"; +``` diff --git a/docs/sdk.erc721enumerable.md b/docs/sdk.erc721enumerable.md index 2472c8d5f..ea9b1f80e 100644 --- a/docs/sdk.erc721enumerable.md +++ b/docs/sdk.erc721enumerable.md @@ -7,8 +7,9 @@ Signature: ```typescript -export declare class Erc721Enumerable +export declare class Erc721Enumerable implements DetectableFeature ``` +Implements: DetectableFeature ## Constructors @@ -16,6 +17,12 @@ export declare class Erc721Enumerable | --- | --- | --- | | [(constructor)(erc721, contractWrapper)](./sdk.erc721enumerable._constructor_.md) | | Constructs a new instance of the Erc721Enumerable class | +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [featureName](./sdk.erc721enumerable.featurename.md) | | "ERC721Enumerable" | | + ## Methods | Method | Modifiers | Description | diff --git a/docs/sdk.erc721mintable.featurename.md b/docs/sdk.erc721mintable.featurename.md new file mode 100644 index 000000000..ae7e02ee6 --- /dev/null +++ b/docs/sdk.erc721mintable.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc721Mintable](./sdk.erc721mintable.md) > [featureName](./sdk.erc721mintable.featurename.md) + +## Erc721Mintable.featureName property + +Signature: + +```typescript +featureName: "ERC721Mintable"; +``` diff --git a/docs/sdk.erc721mintable.md b/docs/sdk.erc721mintable.md index ea1c1d5b4..7c44c9d36 100644 --- a/docs/sdk.erc721mintable.md +++ b/docs/sdk.erc721mintable.md @@ -7,8 +7,9 @@ Signature: ```typescript -export declare class Erc721Mintable +export declare class Erc721Mintable implements DetectableFeature ``` +Implements: DetectableFeature ## Constructors @@ -21,6 +22,7 @@ export declare class Erc721Mintable | Property | Modifiers | Type | Description | | --- | --- | --- | --- | | [batch](./sdk.erc721mintable.batch.md) | | [Erc721BatchMintable](./sdk.erc721batchmintable.md) \| undefined | | +| [featureName](./sdk.erc721mintable.featurename.md) | | "ERC721Mintable" | | ## Methods diff --git a/docs/sdk.erc721supply.featurename.md b/docs/sdk.erc721supply.featurename.md new file mode 100644 index 000000000..aa646176c --- /dev/null +++ b/docs/sdk.erc721supply.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc721Supply](./sdk.erc721supply.md) > [featureName](./sdk.erc721supply.featurename.md) + +## Erc721Supply.featureName property + +Signature: + +```typescript +featureName: "ERC721Supply"; +``` diff --git a/docs/sdk.erc721supply.md b/docs/sdk.erc721supply.md index cb1c98ba2..93f97c971 100644 --- a/docs/sdk.erc721supply.md +++ b/docs/sdk.erc721supply.md @@ -7,8 +7,9 @@ Signature: ```typescript -export declare class Erc721Supply +export declare class Erc721Supply implements DetectableFeature ``` +Implements: DetectableFeature ## Constructors @@ -20,6 +21,7 @@ export declare class Erc721Supply | Property | Modifiers | Type | Description | | --- | --- | --- | --- | +| [featureName](./sdk.erc721supply.featurename.md) | | "ERC721Supply" | | | [owned](./sdk.erc721supply.owned.md) | | [Erc721Enumerable](./sdk.erc721enumerable.md) \| undefined | | ## Methods diff --git a/etc/sdk.api.md b/etc/sdk.api.md index 36993726a..21ed20125 100644 --- a/etc/sdk.api.md +++ b/etc/sdk.api.md @@ -1491,15 +1491,18 @@ export const EditionMetadataWithOwnerOutputSchema: z.ZodObject implements UpdateableNetwork { +export class Erc1155 implements UpdateableNetwork, DetectableFeature { constructor(contractWrapper: ContractWrapper, storage: IStorage, options?: SDKOptions); airdrop(tokenId: BigNumberish, addresses: AirdropInput, data?: BytesLike): Promise; balance(tokenId: BigNumberish): Promise; balanceOf(address: string, tokenId: BigNumberish): Promise; // (undocumented) protected contractWrapper: ContractWrapper; + // (undocumented) + featureName: "ERC1155"; get(tokenId: BigNumberish): Promise; // (undocumented) getAddress(): string; @@ -1525,10 +1528,12 @@ export class Erc1155 impleme } // @public (undocumented) -export class Erc1155Enumerable { +export class Erc1155Enumerable implements DetectableFeature { // Warning: (ae-forgotten-export) The symbol "IERC1155Enumerable" needs to be exported by the entry point index.d.ts constructor(erc1155: Erc1155, contractWrapper: ContractWrapper); all(queryParams?: QueryAllParams): Promise; + // (undocumented) + featureName: "ERC1155Enumerable"; getTotalCount(): Promise; owned(walletAddress?: string): Promise; } @@ -1547,7 +1552,7 @@ export class Erc1155SignatureMinting { // Warning: (ae-forgotten-export) The symbol "BaseERC20" needs to be exported by the entry point index.d.ts // // @public -export class Erc20 implements UpdateableNetwork { +export class Erc20 implements UpdateableNetwork, DetectableFeature { constructor(contractWrapper: ContractWrapper, storage: IStorage, options?: SDKOptions); allowance(spender: string): Promise; allowanceOf(owner: string, spender: string): Promise; @@ -1555,6 +1560,8 @@ export class Erc20 implements Upda balanceOf(address: string): Promise; // (undocumented) protected contractWrapper: ContractWrapper; + // (undocumented) + featureName: "ERC20"; get(): Promise; // (undocumented) getAddress(): string; @@ -1591,12 +1598,14 @@ export class Erc20SignatureMinting { // Warning: (ae-forgotten-export) The symbol "BaseERC721" needs to be exported by the entry point index.d.ts // // @public -export class Erc721 implements UpdateableNetwork { +export class Erc721 implements UpdateableNetwork, DetectableFeature { constructor(contractWrapper: ContractWrapper, storage: IStorage, options?: SDKOptions); balance(): Promise; balanceOf(address: string): Promise; // (undocumented) protected contractWrapper: ContractWrapper; + // (undocumented) + featureName: "ERC721"; get(tokenId: BigNumberish): Promise; // (undocumented) getAddress(): string; @@ -1620,27 +1629,33 @@ export class Erc721 implements } // @public (undocumented) -export class Erc721BatchMintable { +export class Erc721BatchMintable implements DetectableFeature { // Warning: (ae-forgotten-export) The symbol "IMintableERC721" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "IMulticall" needs to be exported by the entry point index.d.ts constructor(erc721: Erc721, contractWrapper: ContractWrapper, storage: IStorage); + // (undocumented) + featureName: "ERC721BatchMintable"; // Warning: (ae-forgotten-export) The symbol "NFTMetadataOrUri" needs to be exported by the entry point index.d.ts to(to: string, metadatas: NFTMetadataOrUri[]): Promise[]>; } // @public (undocumented) -export class Erc721Enumerable { +export class Erc721Enumerable implements DetectableFeature { // Warning: (ae-forgotten-export) The symbol "IERC721Enumerable" needs to be exported by the entry point index.d.ts constructor(erc721: Erc721, contractWrapper: ContractWrapper); all(walletAddress?: string): Promise; + // (undocumented) + featureName: "ERC721Enumerable"; tokenIds(walletAddress?: string): Promise; } // @public (undocumented) -export class Erc721Mintable { +export class Erc721Mintable implements DetectableFeature { constructor(erc721: Erc721, contractWrapper: ContractWrapper, storage: IStorage); // (undocumented) batch: Erc721BatchMintable | undefined; + // (undocumented) + featureName: "ERC721Mintable"; to(to: string, metadata: NFTMetadataOrUri): Promise>; } @@ -1655,11 +1670,13 @@ export class Erc721SignatureMinting { } // @public (undocumented) -export class Erc721Supply { +export class Erc721Supply implements DetectableFeature { // Warning: (ae-forgotten-export) The symbol "IERC721Supply" needs to be exported by the entry point index.d.ts constructor(erc721: Erc721, contractWrapper: ContractWrapper); all(queryParams?: QueryAllParams): Promise; // (undocumented) + featureName: "ERC721Supply"; + // (undocumented) owned: Erc721Enumerable | undefined; totalSupply(): Promise; } diff --git a/scripts/generate-feature-snippets.mjs b/scripts/generate-feature-snippets.mjs new file mode 100644 index 000000000..87261eb50 --- /dev/null +++ b/scripts/generate-feature-snippets.mjs @@ -0,0 +1,143 @@ +import fs from "fs"; +import { TSDocParser, DocExcerpt } from "@microsoft/tsdoc"; + +/** + * This is a simplistic solution until we implement proper DocNode rendering APIs. + */ +export class Formatter { + static renderDocNode(docNode) { + let result = ""; + if (docNode) { + if (docNode instanceof DocExcerpt) { + result += docNode.content.toString(); + } + for (const childNode of docNode.getChildNodes()) { + result += Formatter.renderDocNode(childNode); + } + } + return result; + } + + static renderDocNodes(docNodes) { + let result = ""; + for (const docNode of docNodes) { + result += Formatter.renderDocNode(docNode); + } + return result; + } +} + +const tsdocParser = new TSDocParser(); + +const json = JSON.parse( + fs.readFileSync(`${process.cwd()}/temp/sdk.api.json`, "utf8"), +); + +function languageNameToKey(languageName) { + switch (languageName) { + case "js": + case "jsx": + return "javascript"; + case "ts": + case "tsx": + return "tyepscript"; + default: + return languageName; + } +} + +// Get all the DetectableFeature classes +const classes = json.members[0].members.filter( + (m) => + m.kind === "Class" && + m.excerptTokens.filter((t) => t.text === "DetectableFeature").length > 0, +); + +function parseExampleTag(docComment) { + const exampleBlocks = docComment._customBlocks.filter( + (b) => b._blockTag._tagName === "@example", + ); + + const examplesString = Formatter.renderDocNodes(exampleBlocks); + + const regex = /```([a-zA-Z]*)\n([\S\s]*?)\n```/g; + + let matches; + + const examples = {}; + + while ((matches = regex.exec(examplesString)) !== null) { + // This is necessary to avoid infinite loops with zero-width matches + if (matches.index === regex.lastIndex) { + regex.lastIndex++; + } + examples[languageNameToKey(matches[1])] = matches[2]; + } + return examples; +} + +const baseDocUrl = "https://docs.thirdweb.com/typescript/sdk."; + +const extractReferenceLink = (m, kind, contractName) => { + if (kind === "Property") { + return m.excerptTokens + .filter((e) => e.kind === "Reference") + .map((e) => `${baseDocUrl}${e.text.toLowerCase()}`)[0]; + } + if (kind === "Method") { + return `${baseDocUrl}${contractName}.${m.name}`; + } + return `${baseDocUrl}${m.name}`; +}; + +const parseMembers = (members, kind, contractName) => { + const validMembers = members.filter((m) => m.kind === kind); + return validMembers + .map((m) => { + const parserContext = tsdocParser.parseString(m.docComment); + const docComment = parserContext.docComment; + const examples = parseExampleTag(docComment); + if (Object.keys(examples).length > 0) { + return { + name: m.name, + summary: Formatter.renderDocNode(docComment.summarySection), + remarks: docComment.remarksBlock + ? Formatter.renderDocNode(docComment.remarksBlock.content) + : null, + examples, + reference: extractReferenceLink(m, kind, contractName), + }; + } + return null; + }) + .filter((m) => !!m); +}; + +const moduleMap = classes.reduce((acc, m) => { + const parserContext = tsdocParser.parseString(m.docComment); + const docComment = parserContext.docComment; + const examples = parseExampleTag(docComment); + // if (Object.keys(examples).length > 0) { + const featureName = m.members + .filter((m) => m.kind === "Property" && m.name === "featureName") + .map((m) => m.excerptTokens[1].text.replaceAll('"', ""))[0]; + acc[featureName] = { + name: m.name, + summary: Formatter.renderDocNode(docComment.summarySection), + remarks: docComment.remarksBlock + ? Formatter.renderDocNode(docComment.remarksBlock.content) + : null, + examples, + methods: parseMembers(m.members, "Method", m.name), + properties: parseMembers(m.members, "Property", m.name), + reference: extractReferenceLink(m), + }; + // } + + return acc; +}, {}); + +fs.writeFileSync( + `${process.cwd()}/docs/feature_snippets.json`, + JSON.stringify(moduleMap, null, 2), +); From 925329872ee3a90cbb93dd6461e965aa67fe7abc Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 16:11:27 -0700 Subject: [PATCH 03/15] add more snippets --- docs/feature_snippets.json | 18 ++++++++++++++++++ docs/sdk.contractplatformfee.featurename.md | 11 +++++++++++ docs/sdk.contractplatformfee.md | 9 ++++++++- docs/sdk.contractprimarysale.featurename.md | 11 +++++++++++ docs/sdk.contractprimarysale.md | 6 ++++++ docs/sdk.contractroyalty.featurename.md | 11 +++++++++++ docs/sdk.contractroyalty.md | 9 ++++++++- docs/sdk.thirdwebsdk.getcontractlist.md | 4 ++-- etc/sdk.api.md | 14 ++++++++++---- package.json | 2 +- src/core/classes/contract-platform-fee.ts | 7 ++++++- src/core/classes/contract-royalty.ts | 6 +++++- src/core/classes/contract-sales.ts | 2 ++ 13 files changed, 99 insertions(+), 11 deletions(-) create mode 100644 docs/sdk.contractplatformfee.featurename.md create mode 100644 docs/sdk.contractprimarysale.featurename.md create mode 100644 docs/sdk.contractroyalty.featurename.md diff --git a/docs/feature_snippets.json b/docs/feature_snippets.json index 2e6fb96a8..43923bbf6 100644 --- a/docs/feature_snippets.json +++ b/docs/feature_snippets.json @@ -1,4 +1,22 @@ { + "PlatformFee": { + "name": "ContractPlatformFee", + "summary": "Handles primary sales recipients for a Contract\n\n\n", + "remarks": null, + "examples": {}, + "methods": [], + "properties": [], + "reference": "https://docs.thirdweb.com/typescript/sdk.ContractPlatformFee" + }, + "Royalty": { + "name": "ContractRoyalty", + "summary": "Handles Contract royalties\n\n\n", + "remarks": null, + "examples": {}, + "methods": [], + "properties": [], + "reference": "https://docs.thirdweb.com/typescript/sdk.ContractRoyalty" + }, "ERC1155": { "name": "Erc1155", "summary": "Standard ERC1155 functions\n\n\n", diff --git a/docs/sdk.contractplatformfee.featurename.md b/docs/sdk.contractplatformfee.featurename.md new file mode 100644 index 000000000..8dc607e64 --- /dev/null +++ b/docs/sdk.contractplatformfee.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [ContractPlatformFee](./sdk.contractplatformfee.md) > [featureName](./sdk.contractplatformfee.featurename.md) + +## ContractPlatformFee.featureName property + +Signature: + +```typescript +featureName: "PlatformFee"; +``` diff --git a/docs/sdk.contractplatformfee.md b/docs/sdk.contractplatformfee.md index d1f216927..ac3f7a3eb 100644 --- a/docs/sdk.contractplatformfee.md +++ b/docs/sdk.contractplatformfee.md @@ -9,8 +9,9 @@ Handles primary sales recipients for a Contract Signature: ```typescript -export declare class ContractPlatformFee +export declare class ContractPlatformFee implements DetectableFeature ``` +Implements: DetectableFeature ## Constructors @@ -18,6 +19,12 @@ export declare class ContractPlatformFee | --- | --- | --- | | [(constructor)(contractWrapper)](./sdk.contractplatformfee._constructor_.md) | | Constructs a new instance of the ContractPlatformFee class | +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [featureName](./sdk.contractplatformfee.featurename.md) | | "PlatformFee" | | + ## Methods | Method | Modifiers | Description | diff --git a/docs/sdk.contractprimarysale.featurename.md b/docs/sdk.contractprimarysale.featurename.md new file mode 100644 index 000000000..23aaaa593 --- /dev/null +++ b/docs/sdk.contractprimarysale.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [ContractPrimarySale](./sdk.contractprimarysale.md) > [featureName](./sdk.contractprimarysale.featurename.md) + +## ContractPrimarySale.featureName property + +Signature: + +```typescript +featureName: "PrimarySale"; +``` diff --git a/docs/sdk.contractprimarysale.md b/docs/sdk.contractprimarysale.md index 91ee7099a..b62676481 100644 --- a/docs/sdk.contractprimarysale.md +++ b/docs/sdk.contractprimarysale.md @@ -18,6 +18,12 @@ export declare class ContractPrimarySale | --- | --- | --- | | [(constructor)(contractWrapper)](./sdk.contractprimarysale._constructor_.md) | | Constructs a new instance of the ContractPrimarySale class | +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [featureName](./sdk.contractprimarysale.featurename.md) | | "PrimarySale" | | + ## Methods | Method | Modifiers | Description | diff --git a/docs/sdk.contractroyalty.featurename.md b/docs/sdk.contractroyalty.featurename.md new file mode 100644 index 000000000..1384dc783 --- /dev/null +++ b/docs/sdk.contractroyalty.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [ContractRoyalty](./sdk.contractroyalty.md) > [featureName](./sdk.contractroyalty.featurename.md) + +## ContractRoyalty.featureName property + +Signature: + +```typescript +featureName: "Royalty"; +``` diff --git a/docs/sdk.contractroyalty.md b/docs/sdk.contractroyalty.md index 539c21784..0a3b30e1b 100644 --- a/docs/sdk.contractroyalty.md +++ b/docs/sdk.contractroyalty.md @@ -9,8 +9,9 @@ Handles Contract royalties Signature: ```typescript -export declare class ContractRoyalty +export declare class ContractRoyalty implements DetectableFeature ``` +Implements: DetectableFeature ## Constructors @@ -18,6 +19,12 @@ export declare class ContractRoyaltyContractRoyalty class | +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [featureName](./sdk.contractroyalty.featurename.md) | | "Royalty" | | + ## Methods | Method | Modifiers | Description | diff --git a/docs/sdk.thirdwebsdk.getcontractlist.md b/docs/sdk.thirdwebsdk.getcontractlist.md index cb67fc16f..b89136130 100644 --- a/docs/sdk.thirdwebsdk.getcontractlist.md +++ b/docs/sdk.thirdwebsdk.getcontractlist.md @@ -11,7 +11,7 @@ Return all the contracts deployed by the specified address ```typescript getContractList(walletAddress: string): Promise<{ address: string; - contractType: "custom" | "token" | "pack" | "split" | "edition" | "edition-drop" | "token-drop" | "vote" | "marketplace" | "nft-drop" | "nft-collection"; + contractType: "custom" | "token" | "pack" | "edition" | "split" | "edition-drop" | "token-drop" | "vote" | "marketplace" | "nft-drop" | "nft-collection"; metadata: () => Promise; }[]>; ``` @@ -24,5 +24,5 @@ getContractList(walletAddress: string): Promise<{ Returns: -Promise<{ address: string; contractType: "custom" \| "token" \| "pack" \| "split" \| "edition" \| "edition-drop" \| "token-drop" \| "vote" \| "marketplace" \| "nft-drop" \| "nft-collection"; metadata: () => Promise<any>; }\[\]> +Promise<{ address: string; contractType: "custom" \| "token" \| "pack" \| "edition" \| "split" \| "edition-drop" \| "token-drop" \| "vote" \| "marketplace" \| "nft-drop" \| "nft-collection"; metadata: () => Promise<any>; }\[\]> diff --git a/etc/sdk.api.md b/etc/sdk.api.md index 21ed20125..c447bb195 100644 --- a/etc/sdk.api.md +++ b/etc/sdk.api.md @@ -652,10 +652,13 @@ export class ContractMetadata { +export class ContractPlatformFee implements DetectableFeature { constructor(contractWrapper: ContractWrapper); + // (undocumented) + featureName: "PlatformFee"; get(): Promise<{ platform_fee_basis_points: number; platform_fee_recipient: string; @@ -669,6 +672,8 @@ export class ContractPlatformFee { // @public export class ContractPrimarySale { constructor(contractWrapper: ContractWrapper); + // (undocumented) + featureName: "PrimarySale"; getRecipient(): Promise; setRecipient(recipient: string): Promise; } @@ -708,8 +713,10 @@ export class ContractRoles { +export class ContractRoyalty implements DetectableFeature { constructor(contractWrapper: ContractWrapper, metadata: ContractMetadata); + // (undocumented) + featureName: "Royalty"; getDefaultRoyaltyInfo(): Promise<{ seller_fee_basis_points: number; fee_recipient: string; @@ -1491,7 +1498,6 @@ export const EditionMetadataWithOwnerOutputSchema: z.ZodObject implements UpdateableNetwork, DetectableFeature { @@ -4175,7 +4181,7 @@ export class ThirdwebSDK extends RPCConnectionHandler { getContractFromAbi(address: string, abi: ContractInterface): SmartContract; getContractList(walletAddress: string): Promise<{ address: string; - contractType: "custom" | "token" | "pack" | "split" | "edition" | "edition-drop" | "token-drop" | "vote" | "marketplace" | "nft-drop" | "nft-collection"; + contractType: "custom" | "token" | "pack" | "edition" | "split" | "edition-drop" | "token-drop" | "vote" | "marketplace" | "nft-drop" | "nft-collection"; metadata: () => Promise; }[]>; getEdition(address: string): Edition; diff --git a/package.json b/package.json index ee515aa3a..0d50b3c34 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "full-build": "yarn typechain && yarn extract-abi && yarn build:lib && yarn generate-types && yarn extract-api", "generate-md-docs": "yarn api-documenter markdown -i ./temp -o ./docs", "generate-docs": "yarn full-build && yarn generate-md-docs", - "generate-snippets": "node ./scripts/generate-snippets.mjs", + "generate-snippets": "node ./scripts/generate-snippets.mjs && node ./scripts/generate-feature-snippets.mjs", "build": "yarn clean && yarn generate-docs && yarn generate-snippets", "test": "echo \"\nUse 'yarn run test:all' to run all tests\nPass a test file pattern from ./test to run\n\n\t$ yarn run test test/pack.test.ts\" && ts-mocha -t 120000 -r esm -p tsconfig.testing.json", "test:all": "ts-mocha --parallel --paths -t 120000 -r esm -p tsconfig.testing.json './test/**/*.test.ts'" diff --git a/src/core/classes/contract-platform-fee.ts b/src/core/classes/contract-platform-fee.ts index fd0c94eef..6a0e7afe7 100644 --- a/src/core/classes/contract-platform-fee.ts +++ b/src/core/classes/contract-platform-fee.ts @@ -3,12 +3,17 @@ import { ContractWrapper } from "./contract-wrapper"; import { TransactionResult } from "../types"; import { CommonPlatformFeeSchema } from "../../schema"; import { z } from "zod"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; +import { FEATURE_PLATFORM_FEE } from "../../constants/thirdweb-features"; /** * Handles primary sales recipients for a Contract * @public */ -export class ContractPlatformFee { +export class ContractPlatformFee + implements DetectableFeature +{ + featureName = FEATURE_PLATFORM_FEE.name; private contractWrapper; constructor(contractWrapper: ContractWrapper) { diff --git a/src/core/classes/contract-royalty.ts b/src/core/classes/contract-royalty.ts index 055e12ba7..b9de1b4be 100644 --- a/src/core/classes/contract-royalty.ts +++ b/src/core/classes/contract-royalty.ts @@ -5,6 +5,8 @@ import { ContractWrapper } from "./contract-wrapper"; import { z } from "zod"; import { TransactionResult } from "../types"; import { BigNumberish } from "ethers"; +import { FEATURE_ROYALTY } from "../../constants/thirdweb-features"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; /** * Handles Contract royalties @@ -13,7 +15,9 @@ import { BigNumberish } from "ethers"; export class ContractRoyalty< TContract extends IRoyalty & (IThirdwebContract | ThirdwebContract), TSchema extends IGenericSchemaType, -> { +> implements DetectableFeature +{ + featureName = FEATURE_ROYALTY.name; private contractWrapper; private metadata; diff --git a/src/core/classes/contract-sales.ts b/src/core/classes/contract-sales.ts index 60d0b5e35..88a2f7c38 100644 --- a/src/core/classes/contract-sales.ts +++ b/src/core/classes/contract-sales.ts @@ -1,12 +1,14 @@ import { IPrimarySale } from "contracts"; import { ContractWrapper } from "./contract-wrapper"; import { TransactionResult } from "../types"; +import { FEATURE_PRIMARY_SALE } from "../../constants/thirdweb-features"; /** * Handles primary sales recipients for a Contract * @public */ export class ContractPrimarySale { + featureName = FEATURE_PRIMARY_SALE.name; private contractWrapper; constructor(contractWrapper: ContractWrapper) { From b89ea311c159ab60c1f872af896ae511db5b1f65 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 16:14:01 -0700 Subject: [PATCH 04/15] add permissions --- docs/feature_snippets.json | 28 +++++++++++++++++++++++++++ docs/sdk.contractroles.featurename.md | 11 +++++++++++ docs/sdk.contractroles.md | 9 ++++++++- etc/sdk.api.md | 4 +++- src/core/classes/contract-roles.ts | 6 +++++- 5 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 docs/sdk.contractroles.featurename.md diff --git a/docs/feature_snippets.json b/docs/feature_snippets.json index 43923bbf6..aa042c7e2 100644 --- a/docs/feature_snippets.json +++ b/docs/feature_snippets.json @@ -8,6 +8,34 @@ "properties": [], "reference": "https://docs.thirdweb.com/typescript/sdk.ContractPlatformFee" }, + "Permissions": { + "name": "ContractRoles", + "summary": "Handles Contract roles and permissions\n\n\n", + "remarks": null, + "examples": {}, + "methods": [ + { + "name": "get", + "summary": "Call this to get a list of addresses that are members of a specific role.\n\n", + "remarks": "\n\nSee {@link ContractRoles.getAll} to get get a list of addresses for all supported roles on the contract.\n\n", + "examples": { + "javascript": "const minterAddresses: string[] = await contract.getRoleMemberList(\"minter\");" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.ContractRoles.get" + }, + { + "name": "setAll", + "summary": "Call this to OVERWRITE the list of addresses that are members of specific roles.\n\nEvery role in the list will be overwritten with the new list of addresses provided with them. If you want to add or remove addresses for a single address use {@link ContractRoles.grant} and {@link ContractRoles.revoke} respectively instead.\n\n", + "remarks": null, + "examples": { + "javascript": "const minterAddresses: string[] = await contract.getRoleMemberList(\"minter\");\nawait contract.setAll({\n minter: []\n});\nconsole.log(await contract.getRoleMemberList(\"minter\")); // No matter what members had the role before, the new list will be set to []" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.ContractRoles.setAll" + } + ], + "properties": [], + "reference": "https://docs.thirdweb.com/typescript/sdk.ContractRoles" + }, "Royalty": { "name": "ContractRoyalty", "summary": "Handles Contract royalties\n\n\n", diff --git a/docs/sdk.contractroles.featurename.md b/docs/sdk.contractroles.featurename.md new file mode 100644 index 000000000..cb4a7fbc8 --- /dev/null +++ b/docs/sdk.contractroles.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [ContractRoles](./sdk.contractroles.md) > [featureName](./sdk.contractroles.featurename.md) + +## ContractRoles.featureName property + +Signature: + +```typescript +featureName: "Permissions"; +``` diff --git a/docs/sdk.contractroles.md b/docs/sdk.contractroles.md index 650f80c2b..f6b16d710 100644 --- a/docs/sdk.contractroles.md +++ b/docs/sdk.contractroles.md @@ -9,8 +9,9 @@ Handles Contract roles and permissions Signature: ```typescript -export declare class ContractRoles +export declare class ContractRoles implements DetectableFeature ``` +Implements: DetectableFeature ## Constructors @@ -18,6 +19,12 @@ export declare class ContractRolesContractRoles class | +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [featureName](./sdk.contractroles.featurename.md) | | "Permissions" | | + ## Methods | Method | Modifiers | Description | diff --git a/etc/sdk.api.md b/etc/sdk.api.md index c447bb195..f5d50ec4a 100644 --- a/etc/sdk.api.md +++ b/etc/sdk.api.md @@ -696,8 +696,10 @@ export class ContractPublishedMetadata { // Warning: (ae-forgotten-export) The symbol "IPermissionsEnumerable" needs to be exported by the entry point index.d.ts // // @public -export class ContractRoles { +export class ContractRoles implements DetectableFeature { constructor(contractWrapper: ContractWrapper, roles: readonly TRole[]); + // (undocumented) + featureName: "Permissions"; get(role: TRole): Promise; getAll(): Promise>; grant(role: TRole, address: string): Promise; diff --git a/src/core/classes/contract-roles.ts b/src/core/classes/contract-roles.ts index 3f12ace1f..2273135d0 100644 --- a/src/core/classes/contract-roles.ts +++ b/src/core/classes/contract-roles.ts @@ -4,6 +4,8 @@ import invariant from "tiny-invariant"; import { ContractWrapper } from "./contract-wrapper"; import { MissingRoleError } from "../../common/error"; import { IPermissionsEnumerable } from "contracts"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; +import { FEATURE_PERMISSIONS } from "../../constants/thirdweb-features"; /** * Handles Contract roles and permissions @@ -12,7 +14,9 @@ import { IPermissionsEnumerable } from "contracts"; export class ContractRoles< TContract extends IPermissionsEnumerable, TRole extends Role, -> { +> implements DetectableFeature +{ + featureName = FEATURE_PERMISSIONS.name; private contractWrapper; private readonly roles; From 0059d3affd28614c05eb34582d99bfaca3e7da9a Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 16:27:07 -0700 Subject: [PATCH 05/15] fix inherit doc links --- docs/feature_snippets.json | 11 ++++++++++- docs/sdk.contractplatformfee.md | 2 +- docs/sdk.contractprimarysale.md | 3 ++- docs/sdk.md | 2 +- docs/sdk.nftcollection.getall.md | 10 ++++++---- docs/sdk.nftcollection.getowned.md | 7 +++++++ docs/sdk.nftcollection.md | 6 +++--- docs/sdk.nftcollection.totalsupply.md | 3 +++ docs/sdk.nftdrop.getall.md | 10 ++++++---- docs/sdk.nftdrop.getowned.md | 7 +++++++ docs/sdk.nftdrop.md | 6 +++--- docs/sdk.nftdrop.totalsupply.md | 3 +++ etc/sdk.api.md | 18 +++--------------- src/contracts/nft-collection.ts | 8 ++++---- src/contracts/nft-drop.ts | 8 ++++---- src/core/classes/contract-platform-fee.ts | 2 +- src/core/classes/contract-sales.ts | 5 ++++- 17 files changed, 68 insertions(+), 43 deletions(-) diff --git a/docs/feature_snippets.json b/docs/feature_snippets.json index aa042c7e2..fd3ce1c2c 100644 --- a/docs/feature_snippets.json +++ b/docs/feature_snippets.json @@ -1,13 +1,22 @@ { "PlatformFee": { "name": "ContractPlatformFee", - "summary": "Handles primary sales recipients for a Contract\n\n\n", + "summary": "Handles platform fees for a Contract\n\n\n", "remarks": null, "examples": {}, "methods": [], "properties": [], "reference": "https://docs.thirdweb.com/typescript/sdk.ContractPlatformFee" }, + "PrimarySale": { + "name": "ContractPrimarySale", + "summary": "Handles primary sales recipients for a Contract\n\n\n", + "remarks": null, + "examples": {}, + "methods": [], + "properties": [], + "reference": "https://docs.thirdweb.com/typescript/sdk.ContractPrimarySale" + }, "Permissions": { "name": "ContractRoles", "summary": "Handles Contract roles and permissions\n\n\n", diff --git a/docs/sdk.contractplatformfee.md b/docs/sdk.contractplatformfee.md index ac3f7a3eb..ee6cec1af 100644 --- a/docs/sdk.contractplatformfee.md +++ b/docs/sdk.contractplatformfee.md @@ -4,7 +4,7 @@ ## ContractPlatformFee class -Handles primary sales recipients for a Contract +Handles platform fees for a Contract Signature: diff --git a/docs/sdk.contractprimarysale.md b/docs/sdk.contractprimarysale.md index b62676481..a897d845b 100644 --- a/docs/sdk.contractprimarysale.md +++ b/docs/sdk.contractprimarysale.md @@ -9,8 +9,9 @@ Handles primary sales recipients for a Contract Signature: ```typescript -export declare class ContractPrimarySale +export declare class ContractPrimarySale implements DetectableFeature ``` +Implements: DetectableFeature ## Constructors diff --git a/docs/sdk.md b/docs/sdk.md index 215bed643..9b9a6c135 100644 --- a/docs/sdk.md +++ b/docs/sdk.md @@ -12,7 +12,7 @@ | [ContractEncoder](./sdk.contractencoder.md) | Encodes and decodes Contract functions | | [ContractEvents](./sdk.contractevents.md) | Listen to Contract events in real time | | [ContractMetadata](./sdk.contractmetadata.md) | Handles metadata for a Contract | -| [ContractPlatformFee](./sdk.contractplatformfee.md) | Handles primary sales recipients for a Contract | +| [ContractPlatformFee](./sdk.contractplatformfee.md) | Handles platform fees for a Contract | | [ContractPrimarySale](./sdk.contractprimarysale.md) | Handles primary sales recipients for a Contract | | [ContractRoles](./sdk.contractroles.md) | Handles Contract roles and permissions | | [ContractRoyalty](./sdk.contractroyalty.md) | Handles Contract royalties | diff --git a/docs/sdk.nftcollection.getall.md b/docs/sdk.nftcollection.getall.md index ed5cb518e..f9f58eba8 100644 --- a/docs/sdk.nftcollection.getall.md +++ b/docs/sdk.nftcollection.getall.md @@ -4,7 +4,7 @@ ## NFTCollection.getAll() method -Get Owned NFTs +Get All Minted NFTs Signature: @@ -16,15 +16,17 @@ getAll(queryParams?: QueryAllParams): Promise; | Parameter | Type | Description | | --- | --- | --- | -| queryParams | [QueryAllParams](./sdk.queryallparams.md) | (Optional) | +| queryParams | [QueryAllParams](./sdk.queryallparams.md) | (Optional) optional filtering to only fetch a subset of results. | Returns: Promise<[NFTMetadataOwner](./sdk.nftmetadataowner.md)\[\]> -The NFT metadata for all NFTs in the contract. +The NFT metadata for all NFTs queried. ## Remarks -Get all the data associated with the NFTs owned by a specific wallet. +Get all the data associated with every NFT in this contract. + +By default, returns the first 100 NFTs, use queryParams to fetch more. diff --git a/docs/sdk.nftcollection.getowned.md b/docs/sdk.nftcollection.getowned.md index c15dee586..1aee16580 100644 --- a/docs/sdk.nftcollection.getowned.md +++ b/docs/sdk.nftcollection.getowned.md @@ -4,6 +4,7 @@ ## NFTCollection.getOwned() method +Get Owned NFTs Signature: @@ -21,3 +22,9 @@ getOwned(walletAddress?: string): Promise; Promise<[NFTMetadataOwner](./sdk.nftmetadataowner.md)\[\]> +The NFT metadata for all NFTs in the contract. + +## Remarks + +Get all the data associated with the NFTs owned by a specific wallet. + diff --git a/docs/sdk.nftcollection.md b/docs/sdk.nftcollection.md index f6624b122..1eb2a2be3 100644 --- a/docs/sdk.nftcollection.md +++ b/docs/sdk.nftcollection.md @@ -53,13 +53,13 @@ const contract = sdk.getNFTCollection("{{contract_address}}"); | Method | Modifiers | Description | | --- | --- | --- | | [burn(tokenId)](./sdk.nftcollection.burn.md) | | Burn a single NFT | -| [getAll(queryParams)](./sdk.nftcollection.getall.md) | | Get Owned NFTs | -| [getOwned(walletAddress)](./sdk.nftcollection.getowned.md) | | | +| [getAll(queryParams)](./sdk.nftcollection.getall.md) | | Get All Minted NFTs | +| [getOwned(walletAddress)](./sdk.nftcollection.getowned.md) | | Get Owned NFTs | | [getOwnedTokenIds(walletAddress)](./sdk.nftcollection.getownedtokenids.md) | | | | [isTransferRestricted()](./sdk.nftcollection.istransferrestricted.md) | | Get whether users can transfer NFTs from this contract | | [mintBatch(metadata)](./sdk.nftcollection.mintbatch.md) | | Mint Many unique NFTs | | [mintBatchTo(walletAddress, metadata)](./sdk.nftcollection.mintbatchto.md) | | Mint Many unique NFTs | | [mintTo(walletAddress, metadata)](./sdk.nftcollection.mintto.md) | | Mint a unique NFT | | [mintToSelf(metadata)](./sdk.nftcollection.minttoself.md) | | Mint a unique NFT | -| [totalSupply()](./sdk.nftcollection.totalsupply.md) | | | +| [totalSupply()](./sdk.nftcollection.totalsupply.md) | | Get the number of NFTs minted | diff --git a/docs/sdk.nftcollection.totalsupply.md b/docs/sdk.nftcollection.totalsupply.md index 140f34d23..54abeb3ed 100644 --- a/docs/sdk.nftcollection.totalsupply.md +++ b/docs/sdk.nftcollection.totalsupply.md @@ -4,6 +4,7 @@ ## NFTCollection.totalSupply() method +Get the number of NFTs minted Signature: @@ -14,3 +15,5 @@ totalSupply(): Promise; Promise<BigNumber> +the total number of NFTs minted in this contract + diff --git a/docs/sdk.nftdrop.getall.md b/docs/sdk.nftdrop.getall.md index 5fded4225..dcabe6bd1 100644 --- a/docs/sdk.nftdrop.getall.md +++ b/docs/sdk.nftdrop.getall.md @@ -4,7 +4,7 @@ ## NFTDrop.getAll() method -Get Owned NFTs +Get All Minted NFTs Signature: @@ -16,15 +16,17 @@ getAll(queryParams?: QueryAllParams): Promise; | Parameter | Type | Description | | --- | --- | --- | -| queryParams | [QueryAllParams](./sdk.queryallparams.md) | (Optional) | +| queryParams | [QueryAllParams](./sdk.queryallparams.md) | (Optional) optional filtering to only fetch a subset of results. | Returns: Promise<[NFTMetadataOwner](./sdk.nftmetadataowner.md)\[\]> -The NFT metadata for all NFTs in the contract. +The NFT metadata for all NFTs queried. ## Remarks -Get all the data associated with the NFTs owned by a specific wallet. +Get all the data associated with every NFT in this contract. + +By default, returns the first 100 NFTs, use queryParams to fetch more. diff --git a/docs/sdk.nftdrop.getowned.md b/docs/sdk.nftdrop.getowned.md index b517df965..1db200ed6 100644 --- a/docs/sdk.nftdrop.getowned.md +++ b/docs/sdk.nftdrop.getowned.md @@ -4,6 +4,7 @@ ## NFTDrop.getOwned() method +Get Owned NFTs Signature: @@ -21,3 +22,9 @@ getOwned(walletAddress?: string): Promise; Promise<[NFTMetadataOwner](./sdk.nftmetadataowner.md)\[\]> +The NFT metadata for all NFTs in the contract. + +## Remarks + +Get all the data associated with the NFTs owned by a specific wallet. + diff --git a/docs/sdk.nftdrop.md b/docs/sdk.nftdrop.md index 6f9cab506..f5f11f0a8 100644 --- a/docs/sdk.nftdrop.md +++ b/docs/sdk.nftdrop.md @@ -57,13 +57,13 @@ const contract = sdk.getNFTDrop("{{contract_address}}"); | [claim(quantity, proofs)](./sdk.nftdrop.claim.md) | | Claim NFTs to the connected wallet. | | [claimTo(destinationAddress, quantity, proofs)](./sdk.nftdrop.claimto.md) | | Claim unique NFTs to a specific Wallet | | [createBatch(metadatas)](./sdk.nftdrop.createbatch.md) | | Create a batch of unique NFTs to be claimed in the future | -| [getAll(queryParams)](./sdk.nftdrop.getall.md) | | Get Owned NFTs | +| [getAll(queryParams)](./sdk.nftdrop.getall.md) | | Get All Minted NFTs | | [getAllClaimed(queryParams)](./sdk.nftdrop.getallclaimed.md) | | Get All Claimed NFTs | | [getAllUnclaimed(queryParams)](./sdk.nftdrop.getallunclaimed.md) | | Get All Unclaimed NFTs | -| [getOwned(walletAddress)](./sdk.nftdrop.getowned.md) | | | +| [getOwned(walletAddress)](./sdk.nftdrop.getowned.md) | | Get Owned NFTs | | [getOwnedTokenIds(walletAddress)](./sdk.nftdrop.getownedtokenids.md) | | | | [isTransferRestricted()](./sdk.nftdrop.istransferrestricted.md) | | Get whether users can transfer NFTs from this contract | | [totalClaimedSupply()](./sdk.nftdrop.totalclaimedsupply.md) | | Get the claimed supply | -| [totalSupply()](./sdk.nftdrop.totalsupply.md) | | | +| [totalSupply()](./sdk.nftdrop.totalsupply.md) | | Get the number of NFTs minted | | [totalUnclaimedSupply()](./sdk.nftdrop.totalunclaimedsupply.md) | | Get the unclaimed supply | diff --git a/docs/sdk.nftdrop.totalsupply.md b/docs/sdk.nftdrop.totalsupply.md index a54ff30a2..371e21d63 100644 --- a/docs/sdk.nftdrop.totalsupply.md +++ b/docs/sdk.nftdrop.totalsupply.md @@ -4,6 +4,7 @@ ## NFTDrop.totalSupply() method +Get the number of NFTs minted Signature: @@ -14,3 +15,5 @@ totalSupply(): Promise; Promise<BigNumber> +the total number of NFTs minted in this contract + diff --git a/etc/sdk.api.md b/etc/sdk.api.md index f5d50ec4a..b5d8c4502 100644 --- a/etc/sdk.api.md +++ b/etc/sdk.api.md @@ -670,7 +670,7 @@ export class ContractPlatformFee implements Dete // Warning: (ae-forgotten-export) The symbol "IPrimarySale" needs to be exported by the entry point index.d.ts // // @public -export class ContractPrimarySale { +export class ContractPrimarySale implements DetectableFeature { constructor(contractWrapper: ContractWrapper); // (undocumented) featureName: "PrimarySale"; @@ -2252,11 +2252,8 @@ export class NFTCollection extends Erc721 { // (undocumented) events: ContractEvents; getAll(queryParams?: QueryAllParams): Promise; - // Warning: (ae-unresolved-inheritdoc-reference) The @inheritDoc reference could not be resolved: The package "@thirdweb-dev/sdk" does not have an export "Erc721Owned" - // - // (undocumented) getOwned(walletAddress?: string): Promise; - // Warning: (ae-unresolved-inheritdoc-reference) The @inheritDoc reference could not be resolved: The package "@thirdweb-dev/sdk" does not have an export "Erc721Owned" + // Warning: (ae-unresolved-inheritdoc-reference) The @inheritDoc reference could not be resolved: No member was found with name "tokendIds" // // (undocumented) getOwnedTokenIds(walletAddress?: string): Promise; @@ -2380,9 +2377,6 @@ export class NFTCollection extends Erc721 { }>; }; signature: Erc721SignatureMinting; - // Warning: (ae-unresolved-inheritdoc-reference) The @inheritDoc reference could not be resolved: No member was found with name "totalSupply" - // - // (undocumented) totalSupply(): Promise; } @@ -2424,11 +2418,8 @@ export class NFTDrop extends Erc721 { getAll(queryParams?: QueryAllParams): Promise; getAllClaimed(queryParams?: QueryAllParams): Promise; getAllUnclaimed(queryParams?: QueryAllParams): Promise; - // Warning: (ae-unresolved-inheritdoc-reference) The @inheritDoc reference could not be resolved: The package "@thirdweb-dev/sdk" does not have an export "Erc721Owned" - // - // (undocumented) getOwned(walletAddress?: string): Promise; - // Warning: (ae-unresolved-inheritdoc-reference) The @inheritDoc reference could not be resolved: The package "@thirdweb-dev/sdk" does not have an export "Erc721Owned" + // Warning: (ae-unresolved-inheritdoc-reference) The @inheritDoc reference could not be resolved: No member was found with name "tokendIds" // // (undocumented) getOwnedTokenIds(walletAddress?: string): Promise; @@ -2561,9 +2552,6 @@ export class NFTDrop extends Erc721 { }>; }; totalClaimedSupply(): Promise; - // Warning: (ae-unresolved-inheritdoc-reference) The @inheritDoc reference could not be resolved: No member was found with name "totalSupply" - // - // (undocumented) totalSupply(): Promise; totalUnclaimedSupply(): Promise; } diff --git a/src/contracts/nft-collection.ts b/src/contracts/nft-collection.ts index acd523f83..e3d22d913 100644 --- a/src/contracts/nft-collection.ts +++ b/src/contracts/nft-collection.ts @@ -150,7 +150,7 @@ export class NFTCollection extends Erc721 { *******************************/ /** - * {@inheritDoc Erc721Enumerable.all} + * {@inheritDoc Erc721Supply.all} */ public async getAll( queryParams?: QueryAllParams, @@ -158,21 +158,21 @@ export class NFTCollection extends Erc721 { return this._query.all(queryParams); } /** - * {@inheritDoc Erc721Owned.all} + * {@inheritDoc Erc721Enumerable.all} */ public async getOwned(walletAddress?: string): Promise { return this._owned.all(walletAddress); } /** - * {@inheritDoc Erc721Owned.tokendIds} + * {@inheritDoc Erc721Enumerable.tokendIds} */ public async getOwnedTokenIds(walletAddress?: string): Promise { return this._owned.tokenIds(walletAddress); } /** - * {@inheritDoc Erc721Enumerable.totalSupply} + * {@inheritDoc Erc721Supply.totalSupply} */ public async totalSupply() { return this._query.totalSupply(); diff --git a/src/contracts/nft-drop.ts b/src/contracts/nft-drop.ts index 65dd65e03..7a85d4aa2 100644 --- a/src/contracts/nft-drop.ts +++ b/src/contracts/nft-drop.ts @@ -197,7 +197,7 @@ export class NFTDrop extends Erc721 { *******************************/ /** - * {@inheritDoc Erc721Enumerable.all} + * {@inheritDoc Erc721Supply.all} */ public async getAll( queryParams?: QueryAllParams, @@ -205,21 +205,21 @@ export class NFTDrop extends Erc721 { return this._query.all(queryParams); } /** - * {@inheritDoc Erc721Owned.all} + * {@inheritDoc Erc721Enumerable.all} */ public async getOwned(walletAddress?: string): Promise { return this._owned.all(walletAddress); } /** - * {@inheritDoc Erc721Owned.tokendIds} + * {@inheritDoc Erc721Enumerable.tokendIds} */ public async getOwnedTokenIds(walletAddress?: string): Promise { return this._owned.tokenIds(walletAddress); } /** - * {@inheritDoc Erc721Enumerable.totalSupply} + * {@inheritDoc Erc721Supply.totalSupply} */ public async totalSupply() { return this._query.totalSupply(); diff --git a/src/core/classes/contract-platform-fee.ts b/src/core/classes/contract-platform-fee.ts index 6a0e7afe7..abccd2b77 100644 --- a/src/core/classes/contract-platform-fee.ts +++ b/src/core/classes/contract-platform-fee.ts @@ -7,7 +7,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; import { FEATURE_PLATFORM_FEE } from "../../constants/thirdweb-features"; /** - * Handles primary sales recipients for a Contract + * Handles platform fees for a Contract * @public */ export class ContractPlatformFee diff --git a/src/core/classes/contract-sales.ts b/src/core/classes/contract-sales.ts index 88a2f7c38..a920cd95e 100644 --- a/src/core/classes/contract-sales.ts +++ b/src/core/classes/contract-sales.ts @@ -2,12 +2,15 @@ import { IPrimarySale } from "contracts"; import { ContractWrapper } from "./contract-wrapper"; import { TransactionResult } from "../types"; import { FEATURE_PRIMARY_SALE } from "../../constants/thirdweb-features"; +import { DetectableFeature } from "../interfaces/DetectableFeature"; /** * Handles primary sales recipients for a Contract * @public */ -export class ContractPrimarySale { +export class ContractPrimarySale + implements DetectableFeature +{ featureName = FEATURE_PRIMARY_SALE.name; private contractWrapper; From 4cc92b73936f5b7abec504ae05ff19fe24504431 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 16:44:55 -0700 Subject: [PATCH 06/15] add top level docs for main features --- docs/feature_snippets.json | 24 +++++++++++++++--------- docs/sdk.erc1155.md | 17 ++++++++++++++++- docs/sdk.erc20.md | 15 ++++++++++++++- docs/sdk.erc721.md | 17 ++++++++++++++++- docs/sdk.md | 6 +++--- src/core/classes/erc-1155.ts | 11 ++++++++++- src/core/classes/erc-20.ts | 9 ++++++++- src/core/classes/erc-721.ts | 11 ++++++++++- 8 files changed, 92 insertions(+), 18 deletions(-) diff --git a/docs/feature_snippets.json b/docs/feature_snippets.json index fd3ce1c2c..4c5bfaa1b 100644 --- a/docs/feature_snippets.json +++ b/docs/feature_snippets.json @@ -56,9 +56,11 @@ }, "ERC1155": { "name": "Erc1155", - "summary": "Standard ERC1155 functions\n\n\n", - "remarks": null, - "examples": {}, + "summary": "Standard ERC1155 NFT functions\n\n", + "remarks": "\n\nBasic functionality for a ERC1155 contract that handles IPFS storage for you.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"0x...\");\nconst walletAddress = \"0x...\";\nconst tokenId = 0;\nconst nft = await contract.edition.get(tokenId);\nawait contract.edition.transfer(walletAddress, tokenId, 2);" + }, "methods": [ { "name": "airdrop", @@ -130,9 +132,11 @@ }, "ERC20": { "name": "Erc20", - "summary": "Standard ERC20 functions\n\n\n", - "remarks": null, - "examples": {}, + "summary": "Standard ERC20 Token functions\n\n", + "remarks": "\n\nBasic functionality for a ERC20 contract that handles all unit transformation for you.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"0x...\");\nconst walletAddress = \"0x...\";\nawait contract.token.transfer(walletAddress, 0.8);" + }, "methods": [ { "name": "allowance", @@ -221,9 +225,11 @@ }, "ERC721": { "name": "Erc721", - "summary": "Standard ERC721 functions\n\n\n", - "remarks": null, - "examples": {}, + "summary": "Standard ERC721 NFT functions\n\n", + "remarks": "\n\nBasic functionality for a ERC721 contract that handles IPFS storage for you.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"0x...\");\nconst walletAddress = \"0x...\";\nconst tokenId = 0;\nconst nft = await contract.nft.get(tokenId);\nawait contract.nft.transfer(walletAddress, tokenId);" + }, "methods": [ { "name": "balanceOf", diff --git a/docs/sdk.erc1155.md b/docs/sdk.erc1155.md index 6c1493a53..dbae129bf 100644 --- a/docs/sdk.erc1155.md +++ b/docs/sdk.erc1155.md @@ -4,7 +4,7 @@ ## Erc1155 class -Standard ERC1155 functions +Standard ERC1155 NFT functions Signature: @@ -13,6 +13,21 @@ export declare class Erc1155 ``` Implements: UpdateableNetwork, DetectableFeature +## Remarks + +Basic functionality for a ERC1155 contract that handles IPFS storage for you. + +## Example + + +```javascript +const contract = sdk.getContract("0x..."); +const walletAddress = "0x..."; +const tokenId = 0; +const nft = await contract.edition.get(tokenId); +await contract.edition.transfer(walletAddress, tokenId, 2); +``` + ## Constructors | Constructor | Modifiers | Description | diff --git a/docs/sdk.erc20.md b/docs/sdk.erc20.md index 74279bf5b..c33c15690 100644 --- a/docs/sdk.erc20.md +++ b/docs/sdk.erc20.md @@ -4,7 +4,7 @@ ## Erc20 class -Standard ERC20 functions +Standard ERC20 Token functions Signature: @@ -13,6 +13,19 @@ export declare class Erc20 impleme ``` Implements: UpdateableNetwork, DetectableFeature +## Remarks + +Basic functionality for a ERC20 contract that handles all unit transformation for you. + +## Example + + +```javascript +const contract = sdk.getContract("0x..."); +const walletAddress = "0x..."; +await contract.token.transfer(walletAddress, 0.8); +``` + ## Constructors | Constructor | Modifiers | Description | diff --git a/docs/sdk.erc721.md b/docs/sdk.erc721.md index 2c2d5c1f3..f6ee37385 100644 --- a/docs/sdk.erc721.md +++ b/docs/sdk.erc721.md @@ -4,7 +4,7 @@ ## Erc721 class -Standard ERC721 functions +Standard ERC721 NFT functions Signature: @@ -13,6 +13,21 @@ export declare class Erc721 imp ``` Implements: UpdateableNetwork, DetectableFeature +## Remarks + +Basic functionality for a ERC721 contract that handles IPFS storage for you. + +## Example + + +```javascript +const contract = sdk.getContract("0x..."); +const walletAddress = "0x..."; +const tokenId = 0; +const nft = await contract.nft.get(tokenId); +await contract.nft.transfer(walletAddress, tokenId); +``` + ## Constructors | Constructor | Modifiers | Description | diff --git a/docs/sdk.md b/docs/sdk.md index 9b9a6c135..9353c0192 100644 --- a/docs/sdk.md +++ b/docs/sdk.md @@ -22,12 +22,12 @@ | [DropErc1155History](./sdk.droperc1155history.md) | Manages history for Edition Drop contracts | | [Edition](./sdk.edition.md) | Create a collection of NFTs that lets you mint multiple copies of each NFT. | | [EditionDrop](./sdk.editiondrop.md) | Setup a collection of NFTs with a customizable number of each NFT that are minted as users claim them. | -| [Erc1155](./sdk.erc1155.md) | Standard ERC1155 functions | +| [Erc1155](./sdk.erc1155.md) | Standard ERC1155 NFT functions | | [Erc1155Enumerable](./sdk.erc1155enumerable.md) | | | [Erc1155SignatureMinting](./sdk.erc1155signatureminting.md) | Enables generating dynamic ERC1155 NFTs with rules and an associated signature, which can then be minted by anyone securely | -| [Erc20](./sdk.erc20.md) | Standard ERC20 functions | +| [Erc20](./sdk.erc20.md) | Standard ERC20 Token functions | | [Erc20SignatureMinting](./sdk.erc20signatureminting.md) | Enables generating ERC20 Tokens with rules and an associated signature, which can then be minted by anyone securely | -| [Erc721](./sdk.erc721.md) | Standard ERC721 functions | +| [Erc721](./sdk.erc721.md) | Standard ERC721 NFT functions | | [Erc721BatchMintable](./sdk.erc721batchmintable.md) | | | [Erc721Enumerable](./sdk.erc721enumerable.md) | | | [Erc721Mintable](./sdk.erc721mintable.md) | | diff --git a/src/core/classes/erc-1155.ts b/src/core/classes/erc-1155.ts index 1d73c303e..321ea031b 100644 --- a/src/core/classes/erc-1155.ts +++ b/src/core/classes/erc-1155.ts @@ -26,7 +26,16 @@ import { FEATURE_EDITION } from "../../constants/erc1155-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; /** - * Standard ERC1155 functions + * Standard ERC1155 NFT functions + * @remarks Basic functionality for a ERC1155 contract that handles IPFS storage for you. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * const walletAddress = "0x..."; + * const tokenId = 0; + * const nft = await contract.edition.get(tokenId); + * await contract.edition.transfer(walletAddress, tokenId, 2); + * ``` * @public */ export class Erc1155 diff --git a/src/core/classes/erc-20.ts b/src/core/classes/erc-20.ts index a71d22ca9..5a2072312 100644 --- a/src/core/classes/erc-20.ts +++ b/src/core/classes/erc-20.ts @@ -19,7 +19,14 @@ import { FEATURE_TOKEN } from "../../constants/erc20-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; /** - * Standard ERC20 functions + * Standard ERC20 Token functions + * @remarks Basic functionality for a ERC20 contract that handles all unit transformation for you. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * const walletAddress = "0x..."; + * await contract.token.transfer(walletAddress, 0.8); + * ``` * @public */ export class Erc20 diff --git a/src/core/classes/erc-721.ts b/src/core/classes/erc-721.ts index a54413336..0fd544fb6 100644 --- a/src/core/classes/erc-721.ts +++ b/src/core/classes/erc-721.ts @@ -21,7 +21,16 @@ import { FEATURE_NFT } from "../../constants/erc721-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; /** - * Standard ERC721 functions + * Standard ERC721 NFT functions + * @remarks Basic functionality for a ERC721 contract that handles IPFS storage for you. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * const walletAddress = "0x..."; + * const tokenId = 0; + * const nft = await contract.nft.get(tokenId); + * await contract.nft.transfer(walletAddress, tokenId); + * ``` * @public */ export class Erc721 From 10b024b2b7bd58a0835148886141068330f39ac5 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 17:41:21 -0700 Subject: [PATCH 07/15] more code snippets --- docs/feature_snippets.json | 42 +++++--- docs/sdk.erc1155enumerable.md | 14 +++ docs/sdk.erc721batchmintable.md | 14 +++ docs/sdk.erc721enumerable.all.md | 2 +- docs/sdk.erc721enumerable.md | 15 +++ docs/sdk.erc721mintable.md | 14 +++ docs/sdk.erc721mintable.to.md | 2 +- docs/sdk.erc721supply.md | 14 +++ docs/sdk.md | 10 +- docs/sdk.nftcollection.getall.md | 8 ++ docs/sdk.nftcollection.getowned.md | 12 ++- docs/sdk.nftcollection.mintbatch.md | 23 +++- docs/sdk.nftcollection.mintbatchto.md | 24 +++++ docs/sdk.nftcollection.mintto.md | 20 ++++ docs/sdk.nftcollection.minttoself.md | 17 +++ docs/sdk.nftdrop.getall.md | 8 ++ docs/sdk.nftdrop.getowned.md | 12 ++- docs/snippets.json | 54 ++++++++++ etc/sdk.api.md | 10 +- src/contracts/nft-collection.ts | 119 +++++++++++++++++++-- src/contracts/nft-drop.ts | 29 ++++- src/core/classes/erc-1155-enumerable.ts | 10 ++ src/core/classes/erc-721-batch-mintable.ts | 10 ++ src/core/classes/erc-721-enumerable.ts | 13 ++- src/core/classes/erc-721-mintable.ts | 12 ++- src/core/classes/erc-721-supply.ts | 10 ++ 26 files changed, 477 insertions(+), 41 deletions(-) diff --git a/docs/feature_snippets.json b/docs/feature_snippets.json index 4c5bfaa1b..9fc67fbee 100644 --- a/docs/feature_snippets.json +++ b/docs/feature_snippets.json @@ -104,9 +104,11 @@ }, "ERC1155Enumerable": { "name": "Erc1155Enumerable", - "summary": "", - "remarks": null, - "examples": {}, + "summary": "List ERC1155 NFTs\n\n", + "remarks": "\n\nEasily list all the NFTs in a ERC1155 contract.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"0x...\");\nconst nfts = await contract.edition.query.all();" + }, "methods": [ { "name": "all", @@ -264,9 +266,11 @@ }, "ERC721BatchMintable": { "name": "Erc721BatchMintable", - "summary": "", - "remarks": null, - "examples": {}, + "summary": "Mint Many ERC721 NFTs at once\n\n", + "remarks": "\n\nNFT batch minting functionality that handles IPFS storage for you.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"0x...\");\nawait contract.nft.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]);" + }, "methods": [ { "name": "to", @@ -283,9 +287,11 @@ }, "ERC721Enumerable": { "name": "Erc721Enumerable", - "summary": "", - "remarks": null, - "examples": {}, + "summary": "List owned ERC721 NFTs\n\n", + "remarks": "\n\nEasily list all the NFTs from a ERC721 contract, owned by a certain wallet.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"0x...\");\nconst walletAddress = \"0x...\";\nconst ownedNFTs = await contract.nft.query.owned.all(walletAddress);" + }, "methods": [ { "name": "all", @@ -302,16 +308,18 @@ }, "ERC721Mintable": { "name": "Erc721Mintable", - "summary": "", - "remarks": null, - "examples": {}, + "summary": "Mint ERC721 NFTs\n\n", + "remarks": "\n\nNFT minting functionality that handles IPFS storage for you.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"0x...\");\nawait contract.nft.mint.to(walletAddress, nftMetadata);" + }, "methods": [ { "name": "to", "summary": "Mint a unique NFT\n\n", "remarks": "\n\nMint a unique NFT to a specified wallet.\n\n", "examples": { - "javascript": "// Address of the wallet you want to mint the NFT to\nconst walletAddress = \"{{wallet_address}}\";\n\n// Custom metadata of the NFT, note that you can fully customize this metadata with other properties.\nconst metadata = {\n name: \"Cool NFT\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/image.png\"), // This can be an image url or file\n};\n\nconst tx = await contract.mintTo(walletAddress, metadata);\nconst receipt = tx.receipt; // the transaction receipt\nconst tokenId = tx.id; // the id of the NFT minted\nconst nft = await tx.data(); // (optional) fetch details of minted NFT" + "javascript": "// Address of the wallet you want to mint the NFT to\nconst walletAddress = \"{{wallet_address}}\";\n\n// Custom metadata of the NFT, note that you can fully customize this metadata with other properties.\nconst metadata = {\n name: \"Cool NFT\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/image.png\"), // This can be an image url or file\n};\n\nconst tx = await contract.mint.to(walletAddress, metadata);\nconst receipt = tx.receipt; // the transaction receipt\nconst tokenId = tx.id; // the id of the NFT minted\nconst nft = await tx.data(); // (optional) fetch details of minted NFT" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721Mintable.to" } @@ -321,9 +329,11 @@ }, "ERC721Supply": { "name": "Erc721Supply", - "summary": "", - "remarks": null, - "examples": {}, + "summary": "List ERC721 NFTs\n\n", + "remarks": "\n\nEasily list all the NFTs in a ERC721 contract.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"0x...\");\nconst nfts = await contract.nft.query.all();" + }, "methods": [ { "name": "all", diff --git a/docs/sdk.erc1155enumerable.md b/docs/sdk.erc1155enumerable.md index aa551195c..ce7bdcae9 100644 --- a/docs/sdk.erc1155enumerable.md +++ b/docs/sdk.erc1155enumerable.md @@ -4,6 +4,8 @@ ## Erc1155Enumerable class +List ERC1155 NFTs + Signature: ```typescript @@ -11,6 +13,18 @@ export declare class Erc1155Enumerable implements DetectableFeature ``` Implements: DetectableFeature +## Remarks + +Easily list all the NFTs in a ERC1155 contract. + +## Example + + +```javascript +const contract = sdk.getContract("0x..."); +const nfts = await contract.edition.query.all(); +``` + ## Constructors | Constructor | Modifiers | Description | diff --git a/docs/sdk.erc721batchmintable.md b/docs/sdk.erc721batchmintable.md index 90b7c5045..8abad4893 100644 --- a/docs/sdk.erc721batchmintable.md +++ b/docs/sdk.erc721batchmintable.md @@ -4,6 +4,8 @@ ## Erc721BatchMintable class +Mint Many ERC721 NFTs at once + Signature: ```typescript @@ -11,6 +13,18 @@ export declare class Erc721BatchMintable implements DetectableFeature ``` Implements: DetectableFeature +## Remarks + +NFT batch minting functionality that handles IPFS storage for you. + +## Example + + +```javascript +const contract = sdk.getContract("0x..."); +await contract.nft.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]); +``` + ## Constructors | Constructor | Modifiers | Description | diff --git a/docs/sdk.erc721enumerable.all.md b/docs/sdk.erc721enumerable.all.md index 72a03e963..c49d646bc 100644 --- a/docs/sdk.erc721enumerable.all.md +++ b/docs/sdk.erc721enumerable.all.md @@ -16,7 +16,7 @@ all(walletAddress?: string): Promise; | Parameter | Type | Description | | --- | --- | --- | -| walletAddress | string | (Optional) | +| walletAddress | string | (Optional) the wallet address to query, defaults to the connected wallet | Returns: diff --git a/docs/sdk.erc721enumerable.md b/docs/sdk.erc721enumerable.md index ea9b1f80e..8aa9361b3 100644 --- a/docs/sdk.erc721enumerable.md +++ b/docs/sdk.erc721enumerable.md @@ -4,6 +4,8 @@ ## Erc721Enumerable class +List owned ERC721 NFTs + Signature: ```typescript @@ -11,6 +13,19 @@ export declare class Erc721Enumerable implements DetectableFeature ``` Implements: DetectableFeature +## Remarks + +Easily list all the NFTs from a ERC721 contract, owned by a certain wallet. + +## Example + + +```javascript +const contract = sdk.getContract("0x..."); +const walletAddress = "0x..."; +const ownedNFTs = await contract.nft.query.owned.all(walletAddress); +``` + ## Constructors | Constructor | Modifiers | Description | diff --git a/docs/sdk.erc721mintable.md b/docs/sdk.erc721mintable.md index 7c44c9d36..bfeca80aa 100644 --- a/docs/sdk.erc721mintable.md +++ b/docs/sdk.erc721mintable.md @@ -4,6 +4,8 @@ ## Erc721Mintable class +Mint ERC721 NFTs + Signature: ```typescript @@ -11,6 +13,18 @@ export declare class Erc721Mintable implements DetectableFeature ``` Implements: DetectableFeature +## Remarks + +NFT minting functionality that handles IPFS storage for you. + +## Example + + +```javascript +const contract = sdk.getContract("0x..."); +await contract.nft.mint.to(walletAddress, nftMetadata); +``` + ## Constructors | Constructor | Modifiers | Description | diff --git a/docs/sdk.erc721mintable.to.md b/docs/sdk.erc721mintable.to.md index 763522944..ae6ea6326 100644 --- a/docs/sdk.erc721mintable.to.md +++ b/docs/sdk.erc721mintable.to.md @@ -41,7 +41,7 @@ const metadata = { image: fs.readFileSync("path/to/image.png"), // This can be an image url or file }; -const tx = await contract.mintTo(walletAddress, metadata); +const tx = await contract.mint.to(walletAddress, metadata); const receipt = tx.receipt; // the transaction receipt const tokenId = tx.id; // the id of the NFT minted const nft = await tx.data(); // (optional) fetch details of minted NFT diff --git a/docs/sdk.erc721supply.md b/docs/sdk.erc721supply.md index 93f97c971..556dc5ff8 100644 --- a/docs/sdk.erc721supply.md +++ b/docs/sdk.erc721supply.md @@ -4,6 +4,8 @@ ## Erc721Supply class +List ERC721 NFTs + Signature: ```typescript @@ -11,6 +13,18 @@ export declare class Erc721Supply implements DetectableFeature ``` Implements: DetectableFeature +## Remarks + +Easily list all the NFTs in a ERC721 contract. + +## Example + + +```javascript +const contract = sdk.getContract("0x..."); +const nfts = await contract.nft.query.all(); +``` + ## Constructors | Constructor | Modifiers | Description | diff --git a/docs/sdk.md b/docs/sdk.md index 9353c0192..2823e730f 100644 --- a/docs/sdk.md +++ b/docs/sdk.md @@ -23,16 +23,16 @@ | [Edition](./sdk.edition.md) | Create a collection of NFTs that lets you mint multiple copies of each NFT. | | [EditionDrop](./sdk.editiondrop.md) | Setup a collection of NFTs with a customizable number of each NFT that are minted as users claim them. | | [Erc1155](./sdk.erc1155.md) | Standard ERC1155 NFT functions | -| [Erc1155Enumerable](./sdk.erc1155enumerable.md) | | +| [Erc1155Enumerable](./sdk.erc1155enumerable.md) | List ERC1155 NFTs | | [Erc1155SignatureMinting](./sdk.erc1155signatureminting.md) | Enables generating dynamic ERC1155 NFTs with rules and an associated signature, which can then be minted by anyone securely | | [Erc20](./sdk.erc20.md) | Standard ERC20 Token functions | | [Erc20SignatureMinting](./sdk.erc20signatureminting.md) | Enables generating ERC20 Tokens with rules and an associated signature, which can then be minted by anyone securely | | [Erc721](./sdk.erc721.md) | Standard ERC721 NFT functions | -| [Erc721BatchMintable](./sdk.erc721batchmintable.md) | | -| [Erc721Enumerable](./sdk.erc721enumerable.md) | | -| [Erc721Mintable](./sdk.erc721mintable.md) | | +| [Erc721BatchMintable](./sdk.erc721batchmintable.md) | Mint Many ERC721 NFTs at once | +| [Erc721Enumerable](./sdk.erc721enumerable.md) | List owned ERC721 NFTs | +| [Erc721Mintable](./sdk.erc721mintable.md) | Mint ERC721 NFTs | | [Erc721SignatureMinting](./sdk.erc721signatureminting.md) | Enables generating dynamic ERC721 NFTs with rules and an associated signature, which can then be minted by anyone securely | -| [Erc721Supply](./sdk.erc721supply.md) | | +| [Erc721Supply](./sdk.erc721supply.md) | List ERC721 NFTs | | [GasCostEstimator](./sdk.gascostestimator.md) | Estimates the gas cost of Contract calls | | [IpfsStorage](./sdk.ipfsstorage.md) | IPFS Storage implementation, accepts custom IPFS gateways | | [Marketplace](./sdk.marketplace.md) | Create your own whitelabel marketplace that enables users to buy and sell any digital assets. | diff --git a/docs/sdk.nftcollection.getall.md b/docs/sdk.nftcollection.getall.md index f9f58eba8..ef825728c 100644 --- a/docs/sdk.nftcollection.getall.md +++ b/docs/sdk.nftcollection.getall.md @@ -30,3 +30,11 @@ Get all the data associated with every NFT in this contract. By default, returns the first 100 NFTs, use queryParams to fetch more. +## Example + + +```javascript +const nfts = await contract.getAll(); +console.log(nfts); +``` + diff --git a/docs/sdk.nftcollection.getowned.md b/docs/sdk.nftcollection.getowned.md index 1aee16580..4b3f37ace 100644 --- a/docs/sdk.nftcollection.getowned.md +++ b/docs/sdk.nftcollection.getowned.md @@ -16,7 +16,7 @@ getOwned(walletAddress?: string): Promise; | Parameter | Type | Description | | --- | --- | --- | -| walletAddress | string | (Optional) | +| walletAddress | string | (Optional) the wallet address to query, defaults to the connected wallet | Returns: @@ -28,3 +28,13 @@ The NFT metadata for all NFTs in the contract. Get all the data associated with the NFTs owned by a specific wallet. +## Example + + +```javascript +// Address of the wallet to get the NFTs of +const address = "{{wallet_address}}"; +const nfts = await contract.getOwned(address); +console.log(nfts); +``` + diff --git a/docs/sdk.nftcollection.mintbatch.md b/docs/sdk.nftcollection.mintbatch.md index d32996c83..a0412f1a0 100644 --- a/docs/sdk.nftcollection.mintbatch.md +++ b/docs/sdk.nftcollection.mintbatch.md @@ -24,5 +24,26 @@ Promise<[TransactionResultWithId](./sdk.transactionresultwithid.md)&l ## Remarks -Mint many unique NFTs at once to a specified wallet. +Mint many unique NFTs at once to the connected wallet + +## Example + + +```javascript* +// Custom metadata of the NFTs you want to mint. +const metadatas = [{ + name: "Cool NFT #1", + description: "This is a cool NFT", + image: fs.readFileSync("path/to/image.png"), // This can be an image url or file +}, { + name: "Cool NFT #2", + description: "This is a cool NFT", + image: fs.readFileSync("path/to/other/image.png"), +}]; + +const tx = await contract.mintBatch(metadatas); +const receipt = tx[0].receipt; // same transaction receipt for all minted NFTs +const firstTokenId = tx[0].id; // token id of the first minted NFT +const firstNFT = await tx[0].data(); // (optional) fetch details of the first minted NFT +``` diff --git a/docs/sdk.nftcollection.mintbatchto.md b/docs/sdk.nftcollection.mintbatchto.md index ccd7720df..6cea6534d 100644 --- a/docs/sdk.nftcollection.mintbatchto.md +++ b/docs/sdk.nftcollection.mintbatchto.md @@ -27,3 +27,27 @@ Promise<[TransactionResultWithId](./sdk.transactionresultwithid.md)&l Mint many unique NFTs at once to a specified wallet. +## Example + + +```javascript +// Address of the wallet you want to mint the NFT to +const walletAddress = "{{wallet_address}}"; + +// Custom metadata of the NFTs you want to mint. +const metadatas = [{ + name: "Cool NFT #1", + description: "This is a cool NFT", + image: fs.readFileSync("path/to/image.png"), // This can be an image url or file +}, { + name: "Cool NFT #2", + description: "This is a cool NFT", + image: fs.readFileSync("path/to/other/image.png"), +}]; + +const tx = await contract.mintBatchTo(walletAddress, metadatas); +const receipt = tx[0].receipt; // same transaction receipt for all minted NFTs +const firstTokenId = tx[0].id; // token id of the first minted NFT +const firstNFT = await tx[0].data(); // (optional) fetch details of the first minted NFT +``` + diff --git a/docs/sdk.nftcollection.mintto.md b/docs/sdk.nftcollection.mintto.md index f7ec72b1d..29d0637b6 100644 --- a/docs/sdk.nftcollection.mintto.md +++ b/docs/sdk.nftcollection.mintto.md @@ -27,3 +27,23 @@ Promise<[TransactionResultWithId](./sdk.transactionresultwithid.md)&l Mint a unique NFT to a specified wallet. +## Example + + +```javascript +// Address of the wallet you want to mint the NFT to +const walletAddress = "{{wallet_address}}"; + +// Custom metadata of the NFT, note that you can fully customize this metadata with other properties. +const metadata = { + name: "Cool NFT", + description: "This is a cool NFT", + image: fs.readFileSync("path/to/image.png"), // This can be an image url or file +}; + +const tx = await contract.mintTo(walletAddress, metadata); +const receipt = tx.receipt; // the transaction receipt +const tokenId = tx.id; // the id of the NFT minted +const nft = await tx.data(); // (optional) fetch details of minted NFT +``` + diff --git a/docs/sdk.nftcollection.minttoself.md b/docs/sdk.nftcollection.minttoself.md index beb48781e..8eb869cb7 100644 --- a/docs/sdk.nftcollection.minttoself.md +++ b/docs/sdk.nftcollection.minttoself.md @@ -26,3 +26,20 @@ Promise<[TransactionResultWithId](./sdk.transactionresultwithid.md)&l Mint a unique NFT to a specified wallet. +## Example + + +```javascript* +// Custom metadata of the NFT, note that you can fully customize this metadata with other properties. +const metadata = { + name: "Cool NFT", + description: "This is a cool NFT", + image: fs.readFileSync("path/to/image.png"), // This can be an image url or file +}; + +const tx = await contract.mintToSelf(metadata); +const receipt = tx.receipt; // the transaction receipt +const tokenId = tx.id; // the id of the NFT minted +const nft = await tx.data(); // (optional) fetch details of minted NFT +``` + diff --git a/docs/sdk.nftdrop.getall.md b/docs/sdk.nftdrop.getall.md index dcabe6bd1..a4cb8aa84 100644 --- a/docs/sdk.nftdrop.getall.md +++ b/docs/sdk.nftdrop.getall.md @@ -30,3 +30,11 @@ Get all the data associated with every NFT in this contract. By default, returns the first 100 NFTs, use queryParams to fetch more. +## Example + + +```javascript +const nfts = await contract.getAll(); +console.log(nfts); +``` + diff --git a/docs/sdk.nftdrop.getowned.md b/docs/sdk.nftdrop.getowned.md index 1db200ed6..2211610de 100644 --- a/docs/sdk.nftdrop.getowned.md +++ b/docs/sdk.nftdrop.getowned.md @@ -16,7 +16,7 @@ getOwned(walletAddress?: string): Promise; | Parameter | Type | Description | | --- | --- | --- | -| walletAddress | string | (Optional) | +| walletAddress | string | (Optional) the wallet address to query, defaults to the connected wallet | Returns: @@ -28,3 +28,13 @@ The NFT metadata for all NFTs in the contract. Get all the data associated with the NFTs owned by a specific wallet. +## Example + + +```javascript +// Address of the wallet to get the NFTs of +const address = "{{wallet_address}}"; +const nfts = await contract.getOwned(address); +console.log(nfts); +``` + diff --git a/docs/snippets.json b/docs/snippets.json index 12852eb72..8d0d5cb58 100644 --- a/docs/snippets.json +++ b/docs/snippets.json @@ -253,6 +253,42 @@ "javascript": "import { ThirdwebSDK } from \"@thirdweb-dev/sdk\";\n\n// You can switch out this provider with any wallet or provider setup you like.\nconst provider = ethers.Wallet.createRandom();\nconst sdk = new ThirdwebSDK(provider);\nconst contract = sdk.getNFTCollection(\"{{contract_address}}\");" }, "methods": [ + { + "name": "getAll", + "summary": "Get All Minted NFTs\n\n", + "remarks": "\n\nGet all the data associated with every NFT in this contract.\n\nBy default, returns the first 100 NFTs, use queryParams to fetch more.\n\n", + "examples": { + "javascript": "const nfts = await contract.getAll();\nconsole.log(nfts);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.NFTCollection.getAll" + }, + { + "name": "getOwned", + "summary": "Get Owned NFTs\n\n", + "remarks": "\n\nGet all the data associated with the NFTs owned by a specific wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet to get the NFTs of\nconst address = \"{{wallet_address}}\";\nconst nfts = await contract.getOwned(address);\nconsole.log(nfts);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.NFTCollection.getOwned" + }, + { + "name": "mintBatchTo", + "summary": "Mint Many unique NFTs\n\n", + "remarks": "\n\nMint many unique NFTs at once to a specified wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet you want to mint the NFT to\nconst walletAddress = \"{{wallet_address}}\";\n\n// Custom metadata of the NFTs you want to mint.\nconst metadatas = [{\n name: \"Cool NFT #1\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/image.png\"), // This can be an image url or file\n}, {\n name: \"Cool NFT #2\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/other/image.png\"),\n}];\n\nconst tx = await contract.mintBatchTo(walletAddress, metadatas);\nconst receipt = tx[0].receipt; // same transaction receipt for all minted NFTs\nconst firstTokenId = tx[0].id; // token id of the first minted NFT\nconst firstNFT = await tx[0].data(); // (optional) fetch details of the first minted NFT" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.NFTCollection.mintBatchTo" + }, + { + "name": "mintTo", + "summary": "Mint a unique NFT\n\n", + "remarks": "\n\nMint a unique NFT to a specified wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet you want to mint the NFT to\nconst walletAddress = \"{{wallet_address}}\";\n\n// Custom metadata of the NFT, note that you can fully customize this metadata with other properties.\nconst metadata = {\n name: \"Cool NFT\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/image.png\"), // This can be an image url or file\n};\n\nconst tx = await contract.mintTo(walletAddress, metadata);\nconst receipt = tx.receipt; // the transaction receipt\nconst tokenId = tx.id; // the id of the NFT minted\nconst nft = await tx.data(); // (optional) fetch details of minted NFT" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.NFTCollection.mintTo" + }, { "name": "balanceOf", "summary": "Get NFT Balance\n\n", @@ -329,6 +365,15 @@ }, "reference": "https://docs.thirdweb.com/typescript/sdk.NFTDrop.createBatch" }, + { + "name": "getAll", + "summary": "Get All Minted NFTs\n\n", + "remarks": "\n\nGet all the data associated with every NFT in this contract.\n\nBy default, returns the first 100 NFTs, use queryParams to fetch more.\n\n", + "examples": { + "javascript": "const nfts = await contract.getAll();\nconsole.log(nfts);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.NFTDrop.getAll" + }, { "name": "getAllClaimed", "summary": "Get All Claimed NFTs\n\n", @@ -347,6 +392,15 @@ }, "reference": "https://docs.thirdweb.com/typescript/sdk.NFTDrop.getAllUnclaimed" }, + { + "name": "getOwned", + "summary": "Get Owned NFTs\n\n", + "remarks": "\n\nGet all the data associated with the NFTs owned by a specific wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet to get the NFTs of\nconst address = \"{{wallet_address}}\";\nconst nfts = await contract.getOwned(address);\nconsole.log(nfts);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.NFTDrop.getOwned" + }, { "name": "totalClaimedSupply", "summary": "Get the claimed supply\n\n", diff --git a/etc/sdk.api.md b/etc/sdk.api.md index b5d8c4502..7bcd4b46c 100644 --- a/etc/sdk.api.md +++ b/etc/sdk.api.md @@ -1535,7 +1535,7 @@ export class Erc1155 impleme transfer(to: string, tokenId: BigNumberish, amount: BigNumberish, data?: BytesLike): Promise; } -// @public (undocumented) +// @public export class Erc1155Enumerable implements DetectableFeature { // Warning: (ae-forgotten-export) The symbol "IERC1155Enumerable" needs to be exported by the entry point index.d.ts constructor(erc1155: Erc1155, contractWrapper: ContractWrapper); @@ -1636,7 +1636,7 @@ export class Erc721 implements transfer(to: string, tokenId: BigNumberish): Promise; } -// @public (undocumented) +// @public export class Erc721BatchMintable implements DetectableFeature { // Warning: (ae-forgotten-export) The symbol "IMintableERC721" needs to be exported by the entry point index.d.ts // Warning: (ae-forgotten-export) The symbol "IMulticall" needs to be exported by the entry point index.d.ts @@ -1647,7 +1647,7 @@ export class Erc721BatchMintable implements DetectableFeature { to(to: string, metadatas: NFTMetadataOrUri[]): Promise[]>; } -// @public (undocumented) +// @public export class Erc721Enumerable implements DetectableFeature { // Warning: (ae-forgotten-export) The symbol "IERC721Enumerable" needs to be exported by the entry point index.d.ts constructor(erc721: Erc721, contractWrapper: ContractWrapper); @@ -1657,7 +1657,7 @@ export class Erc721Enumerable implements DetectableFeature { tokenIds(walletAddress?: string): Promise; } -// @public (undocumented) +// @public export class Erc721Mintable implements DetectableFeature { constructor(erc721: Erc721, contractWrapper: ContractWrapper, storage: IStorage); // (undocumented) @@ -1677,7 +1677,7 @@ export class Erc721SignatureMinting { verify(signedPayload: SignedPayload721): Promise; } -// @public (undocumented) +// @public export class Erc721Supply implements DetectableFeature { // Warning: (ae-forgotten-export) The symbol "IERC721Supply" needs to be exported by the entry point index.d.ts constructor(erc721: Erc721, contractWrapper: ContractWrapper); diff --git a/src/contracts/nft-collection.ts b/src/contracts/nft-collection.ts index e3d22d913..84944819f 100644 --- a/src/contracts/nft-collection.ts +++ b/src/contracts/nft-collection.ts @@ -150,15 +150,40 @@ export class NFTCollection extends Erc721 { *******************************/ /** - * {@inheritDoc Erc721Supply.all} + * Get All Minted NFTs + * + * @remarks Get all the data associated with every NFT in this contract. + * + * By default, returns the first 100 NFTs, use queryParams to fetch more. + * + * @example + * ```javascript + * const nfts = await contract.getAll(); + * console.log(nfts); + * ``` + * @param queryParams - optional filtering to only fetch a subset of results. + * @returns The NFT metadata for all NFTs queried. */ public async getAll( queryParams?: QueryAllParams, ): Promise { return this._query.all(queryParams); } + /** - * {@inheritDoc Erc721Enumerable.all} + * Get Owned NFTs + * + * @remarks Get all the data associated with the NFTs owned by a specific wallet. + * + * @example + * ```javascript + * // Address of the wallet to get the NFTs of + * const address = "{{wallet_address}}"; + * const nfts = await contract.getOwned(address); + * console.log(nfts); + * ``` + * @param walletAddress - the wallet address to query, defaults to the connected wallet + * @returns The NFT metadata for all NFTs in the contract. */ public async getOwned(walletAddress?: string): Promise { return this._owned.all(walletAddress); @@ -194,7 +219,24 @@ export class NFTCollection extends Erc721 { *******************************/ /** - * {@inheritDoc Erc721Mintable.to} + * Mint a unique NFT + * + * @remarks Mint a unique NFT to a specified wallet. + * + * @example + * ```javascript* + * // Custom metadata of the NFT, note that you can fully customize this metadata with other properties. + * const metadata = { + * name: "Cool NFT", + * description: "This is a cool NFT", + * image: fs.readFileSync("path/to/image.png"), // This can be an image url or file + * }; + * + * const tx = await contract.mintToSelf(metadata); + * const receipt = tx.receipt; // the transaction receipt + * const tokenId = tx.id; // the id of the NFT minted + * const nft = await tx.data(); // (optional) fetch details of minted NFT + * ``` */ public async mintToSelf( metadata: NFTMetadataOrUri, @@ -204,7 +246,27 @@ export class NFTCollection extends Erc721 { } /** - * {@inheritDoc Erc721Mintable.to} + * Mint a unique NFT + * + * @remarks Mint a unique NFT to a specified wallet. + * + * @example + * ```javascript + * // Address of the wallet you want to mint the NFT to + * const walletAddress = "{{wallet_address}}"; + * + * // Custom metadata of the NFT, note that you can fully customize this metadata with other properties. + * const metadata = { + * name: "Cool NFT", + * description: "This is a cool NFT", + * image: fs.readFileSync("path/to/image.png"), // This can be an image url or file + * }; + * + * const tx = await contract.mintTo(walletAddress, metadata); + * const receipt = tx.receipt; // the transaction receipt + * const tokenId = tx.id; // the id of the NFT minted + * const nft = await tx.data(); // (optional) fetch details of minted NFT + * ``` */ public async mintTo( walletAddress: string, @@ -213,7 +275,28 @@ export class NFTCollection extends Erc721 { return this._mint.to(walletAddress, metadata); } /** - * {@inheritDoc Erc721BatchMintable.to} + * Mint Many unique NFTs + * + * @remarks Mint many unique NFTs at once to the connected wallet + * + * @example + * ```javascript* + * // Custom metadata of the NFTs you want to mint. + * const metadatas = [{ + * name: "Cool NFT #1", + * description: "This is a cool NFT", + * image: fs.readFileSync("path/to/image.png"), // This can be an image url or file + * }, { + * name: "Cool NFT #2", + * description: "This is a cool NFT", + * image: fs.readFileSync("path/to/other/image.png"), + * }]; + * + * const tx = await contract.mintBatch(metadatas); + * const receipt = tx[0].receipt; // same transaction receipt for all minted NFTs + * const firstTokenId = tx[0].id; // token id of the first minted NFT + * const firstNFT = await tx[0].data(); // (optional) fetch details of the first minted NFT + * ``` */ public async mintBatch( metadata: NFTMetadataOrUri[], @@ -222,7 +305,31 @@ export class NFTCollection extends Erc721 { return this._batchMint.to(signerAddress, metadata); } /** - * {@inheritDoc Erc721BatchMintable.to} + * Mint Many unique NFTs + * + * @remarks Mint many unique NFTs at once to a specified wallet. + * + * @example + * ```javascript + * // Address of the wallet you want to mint the NFT to + * const walletAddress = "{{wallet_address}}"; + * + * // Custom metadata of the NFTs you want to mint. + * const metadatas = [{ + * name: "Cool NFT #1", + * description: "This is a cool NFT", + * image: fs.readFileSync("path/to/image.png"), // This can be an image url or file + * }, { + * name: "Cool NFT #2", + * description: "This is a cool NFT", + * image: fs.readFileSync("path/to/other/image.png"), + * }]; + * + * const tx = await contract.mintBatchTo(walletAddress, metadatas); + * const receipt = tx[0].receipt; // same transaction receipt for all minted NFTs + * const firstTokenId = tx[0].id; // token id of the first minted NFT + * const firstNFT = await tx[0].data(); // (optional) fetch details of the first minted NFT + * ``` */ public async mintBatchTo( walletAddress: string, diff --git a/src/contracts/nft-drop.ts b/src/contracts/nft-drop.ts index 7a85d4aa2..974e88922 100644 --- a/src/contracts/nft-drop.ts +++ b/src/contracts/nft-drop.ts @@ -197,15 +197,40 @@ export class NFTDrop extends Erc721 { *******************************/ /** - * {@inheritDoc Erc721Supply.all} + * Get All Minted NFTs + * + * @remarks Get all the data associated with every NFT in this contract. + * + * By default, returns the first 100 NFTs, use queryParams to fetch more. + * + * @example + * ```javascript + * const nfts = await contract.getAll(); + * console.log(nfts); + * ``` + * @param queryParams - optional filtering to only fetch a subset of results. + * @returns The NFT metadata for all NFTs queried. */ public async getAll( queryParams?: QueryAllParams, ): Promise { return this._query.all(queryParams); } + /** - * {@inheritDoc Erc721Enumerable.all} + * Get Owned NFTs + * + * @remarks Get all the data associated with the NFTs owned by a specific wallet. + * + * @example + * ```javascript + * // Address of the wallet to get the NFTs of + * const address = "{{wallet_address}}"; + * const nfts = await contract.getOwned(address); + * console.log(nfts); + * ``` + * @param walletAddress - the wallet address to query, defaults to the connected wallet + * @returns The NFT metadata for all NFTs in the contract. */ public async getOwned(walletAddress?: string): Promise { return this._owned.all(walletAddress); diff --git a/src/core/classes/erc-1155-enumerable.ts b/src/core/classes/erc-1155-enumerable.ts index 86f678492..e9979d2f1 100644 --- a/src/core/classes/erc-1155-enumerable.ts +++ b/src/core/classes/erc-1155-enumerable.ts @@ -8,6 +8,16 @@ import { BaseERC1155 } from "../../types/eips"; import { DetectableFeature } from "../interfaces/DetectableFeature"; import { FEATURE_EDITION_ENUMERABLE } from "../../constants/erc1155-features"; +/** + * List ERC1155 NFTs + * @remarks Easily list all the NFTs in a ERC1155 contract. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * const nfts = await contract.edition.query.all(); + * ``` + * @public + */ export class Erc1155Enumerable implements DetectableFeature { featureName = FEATURE_EDITION_ENUMERABLE.name; private contractWrapper: ContractWrapper; diff --git a/src/core/classes/erc-721-batch-mintable.ts b/src/core/classes/erc-721-batch-mintable.ts index 06853c1ed..4f30e03e9 100644 --- a/src/core/classes/erc-721-batch-mintable.ts +++ b/src/core/classes/erc-721-batch-mintable.ts @@ -10,6 +10,16 @@ import { BaseERC721 } from "../../types/eips"; import { FEATURE_NFT_BATCH_MINTABLE } from "../../constants/erc721-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; +/** + * Mint Many ERC721 NFTs at once + * @remarks NFT batch minting functionality that handles IPFS storage for you. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * await contract.nft.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]); + * ``` + * @public + */ export class Erc721BatchMintable implements DetectableFeature { featureName = FEATURE_NFT_BATCH_MINTABLE.name; private contractWrapper: ContractWrapper; diff --git a/src/core/classes/erc-721-enumerable.ts b/src/core/classes/erc-721-enumerable.ts index 80c1d623c..3651060d8 100644 --- a/src/core/classes/erc-721-enumerable.ts +++ b/src/core/classes/erc-721-enumerable.ts @@ -7,6 +7,17 @@ import { BaseERC721 } from "../../types/eips"; import { FEATURE_NFT_ENUMERABLE } from "../../constants/erc721-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; +/** + * List owned ERC721 NFTs + * @remarks Easily list all the NFTs from a ERC721 contract, owned by a certain wallet. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * const walletAddress = "0x..."; + * const ownedNFTs = await contract.nft.query.owned.all(walletAddress); + * ``` + * @public + */ export class Erc721Enumerable implements DetectableFeature { featureName = FEATURE_NFT_ENUMERABLE.name; private contractWrapper: ContractWrapper; @@ -32,7 +43,7 @@ export class Erc721Enumerable implements DetectableFeature { * const nfts = await contract.query.owned.all(address); * console.log(nfts); * ``` - * + * @param walletAddress - the wallet address to query, defaults to the connected wallet * @returns The NFT metadata for all NFTs in the contract. */ public async all(walletAddress?: string): Promise { diff --git a/src/core/classes/erc-721-mintable.ts b/src/core/classes/erc-721-mintable.ts index cf04b5eca..f41e467bf 100644 --- a/src/core/classes/erc-721-mintable.ts +++ b/src/core/classes/erc-721-mintable.ts @@ -12,6 +12,16 @@ import { BaseERC721 } from "../../types/eips"; import { FEATURE_NFT_MINTABLE } from "../../constants/erc721-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; +/** + * Mint ERC721 NFTs + * @remarks NFT minting functionality that handles IPFS storage for you. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * await contract.nft.mint.to(walletAddress, nftMetadata); + * ``` + * @public + */ export class Erc721Mintable implements DetectableFeature { featureName = FEATURE_NFT_MINTABLE.name; private contractWrapper: ContractWrapper; @@ -48,7 +58,7 @@ export class Erc721Mintable implements DetectableFeature { * image: fs.readFileSync("path/to/image.png"), // This can be an image url or file * }; * - * const tx = await contract.mintTo(walletAddress, metadata); + * const tx = await contract.mint.to(walletAddress, metadata); * const receipt = tx.receipt; // the transaction receipt * const tokenId = tx.id; // the id of the NFT minted * const nft = await tx.data(); // (optional) fetch details of minted NFT diff --git a/src/core/classes/erc-721-supply.ts b/src/core/classes/erc-721-supply.ts index ab3274746..0907cee23 100644 --- a/src/core/classes/erc-721-supply.ts +++ b/src/core/classes/erc-721-supply.ts @@ -10,6 +10,16 @@ import { Erc721Enumerable } from "./erc-721-enumerable"; import { FEATURE_NFT_SUPPLY } from "../../constants/erc721-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; +/** + * List ERC721 NFTs + * @remarks Easily list all the NFTs in a ERC721 contract. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * const nfts = await contract.nft.query.all(); + * ``` + * @public + */ export class Erc721Supply implements DetectableFeature { featureName = FEATURE_NFT_SUPPLY.name; private contractWrapper: ContractWrapper; From 4a5a5c6a27cf27970483205f5aa7328d50643940 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 17:49:00 -0700 Subject: [PATCH 08/15] fix script for node 14 --- scripts/generate-feature-snippets.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/generate-feature-snippets.mjs b/scripts/generate-feature-snippets.mjs index 87261eb50..9692e2615 100644 --- a/scripts/generate-feature-snippets.mjs +++ b/scripts/generate-feature-snippets.mjs @@ -120,7 +120,7 @@ const moduleMap = classes.reduce((acc, m) => { // if (Object.keys(examples).length > 0) { const featureName = m.members .filter((m) => m.kind === "Property" && m.name === "featureName") - .map((m) => m.excerptTokens[1].text.replaceAll('"', ""))[0]; + .map((m) => m.excerptTokens[1].text.replace('"', "").replace('"', ""))[0]; acc[featureName] = { name: m.name, summary: Formatter.renderDocNode(docComment.summarySection), From 734ec23366d0503af2ba25c694f24e75fa3d08ee Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 17:57:17 -0700 Subject: [PATCH 09/15] udpate snippet format --- docs/feature_snippets.json | 104 +++++++++++++++++++------- docs/sdk.erc721.balanceof.md | 5 +- docs/sdk.erc721.get.md | 2 +- docs/sdk.erc721.md | 2 +- docs/sdk.erc721.transfer.md | 8 +- docs/snippets.json | 12 +-- scripts/generate-feature-snippets.mjs | 4 +- src/core/classes/erc-721.ts | 17 +---- 8 files changed, 93 insertions(+), 61 deletions(-) diff --git a/docs/feature_snippets.json b/docs/feature_snippets.json index 9fc67fbee..a047ced22 100644 --- a/docs/feature_snippets.json +++ b/docs/feature_snippets.json @@ -30,7 +30,9 @@ "examples": { "javascript": "const minterAddresses: string[] = await contract.getRoleMemberList(\"minter\");" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.ContractRoles.get" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.ContractRoles.get" + } }, { "name": "setAll", @@ -39,7 +41,9 @@ "examples": { "javascript": "const minterAddresses: string[] = await contract.getRoleMemberList(\"minter\");\nawait contract.setAll({\n minter: []\n});\nconsole.log(await contract.getRoleMemberList(\"minter\")); // No matter what members had the role before, the new list will be set to []" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.ContractRoles.setAll" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.ContractRoles.setAll" + } } ], "properties": [], @@ -69,7 +73,9 @@ "examples": { "javascript": "// Array of objects of addresses and quantities to airdrop NFTs to\nconst addresses = [\n {\n address: \"0x...\",\n quantity: 2,\n },\n {\n address: \"0x...\",\n quantity: 3,\n },\n];\nconst tokenId = \"0\";\nawait contract.airdrop(addresses, tokenId);\n\n// You can also pass an array of addresses, it will airdrop 1 NFT per address\nconst addresses = [\n \"0x...\", \"0x...\", \"0x...\",\n]\nconst tokenId = \"0\";\nawait contract.airdrop(addresses, tokenId);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.airdrop" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155.airdrop" + } }, { "name": "balanceOf", @@ -78,7 +84,9 @@ "examples": { "javascript": "// Address of the wallet to check NFT balance\nconst address = \"{{wallet_address}}\";\n// Id of the NFT to check\nconst tokenId = 0;\n\nconst balance = await contract.balanceOf(address, tokenId);\nconsole.log(balance);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.balanceOf" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155.balanceOf" + } }, { "name": "get", @@ -87,7 +95,9 @@ "examples": { "javascript": "const nft = await contract.get(\"0\");\nconsole.log(nft);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.get" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155.get" + } }, { "name": "transfer", @@ -96,7 +106,9 @@ "examples": { "javascript": "// Address of the wallet you want to send the NFT to\nconst toAddress = \"{{wallet_address}}\";\n\n// The token ID of the NFT you want to send\nconst tokenId = \"0\";\n// How many copies of the NFTs to transfer\nconst amount = 3;\n\nawait contract.transfer(toAddress, tokenId, amount);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.transfer" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155.transfer" + } } ], "properties": [], @@ -117,7 +129,9 @@ "examples": { "javascript": "const nfts = await contract.getAll();\nconsole.log(nfts);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155Enumerable.all" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155Enumerable.all" + } }, { "name": "owned", @@ -126,7 +140,9 @@ "examples": { "javascript": "// Address of the wallet to get the NFTs of\nconst address = \"{{wallet_address}}\";\nconst nfts = await contract.getOwned(address);\nconsole.log(nfts);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155Enumerable.owned" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155Enumerable.owned" + } } ], "properties": [], @@ -147,7 +163,9 @@ "examples": { "javascript": "// Address of the wallet to check token allowance\nconst spenderAddress = \"0x...\";\n\nconst allowance = await contract.allowanceOf(otherAddress);\nconsole.log(allowance);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.allowance" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.allowance" + } }, { "name": "allowanceOf", @@ -156,7 +174,9 @@ "examples": { "javascript": "// Address of the wallet who owns the funds\nconst address = \"{{wallet_address}}\";\n\n// Address of the wallet to check token allowance\nconst spenderAddress = \"0x...\";\n\nconst allowance = await contract.allowanceOf(address, spenderAddress);\nconsole.log(allowance);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.allowanceOf" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.allowanceOf" + } }, { "name": "balance", @@ -165,7 +185,9 @@ "examples": { "javascript": "const balance = await contract.balance();\nconsole.log(balance);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.balance" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.balance" + } }, { "name": "balanceOf", @@ -174,7 +196,9 @@ "examples": { "javascript": "// Address of the wallet to check token balance\nconst address = \"{{wallet_address}}\";\n\nconst balance = await contract.balanceOf(address);\nconsole.log(balance);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.balanceOf" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.balanceOf" + } }, { "name": "get", @@ -183,7 +207,9 @@ "examples": { "javascript": "const token = await contract.get();\nconsole.log(token);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.get" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.get" + } }, { "name": "setAllowance", @@ -192,7 +218,9 @@ "examples": { "javascript": "// Address of the wallet to allow transfers from\nconst spenderAddress = \"0x...\";\n\n// The number of tokens to give as allowance\nconst amount = 100\n\nawait contract.setAllowance(spenderAddress, amount);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.setAllowance" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.setAllowance" + } }, { "name": "transfer", @@ -201,7 +229,9 @@ "examples": { "javascript": "// Address of the wallet you want to send the tokens to\nconst toAddress = \"0x...\";\n\n// The amount of tokens you want to send\nconst amount = 0.1;\n\nawait contract.transfer(toAddress, amount);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.transfer" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.transfer" + } }, { "name": "transferBatch", @@ -210,7 +240,9 @@ "examples": { "javascript": "// Data of the tokens you want to mint\nconst data = [\n {\n toAddress: \"{{wallet_address}}\", // Address to mint tokens to\n amount: 100, // How many tokens to mint to specified address\n },\n {\n toAddress: \"0x...\",\n amount: 100,\n }\n]\n\nawait contract.transferBatch(data);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.transferBatch" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.transferBatch" + } }, { "name": "transferFrom", @@ -219,7 +251,9 @@ "examples": { "javascript": "// Address of the wallet sending the tokens\nconst fromAddress = \"{{wallet_address}}\";\n\n// Address of the wallet you want to send the tokens to\nconst toAddress = \"0x...\";\n\n// The number of tokens you want to send\nconst amount = 1.2\n\n// Note that the connected wallet must have approval to transfer the tokens of the fromAddress\nawait contract.transferFrom(fromAddress, toAddress, amount);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.transferFrom" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.transferFrom" + } } ], "properties": [], @@ -230,7 +264,7 @@ "summary": "Standard ERC721 NFT functions\n\n", "remarks": "\n\nBasic functionality for a ERC721 contract that handles IPFS storage for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nconst walletAddress = \"0x...\";\nconst tokenId = 0;\nconst nft = await contract.nft.get(tokenId);\nawait contract.nft.transfer(walletAddress, tokenId);" + "javascript": "const contract = sdk.getContract(\"0x...\");\nconst walletAddress = \"{{wallet_address}}\";\nconst tokenId = 0;\nconst nft = await contract.nft.get(tokenId);\nawait contract.nft.transfer(walletAddress, tokenId);" }, "methods": [ { @@ -238,27 +272,33 @@ "summary": "Get NFT Balance\n\n", "remarks": "\n\nGet a wallets NFT balance (number of NFTs in this contract owned by the wallet).\n\n", "examples": { - "javascript": "// Address of the wallet to check NFT balance\nconst address = \"{{wallet_address}}\";\n\nconst balance = await contract.balanceOf(address);\nconsole.log(balance);" + "javascript": "const balance = await contract.balanceOf(walletAddress);\nconsole.log(balance);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.balanceOf" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721.balanceOf" + } }, { "name": "get", "summary": "Get a single NFT Metadata\n\n", "remarks": null, "examples": { - "javascript": "const nft = await contract.get(\"0\");\nconsole.log(nft);" + "javascript": "const nft = await contract.get(tokenId);\nconsole.log(nft);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.get" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721.get" + } }, { "name": "transfer", "summary": "Transfer a single NFT\n\n", "remarks": "\n\nTransfer an NFT from the connected wallet to another wallet.\n\n", "examples": { - "javascript": "// Address of the wallet you want to send the NFT to\nconst toAddress = \"{{wallet_address}}\";\n\n// The token ID of the NFT you want to send\nconst tokenId = \"0\";\n\nawait contract.transfer(toAddress, tokenId);" + "javascript": "await contract.transfer(walletAddress, tokenId);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.transfer" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721.transfer" + } } ], "properties": [], @@ -279,7 +319,9 @@ "examples": { "javascript": "// Address of the wallet you want to mint the NFT to\nconst walletAddress = \"{{wallet_address}}\";\n\n// Custom metadata of the NFTs you want to mint.\nconst metadatas = [{\n name: \"Cool NFT #1\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/image.png\"), // This can be an image url or file\n}, {\n name: \"Cool NFT #2\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/other/image.png\"),\n}];\n\nconst tx = await contract.mintBatchTo(walletAddress, metadatas);\nconst receipt = tx[0].receipt; // same transaction receipt for all minted NFTs\nconst firstTokenId = tx[0].id; // token id of the first minted NFT\nconst firstNFT = await tx[0].data(); // (optional) fetch details of the first minted NFT" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721BatchMintable.to" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721BatchMintable.to" + } } ], "properties": [], @@ -300,7 +342,9 @@ "examples": { "javascript": "// Address of the wallet to get the NFTs of\nconst address = \"{{wallet_address}}\";\nconst nfts = await contract.query.owned.all(address);\nconsole.log(nfts);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721Enumerable.all" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721Enumerable.all" + } } ], "properties": [], @@ -321,7 +365,9 @@ "examples": { "javascript": "// Address of the wallet you want to mint the NFT to\nconst walletAddress = \"{{wallet_address}}\";\n\n// Custom metadata of the NFT, note that you can fully customize this metadata with other properties.\nconst metadata = {\n name: \"Cool NFT\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/image.png\"), // This can be an image url or file\n};\n\nconst tx = await contract.mint.to(walletAddress, metadata);\nconst receipt = tx.receipt; // the transaction receipt\nconst tokenId = tx.id; // the id of the NFT minted\nconst nft = await tx.data(); // (optional) fetch details of minted NFT" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721Mintable.to" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721Mintable.to" + } } ], "properties": [], @@ -342,7 +388,9 @@ "examples": { "javascript": "const nfts = await contract.query.all();\nconsole.log(nfts);" }, - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721Supply.all" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721Supply.all" + } } ], "properties": [], diff --git a/docs/sdk.erc721.balanceof.md b/docs/sdk.erc721.balanceof.md index 1d46c1e3f..d92095a4a 100644 --- a/docs/sdk.erc721.balanceof.md +++ b/docs/sdk.erc721.balanceof.md @@ -30,10 +30,7 @@ Get a wallets NFT balance (number of NFTs in this contract owned by the wallet). ```javascript -// Address of the wallet to check NFT balance -const address = "{{wallet_address}}"; - -const balance = await contract.balanceOf(address); +const balance = await contract.balanceOf(walletAddress); console.log(balance); ``` diff --git a/docs/sdk.erc721.get.md b/docs/sdk.erc721.get.md index 7e090ee75..cb14cb20c 100644 --- a/docs/sdk.erc721.get.md +++ b/docs/sdk.erc721.get.md @@ -28,7 +28,7 @@ The NFT metadata ```javascript -const nft = await contract.get("0"); +const nft = await contract.get(tokenId); console.log(nft); ``` diff --git a/docs/sdk.erc721.md b/docs/sdk.erc721.md index f6ee37385..119832bd4 100644 --- a/docs/sdk.erc721.md +++ b/docs/sdk.erc721.md @@ -22,7 +22,7 @@ Basic functionality for a ERC721 contract that handles IPFS storage for you. ```javascript const contract = sdk.getContract("0x..."); -const walletAddress = "0x..."; +const walletAddress = "{{wallet_address}}"; const tokenId = 0; const nft = await contract.nft.get(tokenId); await contract.nft.transfer(walletAddress, tokenId); diff --git a/docs/sdk.erc721.transfer.md b/docs/sdk.erc721.transfer.md index fe8e980da..cf099ea26 100644 --- a/docs/sdk.erc721.transfer.md +++ b/docs/sdk.erc721.transfer.md @@ -31,12 +31,6 @@ Transfer an NFT from the connected wallet to another wallet. ```javascript -// Address of the wallet you want to send the NFT to -const toAddress = "{{wallet_address}}"; - -// The token ID of the NFT you want to send -const tokenId = "0"; - -await contract.transfer(toAddress, tokenId); +await contract.transfer(walletAddress, tokenId); ``` diff --git a/docs/snippets.json b/docs/snippets.json index 8d0d5cb58..086824d84 100644 --- a/docs/snippets.json +++ b/docs/snippets.json @@ -294,7 +294,7 @@ "summary": "Get NFT Balance\n\n", "remarks": "\n\nGet a wallets NFT balance (number of NFTs in this contract owned by the wallet).\n\n", "examples": { - "javascript": "// Address of the wallet to check NFT balance\nconst address = \"{{wallet_address}}\";\n\nconst balance = await contract.balanceOf(address);\nconsole.log(balance);" + "javascript": "const balance = await contract.balanceOf(walletAddress);\nconsole.log(balance);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.balanceOf" }, @@ -303,7 +303,7 @@ "summary": "Get a single NFT Metadata\n\n", "remarks": null, "examples": { - "javascript": "const nft = await contract.get(\"0\");\nconsole.log(nft);" + "javascript": "const nft = await contract.get(tokenId);\nconsole.log(nft);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.get" }, @@ -312,7 +312,7 @@ "summary": "Transfer a single NFT\n\n", "remarks": "\n\nTransfer an NFT from the connected wallet to another wallet.\n\n", "examples": { - "javascript": "// Address of the wallet you want to send the NFT to\nconst toAddress = \"{{wallet_address}}\";\n\n// The token ID of the NFT you want to send\nconst tokenId = \"0\";\n\nawait contract.transfer(toAddress, tokenId);" + "javascript": "await contract.transfer(walletAddress, tokenId);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.transfer" } @@ -424,7 +424,7 @@ "summary": "Get NFT Balance\n\n", "remarks": "\n\nGet a wallets NFT balance (number of NFTs in this contract owned by the wallet).\n\n", "examples": { - "javascript": "// Address of the wallet to check NFT balance\nconst address = \"{{wallet_address}}\";\n\nconst balance = await contract.balanceOf(address);\nconsole.log(balance);" + "javascript": "const balance = await contract.balanceOf(walletAddress);\nconsole.log(balance);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.balanceOf" }, @@ -433,7 +433,7 @@ "summary": "Get a single NFT Metadata\n\n", "remarks": null, "examples": { - "javascript": "const nft = await contract.get(\"0\");\nconsole.log(nft);" + "javascript": "const nft = await contract.get(tokenId);\nconsole.log(nft);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.get" }, @@ -442,7 +442,7 @@ "summary": "Transfer a single NFT\n\n", "remarks": "\n\nTransfer an NFT from the connected wallet to another wallet.\n\n", "examples": { - "javascript": "// Address of the wallet you want to send the NFT to\nconst toAddress = \"{{wallet_address}}\";\n\n// The token ID of the NFT you want to send\nconst tokenId = \"0\";\n\nawait contract.transfer(toAddress, tokenId);" + "javascript": "await contract.transfer(walletAddress, tokenId);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.transfer" } diff --git a/scripts/generate-feature-snippets.mjs b/scripts/generate-feature-snippets.mjs index 9692e2615..e6e4925e8 100644 --- a/scripts/generate-feature-snippets.mjs +++ b/scripts/generate-feature-snippets.mjs @@ -105,7 +105,9 @@ const parseMembers = (members, kind, contractName) => { ? Formatter.renderDocNode(docComment.remarksBlock.content) : null, examples, - reference: extractReferenceLink(m, kind, contractName), + reference: { + javascript: extractReferenceLink(m, kind, contractName), + }, }; } return null; diff --git a/src/core/classes/erc-721.ts b/src/core/classes/erc-721.ts index 0fd544fb6..d9d32af59 100644 --- a/src/core/classes/erc-721.ts +++ b/src/core/classes/erc-721.ts @@ -26,7 +26,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @example * ```javascript * const contract = sdk.getContract("0x..."); - * const walletAddress = "0x..."; + * const walletAddress = "{{wallet_address}}"; * const tokenId = 0; * const nft = await contract.nft.get(tokenId); * await contract.nft.transfer(walletAddress, tokenId); @@ -84,7 +84,7 @@ export class Erc721 * * @example * ```javascript - * const nft = await contract.get("0"); + * const nft = await contract.get(tokenId); * console.log(nft); * ``` * @param tokenId - the tokenId of the NFT to retrieve @@ -115,10 +115,7 @@ export class Erc721 * * @example * ```javascript - * // Address of the wallet to check NFT balance - * const address = "{{wallet_address}}"; - * - * const balance = await contract.balanceOf(address); + * const balance = await contract.balanceOf(walletAddress); * console.log(balance); * ``` */ @@ -156,13 +153,7 @@ export class Erc721 * * @example * ```javascript - * // Address of the wallet you want to send the NFT to - * const toAddress = "{{wallet_address}}"; - * - * // The token ID of the NFT you want to send - * const tokenId = "0"; - * - * await contract.transfer(toAddress, tokenId); + * await contract.transfer(walletAddress, tokenId); * ``` */ public async transfer( From df12e1c613e1fb407b4670c2e647f7da588cac73 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 18:33:10 -0700 Subject: [PATCH 10/15] polish code snippets --- docs/feature_snippets.json | 40 +++++++-------- docs/sdk.edition.getall.md | 9 +++- docs/sdk.edition.getowned.md | 9 ++++ docs/sdk.edition.md | 2 +- docs/sdk.erc1155.balanceof.md | 9 ++-- docs/sdk.erc1155.get.md | 1 - docs/sdk.erc1155.md | 5 +- docs/sdk.erc1155.transfer.md | 8 +-- docs/sdk.erc1155enumerable.all.md | 3 +- docs/sdk.erc1155enumerable.owned.md | 3 +- docs/sdk.erc20.allowance.md | 2 - docs/sdk.erc20.allowanceof.md | 9 ++-- docs/sdk.erc20.balanceof.md | 6 +-- docs/sdk.erc20.get.md | 1 - docs/sdk.erc20.md | 3 +- docs/sdk.erc20.setallowance.md | 2 - docs/sdk.erc20.transfer.md | 2 - docs/sdk.erc20.transferfrom.md | 3 -- docs/sdk.erc721.balanceof.md | 1 + docs/sdk.erc721.get.md | 2 +- docs/sdk.erc721.md | 3 -- docs/sdk.erc721.transfer.md | 2 + docs/sdk.erc721enumerable.all.md | 1 - docs/sdk.erc721supply.all.md | 1 - docs/snippets.json | 56 ++++++++++++++------- src/contracts/edition.ts | 26 +++++++++- src/core/classes/erc-1155-batch-mintable.ts | 12 ++++- src/core/classes/erc-1155-enumerable.ts | 6 +-- src/core/classes/erc-1155-mintable.ts | 10 ++++ src/core/classes/erc-1155.ts | 23 +++------ src/core/classes/erc-20-mintable.ts | 11 +++- src/core/classes/erc-20.ts | 28 +++-------- src/core/classes/erc-721-enumerable.ts | 1 - src/core/classes/erc-721-supply.ts | 1 - src/core/classes/erc-721.ts | 8 +-- 35 files changed, 166 insertions(+), 143 deletions(-) diff --git a/docs/feature_snippets.json b/docs/feature_snippets.json index a047ced22..7d9a5e855 100644 --- a/docs/feature_snippets.json +++ b/docs/feature_snippets.json @@ -63,7 +63,7 @@ "summary": "Standard ERC1155 NFT functions\n\n", "remarks": "\n\nBasic functionality for a ERC1155 contract that handles IPFS storage for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nconst walletAddress = \"0x...\";\nconst tokenId = 0;\nconst nft = await contract.edition.get(tokenId);\nawait contract.edition.transfer(walletAddress, tokenId, 2);" + "javascript": "const contract = sdk.getContract(\"0x...\");\nawait contract.edition.transfer(walletAddress, tokenId, quantity);" }, "methods": [ { @@ -82,7 +82,7 @@ "summary": "Get NFT Balance\n\n", "remarks": "\n\nGet a wallets NFT balance (number of NFTs in this contract owned by the wallet).\n\n", "examples": { - "javascript": "// Address of the wallet to check NFT balance\nconst address = \"{{wallet_address}}\";\n// Id of the NFT to check\nconst tokenId = 0;\n\nconst balance = await contract.balanceOf(address, tokenId);\nconsole.log(balance);" + "javascript": "// Address of the wallet to check NFT balance\nconst walletAddress = \"{{wallet_address}}\";\nconst tokenId = 0; // Id of the NFT to check\nconst balance = await contract.balanceOf(walletAddress, tokenId);" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155.balanceOf" @@ -93,7 +93,7 @@ "summary": "Get a single NFT Metadata\n\n", "remarks": null, "examples": { - "javascript": "const nft = await contract.get(\"0\");\nconsole.log(nft);" + "javascript": "const nft = await contract.get(\"0\");" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155.get" @@ -104,7 +104,7 @@ "summary": "Transfer a single NFT\n\n", "remarks": "\n\nTransfer an NFT from the connected wallet to another wallet.\n\n", "examples": { - "javascript": "// Address of the wallet you want to send the NFT to\nconst toAddress = \"{{wallet_address}}\";\n\n// The token ID of the NFT you want to send\nconst tokenId = \"0\";\n// How many copies of the NFTs to transfer\nconst amount = 3;\n\nawait contract.transfer(toAddress, tokenId, amount);" + "javascript": "// Address of the wallet you want to send the NFT to\nconst toAddress = \"{{wallet_address}}\";\nconst tokenId = \"0\"; // The token ID of the NFT you want to send\nconst amount = 3; // How many copies of the NFTs to transfer\nawait contract.transfer(toAddress, tokenId, amount);" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155.transfer" @@ -127,7 +127,7 @@ "summary": "Get All NFTs\n\n", "remarks": "\n\nGet all the data associated with every NFT in this contract.\n\nBy default, returns the first 100 NFTs, use queryParams to fetch more.\n\n", "examples": { - "javascript": "const nfts = await contract.getAll();\nconsole.log(nfts);" + "javascript": "const nfts = await contract.edition.query.all();" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155Enumerable.all" @@ -138,7 +138,7 @@ "summary": "Get Owned NFTs\n\n", "remarks": "\n\nGet all the data associated with the NFTs owned by a specific wallet.\n\n", "examples": { - "javascript": "// Address of the wallet to get the NFTs of\nconst address = \"{{wallet_address}}\";\nconst nfts = await contract.getOwned(address);\nconsole.log(nfts);" + "javascript": "// Address of the wallet to get the NFTs of\nconst address = \"{{wallet_address}}\";\nconst nfts = await contract.edition.query.owned(address);" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155Enumerable.owned" @@ -153,7 +153,7 @@ "summary": "Standard ERC20 Token functions\n\n", "remarks": "\n\nBasic functionality for a ERC20 contract that handles all unit transformation for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nconst walletAddress = \"0x...\";\nawait contract.token.transfer(walletAddress, 0.8);" + "javascript": "const contract = sdk.getContract(\"0x...\");\nawait contract.token.transfer(walletAddress, amount);" }, "methods": [ { @@ -161,7 +161,7 @@ "summary": "Get Token Allowance\n\n", "remarks": "\n\nGet the allowance of a 'spender' wallet over the connected wallet's funds - the allowance of a different address for a token is the amount of tokens that the `spender` wallet is allowed to spend on behalf of the connected wallet.\n\n", "examples": { - "javascript": "// Address of the wallet to check token allowance\nconst spenderAddress = \"0x...\";\n\nconst allowance = await contract.allowanceOf(otherAddress);\nconsole.log(allowance);" + "javascript": "// Address of the wallet to check token allowance\nconst spenderAddress = \"0x...\";\nconst allowance = await contract.allowanceOf(otherAddress);" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.allowance" @@ -172,7 +172,7 @@ "summary": "Get Token Allowance\n\n", "remarks": "\n\nGet the allowance of one wallet over another wallet's funds - the allowance of a different address for a token is the amount of tokens that the wallet is allowed to spend on behalf of the specified wallet.\n\n", "examples": { - "javascript": "// Address of the wallet who owns the funds\nconst address = \"{{wallet_address}}\";\n\n// Address of the wallet to check token allowance\nconst spenderAddress = \"0x...\";\n\nconst allowance = await contract.allowanceOf(address, spenderAddress);\nconsole.log(allowance);" + "javascript": "// Address of the wallet who owns the funds\nconst owner = \"{{wallet_address}}\";\n// Address of the wallet to check token allowance\nconst spender = \"0x...\";\nconst allowance = await contract.allowanceOf(owner, spender);" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.allowanceOf" @@ -194,7 +194,7 @@ "summary": "Get Token Balance\n\n", "remarks": "\n\nGet a wallets token balance.\n\n", "examples": { - "javascript": "// Address of the wallet to check token balance\nconst address = \"{{wallet_address}}\";\n\nconst balance = await contract.balanceOf(address);\nconsole.log(balance);" + "javascript": "// Address of the wallet to check token balance\nconst walletAddress = \"{{wallet_address}}\";\nconst balance = await contract.balanceOf(walletAddress);" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.balanceOf" @@ -205,7 +205,7 @@ "summary": "Get the token Metadata (name, symbol, etc...)\n\n", "remarks": null, "examples": { - "javascript": "const token = await contract.get();\nconsole.log(token);" + "javascript": "const token = await contract.get();" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.get" @@ -216,7 +216,7 @@ "summary": "Allows the specified `spender` wallet to transfer the given `amount` of tokens to another wallet\n\n", "remarks": null, "examples": { - "javascript": "// Address of the wallet to allow transfers from\nconst spenderAddress = \"0x...\";\n\n// The number of tokens to give as allowance\nconst amount = 100\n\nawait contract.setAllowance(spenderAddress, amount);" + "javascript": "// Address of the wallet to allow transfers from\nconst spenderAddress = \"0x...\";\n// The number of tokens to give as allowance\nconst amount = 100\nawait contract.setAllowance(spenderAddress, amount);" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.setAllowance" @@ -227,7 +227,7 @@ "summary": "Transfer Tokens\n\n", "remarks": "\n\nTransfer tokens from the connected wallet to another wallet.\n\n", "examples": { - "javascript": "// Address of the wallet you want to send the tokens to\nconst toAddress = \"0x...\";\n\n// The amount of tokens you want to send\nconst amount = 0.1;\n\nawait contract.transfer(toAddress, amount);" + "javascript": "// Address of the wallet you want to send the tokens to\nconst toAddress = \"0x...\";\n// The amount of tokens you want to send\nconst amount = 0.1;\nawait contract.transfer(toAddress, amount);" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.transfer" @@ -249,7 +249,7 @@ "summary": "Transfer Tokens From Address\n\n", "remarks": "\n\nTransfer tokens from one wallet to another\n\n", "examples": { - "javascript": "// Address of the wallet sending the tokens\nconst fromAddress = \"{{wallet_address}}\";\n\n// Address of the wallet you want to send the tokens to\nconst toAddress = \"0x...\";\n\n// The number of tokens you want to send\nconst amount = 1.2\n\n// Note that the connected wallet must have approval to transfer the tokens of the fromAddress\nawait contract.transferFrom(fromAddress, toAddress, amount);" + "javascript": "// Address of the wallet sending the tokens\nconst fromAddress = \"{{wallet_address}}\";\n// Address of the wallet you want to send the tokens to\nconst toAddress = \"0x...\";\n// The number of tokens you want to send\nconst amount = 1.2\n// Note that the connected wallet must have approval to transfer the tokens of the fromAddress\nawait contract.transferFrom(fromAddress, toAddress, amount);" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20.transferFrom" @@ -264,7 +264,7 @@ "summary": "Standard ERC721 NFT functions\n\n", "remarks": "\n\nBasic functionality for a ERC721 contract that handles IPFS storage for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nconst walletAddress = \"{{wallet_address}}\";\nconst tokenId = 0;\nconst nft = await contract.nft.get(tokenId);\nawait contract.nft.transfer(walletAddress, tokenId);" + "javascript": "const contract = sdk.getContract(\"0x...\");\nawait contract.nft.transfer(walletAddress, tokenId);" }, "methods": [ { @@ -272,7 +272,7 @@ "summary": "Get NFT Balance\n\n", "remarks": "\n\nGet a wallets NFT balance (number of NFTs in this contract owned by the wallet).\n\n", "examples": { - "javascript": "const balance = await contract.balanceOf(walletAddress);\nconsole.log(balance);" + "javascript": "const walletAddress = \"{{wallet_address}}\";\nconst balance = await contract.balanceOf(walletAddress);\nconsole.log(balance);" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721.balanceOf" @@ -283,7 +283,7 @@ "summary": "Get a single NFT Metadata\n\n", "remarks": null, "examples": { - "javascript": "const nft = await contract.get(tokenId);\nconsole.log(nft);" + "javascript": "const tokenId = 0;\nconst nft = await contract.get(tokenId);" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721.get" @@ -294,7 +294,7 @@ "summary": "Transfer a single NFT\n\n", "remarks": "\n\nTransfer an NFT from the connected wallet to another wallet.\n\n", "examples": { - "javascript": "await contract.transfer(walletAddress, tokenId);" + "javascript": "const walletAddress = \"{{wallet_address}}\";\nconst tokenId = 0;\nawait contract.transfer(walletAddress, tokenId);" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721.transfer" @@ -340,7 +340,7 @@ "summary": "Get Owned NFTs\n\n", "remarks": "\n\nGet all the data associated with the NFTs owned by a specific wallet.\n\n", "examples": { - "javascript": "// Address of the wallet to get the NFTs of\nconst address = \"{{wallet_address}}\";\nconst nfts = await contract.query.owned.all(address);\nconsole.log(nfts);" + "javascript": "// Address of the wallet to get the NFTs of\nconst address = \"{{wallet_address}}\";\nconst nfts = await contract.query.owned.all(address);" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721Enumerable.all" @@ -386,7 +386,7 @@ "summary": "Get All Minted NFTs\n\n", "remarks": "\n\nGet all the data associated with every NFT in this contract.\n\nBy default, returns the first 100 NFTs, use queryParams to fetch more.\n\n", "examples": { - "javascript": "const nfts = await contract.query.all();\nconsole.log(nfts);" + "javascript": "const nfts = await contract.query.all();" }, "reference": { "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721Supply.all" diff --git a/docs/sdk.edition.getall.md b/docs/sdk.edition.getall.md index 7ee9aa60b..1b875b5ae 100644 --- a/docs/sdk.edition.getall.md +++ b/docs/sdk.edition.getall.md @@ -4,7 +4,7 @@ ## Edition.getAll() method -Get All NFTs +Get All Minted NFTs Signature: @@ -30,3 +30,10 @@ Get all the data associated with every NFT in this contract. By default, returns the first 100 NFTs, use queryParams to fetch more. +## Example + + +```javascript +const nfts = await contract.getAll(); +``` + diff --git a/docs/sdk.edition.getowned.md b/docs/sdk.edition.getowned.md index 86853c93f..8a4faea15 100644 --- a/docs/sdk.edition.getowned.md +++ b/docs/sdk.edition.getowned.md @@ -28,3 +28,12 @@ The NFT metadata for all NFTs in the contract. Get all the data associated with the NFTs owned by a specific wallet. +## Example + + +```javascript +// Address of the wallet to get the NFTs of +const address = "{{wallet_address}}"; +const nfts = await contract.getOwned(address); +``` + diff --git a/docs/sdk.edition.md b/docs/sdk.edition.md index 1ba88f07b..71cafdd15 100644 --- a/docs/sdk.edition.md +++ b/docs/sdk.edition.md @@ -53,7 +53,7 @@ const contract = sdk.getEdition("{{contract_address}}"); | Method | Modifiers | Description | | --- | --- | --- | | [burn(tokenId, amount)](./sdk.edition.burn.md) | | Burn a single NFT | -| [getAll(queryParams)](./sdk.edition.getall.md) | | Get All NFTs | +| [getAll(queryParams)](./sdk.edition.getall.md) | | Get All Minted NFTs | | [getOwned(walletAddress)](./sdk.edition.getowned.md) | | Get Owned NFTs | | [getTotalCount()](./sdk.edition.gettotalcount.md) | | Get the number of NFTs minted | | [isTransferRestricted()](./sdk.edition.istransferrestricted.md) | | Get whether users can transfer NFTs from this contract | diff --git a/docs/sdk.erc1155.balanceof.md b/docs/sdk.erc1155.balanceof.md index 1bc1a0a4e..43eee4819 100644 --- a/docs/sdk.erc1155.balanceof.md +++ b/docs/sdk.erc1155.balanceof.md @@ -32,11 +32,8 @@ Get a wallets NFT balance (number of NFTs in this contract owned by the wallet). ```javascript // Address of the wallet to check NFT balance -const address = "{{wallet_address}}"; -// Id of the NFT to check -const tokenId = 0; - -const balance = await contract.balanceOf(address, tokenId); -console.log(balance); +const walletAddress = "{{wallet_address}}"; +const tokenId = 0; // Id of the NFT to check +const balance = await contract.balanceOf(walletAddress, tokenId); ``` diff --git a/docs/sdk.erc1155.get.md b/docs/sdk.erc1155.get.md index 7adfb744a..39476133d 100644 --- a/docs/sdk.erc1155.get.md +++ b/docs/sdk.erc1155.get.md @@ -29,6 +29,5 @@ The NFT metadata ```javascript const nft = await contract.get("0"); -console.log(nft); ``` diff --git a/docs/sdk.erc1155.md b/docs/sdk.erc1155.md index dbae129bf..5eb1652a2 100644 --- a/docs/sdk.erc1155.md +++ b/docs/sdk.erc1155.md @@ -22,10 +22,7 @@ Basic functionality for a ERC1155 contract that handles IPFS storage for you. ```javascript const contract = sdk.getContract("0x..."); -const walletAddress = "0x..."; -const tokenId = 0; -const nft = await contract.edition.get(tokenId); -await contract.edition.transfer(walletAddress, tokenId, 2); +await contract.edition.transfer(walletAddress, tokenId, quantity); ``` ## Constructors diff --git a/docs/sdk.erc1155.transfer.md b/docs/sdk.erc1155.transfer.md index 7ee8591fc..df07da39f 100644 --- a/docs/sdk.erc1155.transfer.md +++ b/docs/sdk.erc1155.transfer.md @@ -35,12 +35,8 @@ Transfer an NFT from the connected wallet to another wallet. ```javascript // Address of the wallet you want to send the NFT to const toAddress = "{{wallet_address}}"; - -// The token ID of the NFT you want to send -const tokenId = "0"; -// How many copies of the NFTs to transfer -const amount = 3; - +const tokenId = "0"; // The token ID of the NFT you want to send +const amount = 3; // How many copies of the NFTs to transfer await contract.transfer(toAddress, tokenId, amount); ``` diff --git a/docs/sdk.erc1155enumerable.all.md b/docs/sdk.erc1155enumerable.all.md index 6e6207eae..e6c0f8878 100644 --- a/docs/sdk.erc1155enumerable.all.md +++ b/docs/sdk.erc1155enumerable.all.md @@ -34,7 +34,6 @@ By default, returns the first 100 NFTs, use queryParams to fetch more. ```javascript -const nfts = await contract.getAll(); -console.log(nfts); +const nfts = await contract.edition.query.all(); ``` diff --git a/docs/sdk.erc1155enumerable.owned.md b/docs/sdk.erc1155enumerable.owned.md index a0073363b..468b866bb 100644 --- a/docs/sdk.erc1155enumerable.owned.md +++ b/docs/sdk.erc1155enumerable.owned.md @@ -34,7 +34,6 @@ Get all the data associated with the NFTs owned by a specific wallet. ```javascript // Address of the wallet to get the NFTs of const address = "{{wallet_address}}"; -const nfts = await contract.getOwned(address); -console.log(nfts); +const nfts = await contract.edition.query.owned(address); ``` diff --git a/docs/sdk.erc20.allowance.md b/docs/sdk.erc20.allowance.md index aea0ec399..763d27893 100644 --- a/docs/sdk.erc20.allowance.md +++ b/docs/sdk.erc20.allowance.md @@ -34,8 +34,6 @@ Get the allowance of a 'spender' wallet over the connected wallet's funds - the ```javascript // Address of the wallet to check token allowance const spenderAddress = "0x..."; - const allowance = await contract.allowanceOf(otherAddress); -console.log(allowance); ``` diff --git a/docs/sdk.erc20.allowanceof.md b/docs/sdk.erc20.allowanceof.md index 371ef7274..c43b82bc4 100644 --- a/docs/sdk.erc20.allowanceof.md +++ b/docs/sdk.erc20.allowanceof.md @@ -34,12 +34,9 @@ Get the allowance of one wallet over another wallet's funds - the allowance of a ```javascript // Address of the wallet who owns the funds -const address = "{{wallet_address}}"; - +const owner = "{{wallet_address}}"; // Address of the wallet to check token allowance -const spenderAddress = "0x..."; - -const allowance = await contract.allowanceOf(address, spenderAddress); -console.log(allowance); +const spender = "0x..."; +const allowance = await contract.allowanceOf(owner, spender); ``` diff --git a/docs/sdk.erc20.balanceof.md b/docs/sdk.erc20.balanceof.md index 1ba507b02..5b4e30a6c 100644 --- a/docs/sdk.erc20.balanceof.md +++ b/docs/sdk.erc20.balanceof.md @@ -33,9 +33,7 @@ Get a wallets token balance. ```javascript // Address of the wallet to check token balance -const address = "{{wallet_address}}"; - -const balance = await contract.balanceOf(address); -console.log(balance); +const walletAddress = "{{wallet_address}}"; +const balance = await contract.balanceOf(walletAddress); ``` diff --git a/docs/sdk.erc20.get.md b/docs/sdk.erc20.get.md index df98adc65..f1c21b0c0 100644 --- a/docs/sdk.erc20.get.md +++ b/docs/sdk.erc20.get.md @@ -22,6 +22,5 @@ The token metadata ```javascript const token = await contract.get(); -console.log(token); ``` diff --git a/docs/sdk.erc20.md b/docs/sdk.erc20.md index c33c15690..66d335e1d 100644 --- a/docs/sdk.erc20.md +++ b/docs/sdk.erc20.md @@ -22,8 +22,7 @@ Basic functionality for a ERC20 contract that handles all unit transformation fo ```javascript const contract = sdk.getContract("0x..."); -const walletAddress = "0x..."; -await contract.token.transfer(walletAddress, 0.8); +await contract.token.transfer(walletAddress, amount); ``` ## Constructors diff --git a/docs/sdk.erc20.setallowance.md b/docs/sdk.erc20.setallowance.md index 437ecf7d9..cfe3bf9d7 100644 --- a/docs/sdk.erc20.setallowance.md +++ b/docs/sdk.erc20.setallowance.md @@ -29,10 +29,8 @@ Promise<[TransactionResult](./sdk.transactionresult.md)> ```javascript // Address of the wallet to allow transfers from const spenderAddress = "0x..."; - // The number of tokens to give as allowance const amount = 100 - await contract.setAllowance(spenderAddress, amount); ``` diff --git a/docs/sdk.erc20.transfer.md b/docs/sdk.erc20.transfer.md index 35b5a75c0..d8a91850a 100644 --- a/docs/sdk.erc20.transfer.md +++ b/docs/sdk.erc20.transfer.md @@ -33,10 +33,8 @@ Transfer tokens from the connected wallet to another wallet. ```javascript // Address of the wallet you want to send the tokens to const toAddress = "0x..."; - // The amount of tokens you want to send const amount = 0.1; - await contract.transfer(toAddress, amount); ``` diff --git a/docs/sdk.erc20.transferfrom.md b/docs/sdk.erc20.transferfrom.md index 878e3699e..b91296763 100644 --- a/docs/sdk.erc20.transferfrom.md +++ b/docs/sdk.erc20.transferfrom.md @@ -34,13 +34,10 @@ Transfer tokens from one wallet to another ```javascript // Address of the wallet sending the tokens const fromAddress = "{{wallet_address}}"; - // Address of the wallet you want to send the tokens to const toAddress = "0x..."; - // The number of tokens you want to send const amount = 1.2 - // Note that the connected wallet must have approval to transfer the tokens of the fromAddress await contract.transferFrom(fromAddress, toAddress, amount); ``` diff --git a/docs/sdk.erc721.balanceof.md b/docs/sdk.erc721.balanceof.md index d92095a4a..2b55e5dfb 100644 --- a/docs/sdk.erc721.balanceof.md +++ b/docs/sdk.erc721.balanceof.md @@ -30,6 +30,7 @@ Get a wallets NFT balance (number of NFTs in this contract owned by the wallet). ```javascript +const walletAddress = "{{wallet_address}}"; const balance = await contract.balanceOf(walletAddress); console.log(balance); ``` diff --git a/docs/sdk.erc721.get.md b/docs/sdk.erc721.get.md index cb14cb20c..9e9a75028 100644 --- a/docs/sdk.erc721.get.md +++ b/docs/sdk.erc721.get.md @@ -28,7 +28,7 @@ The NFT metadata ```javascript +const tokenId = 0; const nft = await contract.get(tokenId); -console.log(nft); ``` diff --git a/docs/sdk.erc721.md b/docs/sdk.erc721.md index 119832bd4..030553260 100644 --- a/docs/sdk.erc721.md +++ b/docs/sdk.erc721.md @@ -22,9 +22,6 @@ Basic functionality for a ERC721 contract that handles IPFS storage for you. ```javascript const contract = sdk.getContract("0x..."); -const walletAddress = "{{wallet_address}}"; -const tokenId = 0; -const nft = await contract.nft.get(tokenId); await contract.nft.transfer(walletAddress, tokenId); ``` diff --git a/docs/sdk.erc721.transfer.md b/docs/sdk.erc721.transfer.md index cf099ea26..a108f61f6 100644 --- a/docs/sdk.erc721.transfer.md +++ b/docs/sdk.erc721.transfer.md @@ -31,6 +31,8 @@ Transfer an NFT from the connected wallet to another wallet. ```javascript +const walletAddress = "{{wallet_address}}"; +const tokenId = 0; await contract.transfer(walletAddress, tokenId); ``` diff --git a/docs/sdk.erc721enumerable.all.md b/docs/sdk.erc721enumerable.all.md index c49d646bc..fac318388 100644 --- a/docs/sdk.erc721enumerable.all.md +++ b/docs/sdk.erc721enumerable.all.md @@ -35,6 +35,5 @@ Get all the data associated with the NFTs owned by a specific wallet. // Address of the wallet to get the NFTs of const address = "{{wallet_address}}"; const nfts = await contract.query.owned.all(address); -console.log(nfts); ``` diff --git a/docs/sdk.erc721supply.all.md b/docs/sdk.erc721supply.all.md index b5a17a956..eee3db986 100644 --- a/docs/sdk.erc721supply.all.md +++ b/docs/sdk.erc721supply.all.md @@ -35,6 +35,5 @@ By default, returns the first 100 NFTs, use queryParams to fetch more. ```javascript const nfts = await contract.query.all(); -console.log(nfts); ``` diff --git a/docs/snippets.json b/docs/snippets.json index 086824d84..a337c9c49 100644 --- a/docs/snippets.json +++ b/docs/snippets.json @@ -7,6 +7,24 @@ "javascript": "import { ThirdwebSDK } from \"@thirdweb-dev/sdk\";\n\n// You can switch out this provider with any wallet or provider setup you like.\nconst provider = ethers.Wallet.createRandom();\nconst sdk = new ThirdwebSDK(provider);\nconst contract = sdk.getEdition(\"{{contract_address}}\");" }, "methods": [ + { + "name": "getAll", + "summary": "Get All Minted NFTs\n\n", + "remarks": "\n\nGet all the data associated with every NFT in this contract.\n\nBy default, returns the first 100 NFTs, use queryParams to fetch more.\n\n", + "examples": { + "javascript": "const nfts = await contract.getAll();" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Edition.getAll" + }, + { + "name": "getOwned", + "summary": "Get Owned NFTs\n\n", + "remarks": "\n\nGet all the data associated with the NFTs owned by a specific wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet to get the NFTs of\nconst address = \"{{wallet_address}}\";\nconst nfts = await contract.getOwned(address);" + }, + "reference": "https://docs.thirdweb.com/typescript/sdk.Edition.getOwned" + }, { "name": "mintBatchTo", "summary": "Mint Many NFTs with limited supplies\n\n", @@ -39,7 +57,7 @@ "summary": "Get NFT Balance\n\n", "remarks": "\n\nGet a wallets NFT balance (number of NFTs in this contract owned by the wallet).\n\n", "examples": { - "javascript": "// Address of the wallet to check NFT balance\nconst address = \"{{wallet_address}}\";\n// Id of the NFT to check\nconst tokenId = 0;\n\nconst balance = await contract.balanceOf(address, tokenId);\nconsole.log(balance);" + "javascript": "// Address of the wallet to check NFT balance\nconst walletAddress = \"{{wallet_address}}\";\nconst tokenId = 0; // Id of the NFT to check\nconst balance = await contract.balanceOf(walletAddress, tokenId);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.balanceOf" }, @@ -48,7 +66,7 @@ "summary": "Get a single NFT Metadata\n\n", "remarks": null, "examples": { - "javascript": "const nft = await contract.get(\"0\");\nconsole.log(nft);" + "javascript": "const nft = await contract.get(\"0\");" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.get" }, @@ -57,7 +75,7 @@ "summary": "Transfer a single NFT\n\n", "remarks": "\n\nTransfer an NFT from the connected wallet to another wallet.\n\n", "examples": { - "javascript": "// Address of the wallet you want to send the NFT to\nconst toAddress = \"{{wallet_address}}\";\n\n// The token ID of the NFT you want to send\nconst tokenId = \"0\";\n// How many copies of the NFTs to transfer\nconst amount = 3;\n\nawait contract.transfer(toAddress, tokenId, amount);" + "javascript": "// Address of the wallet you want to send the NFT to\nconst toAddress = \"{{wallet_address}}\";\nconst tokenId = \"0\"; // The token ID of the NFT you want to send\nconst amount = 3; // How many copies of the NFTs to transfer\nawait contract.transfer(toAddress, tokenId, amount);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.transfer" } @@ -124,7 +142,7 @@ "summary": "Get NFT Balance\n\n", "remarks": "\n\nGet a wallets NFT balance (number of NFTs in this contract owned by the wallet).\n\n", "examples": { - "javascript": "// Address of the wallet to check NFT balance\nconst address = \"{{wallet_address}}\";\n// Id of the NFT to check\nconst tokenId = 0;\n\nconst balance = await contract.balanceOf(address, tokenId);\nconsole.log(balance);" + "javascript": "// Address of the wallet to check NFT balance\nconst walletAddress = \"{{wallet_address}}\";\nconst tokenId = 0; // Id of the NFT to check\nconst balance = await contract.balanceOf(walletAddress, tokenId);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.balanceOf" }, @@ -133,7 +151,7 @@ "summary": "Get a single NFT Metadata\n\n", "remarks": null, "examples": { - "javascript": "const nft = await contract.get(\"0\");\nconsole.log(nft);" + "javascript": "const nft = await contract.get(\"0\");" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.get" }, @@ -142,7 +160,7 @@ "summary": "Transfer a single NFT\n\n", "remarks": "\n\nTransfer an NFT from the connected wallet to another wallet.\n\n", "examples": { - "javascript": "// Address of the wallet you want to send the NFT to\nconst toAddress = \"{{wallet_address}}\";\n\n// The token ID of the NFT you want to send\nconst tokenId = \"0\";\n// How many copies of the NFTs to transfer\nconst amount = 3;\n\nawait contract.transfer(toAddress, tokenId, amount);" + "javascript": "// Address of the wallet you want to send the NFT to\nconst toAddress = \"{{wallet_address}}\";\nconst tokenId = \"0\"; // The token ID of the NFT you want to send\nconst amount = 3; // How many copies of the NFTs to transfer\nawait contract.transfer(toAddress, tokenId, amount);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155.transfer" } @@ -294,7 +312,7 @@ "summary": "Get NFT Balance\n\n", "remarks": "\n\nGet a wallets NFT balance (number of NFTs in this contract owned by the wallet).\n\n", "examples": { - "javascript": "const balance = await contract.balanceOf(walletAddress);\nconsole.log(balance);" + "javascript": "const walletAddress = \"{{wallet_address}}\";\nconst balance = await contract.balanceOf(walletAddress);\nconsole.log(balance);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.balanceOf" }, @@ -303,7 +321,7 @@ "summary": "Get a single NFT Metadata\n\n", "remarks": null, "examples": { - "javascript": "const nft = await contract.get(tokenId);\nconsole.log(nft);" + "javascript": "const tokenId = 0;\nconst nft = await contract.get(tokenId);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.get" }, @@ -312,7 +330,7 @@ "summary": "Transfer a single NFT\n\n", "remarks": "\n\nTransfer an NFT from the connected wallet to another wallet.\n\n", "examples": { - "javascript": "await contract.transfer(walletAddress, tokenId);" + "javascript": "const walletAddress = \"{{wallet_address}}\";\nconst tokenId = 0;\nawait contract.transfer(walletAddress, tokenId);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.transfer" } @@ -424,7 +442,7 @@ "summary": "Get NFT Balance\n\n", "remarks": "\n\nGet a wallets NFT balance (number of NFTs in this contract owned by the wallet).\n\n", "examples": { - "javascript": "const balance = await contract.balanceOf(walletAddress);\nconsole.log(balance);" + "javascript": "const walletAddress = \"{{wallet_address}}\";\nconst balance = await contract.balanceOf(walletAddress);\nconsole.log(balance);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.balanceOf" }, @@ -433,7 +451,7 @@ "summary": "Get a single NFT Metadata\n\n", "remarks": null, "examples": { - "javascript": "const nft = await contract.get(tokenId);\nconsole.log(nft);" + "javascript": "const tokenId = 0;\nconst nft = await contract.get(tokenId);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.get" }, @@ -442,7 +460,7 @@ "summary": "Transfer a single NFT\n\n", "remarks": "\n\nTransfer an NFT from the connected wallet to another wallet.\n\n", "examples": { - "javascript": "await contract.transfer(walletAddress, tokenId);" + "javascript": "const walletAddress = \"{{wallet_address}}\";\nconst tokenId = 0;\nawait contract.transfer(walletAddress, tokenId);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721.transfer" } @@ -680,7 +698,7 @@ "summary": "Get Token Allowance\n\n", "remarks": "\n\nGet the allowance of a 'spender' wallet over the connected wallet's funds - the allowance of a different address for a token is the amount of tokens that the `spender` wallet is allowed to spend on behalf of the connected wallet.\n\n", "examples": { - "javascript": "// Address of the wallet to check token allowance\nconst spenderAddress = \"0x...\";\n\nconst allowance = await contract.allowanceOf(otherAddress);\nconsole.log(allowance);" + "javascript": "// Address of the wallet to check token allowance\nconst spenderAddress = \"0x...\";\nconst allowance = await contract.allowanceOf(otherAddress);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.allowance" }, @@ -689,7 +707,7 @@ "summary": "Get Token Allowance\n\n", "remarks": "\n\nGet the allowance of one wallet over another wallet's funds - the allowance of a different address for a token is the amount of tokens that the wallet is allowed to spend on behalf of the specified wallet.\n\n", "examples": { - "javascript": "// Address of the wallet who owns the funds\nconst address = \"{{wallet_address}}\";\n\n// Address of the wallet to check token allowance\nconst spenderAddress = \"0x...\";\n\nconst allowance = await contract.allowanceOf(address, spenderAddress);\nconsole.log(allowance);" + "javascript": "// Address of the wallet who owns the funds\nconst owner = \"{{wallet_address}}\";\n// Address of the wallet to check token allowance\nconst spender = \"0x...\";\nconst allowance = await contract.allowanceOf(owner, spender);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.allowanceOf" }, @@ -707,7 +725,7 @@ "summary": "Get Token Balance\n\n", "remarks": "\n\nGet a wallets token balance.\n\n", "examples": { - "javascript": "// Address of the wallet to check token balance\nconst address = \"{{wallet_address}}\";\n\nconst balance = await contract.balanceOf(address);\nconsole.log(balance);" + "javascript": "// Address of the wallet to check token balance\nconst walletAddress = \"{{wallet_address}}\";\nconst balance = await contract.balanceOf(walletAddress);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.balanceOf" }, @@ -716,7 +734,7 @@ "summary": "Get the token Metadata (name, symbol, etc...)\n\n", "remarks": null, "examples": { - "javascript": "const token = await contract.get();\nconsole.log(token);" + "javascript": "const token = await contract.get();" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.get" }, @@ -725,7 +743,7 @@ "summary": "Allows the specified `spender` wallet to transfer the given `amount` of tokens to another wallet\n\n", "remarks": null, "examples": { - "javascript": "// Address of the wallet to allow transfers from\nconst spenderAddress = \"0x...\";\n\n// The number of tokens to give as allowance\nconst amount = 100\n\nawait contract.setAllowance(spenderAddress, amount);" + "javascript": "// Address of the wallet to allow transfers from\nconst spenderAddress = \"0x...\";\n// The number of tokens to give as allowance\nconst amount = 100\nawait contract.setAllowance(spenderAddress, amount);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.setAllowance" }, @@ -734,7 +752,7 @@ "summary": "Transfer Tokens\n\n", "remarks": "\n\nTransfer tokens from the connected wallet to another wallet.\n\n", "examples": { - "javascript": "// Address of the wallet you want to send the tokens to\nconst toAddress = \"0x...\";\n\n// The amount of tokens you want to send\nconst amount = 0.1;\n\nawait contract.transfer(toAddress, amount);" + "javascript": "// Address of the wallet you want to send the tokens to\nconst toAddress = \"0x...\";\n// The amount of tokens you want to send\nconst amount = 0.1;\nawait contract.transfer(toAddress, amount);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.transfer" }, @@ -752,7 +770,7 @@ "summary": "Transfer Tokens From Address\n\n", "remarks": "\n\nTransfer tokens from one wallet to another\n\n", "examples": { - "javascript": "// Address of the wallet sending the tokens\nconst fromAddress = \"{{wallet_address}}\";\n\n// Address of the wallet you want to send the tokens to\nconst toAddress = \"0x...\";\n\n// The number of tokens you want to send\nconst amount = 1.2\n\n// Note that the connected wallet must have approval to transfer the tokens of the fromAddress\nawait contract.transferFrom(fromAddress, toAddress, amount);" + "javascript": "// Address of the wallet sending the tokens\nconst fromAddress = \"{{wallet_address}}\";\n// Address of the wallet you want to send the tokens to\nconst toAddress = \"0x...\";\n// The number of tokens you want to send\nconst amount = 1.2\n// Note that the connected wallet must have approval to transfer the tokens of the fromAddress\nawait contract.transferFrom(fromAddress, toAddress, amount);" }, "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20.transferFrom" } diff --git a/src/contracts/edition.ts b/src/contracts/edition.ts index 9b5f61e28..dea1be307 100644 --- a/src/contracts/edition.ts +++ b/src/contracts/edition.ts @@ -149,7 +149,18 @@ export class Edition extends Erc1155 { *******************************/ /** - * {@inheritDoc Erc1155Enumerable.all} + * Get All Minted NFTs + * + * @remarks Get all the data associated with every NFT in this contract. + * + * By default, returns the first 100 NFTs, use queryParams to fetch more. + * + * @example + * ```javascript + * const nfts = await contract.getAll(); + * ``` + * @param queryParams - optional filtering to only fetch a subset of results. + * @returns The NFT metadata for all NFTs queried. */ public async getAll( queryParams?: QueryAllParams, @@ -158,7 +169,18 @@ export class Edition extends Erc1155 { } /** - * {@inheritDoc Erc1155Enumerable.owned} + * Get Owned NFTs + * + * @remarks Get all the data associated with the NFTs owned by a specific wallet. + * + * @example + * ```javascript + * // Address of the wallet to get the NFTs of + * const address = "{{wallet_address}}"; + * const nfts = await contract.getOwned(address); + * ``` + * + * @returns The NFT metadata for all NFTs in the contract. */ public async getOwned( walletAddress?: string, diff --git a/src/core/classes/erc-1155-batch-mintable.ts b/src/core/classes/erc-1155-batch-mintable.ts index 721513d1f..91d5f64db 100644 --- a/src/core/classes/erc-1155-batch-mintable.ts +++ b/src/core/classes/erc-1155-batch-mintable.ts @@ -11,6 +11,16 @@ import { IStorage } from "../interfaces"; import { FEATURE_EDITION_BATCH_MINTABLE } from "../../constants/erc1155-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; +/** + * Mint Many ERC1155 NFTs at once + * @remarks NFT batch minting functionality that handles IPFS storage for you. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * await contract.edition.mint.batch.to(walletAddress, [nftMetadataWithSupply1, nftMetadataWithSupply2, ...]); + * ``` + * @public + */ export class Erc1155BatchMintable implements DetectableFeature { featureName = FEATURE_EDITION_BATCH_MINTABLE.name; private contractWrapper: ContractWrapper; @@ -54,7 +64,7 @@ export class Erc1155BatchMintable implements DetectableFeature { * }, * }]; * - * const tx = await contract.mintBatchTo(toAddress, metadataWithSupply); + * const tx = await contract.edition.mint.batch.to(toAddress, metadataWithSupply); * const receipt = tx[0].receipt; // same transaction receipt for all minted NFTs * const firstTokenId = tx[0].id; // token id of the first minted NFT * const firstNFT = await tx[0].data(); // (optional) fetch details of the first minted NFT diff --git a/src/core/classes/erc-1155-enumerable.ts b/src/core/classes/erc-1155-enumerable.ts index e9979d2f1..5e4eb23ef 100644 --- a/src/core/classes/erc-1155-enumerable.ts +++ b/src/core/classes/erc-1155-enumerable.ts @@ -40,8 +40,7 @@ export class Erc1155Enumerable implements DetectableFeature { * * @example * ```javascript - * const nfts = await contract.getAll(); - * console.log(nfts); + * const nfts = await contract.edition.query.all(); * ``` * @param queryParams - optional filtering to only fetch a subset of results. * @returns The NFT metadata for all NFTs queried. @@ -80,8 +79,7 @@ export class Erc1155Enumerable implements DetectableFeature { * ```javascript * // Address of the wallet to get the NFTs of * const address = "{{wallet_address}}"; - * const nfts = await contract.getOwned(address); - * console.log(nfts); + * const nfts = await contract.edition.query.owned(address); * ``` * * @returns The NFT metadata for all NFTs in the contract. diff --git a/src/core/classes/erc-1155-mintable.ts b/src/core/classes/erc-1155-mintable.ts index a1a68fcaa..0f2a82c93 100644 --- a/src/core/classes/erc-1155-mintable.ts +++ b/src/core/classes/erc-1155-mintable.ts @@ -13,6 +13,16 @@ import { IStorage } from "../interfaces"; import { DetectableFeature } from "../interfaces/DetectableFeature"; import { FEATURE_EDITION_MINTABLE } from "../../constants/erc1155-features"; +/** + * Mint ERC1155 NFTs + * @remarks NFT minting functionality that handles IPFS storage for you. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * await contract.edition.mint.to(walletAddress, nftMetadata); + * ``` + * @public + */ export class Erc1155Mintable implements DetectableFeature { featureName = FEATURE_EDITION_MINTABLE.name; private contractWrapper: ContractWrapper; diff --git a/src/core/classes/erc-1155.ts b/src/core/classes/erc-1155.ts index 321ea031b..aba247ded 100644 --- a/src/core/classes/erc-1155.ts +++ b/src/core/classes/erc-1155.ts @@ -31,10 +31,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @example * ```javascript * const contract = sdk.getContract("0x..."); - * const walletAddress = "0x..."; - * const tokenId = 0; - * const nft = await contract.edition.get(tokenId); - * await contract.edition.transfer(walletAddress, tokenId, 2); + * await contract.edition.transfer(walletAddress, tokenId, quantity); * ``` * @public */ @@ -90,7 +87,6 @@ export class Erc1155 * @example * ```javascript * const nft = await contract.get("0"); - * console.log(nft); * ``` * @param tokenId - the tokenId of the NFT to retrieve * @returns The NFT metadata @@ -125,12 +121,9 @@ export class Erc1155 * @example * ```javascript * // Address of the wallet to check NFT balance - * const address = "{{wallet_address}}"; - * // Id of the NFT to check - * const tokenId = 0; - * - * const balance = await contract.balanceOf(address, tokenId); - * console.log(balance); + * const walletAddress = "{{wallet_address}}"; + * const tokenId = 0; // Id of the NFT to check + * const balance = await contract.balanceOf(walletAddress, tokenId); * ``` */ public async balanceOf( @@ -175,12 +168,8 @@ export class Erc1155 * ```javascript * // Address of the wallet you want to send the NFT to * const toAddress = "{{wallet_address}}"; - * - * // The token ID of the NFT you want to send - * const tokenId = "0"; - * // How many copies of the NFTs to transfer - * const amount = 3; - * + * const tokenId = "0"; // The token ID of the NFT you want to send + * const amount = 3; // How many copies of the NFTs to transfer * await contract.transfer(toAddress, tokenId, amount); * ``` */ diff --git a/src/core/classes/erc-20-mintable.ts b/src/core/classes/erc-20-mintable.ts index 6e5854f8d..69769ab6e 100644 --- a/src/core/classes/erc-20-mintable.ts +++ b/src/core/classes/erc-20-mintable.ts @@ -9,6 +9,16 @@ import { Erc20BatchMintable } from "./erc-20-batch-mintable"; import { FEATURE_TOKEN_MINTABLE } from "../../constants/erc20-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; +/** + * Mint ERC20 Tokens + * @remarks Token minting functionality that handles unit parsing for you. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * await contract.nft.mint.to(walletAddress, nftMetadata); + * ``` + * @public + */ export class Erc20Mintable implements DetectableFeature { featureName = FEATURE_TOKEN_MINTABLE.name; private contractWrapper: ContractWrapper; @@ -37,7 +47,6 @@ export class Erc20Mintable implements DetectableFeature { * ```javascript * const toAddress = "{{wallet_address}}"; // Address of the wallet you want to mint the tokens to * const amount = "1.5"; // The amount of this token you want to mint - * * await contract.mintTo(toAddress, amount); * ``` */ diff --git a/src/core/classes/erc-20.ts b/src/core/classes/erc-20.ts index 5a2072312..77baf4961 100644 --- a/src/core/classes/erc-20.ts +++ b/src/core/classes/erc-20.ts @@ -24,8 +24,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @example * ```javascript * const contract = sdk.getContract("0x..."); - * const walletAddress = "0x..."; - * await contract.token.transfer(walletAddress, 0.8); + * await contract.token.transfer(walletAddress, amount); * ``` * @public */ @@ -82,7 +81,6 @@ export class Erc20 * @example * ```javascript * const token = await contract.get(); - * console.log(token); * ``` * @returns The token metadata */ @@ -118,10 +116,8 @@ export class Erc20 * @example * ```javascript * // Address of the wallet to check token balance - * const address = "{{wallet_address}}"; - * - * const balance = await contract.balanceOf(address); - * console.log(balance); + * const walletAddress = "{{wallet_address}}"; + * const balance = await contract.balanceOf(walletAddress); * ``` * * @returns The balance of a specific wallet. @@ -150,9 +146,7 @@ export class Erc20 * ```javascript * // Address of the wallet to check token allowance * const spenderAddress = "0x..."; - * * const allowance = await contract.allowanceOf(otherAddress); - * console.log(allowance); * ``` * * @returns The allowance of one wallet over anothers funds. @@ -172,13 +166,10 @@ export class Erc20 * @example * ```javascript * // Address of the wallet who owns the funds - * const address = "{{wallet_address}}"; - * + * const owner = "{{wallet_address}}"; * // Address of the wallet to check token allowance - * const spenderAddress = "0x..."; - * - * const allowance = await contract.allowanceOf(address, spenderAddress); - * console.log(allowance); + * const spender = "0x..."; + * const allowance = await contract.allowanceOf(owner, spender); * ``` * * @returns The allowance of one wallet over anothers funds. @@ -205,10 +196,8 @@ export class Erc20 * ```javascript * // Address of the wallet you want to send the tokens to * const toAddress = "0x..."; - * * // The amount of tokens you want to send * const amount = 0.1; - * * await contract.transfer(toAddress, amount); * ``` */ @@ -233,13 +222,10 @@ export class Erc20 * ```javascript * // Address of the wallet sending the tokens * const fromAddress = "{{wallet_address}}"; - * * // Address of the wallet you want to send the tokens to * const toAddress = "0x..."; - * * // The number of tokens you want to send * const amount = 1.2 - * * // Note that the connected wallet must have approval to transfer the tokens of the fromAddress * await contract.transferFrom(fromAddress, toAddress, amount); * ``` @@ -265,10 +251,8 @@ export class Erc20 * ```javascript * // Address of the wallet to allow transfers from * const spenderAddress = "0x..."; - * * // The number of tokens to give as allowance * const amount = 100 - * * await contract.setAllowance(spenderAddress, amount); * ``` */ diff --git a/src/core/classes/erc-721-enumerable.ts b/src/core/classes/erc-721-enumerable.ts index 3651060d8..17abe7787 100644 --- a/src/core/classes/erc-721-enumerable.ts +++ b/src/core/classes/erc-721-enumerable.ts @@ -41,7 +41,6 @@ export class Erc721Enumerable implements DetectableFeature { * // Address of the wallet to get the NFTs of * const address = "{{wallet_address}}"; * const nfts = await contract.query.owned.all(address); - * console.log(nfts); * ``` * @param walletAddress - the wallet address to query, defaults to the connected wallet * @returns The NFT metadata for all NFTs in the contract. diff --git a/src/core/classes/erc-721-supply.ts b/src/core/classes/erc-721-supply.ts index 0907cee23..31935656e 100644 --- a/src/core/classes/erc-721-supply.ts +++ b/src/core/classes/erc-721-supply.ts @@ -46,7 +46,6 @@ export class Erc721Supply implements DetectableFeature { * @example * ```javascript * const nfts = await contract.query.all(); - * console.log(nfts); * ``` * @param queryParams - optional filtering to only fetch a subset of results. * @returns The NFT metadata for all NFTs queried. diff --git a/src/core/classes/erc-721.ts b/src/core/classes/erc-721.ts index d9d32af59..887f8b3c7 100644 --- a/src/core/classes/erc-721.ts +++ b/src/core/classes/erc-721.ts @@ -26,9 +26,6 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @example * ```javascript * const contract = sdk.getContract("0x..."); - * const walletAddress = "{{wallet_address}}"; - * const tokenId = 0; - * const nft = await contract.nft.get(tokenId); * await contract.nft.transfer(walletAddress, tokenId); * ``` * @public @@ -84,8 +81,8 @@ export class Erc721 * * @example * ```javascript + * const tokenId = 0; * const nft = await contract.get(tokenId); - * console.log(nft); * ``` * @param tokenId - the tokenId of the NFT to retrieve * @returns The NFT metadata @@ -115,6 +112,7 @@ export class Erc721 * * @example * ```javascript + * const walletAddress = "{{wallet_address}}"; * const balance = await contract.balanceOf(walletAddress); * console.log(balance); * ``` @@ -153,6 +151,8 @@ export class Erc721 * * @example * ```javascript + * const walletAddress = "{{wallet_address}}"; + * const tokenId = 0; * await contract.transfer(walletAddress, tokenId); * ``` */ From 24d25d04ee9131d05a0b04b4c6054b4dd8a4e0a1 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 18:44:53 -0700 Subject: [PATCH 11/15] snippets for standard tw features --- docs/feature_snippets.json | 32 ++++++++++++++--------- docs/sdk.contractplatformfee.md | 18 ++++++++++++- docs/sdk.contractprimarysale.md | 15 ++++++++++- docs/sdk.contractroles.md | 15 ++++++++++- docs/sdk.contractroyalty.md | 18 ++++++++++++- docs/sdk.md | 8 +++--- src/core/classes/contract-platform-fee.ts | 12 ++++++++- src/core/classes/contract-roles.ts | 9 ++++++- src/core/classes/contract-royalty.ts | 12 ++++++++- src/core/classes/contract-sales.ts | 9 ++++++- 10 files changed, 124 insertions(+), 24 deletions(-) diff --git a/docs/feature_snippets.json b/docs/feature_snippets.json index 7d9a5e855..5c52b7571 100644 --- a/docs/feature_snippets.json +++ b/docs/feature_snippets.json @@ -1,27 +1,33 @@ { "PlatformFee": { "name": "ContractPlatformFee", - "summary": "Handles platform fees for a Contract\n\n\n", - "remarks": null, - "examples": {}, + "summary": "Handle platform fees and recipients\n\n", + "remarks": "\n\nConfigure platform fees for a contract, which can be applied on certain paid transactions\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"0x...\");\nconst feeInfo = await contract.platformFee.get();\nawait contract.platformFee.set({\n platform_fee_basis_points: 100, // 1% fee\n platform_fee_recipient: \"0x...\" // the fee recipient\n})" + }, "methods": [], "properties": [], "reference": "https://docs.thirdweb.com/typescript/sdk.ContractPlatformFee" }, "PrimarySale": { "name": "ContractPrimarySale", - "summary": "Handles primary sales recipients for a Contract\n\n\n", - "remarks": null, - "examples": {}, + "summary": "Handle primary sales recipients\n\n", + "remarks": "\n\nConfigure primary sale recipients for an entire contract.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"0x...\");\nconst salesRecipient = await contract.sales.getRecipient();\nawait contract.roles.setRecipient(recipientWalletAddress);" + }, "methods": [], "properties": [], "reference": "https://docs.thirdweb.com/typescript/sdk.ContractPrimarySale" }, "Permissions": { "name": "ContractRoles", - "summary": "Handles Contract roles and permissions\n\n\n", - "remarks": null, - "examples": {}, + "summary": "Handle contract permissions\n\n", + "remarks": "\n\nConfigure roles and permissions for a contract, to restrict certain actions.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"0x...\");\nconst rolesAndMembers = await contract.roles.getAll();\nawait contract.roles.grantRole(\"admin\", \"0x...\");" + }, "methods": [ { "name": "get", @@ -51,9 +57,11 @@ }, "Royalty": { "name": "ContractRoyalty", - "summary": "Handles Contract royalties\n\n\n", - "remarks": null, - "examples": {}, + "summary": "Handle contract royalties\n\n", + "remarks": "\n\nConfigure royalties for an entire contract or a particular token.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"0x...\");\nconst royaltyInfo = await contract.royalties.getDefaultRoyaltyInfo();\nawait contract.roles.setTokenRoyaltyInfo(tokenId, {\n seller_fee_basis_points: 100, // 1% royalty fee\n fee_recipient: \"0x...\", // the fee recipient\n});" + }, "methods": [], "properties": [], "reference": "https://docs.thirdweb.com/typescript/sdk.ContractRoyalty" diff --git a/docs/sdk.contractplatformfee.md b/docs/sdk.contractplatformfee.md index ee6cec1af..9fb17a390 100644 --- a/docs/sdk.contractplatformfee.md +++ b/docs/sdk.contractplatformfee.md @@ -4,7 +4,7 @@ ## ContractPlatformFee class -Handles platform fees for a Contract +Handle platform fees and recipients Signature: @@ -13,6 +13,22 @@ export declare class ContractPlatformFee impleme ``` Implements: DetectableFeature +## Remarks + +Configure platform fees for a contract, which can be applied on certain paid transactions + +## Example + + +```javascript +const contract = sdk.getContract("0x..."); +const feeInfo = await contract.platformFee.get(); +await contract.platformFee.set({ + platform_fee_basis_points: 100, // 1% fee + platform_fee_recipient: "0x..." // the fee recipient +}) +``` + ## Constructors | Constructor | Modifiers | Description | diff --git a/docs/sdk.contractprimarysale.md b/docs/sdk.contractprimarysale.md index a897d845b..80d068cea 100644 --- a/docs/sdk.contractprimarysale.md +++ b/docs/sdk.contractprimarysale.md @@ -4,7 +4,7 @@ ## ContractPrimarySale class -Handles primary sales recipients for a Contract +Handle primary sales recipients Signature: @@ -13,6 +13,19 @@ export declare class ContractPrimarySale impleme ``` Implements: DetectableFeature +## Remarks + +Configure primary sale recipients for an entire contract. + +## Example + + +```javascript +const contract = sdk.getContract("0x..."); +const salesRecipient = await contract.sales.getRecipient(); +await contract.roles.setRecipient(recipientWalletAddress); +``` + ## Constructors | Constructor | Modifiers | Description | diff --git a/docs/sdk.contractroles.md b/docs/sdk.contractroles.md index f6b16d710..e11942ac9 100644 --- a/docs/sdk.contractroles.md +++ b/docs/sdk.contractroles.md @@ -4,7 +4,7 @@ ## ContractRoles class -Handles Contract roles and permissions +Handle contract permissions Signature: @@ -13,6 +13,19 @@ export declare class ContractRolesImplements: DetectableFeature +## Remarks + +Configure roles and permissions for a contract, to restrict certain actions. + +## Example + + +```javascript +const contract = sdk.getContract("0x..."); +const rolesAndMembers = await contract.roles.getAll(); +await contract.roles.grantRole("admin", "0x..."); +``` + ## Constructors | Constructor | Modifiers | Description | diff --git a/docs/sdk.contractroyalty.md b/docs/sdk.contractroyalty.md index 0a3b30e1b..1d82538de 100644 --- a/docs/sdk.contractroyalty.md +++ b/docs/sdk.contractroyalty.md @@ -4,7 +4,7 @@ ## ContractRoyalty class -Handles Contract royalties +Handle contract royalties Signature: @@ -13,6 +13,22 @@ export declare class ContractRoyaltyImplements: DetectableFeature +## Remarks + +Configure royalties for an entire contract or a particular token. + +## Example + + +```javascript +const contract = sdk.getContract("0x..."); +const royaltyInfo = await contract.royalties.getDefaultRoyaltyInfo(); +await contract.roles.setTokenRoyaltyInfo(tokenId, { + seller_fee_basis_points: 100, // 1% royalty fee + fee_recipient: "0x...", // the fee recipient +}); +``` + ## Constructors | Constructor | Modifiers | Description | diff --git a/docs/sdk.md b/docs/sdk.md index 2823e730f..62611b2cc 100644 --- a/docs/sdk.md +++ b/docs/sdk.md @@ -12,10 +12,10 @@ | [ContractEncoder](./sdk.contractencoder.md) | Encodes and decodes Contract functions | | [ContractEvents](./sdk.contractevents.md) | Listen to Contract events in real time | | [ContractMetadata](./sdk.contractmetadata.md) | Handles metadata for a Contract | -| [ContractPlatformFee](./sdk.contractplatformfee.md) | Handles platform fees for a Contract | -| [ContractPrimarySale](./sdk.contractprimarysale.md) | Handles primary sales recipients for a Contract | -| [ContractRoles](./sdk.contractroles.md) | Handles Contract roles and permissions | -| [ContractRoyalty](./sdk.contractroyalty.md) | Handles Contract royalties | +| [ContractPlatformFee](./sdk.contractplatformfee.md) | Handle platform fees and recipients | +| [ContractPrimarySale](./sdk.contractprimarysale.md) | Handle primary sales recipients | +| [ContractRoles](./sdk.contractroles.md) | Handle contract permissions | +| [ContractRoyalty](./sdk.contractroyalty.md) | Handle contract royalties | | [DelayedReveal](./sdk.delayedreveal.md) | Handles delayed reveal logic | | [DropClaimConditions](./sdk.dropclaimconditions.md) | Manages claim conditions for NFT Drop contracts | | [DropErc1155ClaimConditions](./sdk.droperc1155claimconditions.md) | Manages claim conditions for Edition Drop contracts | diff --git a/src/core/classes/contract-platform-fee.ts b/src/core/classes/contract-platform-fee.ts index abccd2b77..20b34fe2a 100644 --- a/src/core/classes/contract-platform-fee.ts +++ b/src/core/classes/contract-platform-fee.ts @@ -7,7 +7,17 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; import { FEATURE_PLATFORM_FEE } from "../../constants/thirdweb-features"; /** - * Handles platform fees for a Contract + * Handle platform fees and recipients + * @remarks Configure platform fees for a contract, which can be applied on certain paid transactions + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * const feeInfo = await contract.platformFee.get(); + * await contract.platformFee.set({ + * platform_fee_basis_points: 100, // 1% fee + * platform_fee_recipient: "0x..." // the fee recipient + * }) + * ``` * @public */ export class ContractPlatformFee diff --git a/src/core/classes/contract-roles.ts b/src/core/classes/contract-roles.ts index 2273135d0..abe0806e4 100644 --- a/src/core/classes/contract-roles.ts +++ b/src/core/classes/contract-roles.ts @@ -8,7 +8,14 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; import { FEATURE_PERMISSIONS } from "../../constants/thirdweb-features"; /** - * Handles Contract roles and permissions + * Handle contract permissions + * @remarks Configure roles and permissions for a contract, to restrict certain actions. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * const rolesAndMembers = await contract.roles.getAll(); + * await contract.roles.grantRole("admin", "0x..."); + * ``` * @public */ export class ContractRoles< diff --git a/src/core/classes/contract-royalty.ts b/src/core/classes/contract-royalty.ts index b9de1b4be..5afed4057 100644 --- a/src/core/classes/contract-royalty.ts +++ b/src/core/classes/contract-royalty.ts @@ -9,7 +9,17 @@ import { FEATURE_ROYALTY } from "../../constants/thirdweb-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; /** - * Handles Contract royalties + * Handle contract royalties + * @remarks Configure royalties for an entire contract or a particular token. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * const royaltyInfo = await contract.royalties.getDefaultRoyaltyInfo(); + * await contract.roles.setTokenRoyaltyInfo(tokenId, { + * seller_fee_basis_points: 100, // 1% royalty fee + * fee_recipient: "0x...", // the fee recipient + * }); + * ``` * @public */ export class ContractRoyalty< diff --git a/src/core/classes/contract-sales.ts b/src/core/classes/contract-sales.ts index a920cd95e..fc6e2916e 100644 --- a/src/core/classes/contract-sales.ts +++ b/src/core/classes/contract-sales.ts @@ -5,7 +5,14 @@ import { FEATURE_PRIMARY_SALE } from "../../constants/thirdweb-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; /** - * Handles primary sales recipients for a Contract + * Handle primary sales recipients + * @remarks Configure primary sale recipients for an entire contract. + * @example + * ```javascript + * const contract = sdk.getContract("0x..."); + * const salesRecipient = await contract.sales.getRecipient(); + * await contract.roles.setRecipient(recipientWalletAddress); + * ``` * @public */ export class ContractPrimarySale From c2b7526015fa42f87179738d22d8ed1b103600f8 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 18:55:18 -0700 Subject: [PATCH 12/15] use contract address where possible --- docs/feature_snippets.json | 72 ++++++++++++++------- docs/sdk.contractplatformfee.md | 2 +- docs/sdk.contractprimarysale.md | 2 +- docs/sdk.contractroles.md | 2 +- docs/sdk.contractroyalty.md | 2 +- docs/sdk.erc1155.md | 2 +- docs/sdk.erc1155enumerable.md | 2 +- docs/sdk.erc20.md | 2 +- docs/sdk.erc721.md | 2 +- docs/sdk.erc721batchmintable.md | 2 +- docs/sdk.erc721enumerable.md | 2 +- docs/sdk.erc721mintable.md | 2 +- docs/sdk.erc721supply.md | 2 +- scripts/generate-feature-snippets.mjs | 4 +- src/core/classes/contract-platform-fee.ts | 2 +- src/core/classes/contract-roles.ts | 2 +- src/core/classes/contract-royalty.ts | 2 +- src/core/classes/contract-sales.ts | 2 +- src/core/classes/erc-1155-batch-mintable.ts | 2 +- src/core/classes/erc-1155-enumerable.ts | 2 +- src/core/classes/erc-1155-mintable.ts | 2 +- src/core/classes/erc-1155.ts | 2 +- src/core/classes/erc-20-batch-mintable.ts | 10 +++ src/core/classes/erc-20-mintable.ts | 2 +- src/core/classes/erc-20.ts | 2 +- src/core/classes/erc-721-batch-mintable.ts | 2 +- src/core/classes/erc-721-enumerable.ts | 2 +- src/core/classes/erc-721-mintable.ts | 2 +- src/core/classes/erc-721-supply.ts | 2 +- src/core/classes/erc-721.ts | 2 +- 30 files changed, 88 insertions(+), 52 deletions(-) diff --git a/docs/feature_snippets.json b/docs/feature_snippets.json index 5c52b7571..99194cee7 100644 --- a/docs/feature_snippets.json +++ b/docs/feature_snippets.json @@ -4,29 +4,33 @@ "summary": "Handle platform fees and recipients\n\n", "remarks": "\n\nConfigure platform fees for a contract, which can be applied on certain paid transactions\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nconst feeInfo = await contract.platformFee.get();\nawait contract.platformFee.set({\n platform_fee_basis_points: 100, // 1% fee\n platform_fee_recipient: \"0x...\" // the fee recipient\n})" + "javascript": "const contract = sdk.getContract({{contract_address}});\nconst feeInfo = await contract.platformFee.get();\nawait contract.platformFee.set({\n platform_fee_basis_points: 100, // 1% fee\n platform_fee_recipient: \"0x...\" // the fee recipient\n})" }, "methods": [], "properties": [], - "reference": "https://docs.thirdweb.com/typescript/sdk.ContractPlatformFee" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.ContractPlatformFee" + } }, "PrimarySale": { "name": "ContractPrimarySale", "summary": "Handle primary sales recipients\n\n", "remarks": "\n\nConfigure primary sale recipients for an entire contract.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nconst salesRecipient = await contract.sales.getRecipient();\nawait contract.roles.setRecipient(recipientWalletAddress);" + "javascript": "const contract = sdk.getContract({{contract_address}});\nconst salesRecipient = await contract.sales.getRecipient();\nawait contract.roles.setRecipient(recipientWalletAddress);" }, "methods": [], "properties": [], - "reference": "https://docs.thirdweb.com/typescript/sdk.ContractPrimarySale" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.ContractPrimarySale" + } }, "Permissions": { "name": "ContractRoles", "summary": "Handle contract permissions\n\n", "remarks": "\n\nConfigure roles and permissions for a contract, to restrict certain actions.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nconst rolesAndMembers = await contract.roles.getAll();\nawait contract.roles.grantRole(\"admin\", \"0x...\");" + "javascript": "const contract = sdk.getContract({{contract_address}});\nconst rolesAndMembers = await contract.roles.getAll();\nawait contract.roles.grantRole(\"admin\", \"0x...\");" }, "methods": [ { @@ -53,25 +57,29 @@ } ], "properties": [], - "reference": "https://docs.thirdweb.com/typescript/sdk.ContractRoles" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.ContractRoles" + } }, "Royalty": { "name": "ContractRoyalty", "summary": "Handle contract royalties\n\n", "remarks": "\n\nConfigure royalties for an entire contract or a particular token.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nconst royaltyInfo = await contract.royalties.getDefaultRoyaltyInfo();\nawait contract.roles.setTokenRoyaltyInfo(tokenId, {\n seller_fee_basis_points: 100, // 1% royalty fee\n fee_recipient: \"0x...\", // the fee recipient\n});" + "javascript": "const contract = sdk.getContract({{contract_address}});\nconst royaltyInfo = await contract.royalties.getDefaultRoyaltyInfo();\nawait contract.roles.setTokenRoyaltyInfo(tokenId, {\n seller_fee_basis_points: 100, // 1% royalty fee\n fee_recipient: \"0x...\", // the fee recipient\n});" }, "methods": [], "properties": [], - "reference": "https://docs.thirdweb.com/typescript/sdk.ContractRoyalty" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.ContractRoyalty" + } }, "ERC1155": { "name": "Erc1155", "summary": "Standard ERC1155 NFT functions\n\n", "remarks": "\n\nBasic functionality for a ERC1155 contract that handles IPFS storage for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nawait contract.edition.transfer(walletAddress, tokenId, quantity);" + "javascript": "const contract = sdk.getContract({{contract_address}});\nawait contract.edition.transfer(walletAddress, tokenId, quantity);" }, "methods": [ { @@ -120,14 +128,16 @@ } ], "properties": [], - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155" + } }, "ERC1155Enumerable": { "name": "Erc1155Enumerable", "summary": "List ERC1155 NFTs\n\n", "remarks": "\n\nEasily list all the NFTs in a ERC1155 contract.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nconst nfts = await contract.edition.query.all();" + "javascript": "const contract = sdk.getContract({{contract_address}});\nconst nfts = await contract.edition.query.all();" }, "methods": [ { @@ -154,14 +164,16 @@ } ], "properties": [], - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc1155Enumerable" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155Enumerable" + } }, "ERC20": { "name": "Erc20", "summary": "Standard ERC20 Token functions\n\n", "remarks": "\n\nBasic functionality for a ERC20 contract that handles all unit transformation for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nawait contract.token.transfer(walletAddress, amount);" + "javascript": "const contract = sdk.getContract({{contract_address}});\nawait contract.token.transfer(walletAddress, amount);" }, "methods": [ { @@ -265,14 +277,16 @@ } ], "properties": [], - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc20" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20" + } }, "ERC721": { "name": "Erc721", "summary": "Standard ERC721 NFT functions\n\n", "remarks": "\n\nBasic functionality for a ERC721 contract that handles IPFS storage for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nawait contract.nft.transfer(walletAddress, tokenId);" + "javascript": "const contract = sdk.getContract({{contract_address}});\nawait contract.nft.transfer(walletAddress, tokenId);" }, "methods": [ { @@ -310,14 +324,16 @@ } ], "properties": [], - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721" + } }, "ERC721BatchMintable": { "name": "Erc721BatchMintable", "summary": "Mint Many ERC721 NFTs at once\n\n", "remarks": "\n\nNFT batch minting functionality that handles IPFS storage for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nawait contract.nft.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]);" + "javascript": "const contract = sdk.getContract({{contract_address}});\nawait contract.nft.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]);" }, "methods": [ { @@ -333,14 +349,16 @@ } ], "properties": [], - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721BatchMintable" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721BatchMintable" + } }, "ERC721Enumerable": { "name": "Erc721Enumerable", "summary": "List owned ERC721 NFTs\n\n", "remarks": "\n\nEasily list all the NFTs from a ERC721 contract, owned by a certain wallet.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nconst walletAddress = \"0x...\";\nconst ownedNFTs = await contract.nft.query.owned.all(walletAddress);" + "javascript": "const contract = sdk.getContract({{contract_address}});\nconst walletAddress = \"0x...\";\nconst ownedNFTs = await contract.nft.query.owned.all(walletAddress);" }, "methods": [ { @@ -356,14 +374,16 @@ } ], "properties": [], - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721Enumerable" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721Enumerable" + } }, "ERC721Mintable": { "name": "Erc721Mintable", "summary": "Mint ERC721 NFTs\n\n", "remarks": "\n\nNFT minting functionality that handles IPFS storage for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nawait contract.nft.mint.to(walletAddress, nftMetadata);" + "javascript": "const contract = sdk.getContract({{contract_address}});\nawait contract.nft.mint.to(walletAddress, nftMetadata);" }, "methods": [ { @@ -379,14 +399,16 @@ } ], "properties": [], - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721Mintable" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721Mintable" + } }, "ERC721Supply": { "name": "Erc721Supply", "summary": "List ERC721 NFTs\n\n", "remarks": "\n\nEasily list all the NFTs in a ERC721 contract.\n\n", "examples": { - "javascript": "const contract = sdk.getContract(\"0x...\");\nconst nfts = await contract.nft.query.all();" + "javascript": "const contract = sdk.getContract({{contract_address}});\nconst nfts = await contract.nft.query.all();" }, "methods": [ { @@ -402,6 +424,8 @@ } ], "properties": [], - "reference": "https://docs.thirdweb.com/typescript/sdk.Erc721Supply" + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc721Supply" + } } } \ No newline at end of file diff --git a/docs/sdk.contractplatformfee.md b/docs/sdk.contractplatformfee.md index 9fb17a390..437c662a9 100644 --- a/docs/sdk.contractplatformfee.md +++ b/docs/sdk.contractplatformfee.md @@ -21,7 +21,7 @@ Configure platform fees for a contract, which can be applied on certain paid tra ```javascript -const contract = sdk.getContract("0x..."); +const contract = sdk.getContract({{contract_address}}); const feeInfo = await contract.platformFee.get(); await contract.platformFee.set({ platform_fee_basis_points: 100, // 1% fee diff --git a/docs/sdk.contractprimarysale.md b/docs/sdk.contractprimarysale.md index 80d068cea..e3ad2d97d 100644 --- a/docs/sdk.contractprimarysale.md +++ b/docs/sdk.contractprimarysale.md @@ -21,7 +21,7 @@ Configure primary sale recipients for an entire contract. ```javascript -const contract = sdk.getContract("0x..."); +const contract = sdk.getContract({{contract_address}}); const salesRecipient = await contract.sales.getRecipient(); await contract.roles.setRecipient(recipientWalletAddress); ``` diff --git a/docs/sdk.contractroles.md b/docs/sdk.contractroles.md index e11942ac9..7437ff620 100644 --- a/docs/sdk.contractroles.md +++ b/docs/sdk.contractroles.md @@ -21,7 +21,7 @@ Configure roles and permissions for a contract, to restrict certain actions. ```javascript -const contract = sdk.getContract("0x..."); +const contract = sdk.getContract({{contract_address}}); const rolesAndMembers = await contract.roles.getAll(); await contract.roles.grantRole("admin", "0x..."); ``` diff --git a/docs/sdk.contractroyalty.md b/docs/sdk.contractroyalty.md index 1d82538de..b24da53ce 100644 --- a/docs/sdk.contractroyalty.md +++ b/docs/sdk.contractroyalty.md @@ -21,7 +21,7 @@ Configure royalties for an entire contract or a particular token. ```javascript -const contract = sdk.getContract("0x..."); +const contract = sdk.getContract({{contract_address}}); const royaltyInfo = await contract.royalties.getDefaultRoyaltyInfo(); await contract.roles.setTokenRoyaltyInfo(tokenId, { seller_fee_basis_points: 100, // 1% royalty fee diff --git a/docs/sdk.erc1155.md b/docs/sdk.erc1155.md index 5eb1652a2..ebfa5ff81 100644 --- a/docs/sdk.erc1155.md +++ b/docs/sdk.erc1155.md @@ -21,7 +21,7 @@ Basic functionality for a ERC1155 contract that handles IPFS storage for you. ```javascript -const contract = sdk.getContract("0x..."); +const contract = sdk.getContract({{contract_address}}); await contract.edition.transfer(walletAddress, tokenId, quantity); ``` diff --git a/docs/sdk.erc1155enumerable.md b/docs/sdk.erc1155enumerable.md index ce7bdcae9..e2c1ffacc 100644 --- a/docs/sdk.erc1155enumerable.md +++ b/docs/sdk.erc1155enumerable.md @@ -21,7 +21,7 @@ Easily list all the NFTs in a ERC1155 contract. ```javascript -const contract = sdk.getContract("0x..."); +const contract = sdk.getContract({{contract_address}}); const nfts = await contract.edition.query.all(); ``` diff --git a/docs/sdk.erc20.md b/docs/sdk.erc20.md index 66d335e1d..b27fc8cf1 100644 --- a/docs/sdk.erc20.md +++ b/docs/sdk.erc20.md @@ -21,7 +21,7 @@ Basic functionality for a ERC20 contract that handles all unit transformation fo ```javascript -const contract = sdk.getContract("0x..."); +const contract = sdk.getContract({{contract_address}}); await contract.token.transfer(walletAddress, amount); ``` diff --git a/docs/sdk.erc721.md b/docs/sdk.erc721.md index 030553260..b63a84698 100644 --- a/docs/sdk.erc721.md +++ b/docs/sdk.erc721.md @@ -21,7 +21,7 @@ Basic functionality for a ERC721 contract that handles IPFS storage for you. ```javascript -const contract = sdk.getContract("0x..."); +const contract = sdk.getContract({{contract_address}}); await contract.nft.transfer(walletAddress, tokenId); ``` diff --git a/docs/sdk.erc721batchmintable.md b/docs/sdk.erc721batchmintable.md index 8abad4893..e97df325b 100644 --- a/docs/sdk.erc721batchmintable.md +++ b/docs/sdk.erc721batchmintable.md @@ -21,7 +21,7 @@ NFT batch minting functionality that handles IPFS storage for you. ```javascript -const contract = sdk.getContract("0x..."); +const contract = sdk.getContract({{contract_address}}); await contract.nft.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]); ``` diff --git a/docs/sdk.erc721enumerable.md b/docs/sdk.erc721enumerable.md index 8aa9361b3..ebe3bae87 100644 --- a/docs/sdk.erc721enumerable.md +++ b/docs/sdk.erc721enumerable.md @@ -21,7 +21,7 @@ Easily list all the NFTs from a ERC721 contract, owned by a certain wallet. ```javascript -const contract = sdk.getContract("0x..."); +const contract = sdk.getContract({{contract_address}}); const walletAddress = "0x..."; const ownedNFTs = await contract.nft.query.owned.all(walletAddress); ``` diff --git a/docs/sdk.erc721mintable.md b/docs/sdk.erc721mintable.md index bfeca80aa..da9dc6216 100644 --- a/docs/sdk.erc721mintable.md +++ b/docs/sdk.erc721mintable.md @@ -21,7 +21,7 @@ NFT minting functionality that handles IPFS storage for you. ```javascript -const contract = sdk.getContract("0x..."); +const contract = sdk.getContract({{contract_address}}); await contract.nft.mint.to(walletAddress, nftMetadata); ``` diff --git a/docs/sdk.erc721supply.md b/docs/sdk.erc721supply.md index 556dc5ff8..80306ff4d 100644 --- a/docs/sdk.erc721supply.md +++ b/docs/sdk.erc721supply.md @@ -21,7 +21,7 @@ Easily list all the NFTs in a ERC721 contract. ```javascript -const contract = sdk.getContract("0x..."); +const contract = sdk.getContract({{contract_address}}); const nfts = await contract.nft.query.all(); ``` diff --git a/scripts/generate-feature-snippets.mjs b/scripts/generate-feature-snippets.mjs index e6e4925e8..c5b69ea67 100644 --- a/scripts/generate-feature-snippets.mjs +++ b/scripts/generate-feature-snippets.mjs @@ -132,7 +132,9 @@ const moduleMap = classes.reduce((acc, m) => { examples, methods: parseMembers(m.members, "Method", m.name), properties: parseMembers(m.members, "Property", m.name), - reference: extractReferenceLink(m), + reference: { + javascript: extractReferenceLink(m), + }, }; // } diff --git a/src/core/classes/contract-platform-fee.ts b/src/core/classes/contract-platform-fee.ts index 20b34fe2a..d790799e5 100644 --- a/src/core/classes/contract-platform-fee.ts +++ b/src/core/classes/contract-platform-fee.ts @@ -11,7 +11,7 @@ import { FEATURE_PLATFORM_FEE } from "../../constants/thirdweb-features"; * @remarks Configure platform fees for a contract, which can be applied on certain paid transactions * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * const feeInfo = await contract.platformFee.get(); * await contract.platformFee.set({ * platform_fee_basis_points: 100, // 1% fee diff --git a/src/core/classes/contract-roles.ts b/src/core/classes/contract-roles.ts index abe0806e4..4b7149d47 100644 --- a/src/core/classes/contract-roles.ts +++ b/src/core/classes/contract-roles.ts @@ -12,7 +12,7 @@ import { FEATURE_PERMISSIONS } from "../../constants/thirdweb-features"; * @remarks Configure roles and permissions for a contract, to restrict certain actions. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * const rolesAndMembers = await contract.roles.getAll(); * await contract.roles.grantRole("admin", "0x..."); * ``` diff --git a/src/core/classes/contract-royalty.ts b/src/core/classes/contract-royalty.ts index 5afed4057..09182c751 100644 --- a/src/core/classes/contract-royalty.ts +++ b/src/core/classes/contract-royalty.ts @@ -13,7 +13,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Configure royalties for an entire contract or a particular token. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * const royaltyInfo = await contract.royalties.getDefaultRoyaltyInfo(); * await contract.roles.setTokenRoyaltyInfo(tokenId, { * seller_fee_basis_points: 100, // 1% royalty fee diff --git a/src/core/classes/contract-sales.ts b/src/core/classes/contract-sales.ts index fc6e2916e..b19797eed 100644 --- a/src/core/classes/contract-sales.ts +++ b/src/core/classes/contract-sales.ts @@ -9,7 +9,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Configure primary sale recipients for an entire contract. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * const salesRecipient = await contract.sales.getRecipient(); * await contract.roles.setRecipient(recipientWalletAddress); * ``` diff --git a/src/core/classes/erc-1155-batch-mintable.ts b/src/core/classes/erc-1155-batch-mintable.ts index 91d5f64db..de3f38cc3 100644 --- a/src/core/classes/erc-1155-batch-mintable.ts +++ b/src/core/classes/erc-1155-batch-mintable.ts @@ -16,7 +16,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks NFT batch minting functionality that handles IPFS storage for you. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * await contract.edition.mint.batch.to(walletAddress, [nftMetadataWithSupply1, nftMetadataWithSupply2, ...]); * ``` * @public diff --git a/src/core/classes/erc-1155-enumerable.ts b/src/core/classes/erc-1155-enumerable.ts index 5e4eb23ef..535de9188 100644 --- a/src/core/classes/erc-1155-enumerable.ts +++ b/src/core/classes/erc-1155-enumerable.ts @@ -13,7 +13,7 @@ import { FEATURE_EDITION_ENUMERABLE } from "../../constants/erc1155-features"; * @remarks Easily list all the NFTs in a ERC1155 contract. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * const nfts = await contract.edition.query.all(); * ``` * @public diff --git a/src/core/classes/erc-1155-mintable.ts b/src/core/classes/erc-1155-mintable.ts index 0f2a82c93..8a0472d7a 100644 --- a/src/core/classes/erc-1155-mintable.ts +++ b/src/core/classes/erc-1155-mintable.ts @@ -18,7 +18,7 @@ import { FEATURE_EDITION_MINTABLE } from "../../constants/erc1155-features"; * @remarks NFT minting functionality that handles IPFS storage for you. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * await contract.edition.mint.to(walletAddress, nftMetadata); * ``` * @public diff --git a/src/core/classes/erc-1155.ts b/src/core/classes/erc-1155.ts index aba247ded..4a219025c 100644 --- a/src/core/classes/erc-1155.ts +++ b/src/core/classes/erc-1155.ts @@ -30,7 +30,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Basic functionality for a ERC1155 contract that handles IPFS storage for you. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * await contract.edition.transfer(walletAddress, tokenId, quantity); * ``` * @public diff --git a/src/core/classes/erc-20-batch-mintable.ts b/src/core/classes/erc-20-batch-mintable.ts index 8365d4a3c..0c7b2fe35 100644 --- a/src/core/classes/erc-20-batch-mintable.ts +++ b/src/core/classes/erc-20-batch-mintable.ts @@ -7,6 +7,16 @@ import { TransactionResult } from "../types"; import { FEATURE_TOKEN_BATCH_MINTABLE } from "../../constants/erc20-features"; import { DetectableFeature } from "../interfaces/DetectableFeature"; +/** + * Mint Many ERC20 Tokens at once + * @remarks Token batch minting functionality that handles unit parsing for you. + * @example + * ```javascript + * const contract = sdk.getContract({{contract_address}}); + * await contract.token.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]); + * ``` + * @public + */ export class Erc20BatchMintable implements DetectableFeature { featureName = FEATURE_TOKEN_BATCH_MINTABLE.name; private contractWrapper: ContractWrapper; diff --git a/src/core/classes/erc-20-mintable.ts b/src/core/classes/erc-20-mintable.ts index 69769ab6e..6da7fabfe 100644 --- a/src/core/classes/erc-20-mintable.ts +++ b/src/core/classes/erc-20-mintable.ts @@ -14,7 +14,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Token minting functionality that handles unit parsing for you. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * await contract.nft.mint.to(walletAddress, nftMetadata); * ``` * @public diff --git a/src/core/classes/erc-20.ts b/src/core/classes/erc-20.ts index 77baf4961..d91b97b9e 100644 --- a/src/core/classes/erc-20.ts +++ b/src/core/classes/erc-20.ts @@ -23,7 +23,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Basic functionality for a ERC20 contract that handles all unit transformation for you. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * await contract.token.transfer(walletAddress, amount); * ``` * @public diff --git a/src/core/classes/erc-721-batch-mintable.ts b/src/core/classes/erc-721-batch-mintable.ts index 4f30e03e9..316a613b7 100644 --- a/src/core/classes/erc-721-batch-mintable.ts +++ b/src/core/classes/erc-721-batch-mintable.ts @@ -15,7 +15,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks NFT batch minting functionality that handles IPFS storage for you. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * await contract.nft.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]); * ``` * @public diff --git a/src/core/classes/erc-721-enumerable.ts b/src/core/classes/erc-721-enumerable.ts index 17abe7787..0ee0abab9 100644 --- a/src/core/classes/erc-721-enumerable.ts +++ b/src/core/classes/erc-721-enumerable.ts @@ -12,7 +12,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Easily list all the NFTs from a ERC721 contract, owned by a certain wallet. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * const walletAddress = "0x..."; * const ownedNFTs = await contract.nft.query.owned.all(walletAddress); * ``` diff --git a/src/core/classes/erc-721-mintable.ts b/src/core/classes/erc-721-mintable.ts index f41e467bf..13a1eea34 100644 --- a/src/core/classes/erc-721-mintable.ts +++ b/src/core/classes/erc-721-mintable.ts @@ -17,7 +17,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks NFT minting functionality that handles IPFS storage for you. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * await contract.nft.mint.to(walletAddress, nftMetadata); * ``` * @public diff --git a/src/core/classes/erc-721-supply.ts b/src/core/classes/erc-721-supply.ts index 31935656e..5737c96f7 100644 --- a/src/core/classes/erc-721-supply.ts +++ b/src/core/classes/erc-721-supply.ts @@ -15,7 +15,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Easily list all the NFTs in a ERC721 contract. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * const nfts = await contract.nft.query.all(); * ``` * @public diff --git a/src/core/classes/erc-721.ts b/src/core/classes/erc-721.ts index 887f8b3c7..3fbe7ad5f 100644 --- a/src/core/classes/erc-721.ts +++ b/src/core/classes/erc-721.ts @@ -25,7 +25,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Basic functionality for a ERC721 contract that handles IPFS storage for you. * @example * ```javascript - * const contract = sdk.getContract("0x..."); + * const contract = sdk.getContract({{contract_address}}); * await contract.nft.transfer(walletAddress, tokenId); * ``` * @public From 741cb5bd5e3eb646fce70d79518564f79b3f9711 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 19:03:23 -0700 Subject: [PATCH 13/15] fix quotes --- src/core/classes/contract-platform-fee.ts | 2 +- src/core/classes/contract-roles.ts | 2 +- src/core/classes/contract-royalty.ts | 2 +- src/core/classes/contract-sales.ts | 2 +- src/core/classes/erc-1155-batch-mintable.ts | 2 +- src/core/classes/erc-1155-enumerable.ts | 2 +- src/core/classes/erc-1155-mintable.ts | 2 +- src/core/classes/erc-1155.ts | 2 +- src/core/classes/erc-20-batch-mintable.ts | 2 +- src/core/classes/erc-20-mintable.ts | 2 +- src/core/classes/erc-20.ts | 2 +- src/core/classes/erc-721-batch-mintable.ts | 2 +- src/core/classes/erc-721-enumerable.ts | 2 +- src/core/classes/erc-721-mintable.ts | 2 +- src/core/classes/erc-721-supply.ts | 2 +- src/core/classes/erc-721.ts | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/core/classes/contract-platform-fee.ts b/src/core/classes/contract-platform-fee.ts index d790799e5..d60ef0756 100644 --- a/src/core/classes/contract-platform-fee.ts +++ b/src/core/classes/contract-platform-fee.ts @@ -11,7 +11,7 @@ import { FEATURE_PLATFORM_FEE } from "../../constants/thirdweb-features"; * @remarks Configure platform fees for a contract, which can be applied on certain paid transactions * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * const feeInfo = await contract.platformFee.get(); * await contract.platformFee.set({ * platform_fee_basis_points: 100, // 1% fee diff --git a/src/core/classes/contract-roles.ts b/src/core/classes/contract-roles.ts index 4b7149d47..a614d79ee 100644 --- a/src/core/classes/contract-roles.ts +++ b/src/core/classes/contract-roles.ts @@ -12,7 +12,7 @@ import { FEATURE_PERMISSIONS } from "../../constants/thirdweb-features"; * @remarks Configure roles and permissions for a contract, to restrict certain actions. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * const rolesAndMembers = await contract.roles.getAll(); * await contract.roles.grantRole("admin", "0x..."); * ``` diff --git a/src/core/classes/contract-royalty.ts b/src/core/classes/contract-royalty.ts index 09182c751..1644d5481 100644 --- a/src/core/classes/contract-royalty.ts +++ b/src/core/classes/contract-royalty.ts @@ -13,7 +13,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Configure royalties for an entire contract or a particular token. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * const royaltyInfo = await contract.royalties.getDefaultRoyaltyInfo(); * await contract.roles.setTokenRoyaltyInfo(tokenId, { * seller_fee_basis_points: 100, // 1% royalty fee diff --git a/src/core/classes/contract-sales.ts b/src/core/classes/contract-sales.ts index b19797eed..0ff82391b 100644 --- a/src/core/classes/contract-sales.ts +++ b/src/core/classes/contract-sales.ts @@ -9,7 +9,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Configure primary sale recipients for an entire contract. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * const salesRecipient = await contract.sales.getRecipient(); * await contract.roles.setRecipient(recipientWalletAddress); * ``` diff --git a/src/core/classes/erc-1155-batch-mintable.ts b/src/core/classes/erc-1155-batch-mintable.ts index de3f38cc3..de0f2c665 100644 --- a/src/core/classes/erc-1155-batch-mintable.ts +++ b/src/core/classes/erc-1155-batch-mintable.ts @@ -16,7 +16,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks NFT batch minting functionality that handles IPFS storage for you. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * await contract.edition.mint.batch.to(walletAddress, [nftMetadataWithSupply1, nftMetadataWithSupply2, ...]); * ``` * @public diff --git a/src/core/classes/erc-1155-enumerable.ts b/src/core/classes/erc-1155-enumerable.ts index 535de9188..e97f1dabb 100644 --- a/src/core/classes/erc-1155-enumerable.ts +++ b/src/core/classes/erc-1155-enumerable.ts @@ -13,7 +13,7 @@ import { FEATURE_EDITION_ENUMERABLE } from "../../constants/erc1155-features"; * @remarks Easily list all the NFTs in a ERC1155 contract. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * const nfts = await contract.edition.query.all(); * ``` * @public diff --git a/src/core/classes/erc-1155-mintable.ts b/src/core/classes/erc-1155-mintable.ts index 8a0472d7a..5e407cc4d 100644 --- a/src/core/classes/erc-1155-mintable.ts +++ b/src/core/classes/erc-1155-mintable.ts @@ -18,7 +18,7 @@ import { FEATURE_EDITION_MINTABLE } from "../../constants/erc1155-features"; * @remarks NFT minting functionality that handles IPFS storage for you. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * await contract.edition.mint.to(walletAddress, nftMetadata); * ``` * @public diff --git a/src/core/classes/erc-1155.ts b/src/core/classes/erc-1155.ts index 4a219025c..b0b5d8f6a 100644 --- a/src/core/classes/erc-1155.ts +++ b/src/core/classes/erc-1155.ts @@ -30,7 +30,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Basic functionality for a ERC1155 contract that handles IPFS storage for you. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * await contract.edition.transfer(walletAddress, tokenId, quantity); * ``` * @public diff --git a/src/core/classes/erc-20-batch-mintable.ts b/src/core/classes/erc-20-batch-mintable.ts index 0c7b2fe35..8e7787dc4 100644 --- a/src/core/classes/erc-20-batch-mintable.ts +++ b/src/core/classes/erc-20-batch-mintable.ts @@ -12,7 +12,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Token batch minting functionality that handles unit parsing for you. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * await contract.token.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]); * ``` * @public diff --git a/src/core/classes/erc-20-mintable.ts b/src/core/classes/erc-20-mintable.ts index 6da7fabfe..1ce46f41e 100644 --- a/src/core/classes/erc-20-mintable.ts +++ b/src/core/classes/erc-20-mintable.ts @@ -14,7 +14,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Token minting functionality that handles unit parsing for you. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * await contract.nft.mint.to(walletAddress, nftMetadata); * ``` * @public diff --git a/src/core/classes/erc-20.ts b/src/core/classes/erc-20.ts index d91b97b9e..ebd7007fa 100644 --- a/src/core/classes/erc-20.ts +++ b/src/core/classes/erc-20.ts @@ -23,7 +23,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Basic functionality for a ERC20 contract that handles all unit transformation for you. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * await contract.token.transfer(walletAddress, amount); * ``` * @public diff --git a/src/core/classes/erc-721-batch-mintable.ts b/src/core/classes/erc-721-batch-mintable.ts index 316a613b7..f5b265bba 100644 --- a/src/core/classes/erc-721-batch-mintable.ts +++ b/src/core/classes/erc-721-batch-mintable.ts @@ -15,7 +15,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks NFT batch minting functionality that handles IPFS storage for you. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * await contract.nft.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]); * ``` * @public diff --git a/src/core/classes/erc-721-enumerable.ts b/src/core/classes/erc-721-enumerable.ts index 0ee0abab9..2f6489a8d 100644 --- a/src/core/classes/erc-721-enumerable.ts +++ b/src/core/classes/erc-721-enumerable.ts @@ -12,7 +12,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Easily list all the NFTs from a ERC721 contract, owned by a certain wallet. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * const walletAddress = "0x..."; * const ownedNFTs = await contract.nft.query.owned.all(walletAddress); * ``` diff --git a/src/core/classes/erc-721-mintable.ts b/src/core/classes/erc-721-mintable.ts index 13a1eea34..0e167c629 100644 --- a/src/core/classes/erc-721-mintable.ts +++ b/src/core/classes/erc-721-mintable.ts @@ -17,7 +17,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks NFT minting functionality that handles IPFS storage for you. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * await contract.nft.mint.to(walletAddress, nftMetadata); * ``` * @public diff --git a/src/core/classes/erc-721-supply.ts b/src/core/classes/erc-721-supply.ts index 5737c96f7..ad1ba35dd 100644 --- a/src/core/classes/erc-721-supply.ts +++ b/src/core/classes/erc-721-supply.ts @@ -15,7 +15,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Easily list all the NFTs in a ERC721 contract. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * const nfts = await contract.nft.query.all(); * ``` * @public diff --git a/src/core/classes/erc-721.ts b/src/core/classes/erc-721.ts index 3fbe7ad5f..56a0794ed 100644 --- a/src/core/classes/erc-721.ts +++ b/src/core/classes/erc-721.ts @@ -25,7 +25,7 @@ import { DetectableFeature } from "../interfaces/DetectableFeature"; * @remarks Basic functionality for a ERC721 contract that handles IPFS storage for you. * @example * ```javascript - * const contract = sdk.getContract({{contract_address}}); + * const contract = sdk.getContract("{{contract_address}}"); * await contract.nft.transfer(walletAddress, tokenId); * ``` * @public From 64f059daed7aeedcb2261711d619133db60aa2a7 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 19:04:26 -0700 Subject: [PATCH 14/15] generate snippets --- docs/feature_snippets.json | 24 ++++++++++++------------ docs/sdk.contractplatformfee.md | 2 +- docs/sdk.contractprimarysale.md | 2 +- docs/sdk.contractroles.md | 2 +- docs/sdk.contractroyalty.md | 2 +- docs/sdk.erc1155.md | 2 +- docs/sdk.erc1155enumerable.md | 2 +- docs/sdk.erc20.md | 2 +- docs/sdk.erc721.md | 2 +- docs/sdk.erc721batchmintable.md | 2 +- docs/sdk.erc721enumerable.md | 2 +- docs/sdk.erc721mintable.md | 2 +- docs/sdk.erc721supply.md | 2 +- 13 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/feature_snippets.json b/docs/feature_snippets.json index 99194cee7..9584799fb 100644 --- a/docs/feature_snippets.json +++ b/docs/feature_snippets.json @@ -4,7 +4,7 @@ "summary": "Handle platform fees and recipients\n\n", "remarks": "\n\nConfigure platform fees for a contract, which can be applied on certain paid transactions\n\n", "examples": { - "javascript": "const contract = sdk.getContract({{contract_address}});\nconst feeInfo = await contract.platformFee.get();\nawait contract.platformFee.set({\n platform_fee_basis_points: 100, // 1% fee\n platform_fee_recipient: \"0x...\" // the fee recipient\n})" + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nconst feeInfo = await contract.platformFee.get();\nawait contract.platformFee.set({\n platform_fee_basis_points: 100, // 1% fee\n platform_fee_recipient: \"0x...\" // the fee recipient\n})" }, "methods": [], "properties": [], @@ -17,7 +17,7 @@ "summary": "Handle primary sales recipients\n\n", "remarks": "\n\nConfigure primary sale recipients for an entire contract.\n\n", "examples": { - "javascript": "const contract = sdk.getContract({{contract_address}});\nconst salesRecipient = await contract.sales.getRecipient();\nawait contract.roles.setRecipient(recipientWalletAddress);" + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nconst salesRecipient = await contract.sales.getRecipient();\nawait contract.roles.setRecipient(recipientWalletAddress);" }, "methods": [], "properties": [], @@ -30,7 +30,7 @@ "summary": "Handle contract permissions\n\n", "remarks": "\n\nConfigure roles and permissions for a contract, to restrict certain actions.\n\n", "examples": { - "javascript": "const contract = sdk.getContract({{contract_address}});\nconst rolesAndMembers = await contract.roles.getAll();\nawait contract.roles.grantRole(\"admin\", \"0x...\");" + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nconst rolesAndMembers = await contract.roles.getAll();\nawait contract.roles.grantRole(\"admin\", \"0x...\");" }, "methods": [ { @@ -66,7 +66,7 @@ "summary": "Handle contract royalties\n\n", "remarks": "\n\nConfigure royalties for an entire contract or a particular token.\n\n", "examples": { - "javascript": "const contract = sdk.getContract({{contract_address}});\nconst royaltyInfo = await contract.royalties.getDefaultRoyaltyInfo();\nawait contract.roles.setTokenRoyaltyInfo(tokenId, {\n seller_fee_basis_points: 100, // 1% royalty fee\n fee_recipient: \"0x...\", // the fee recipient\n});" + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nconst royaltyInfo = await contract.royalties.getDefaultRoyaltyInfo();\nawait contract.roles.setTokenRoyaltyInfo(tokenId, {\n seller_fee_basis_points: 100, // 1% royalty fee\n fee_recipient: \"0x...\", // the fee recipient\n});" }, "methods": [], "properties": [], @@ -79,7 +79,7 @@ "summary": "Standard ERC1155 NFT functions\n\n", "remarks": "\n\nBasic functionality for a ERC1155 contract that handles IPFS storage for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract({{contract_address}});\nawait contract.edition.transfer(walletAddress, tokenId, quantity);" + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nawait contract.edition.transfer(walletAddress, tokenId, quantity);" }, "methods": [ { @@ -137,7 +137,7 @@ "summary": "List ERC1155 NFTs\n\n", "remarks": "\n\nEasily list all the NFTs in a ERC1155 contract.\n\n", "examples": { - "javascript": "const contract = sdk.getContract({{contract_address}});\nconst nfts = await contract.edition.query.all();" + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nconst nfts = await contract.edition.query.all();" }, "methods": [ { @@ -173,7 +173,7 @@ "summary": "Standard ERC20 Token functions\n\n", "remarks": "\n\nBasic functionality for a ERC20 contract that handles all unit transformation for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract({{contract_address}});\nawait contract.token.transfer(walletAddress, amount);" + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nawait contract.token.transfer(walletAddress, amount);" }, "methods": [ { @@ -286,7 +286,7 @@ "summary": "Standard ERC721 NFT functions\n\n", "remarks": "\n\nBasic functionality for a ERC721 contract that handles IPFS storage for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract({{contract_address}});\nawait contract.nft.transfer(walletAddress, tokenId);" + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nawait contract.nft.transfer(walletAddress, tokenId);" }, "methods": [ { @@ -333,7 +333,7 @@ "summary": "Mint Many ERC721 NFTs at once\n\n", "remarks": "\n\nNFT batch minting functionality that handles IPFS storage for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract({{contract_address}});\nawait contract.nft.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]);" + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nawait contract.nft.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]);" }, "methods": [ { @@ -358,7 +358,7 @@ "summary": "List owned ERC721 NFTs\n\n", "remarks": "\n\nEasily list all the NFTs from a ERC721 contract, owned by a certain wallet.\n\n", "examples": { - "javascript": "const contract = sdk.getContract({{contract_address}});\nconst walletAddress = \"0x...\";\nconst ownedNFTs = await contract.nft.query.owned.all(walletAddress);" + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nconst walletAddress = \"0x...\";\nconst ownedNFTs = await contract.nft.query.owned.all(walletAddress);" }, "methods": [ { @@ -383,7 +383,7 @@ "summary": "Mint ERC721 NFTs\n\n", "remarks": "\n\nNFT minting functionality that handles IPFS storage for you.\n\n", "examples": { - "javascript": "const contract = sdk.getContract({{contract_address}});\nawait contract.nft.mint.to(walletAddress, nftMetadata);" + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nawait contract.nft.mint.to(walletAddress, nftMetadata);" }, "methods": [ { @@ -408,7 +408,7 @@ "summary": "List ERC721 NFTs\n\n", "remarks": "\n\nEasily list all the NFTs in a ERC721 contract.\n\n", "examples": { - "javascript": "const contract = sdk.getContract({{contract_address}});\nconst nfts = await contract.nft.query.all();" + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nconst nfts = await contract.nft.query.all();" }, "methods": [ { diff --git a/docs/sdk.contractplatformfee.md b/docs/sdk.contractplatformfee.md index 437c662a9..55fdd32ca 100644 --- a/docs/sdk.contractplatformfee.md +++ b/docs/sdk.contractplatformfee.md @@ -21,7 +21,7 @@ Configure platform fees for a contract, which can be applied on certain paid tra ```javascript -const contract = sdk.getContract({{contract_address}}); +const contract = sdk.getContract("{{contract_address}}"); const feeInfo = await contract.platformFee.get(); await contract.platformFee.set({ platform_fee_basis_points: 100, // 1% fee diff --git a/docs/sdk.contractprimarysale.md b/docs/sdk.contractprimarysale.md index e3ad2d97d..afbe0920d 100644 --- a/docs/sdk.contractprimarysale.md +++ b/docs/sdk.contractprimarysale.md @@ -21,7 +21,7 @@ Configure primary sale recipients for an entire contract. ```javascript -const contract = sdk.getContract({{contract_address}}); +const contract = sdk.getContract("{{contract_address}}"); const salesRecipient = await contract.sales.getRecipient(); await contract.roles.setRecipient(recipientWalletAddress); ``` diff --git a/docs/sdk.contractroles.md b/docs/sdk.contractroles.md index 7437ff620..56e8d0321 100644 --- a/docs/sdk.contractroles.md +++ b/docs/sdk.contractroles.md @@ -21,7 +21,7 @@ Configure roles and permissions for a contract, to restrict certain actions. ```javascript -const contract = sdk.getContract({{contract_address}}); +const contract = sdk.getContract("{{contract_address}}"); const rolesAndMembers = await contract.roles.getAll(); await contract.roles.grantRole("admin", "0x..."); ``` diff --git a/docs/sdk.contractroyalty.md b/docs/sdk.contractroyalty.md index b24da53ce..c225881eb 100644 --- a/docs/sdk.contractroyalty.md +++ b/docs/sdk.contractroyalty.md @@ -21,7 +21,7 @@ Configure royalties for an entire contract or a particular token. ```javascript -const contract = sdk.getContract({{contract_address}}); +const contract = sdk.getContract("{{contract_address}}"); const royaltyInfo = await contract.royalties.getDefaultRoyaltyInfo(); await contract.roles.setTokenRoyaltyInfo(tokenId, { seller_fee_basis_points: 100, // 1% royalty fee diff --git a/docs/sdk.erc1155.md b/docs/sdk.erc1155.md index ebfa5ff81..6059526c0 100644 --- a/docs/sdk.erc1155.md +++ b/docs/sdk.erc1155.md @@ -21,7 +21,7 @@ Basic functionality for a ERC1155 contract that handles IPFS storage for you. ```javascript -const contract = sdk.getContract({{contract_address}}); +const contract = sdk.getContract("{{contract_address}}"); await contract.edition.transfer(walletAddress, tokenId, quantity); ``` diff --git a/docs/sdk.erc1155enumerable.md b/docs/sdk.erc1155enumerable.md index e2c1ffacc..1e2b3b9fe 100644 --- a/docs/sdk.erc1155enumerable.md +++ b/docs/sdk.erc1155enumerable.md @@ -21,7 +21,7 @@ Easily list all the NFTs in a ERC1155 contract. ```javascript -const contract = sdk.getContract({{contract_address}}); +const contract = sdk.getContract("{{contract_address}}"); const nfts = await contract.edition.query.all(); ``` diff --git a/docs/sdk.erc20.md b/docs/sdk.erc20.md index b27fc8cf1..7d54bb47f 100644 --- a/docs/sdk.erc20.md +++ b/docs/sdk.erc20.md @@ -21,7 +21,7 @@ Basic functionality for a ERC20 contract that handles all unit transformation fo ```javascript -const contract = sdk.getContract({{contract_address}}); +const contract = sdk.getContract("{{contract_address}}"); await contract.token.transfer(walletAddress, amount); ``` diff --git a/docs/sdk.erc721.md b/docs/sdk.erc721.md index b63a84698..a769068bf 100644 --- a/docs/sdk.erc721.md +++ b/docs/sdk.erc721.md @@ -21,7 +21,7 @@ Basic functionality for a ERC721 contract that handles IPFS storage for you. ```javascript -const contract = sdk.getContract({{contract_address}}); +const contract = sdk.getContract("{{contract_address}}"); await contract.nft.transfer(walletAddress, tokenId); ``` diff --git a/docs/sdk.erc721batchmintable.md b/docs/sdk.erc721batchmintable.md index e97df325b..cd821de39 100644 --- a/docs/sdk.erc721batchmintable.md +++ b/docs/sdk.erc721batchmintable.md @@ -21,7 +21,7 @@ NFT batch minting functionality that handles IPFS storage for you. ```javascript -const contract = sdk.getContract({{contract_address}}); +const contract = sdk.getContract("{{contract_address}}"); await contract.nft.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]); ``` diff --git a/docs/sdk.erc721enumerable.md b/docs/sdk.erc721enumerable.md index ebe3bae87..d7e1268de 100644 --- a/docs/sdk.erc721enumerable.md +++ b/docs/sdk.erc721enumerable.md @@ -21,7 +21,7 @@ Easily list all the NFTs from a ERC721 contract, owned by a certain wallet. ```javascript -const contract = sdk.getContract({{contract_address}}); +const contract = sdk.getContract("{{contract_address}}"); const walletAddress = "0x..."; const ownedNFTs = await contract.nft.query.owned.all(walletAddress); ``` diff --git a/docs/sdk.erc721mintable.md b/docs/sdk.erc721mintable.md index da9dc6216..b0a444d2f 100644 --- a/docs/sdk.erc721mintable.md +++ b/docs/sdk.erc721mintable.md @@ -21,7 +21,7 @@ NFT minting functionality that handles IPFS storage for you. ```javascript -const contract = sdk.getContract({{contract_address}}); +const contract = sdk.getContract("{{contract_address}}"); await contract.nft.mint.to(walletAddress, nftMetadata); ``` diff --git a/docs/sdk.erc721supply.md b/docs/sdk.erc721supply.md index 80306ff4d..765f07506 100644 --- a/docs/sdk.erc721supply.md +++ b/docs/sdk.erc721supply.md @@ -21,7 +21,7 @@ Easily list all the NFTs in a ERC721 contract. ```javascript -const contract = sdk.getContract({{contract_address}}); +const contract = sdk.getContract("{{contract_address}}"); const nfts = await contract.nft.query.all(); ``` From a7fe9feb4b72ef5ddbc9ae980c1db6868290b5c7 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Wed, 4 May 2022 19:11:31 -0700 Subject: [PATCH 15/15] export new classes --- docs/feature_snippets.json | 100 ++++++++++++++++++ docs/sdk.erc1155.md | 2 +- .../sdk.erc1155batchmintable._constructor_.md | 22 ++++ docs/sdk.erc1155batchmintable.featurename.md | 11 ++ docs/sdk.erc1155batchmintable.md | 45 ++++++++ docs/sdk.erc1155batchmintable.to.md | 59 +++++++++++ docs/sdk.erc1155mintable._constructor_.md | 22 ++++ .../sdk.erc1155mintable.additionalsupplyto.md | 26 +++++ docs/sdk.erc1155mintable.batch.md | 13 +++ docs/sdk.erc1155mintable.featurename.md | 11 ++ docs/sdk.erc1155mintable.md | 47 ++++++++ docs/sdk.erc1155mintable.to.md | 54 ++++++++++ docs/sdk.erc20.md | 2 +- docs/sdk.erc20batchmintable._constructor_.md | 21 ++++ docs/sdk.erc20batchmintable.featurename.md | 11 ++ docs/sdk.erc20batchmintable.md | 45 ++++++++ docs/sdk.erc20batchmintable.to.md | 47 ++++++++ docs/sdk.erc20mintable._constructor_.md | 21 ++++ docs/sdk.erc20mintable.batch.md | 13 +++ docs/sdk.erc20mintable.featurename.md | 11 ++ docs/sdk.erc20mintable.md | 46 ++++++++ docs/sdk.erc20mintable.to.md | 38 +++++++ docs/sdk.md | 4 + etc/sdk.api.md | 42 +++++++- src/core/classes/index.ts | 4 + 25 files changed, 711 insertions(+), 6 deletions(-) create mode 100644 docs/sdk.erc1155batchmintable._constructor_.md create mode 100644 docs/sdk.erc1155batchmintable.featurename.md create mode 100644 docs/sdk.erc1155batchmintable.md create mode 100644 docs/sdk.erc1155batchmintable.to.md create mode 100644 docs/sdk.erc1155mintable._constructor_.md create mode 100644 docs/sdk.erc1155mintable.additionalsupplyto.md create mode 100644 docs/sdk.erc1155mintable.batch.md create mode 100644 docs/sdk.erc1155mintable.featurename.md create mode 100644 docs/sdk.erc1155mintable.md create mode 100644 docs/sdk.erc1155mintable.to.md create mode 100644 docs/sdk.erc20batchmintable._constructor_.md create mode 100644 docs/sdk.erc20batchmintable.featurename.md create mode 100644 docs/sdk.erc20batchmintable.md create mode 100644 docs/sdk.erc20batchmintable.to.md create mode 100644 docs/sdk.erc20mintable._constructor_.md create mode 100644 docs/sdk.erc20mintable.batch.md create mode 100644 docs/sdk.erc20mintable.featurename.md create mode 100644 docs/sdk.erc20mintable.md create mode 100644 docs/sdk.erc20mintable.to.md diff --git a/docs/feature_snippets.json b/docs/feature_snippets.json index 9584799fb..b179625e3 100644 --- a/docs/feature_snippets.json +++ b/docs/feature_snippets.json @@ -132,6 +132,31 @@ "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155" } }, + "ERC1155BatchMintable": { + "name": "Erc1155BatchMintable", + "summary": "Mint Many ERC1155 NFTs at once\n\n", + "remarks": "\n\nNFT batch minting functionality that handles IPFS storage for you.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nawait contract.edition.mint.batch.to(walletAddress, [nftMetadataWithSupply1, nftMetadataWithSupply2, ...]);" + }, + "methods": [ + { + "name": "to", + "summary": "Mint Many NFTs with limited supplies\n\n", + "remarks": "\n\nMint many different NFTs with limited supplies to a specified wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet you want to mint the NFT to\nconst toAddress = \"{{wallet_address}}\"\n\n// Custom metadata and supplies of your NFTs\nconst metadataWithSupply = [{\n supply: 50, // The number of this NFT you want to mint\n metadata: {\n name: \"Cool NFT #1\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/image.png\"), // This can be an image url or file\n },\n}, {\n supply: 100,\n metadata: {\n name: \"Cool NFT #2\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/image.png\"), // This can be an image url or file\n },\n}];\n\nconst tx = await contract.edition.mint.batch.to(toAddress, metadataWithSupply);\nconst receipt = tx[0].receipt; // same transaction receipt for all minted NFTs\nconst firstTokenId = tx[0].id; // token id of the first minted NFT\nconst firstNFT = await tx[0].data(); // (optional) fetch details of the first minted NFT" + }, + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155BatchMintable.to" + } + } + ], + "properties": [], + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155BatchMintable" + } + }, "ERC1155Enumerable": { "name": "Erc1155Enumerable", "summary": "List ERC1155 NFTs\n\n", @@ -168,6 +193,31 @@ "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155Enumerable" } }, + "ERC1155Mintable": { + "name": "Erc1155Mintable", + "summary": "Mint ERC1155 NFTs\n\n", + "remarks": "\n\nNFT minting functionality that handles IPFS storage for you.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nawait contract.edition.mint.to(walletAddress, nftMetadata);" + }, + "methods": [ + { + "name": "to", + "summary": "Mint an NFT with a limited supply\n\n", + "remarks": "\n\nMint an NFT with a limited supply to a specified wallet.\n\n", + "examples": { + "javascript": "// Address of the wallet you want to mint the NFT to\nconst toAddress = \"{{wallet_address}}\"\n\n// Custom metadata of the NFT, note that you can fully customize this metadata with other properties.\nconst metadata = {\n name: \"Cool NFT\",\n description: \"This is a cool NFT\",\n image: fs.readFileSync(\"path/to/image.png\"), // This can be an image url or file\n}\n\nconst metadataWithSupply = {\n metadata,\n supply: 1000, // The number of this NFT you want to mint\n}\n\nconst tx = await contract.mintTo(toAddress, metadataWithSupply);\nconst receipt = tx.receipt; // the transaction receipt\nconst tokenId = tx.id; // the id of the NFT minted\nconst nft = await tx.data(); // (optional) fetch details of minted NFT" + }, + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155Mintable.to" + } + } + ], + "properties": [], + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc1155Mintable" + } + }, "ERC20": { "name": "Erc20", "summary": "Standard ERC20 Token functions\n\n", @@ -281,6 +331,56 @@ "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20" } }, + "ERC20BatchMintable": { + "name": "Erc20BatchMintable", + "summary": "Mint Many ERC20 Tokens at once\n\n", + "remarks": "\n\nToken batch minting functionality that handles unit parsing for you.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nawait contract.token.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]);" + }, + "methods": [ + { + "name": "to", + "summary": "Mint Tokens To Many Wallets\n\n", + "remarks": "\n\nMint tokens to many wallets in one transaction.\n\n", + "examples": { + "javascript": "// Data of the tokens you want to mint\nconst data = [\n {\n toAddress: \"{{wallet_address}}\", // Address to mint tokens to\n amount: 0.2, // How many tokens to mint to specified address\n },\n {\n toAddress: \"0x...\",\n amount: 1.4,\n }\n]\n\nawait contract.mintBatchTo(data);" + }, + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20BatchMintable.to" + } + } + ], + "properties": [], + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20BatchMintable" + } + }, + "ERC20Mintable": { + "name": "Erc20Mintable", + "summary": "Mint ERC20 Tokens\n\n", + "remarks": "\n\nToken minting functionality that handles unit parsing for you.\n\n", + "examples": { + "javascript": "const contract = sdk.getContract(\"{{contract_address}}\");\nawait contract.nft.mint.to(walletAddress, nftMetadata);" + }, + "methods": [ + { + "name": "to", + "summary": "Mint Tokens\n\n", + "remarks": "\n\nMint tokens to a specified address.\n\n", + "examples": { + "javascript": "const toAddress = \"{{wallet_address}}\"; // Address of the wallet you want to mint the tokens to\nconst amount = \"1.5\"; // The amount of this token you want to mint\nawait contract.mintTo(toAddress, amount);" + }, + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20Mintable.to" + } + } + ], + "properties": [], + "reference": { + "javascript": "https://docs.thirdweb.com/typescript/sdk.Erc20Mintable" + } + }, "ERC721": { "name": "Erc721", "summary": "Standard ERC721 NFT functions\n\n", diff --git a/docs/sdk.erc1155.md b/docs/sdk.erc1155.md index 6059526c0..1aa42ee6d 100644 --- a/docs/sdk.erc1155.md +++ b/docs/sdk.erc1155.md @@ -37,7 +37,7 @@ await contract.edition.transfer(walletAddress, tokenId, quantity); | --- | --- | --- | --- | | [contractWrapper](./sdk.erc1155.contractwrapper.md) | | ContractWrapper<T> | | | [featureName](./sdk.erc1155.featurename.md) | | "ERC1155" | | -| [mint](./sdk.erc1155.mint.md) | | Erc1155Mintable \| undefined | | +| [mint](./sdk.erc1155.mint.md) | | [Erc1155Mintable](./sdk.erc1155mintable.md) \| undefined | | | [options](./sdk.erc1155.options.md) | | [SDKOptions](./sdk.sdkoptions.md) | | | [query](./sdk.erc1155.query.md) | | [Erc1155Enumerable](./sdk.erc1155enumerable.md) \| undefined | | | [storage](./sdk.erc1155.storage.md) | | [IStorage](./sdk.istorage.md) | | diff --git a/docs/sdk.erc1155batchmintable._constructor_.md b/docs/sdk.erc1155batchmintable._constructor_.md new file mode 100644 index 000000000..1ed9e2872 --- /dev/null +++ b/docs/sdk.erc1155batchmintable._constructor_.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155BatchMintable](./sdk.erc1155batchmintable.md) > [(constructor)](./sdk.erc1155batchmintable._constructor_.md) + +## Erc1155BatchMintable.(constructor) + +Constructs a new instance of the `Erc1155BatchMintable` class + +Signature: + +```typescript +constructor(erc1155: Erc1155, contractWrapper: ContractWrapper, storage: IStorage); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| erc1155 | [Erc1155](./sdk.erc1155.md)<BaseERC1155> | | +| contractWrapper | ContractWrapper<IMintableERC1155 & IMulticall> | | +| storage | [IStorage](./sdk.istorage.md) | | + diff --git a/docs/sdk.erc1155batchmintable.featurename.md b/docs/sdk.erc1155batchmintable.featurename.md new file mode 100644 index 000000000..fc0b6f62a --- /dev/null +++ b/docs/sdk.erc1155batchmintable.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155BatchMintable](./sdk.erc1155batchmintable.md) > [featureName](./sdk.erc1155batchmintable.featurename.md) + +## Erc1155BatchMintable.featureName property + +Signature: + +```typescript +featureName: "ERC1155BatchMintable"; +``` diff --git a/docs/sdk.erc1155batchmintable.md b/docs/sdk.erc1155batchmintable.md new file mode 100644 index 000000000..90722f957 --- /dev/null +++ b/docs/sdk.erc1155batchmintable.md @@ -0,0 +1,45 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155BatchMintable](./sdk.erc1155batchmintable.md) + +## Erc1155BatchMintable class + +Mint Many ERC1155 NFTs at once + +Signature: + +```typescript +export declare class Erc1155BatchMintable implements DetectableFeature +``` +Implements: DetectableFeature + +## Remarks + +NFT batch minting functionality that handles IPFS storage for you. + +## Example + + +```javascript +const contract = sdk.getContract("{{contract_address}}"); +await contract.edition.mint.batch.to(walletAddress, [nftMetadataWithSupply1, nftMetadataWithSupply2, ...]); +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(erc1155, contractWrapper, storage)](./sdk.erc1155batchmintable._constructor_.md) | | Constructs a new instance of the Erc1155BatchMintable class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [featureName](./sdk.erc1155batchmintable.featurename.md) | | "ERC1155BatchMintable" | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [to(to, metadataWithSupply)](./sdk.erc1155batchmintable.to.md) | | Mint Many NFTs with limited supplies | + diff --git a/docs/sdk.erc1155batchmintable.to.md b/docs/sdk.erc1155batchmintable.to.md new file mode 100644 index 000000000..d9f191fb2 --- /dev/null +++ b/docs/sdk.erc1155batchmintable.to.md @@ -0,0 +1,59 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155BatchMintable](./sdk.erc1155batchmintable.md) > [to](./sdk.erc1155batchmintable.to.md) + +## Erc1155BatchMintable.to() method + +Mint Many NFTs with limited supplies + +Signature: + +```typescript +to(to: string, metadataWithSupply: EditionMetadataOrUri[]): Promise[]>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| to | string | | +| metadataWithSupply | [EditionMetadataOrUri](./sdk.editionmetadataoruri.md)\[\] | | + +Returns: + +Promise<[TransactionResultWithId](./sdk.transactionresultwithid.md)<[EditionMetadata](./sdk.editionmetadata.md)>\[\]> + +## Remarks + +Mint many different NFTs with limited supplies to a specified wallet. + +## Example + + +```javascript +// Address of the wallet you want to mint the NFT to +const toAddress = "{{wallet_address}}" + +// Custom metadata and supplies of your NFTs +const metadataWithSupply = [{ + supply: 50, // The number of this NFT you want to mint + metadata: { + name: "Cool NFT #1", + description: "This is a cool NFT", + image: fs.readFileSync("path/to/image.png"), // This can be an image url or file + }, +}, { + supply: 100, + metadata: { + name: "Cool NFT #2", + description: "This is a cool NFT", + image: fs.readFileSync("path/to/image.png"), // This can be an image url or file + }, +}]; + +const tx = await contract.edition.mint.batch.to(toAddress, metadataWithSupply); +const receipt = tx[0].receipt; // same transaction receipt for all minted NFTs +const firstTokenId = tx[0].id; // token id of the first minted NFT +const firstNFT = await tx[0].data(); // (optional) fetch details of the first minted NFT +``` + diff --git a/docs/sdk.erc1155mintable._constructor_.md b/docs/sdk.erc1155mintable._constructor_.md new file mode 100644 index 000000000..8745be4e9 --- /dev/null +++ b/docs/sdk.erc1155mintable._constructor_.md @@ -0,0 +1,22 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155Mintable](./sdk.erc1155mintable.md) > [(constructor)](./sdk.erc1155mintable._constructor_.md) + +## Erc1155Mintable.(constructor) + +Constructs a new instance of the `Erc1155Mintable` class + +Signature: + +```typescript +constructor(erc1155: Erc1155, contractWrapper: ContractWrapper, storage: IStorage); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| erc1155 | [Erc1155](./sdk.erc1155.md)<BaseERC1155> | | +| contractWrapper | ContractWrapper<IMintableERC1155> | | +| storage | [IStorage](./sdk.istorage.md) | | + diff --git a/docs/sdk.erc1155mintable.additionalsupplyto.md b/docs/sdk.erc1155mintable.additionalsupplyto.md new file mode 100644 index 000000000..189c2d334 --- /dev/null +++ b/docs/sdk.erc1155mintable.additionalsupplyto.md @@ -0,0 +1,26 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155Mintable](./sdk.erc1155mintable.md) > [additionalSupplyTo](./sdk.erc1155mintable.additionalsupplyto.md) + +## Erc1155Mintable.additionalSupplyTo() method + +Increase the supply of an existing NFT and mint it to a given wallet address + +Signature: + +```typescript +additionalSupplyTo(to: string, tokenId: BigNumberish, additionalSupply: BigNumberish): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| to | string | the address to mint to | +| tokenId | BigNumberish | the token id of the NFT to increase supply of | +| additionalSupply | BigNumberish | the additional amount to mint | + +Returns: + +Promise<[TransactionResultWithId](./sdk.transactionresultwithid.md)<[EditionMetadata](./sdk.editionmetadata.md)>> + diff --git a/docs/sdk.erc1155mintable.batch.md b/docs/sdk.erc1155mintable.batch.md new file mode 100644 index 000000000..866358108 --- /dev/null +++ b/docs/sdk.erc1155mintable.batch.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155Mintable](./sdk.erc1155mintable.md) > [batch](./sdk.erc1155mintable.batch.md) + +## Erc1155Mintable.batch property + +Batch mint Tokens to many addresses + +Signature: + +```typescript +batch: Erc1155BatchMintable | undefined; +``` diff --git a/docs/sdk.erc1155mintable.featurename.md b/docs/sdk.erc1155mintable.featurename.md new file mode 100644 index 000000000..d6dd1e220 --- /dev/null +++ b/docs/sdk.erc1155mintable.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155Mintable](./sdk.erc1155mintable.md) > [featureName](./sdk.erc1155mintable.featurename.md) + +## Erc1155Mintable.featureName property + +Signature: + +```typescript +featureName: "ERC1155Mintable"; +``` diff --git a/docs/sdk.erc1155mintable.md b/docs/sdk.erc1155mintable.md new file mode 100644 index 000000000..e42b24126 --- /dev/null +++ b/docs/sdk.erc1155mintable.md @@ -0,0 +1,47 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155Mintable](./sdk.erc1155mintable.md) + +## Erc1155Mintable class + +Mint ERC1155 NFTs + +Signature: + +```typescript +export declare class Erc1155Mintable implements DetectableFeature +``` +Implements: DetectableFeature + +## Remarks + +NFT minting functionality that handles IPFS storage for you. + +## Example + + +```javascript +const contract = sdk.getContract("{{contract_address}}"); +await contract.edition.mint.to(walletAddress, nftMetadata); +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(erc1155, contractWrapper, storage)](./sdk.erc1155mintable._constructor_.md) | | Constructs a new instance of the Erc1155Mintable class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [batch](./sdk.erc1155mintable.batch.md) | | [Erc1155BatchMintable](./sdk.erc1155batchmintable.md) \| undefined | Batch mint Tokens to many addresses | +| [featureName](./sdk.erc1155mintable.featurename.md) | | "ERC1155Mintable" | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [additionalSupplyTo(to, tokenId, additionalSupply)](./sdk.erc1155mintable.additionalsupplyto.md) | | Increase the supply of an existing NFT and mint it to a given wallet address | +| [to(to, metadataWithSupply)](./sdk.erc1155mintable.to.md) | | Mint an NFT with a limited supply | + diff --git a/docs/sdk.erc1155mintable.to.md b/docs/sdk.erc1155mintable.to.md new file mode 100644 index 000000000..957b86daa --- /dev/null +++ b/docs/sdk.erc1155mintable.to.md @@ -0,0 +1,54 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155Mintable](./sdk.erc1155mintable.md) > [to](./sdk.erc1155mintable.to.md) + +## Erc1155Mintable.to() method + +Mint an NFT with a limited supply + +Signature: + +```typescript +to(to: string, metadataWithSupply: EditionMetadataOrUri): Promise>; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| to | string | | +| metadataWithSupply | [EditionMetadataOrUri](./sdk.editionmetadataoruri.md) | | + +Returns: + +Promise<[TransactionResultWithId](./sdk.transactionresultwithid.md)<[EditionMetadata](./sdk.editionmetadata.md)>> + +## Remarks + +Mint an NFT with a limited supply to a specified wallet. + +## Example + + +```javascript +// Address of the wallet you want to mint the NFT to +const toAddress = "{{wallet_address}}" + +// Custom metadata of the NFT, note that you can fully customize this metadata with other properties. +const metadata = { + name: "Cool NFT", + description: "This is a cool NFT", + image: fs.readFileSync("path/to/image.png"), // This can be an image url or file +} + +const metadataWithSupply = { + metadata, + supply: 1000, // The number of this NFT you want to mint +} + +const tx = await contract.mintTo(toAddress, metadataWithSupply); +const receipt = tx.receipt; // the transaction receipt +const tokenId = tx.id; // the id of the NFT minted +const nft = await tx.data(); // (optional) fetch details of minted NFT +``` + diff --git a/docs/sdk.erc20.md b/docs/sdk.erc20.md index 7d54bb47f..11eb0bc47 100644 --- a/docs/sdk.erc20.md +++ b/docs/sdk.erc20.md @@ -37,7 +37,7 @@ await contract.token.transfer(walletAddress, amount); | --- | --- | --- | --- | | [contractWrapper](./sdk.erc20.contractwrapper.md) | | ContractWrapper<T> | | | [featureName](./sdk.erc20.featurename.md) | | "ERC20" | | -| [mint](./sdk.erc20.mint.md) | | Erc20Mintable \| undefined | Mint tokens | +| [mint](./sdk.erc20.mint.md) | | [Erc20Mintable](./sdk.erc20mintable.md) \| undefined | Mint tokens | | [options](./sdk.erc20.options.md) | | [SDKOptions](./sdk.sdkoptions.md) | | | [storage](./sdk.erc20.storage.md) | | [IStorage](./sdk.istorage.md) | | diff --git a/docs/sdk.erc20batchmintable._constructor_.md b/docs/sdk.erc20batchmintable._constructor_.md new file mode 100644 index 000000000..a46678643 --- /dev/null +++ b/docs/sdk.erc20batchmintable._constructor_.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc20BatchMintable](./sdk.erc20batchmintable.md) > [(constructor)](./sdk.erc20batchmintable._constructor_.md) + +## Erc20BatchMintable.(constructor) + +Constructs a new instance of the `Erc20BatchMintable` class + +Signature: + +```typescript +constructor(erc20: Erc20, contractWrapper: ContractWrapper); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| erc20 | [Erc20](./sdk.erc20.md)<BaseERC20> | | +| contractWrapper | ContractWrapper<IMintableERC20 & IMulticall> | | + diff --git a/docs/sdk.erc20batchmintable.featurename.md b/docs/sdk.erc20batchmintable.featurename.md new file mode 100644 index 000000000..cf51d18b9 --- /dev/null +++ b/docs/sdk.erc20batchmintable.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc20BatchMintable](./sdk.erc20batchmintable.md) > [featureName](./sdk.erc20batchmintable.featurename.md) + +## Erc20BatchMintable.featureName property + +Signature: + +```typescript +featureName: "ERC20BatchMintable"; +``` diff --git a/docs/sdk.erc20batchmintable.md b/docs/sdk.erc20batchmintable.md new file mode 100644 index 000000000..b0f8ff753 --- /dev/null +++ b/docs/sdk.erc20batchmintable.md @@ -0,0 +1,45 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc20BatchMintable](./sdk.erc20batchmintable.md) + +## Erc20BatchMintable class + +Mint Many ERC20 Tokens at once + +Signature: + +```typescript +export declare class Erc20BatchMintable implements DetectableFeature +``` +Implements: DetectableFeature + +## Remarks + +Token batch minting functionality that handles unit parsing for you. + +## Example + + +```javascript +const contract = sdk.getContract("{{contract_address}}"); +await contract.token.mint.batch.to(walletAddress, [nftMetadata1, nftMetadata2, ...]); +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(erc20, contractWrapper)](./sdk.erc20batchmintable._constructor_.md) | | Constructs a new instance of the Erc20BatchMintable class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [featureName](./sdk.erc20batchmintable.featurename.md) | | "ERC20BatchMintable" | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [to(args)](./sdk.erc20batchmintable.to.md) | | Mint Tokens To Many Wallets | + diff --git a/docs/sdk.erc20batchmintable.to.md b/docs/sdk.erc20batchmintable.to.md new file mode 100644 index 000000000..2a03f5e1b --- /dev/null +++ b/docs/sdk.erc20batchmintable.to.md @@ -0,0 +1,47 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc20BatchMintable](./sdk.erc20batchmintable.md) > [to](./sdk.erc20batchmintable.to.md) + +## Erc20BatchMintable.to() method + +Mint Tokens To Many Wallets + +Signature: + +```typescript +to(args: TokenMintInput[]): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| args | [TokenMintInput](./sdk.tokenmintinput.md)\[\] | | + +Returns: + +Promise<[TransactionResult](./sdk.transactionresult.md)> + +## Remarks + +Mint tokens to many wallets in one transaction. + +## Example + + +```javascript +// Data of the tokens you want to mint +const data = [ + { + toAddress: "{{wallet_address}}", // Address to mint tokens to + amount: 0.2, // How many tokens to mint to specified address + }, + { + toAddress: "0x...", + amount: 1.4, + } +] + +await contract.mintBatchTo(data); +``` + diff --git a/docs/sdk.erc20mintable._constructor_.md b/docs/sdk.erc20mintable._constructor_.md new file mode 100644 index 000000000..2061483b1 --- /dev/null +++ b/docs/sdk.erc20mintable._constructor_.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc20Mintable](./sdk.erc20mintable.md) > [(constructor)](./sdk.erc20mintable._constructor_.md) + +## Erc20Mintable.(constructor) + +Constructs a new instance of the `Erc20Mintable` class + +Signature: + +```typescript +constructor(erc20: Erc20, contractWrapper: ContractWrapper); +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| erc20 | [Erc20](./sdk.erc20.md)<BaseERC20> | | +| contractWrapper | ContractWrapper<IMintableERC20> | | + diff --git a/docs/sdk.erc20mintable.batch.md b/docs/sdk.erc20mintable.batch.md new file mode 100644 index 000000000..da3f61337 --- /dev/null +++ b/docs/sdk.erc20mintable.batch.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc20Mintable](./sdk.erc20mintable.md) > [batch](./sdk.erc20mintable.batch.md) + +## Erc20Mintable.batch property + +Batch mint Tokens to many addresses + +Signature: + +```typescript +batch: Erc20BatchMintable | undefined; +``` diff --git a/docs/sdk.erc20mintable.featurename.md b/docs/sdk.erc20mintable.featurename.md new file mode 100644 index 000000000..3cbde3a79 --- /dev/null +++ b/docs/sdk.erc20mintable.featurename.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc20Mintable](./sdk.erc20mintable.md) > [featureName](./sdk.erc20mintable.featurename.md) + +## Erc20Mintable.featureName property + +Signature: + +```typescript +featureName: "ERC20Mintable"; +``` diff --git a/docs/sdk.erc20mintable.md b/docs/sdk.erc20mintable.md new file mode 100644 index 000000000..f4ea9879c --- /dev/null +++ b/docs/sdk.erc20mintable.md @@ -0,0 +1,46 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc20Mintable](./sdk.erc20mintable.md) + +## Erc20Mintable class + +Mint ERC20 Tokens + +Signature: + +```typescript +export declare class Erc20Mintable implements DetectableFeature +``` +Implements: DetectableFeature + +## Remarks + +Token minting functionality that handles unit parsing for you. + +## Example + + +```javascript +const contract = sdk.getContract("{{contract_address}}"); +await contract.nft.mint.to(walletAddress, nftMetadata); +``` + +## Constructors + +| Constructor | Modifiers | Description | +| --- | --- | --- | +| [(constructor)(erc20, contractWrapper)](./sdk.erc20mintable._constructor_.md) | | Constructs a new instance of the Erc20Mintable class | + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [batch](./sdk.erc20mintable.batch.md) | | [Erc20BatchMintable](./sdk.erc20batchmintable.md) \| undefined | Batch mint Tokens to many addresses | +| [featureName](./sdk.erc20mintable.featurename.md) | | "ERC20Mintable" | | + +## Methods + +| Method | Modifiers | Description | +| --- | --- | --- | +| [to(to, amount)](./sdk.erc20mintable.to.md) | | Mint Tokens | + diff --git a/docs/sdk.erc20mintable.to.md b/docs/sdk.erc20mintable.to.md new file mode 100644 index 000000000..468bc2452 --- /dev/null +++ b/docs/sdk.erc20mintable.to.md @@ -0,0 +1,38 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc20Mintable](./sdk.erc20mintable.md) > [to](./sdk.erc20mintable.to.md) + +## Erc20Mintable.to() method + +Mint Tokens + +Signature: + +```typescript +to(to: string, amount: Amount): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| to | string | | +| amount | [Amount](./sdk.amount.md) | | + +Returns: + +Promise<[TransactionResult](./sdk.transactionresult.md)> + +## Remarks + +Mint tokens to a specified address. + +## Example + + +```javascript +const toAddress = "{{wallet_address}}"; // Address of the wallet you want to mint the tokens to +const amount = "1.5"; // The amount of this token you want to mint +await contract.mintTo(toAddress, amount); +``` + diff --git a/docs/sdk.md b/docs/sdk.md index 62611b2cc..c155464d5 100644 --- a/docs/sdk.md +++ b/docs/sdk.md @@ -23,9 +23,13 @@ | [Edition](./sdk.edition.md) | Create a collection of NFTs that lets you mint multiple copies of each NFT. | | [EditionDrop](./sdk.editiondrop.md) | Setup a collection of NFTs with a customizable number of each NFT that are minted as users claim them. | | [Erc1155](./sdk.erc1155.md) | Standard ERC1155 NFT functions | +| [Erc1155BatchMintable](./sdk.erc1155batchmintable.md) | Mint Many ERC1155 NFTs at once | | [Erc1155Enumerable](./sdk.erc1155enumerable.md) | List ERC1155 NFTs | +| [Erc1155Mintable](./sdk.erc1155mintable.md) | Mint ERC1155 NFTs | | [Erc1155SignatureMinting](./sdk.erc1155signatureminting.md) | Enables generating dynamic ERC1155 NFTs with rules and an associated signature, which can then be minted by anyone securely | | [Erc20](./sdk.erc20.md) | Standard ERC20 Token functions | +| [Erc20BatchMintable](./sdk.erc20batchmintable.md) | Mint Many ERC20 Tokens at once | +| [Erc20Mintable](./sdk.erc20mintable.md) | Mint ERC20 Tokens | | [Erc20SignatureMinting](./sdk.erc20signatureminting.md) | Enables generating ERC20 Tokens with rules and an associated signature, which can then be minted by anyone securely | | [Erc721](./sdk.erc721.md) | Standard ERC721 NFT functions | | [Erc721BatchMintable](./sdk.erc721batchmintable.md) | Mint Many ERC721 NFTs at once | diff --git a/etc/sdk.api.md b/etc/sdk.api.md index 7bcd4b46c..687322edc 100644 --- a/etc/sdk.api.md +++ b/etc/sdk.api.md @@ -1517,8 +1517,6 @@ export class Erc1155 impleme // @internal (undocumented) getTokenMetadata(tokenId: BigNumberish): Promise; isApproved(address: string, operator: string): Promise; - // Warning: (ae-forgotten-export) The symbol "Erc1155Mintable" needs to be exported by the entry point index.d.ts - // // (undocumented) mint: Erc1155Mintable | undefined; // @internal (undocumented) @@ -1535,6 +1533,16 @@ export class Erc1155 impleme transfer(to: string, tokenId: BigNumberish, amount: BigNumberish, data?: BytesLike): Promise; } +// @public +export class Erc1155BatchMintable implements DetectableFeature { + // Warning: (ae-forgotten-export) The symbol "IMintableERC1155" needs to be exported by the entry point index.d.ts + // Warning: (ae-forgotten-export) The symbol "IMulticall" needs to be exported by the entry point index.d.ts + constructor(erc1155: Erc1155, contractWrapper: ContractWrapper, storage: IStorage); + // (undocumented) + featureName: "ERC1155BatchMintable"; + to(to: string, metadataWithSupply: EditionMetadataOrUri[]): Promise[]>; +} + // @public export class Erc1155Enumerable implements DetectableFeature { // Warning: (ae-forgotten-export) The symbol "IERC1155Enumerable" needs to be exported by the entry point index.d.ts @@ -1546,6 +1554,16 @@ export class Erc1155Enumerable implements DetectableFeature { owned(walletAddress?: string): Promise; } +// @public +export class Erc1155Mintable implements DetectableFeature { + constructor(erc1155: Erc1155, contractWrapper: ContractWrapper, storage: IStorage); + additionalSupplyTo(to: string, tokenId: BigNumberish, additionalSupply: BigNumberish): Promise>; + batch: Erc1155BatchMintable | undefined; + // (undocumented) + featureName: "ERC1155Mintable"; + to(to: string, metadataWithSupply: EditionMetadataOrUri): Promise>; +} + // @public export class Erc1155SignatureMinting { constructor(contractWrapper: ContractWrapper, roles: ContractRoles, storage: IStorage); @@ -1575,7 +1593,6 @@ export class Erc20 implements Upda getAddress(): string; // @internal (undocumented) protected getValue(value: BigNumberish): Promise; - // Warning: (ae-forgotten-export) The symbol "Erc20Mintable" needs to be exported by the entry point index.d.ts mint: Erc20Mintable | undefined; // @internal normalizeAmount(amount: Amount): Promise; @@ -1592,6 +1609,24 @@ export class Erc20 implements Upda transferFrom(from: string, to: string, amount: Amount): Promise; } +// @public +export class Erc20BatchMintable implements DetectableFeature { + // Warning: (ae-forgotten-export) The symbol "IMintableERC20" needs to be exported by the entry point index.d.ts + constructor(erc20: Erc20, contractWrapper: ContractWrapper); + // (undocumented) + featureName: "ERC20BatchMintable"; + to(args: TokenMintInput[]): Promise; +} + +// @public +export class Erc20Mintable implements DetectableFeature { + constructor(erc20: Erc20, contractWrapper: ContractWrapper); + batch: Erc20BatchMintable | undefined; + // (undocumented) + featureName: "ERC20Mintable"; + to(to: string, amount: Amount): Promise; +} + // @public export class Erc20SignatureMinting { constructor(contractWrapper: ContractWrapper, roles: ContractRoles); @@ -1639,7 +1674,6 @@ export class Erc721 implements // @public export class Erc721BatchMintable implements DetectableFeature { // Warning: (ae-forgotten-export) The symbol "IMintableERC721" needs to be exported by the entry point index.d.ts - // Warning: (ae-forgotten-export) The symbol "IMulticall" needs to be exported by the entry point index.d.ts constructor(erc721: Erc721, contractWrapper: ContractWrapper, storage: IStorage); // (undocumented) featureName: "ERC721BatchMintable"; diff --git a/src/core/classes/index.ts b/src/core/classes/index.ts index a2fcde654..b8fdeb575 100644 --- a/src/core/classes/index.ts +++ b/src/core/classes/index.ts @@ -7,6 +7,8 @@ export * from "./drop-claim-conditions"; export * from "./drop-erc1155-claim-conditions"; export * from "./drop-erc1155-history"; export * from "./erc-20"; +export * from "./erc-20-mintable"; +export * from "./erc-20-batch-mintable"; export * from "./erc-20-history"; export * from "./erc-20-signature-minting"; export * from "./erc-721"; @@ -17,6 +19,8 @@ export * from "./erc-721-mintable"; export * from "./erc-721-batch-mintable"; export * from "./erc-1155"; export * from "./erc-1155-enumerable"; +export * from "./erc-1155-mintable"; +export * from "./erc-1155-batch-mintable"; export * from "./erc-1155-signature-minting"; export * from "./marketplace-direct"; export * from "./marketplace-auction";