diff --git a/docs/sdk.erc1155enumerable.gettotalcount.md b/docs/sdk.erc1155enumerable.gettotalcount.md deleted file mode 100644 index 71e19b723..000000000 --- a/docs/sdk.erc1155enumerable.gettotalcount.md +++ /dev/null @@ -1,19 +0,0 @@ - - -[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155Enumerable](./sdk.erc1155enumerable.md) > [getTotalCount](./sdk.erc1155enumerable.gettotalcount.md) - -## Erc1155Enumerable.getTotalCount() method - -Get the number of NFTs minted - -Signature: - -```typescript -getTotalCount(): Promise; -``` -Returns: - -Promise<BigNumber> - -the total number of NFTs minted in this contract - diff --git a/docs/sdk.erc1155enumerable.md b/docs/sdk.erc1155enumerable.md index 44441b074..2a6f5c162 100644 --- a/docs/sdk.erc1155enumerable.md +++ b/docs/sdk.erc1155enumerable.md @@ -42,6 +42,7 @@ const nfts = await contract.edition.query.all(); | Method | Modifiers | Description | | --- | --- | --- | | [all(queryParams)](./sdk.erc1155enumerable.all.md) | | Get All NFTs | -| [getTotalCount()](./sdk.erc1155enumerable.gettotalcount.md) | | Get the number of NFTs minted | | [owned(walletAddress)](./sdk.erc1155enumerable.owned.md) | | Get Owned NFTs | +| [totalCirculatingSupply(tokenId)](./sdk.erc1155enumerable.totalcirculatingsupply.md) | | Get the supply of token for a given tokenId. | +| [totalCount()](./sdk.erc1155enumerable.totalcount.md) | | Get the number of NFTs minted | diff --git a/docs/sdk.erc1155enumerable.totalcirculatingsupply.md b/docs/sdk.erc1155enumerable.totalcirculatingsupply.md new file mode 100644 index 000000000..099167d9f --- /dev/null +++ b/docs/sdk.erc1155enumerable.totalcirculatingsupply.md @@ -0,0 +1,30 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155Enumerable](./sdk.erc1155enumerable.md) > [totalCirculatingSupply](./sdk.erc1155enumerable.totalcirculatingsupply.md) + +## Erc1155Enumerable.totalCirculatingSupply() method + +Get the supply of token for a given tokenId. + +Signature: + +```typescript +totalCirculatingSupply(tokenId: BigNumberish): Promise; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| tokenId | BigNumberish | | + +Returns: + +Promise<BigNumber> + +the total number of NFTs minted in this contract + +## Remarks + +This is \*\*not\*\* the sum of supply of all NFTs in the contract. + diff --git a/docs/sdk.erc1155enumerable.totalcount.md b/docs/sdk.erc1155enumerable.totalcount.md new file mode 100644 index 000000000..4b26045ee --- /dev/null +++ b/docs/sdk.erc1155enumerable.totalcount.md @@ -0,0 +1,23 @@ + + +[Home](./index.md) > [@thirdweb-dev/sdk](./sdk.md) > [Erc1155Enumerable](./sdk.erc1155enumerable.md) > [totalCount](./sdk.erc1155enumerable.totalcount.md) + +## Erc1155Enumerable.totalCount() method + +Get the number of NFTs minted + +Signature: + +```typescript +totalCount(): Promise; +``` +Returns: + +Promise<BigNumber> + +the total number of NFTs minted in this contract + +## Remarks + +This returns the total number of NFTs minted in this contract, \*\*not\*\* the total supply of a given token. + diff --git a/etc/sdk.api.md b/etc/sdk.api.md index 7c3222031..50e5571ed 100644 --- a/etc/sdk.api.md +++ b/etc/sdk.api.md @@ -723,6 +723,8 @@ export class ContractRoles>; grant(role: TRole, address: string): Promise; revoke(role: TRole, address: string): Promise; + // @internal (undocumented) + readonly roles: readonly TRole[]; setAll(rolesWithAddresses: { [key in TRole]?: string[]; }): Promise; @@ -1578,8 +1580,9 @@ export class Erc1155Enumerable implements DetectableFeature { all(queryParams?: QueryAllParams): Promise; // (undocumented) featureName: "ERC1155Enumerable"; - getTotalCount(): Promise; owned(walletAddress?: string): Promise; + totalCirculatingSupply(tokenId: BigNumberish): Promise; + totalCount(): Promise; } // @public diff --git a/package.json b/package.json index 9230db073..2783883d9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@thirdweb-dev/sdk", - "version": "2.3.6", + "version": "2.3.7-1", "description": "The main thirdweb SDK.", "repository": { "type": "git", diff --git a/src/contracts/edition-drop.ts b/src/contracts/edition-drop.ts index 1f3bc1ede..6ede3ab11 100644 --- a/src/contracts/edition-drop.ts +++ b/src/contracts/edition-drop.ts @@ -213,7 +213,7 @@ export class EditionDrop extends Erc1155 { * @public */ public async getTotalCount(): Promise { - return this._query.getTotalCount(); + return this._query.totalCount(); } /** diff --git a/src/contracts/edition.ts b/src/contracts/edition.ts index 5749c81e9..27666fc61 100644 --- a/src/contracts/edition.ts +++ b/src/contracts/edition.ts @@ -197,7 +197,7 @@ export class Edition extends Erc1155 { * @public */ public async getTotalCount(): Promise { - return this._query.getTotalCount(); + return this._query.totalCount(); } /** diff --git a/src/core/classes/contract-roles.ts b/src/core/classes/contract-roles.ts index c635b023f..de4b83024 100644 --- a/src/core/classes/contract-roles.ts +++ b/src/core/classes/contract-roles.ts @@ -25,7 +25,11 @@ export class ContractRoles< { featureName = FEATURE_PERMISSIONS.name; private contractWrapper; - private readonly roles; + /** + * @internal + * @remarks This is used for typing inside react hooks which is why it has to be public. + */ + public readonly roles; constructor( contractWrapper: ContractWrapper, diff --git a/src/core/classes/erc-1155-enumerable.ts b/src/core/classes/erc-1155-enumerable.ts index f5c3b71fa..0f869bc79 100644 --- a/src/core/classes/erc-1155-enumerable.ts +++ b/src/core/classes/erc-1155-enumerable.ts @@ -1,6 +1,6 @@ import { ContractWrapper } from "./contract-wrapper"; import { IERC1155Enumerable } from "contracts"; -import { BigNumber } from "ethers"; +import { BigNumber, BigNumberish } from "ethers"; import { DEFAULT_QUERY_ALL_COUNT, QueryAllParams } from "../../types"; import { EditionMetadata, EditionMetadataOwner } from "../../schema"; import { Erc1155 } from "./erc-1155"; @@ -50,10 +50,7 @@ export class Erc1155Enumerable implements DetectableFeature { const count = BigNumber.from( queryParams?.count || DEFAULT_QUERY_ALL_COUNT, ).toNumber(); - const maxId = Math.min( - (await this.getTotalCount()).toNumber(), - start + count, - ); + const maxId = Math.min((await this.totalCount()).toNumber(), start + count); return await Promise.all( [...Array(maxId - start).keys()].map((i) => this.erc1155.get((start + i).toString()), @@ -63,13 +60,28 @@ export class Erc1155Enumerable implements DetectableFeature { /** * Get the number of NFTs minted + * @remarks This returns the total number of NFTs minted in this contract, **not** the total supply of a given token. + * * @returns the total number of NFTs minted in this contract * @public */ - public async getTotalCount(): Promise { + public async totalCount(): Promise { return await this.contractWrapper.readContract.nextTokenIdToMint(); } + /** + * Get the supply of token for a given tokenId. + * @remarks This is **not** the sum of supply of all NFTs in the contract. + * + * @returns the total number of NFTs minted in this contract + * @public + */ + public async totalCirculatingSupply( + tokenId: BigNumberish, + ): Promise { + return await this.contractWrapper.readContract.totalSupply(tokenId); + } + /** * Get Owned NFTs *