Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions docs/sdk.erc1155enumerable.gettotalcount.md

This file was deleted.

3 changes: 2 additions & 1 deletion docs/sdk.erc1155enumerable.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |

30 changes: 30 additions & 0 deletions docs/sdk.erc1155enumerable.totalcirculatingsupply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/sdk](./sdk.md) &gt; [Erc1155Enumerable](./sdk.erc1155enumerable.md) &gt; [totalCirculatingSupply](./sdk.erc1155enumerable.totalcirculatingsupply.md)

## Erc1155Enumerable.totalCirculatingSupply() method

Get the supply of token for a given tokenId.

<b>Signature:</b>

```typescript
totalCirculatingSupply(tokenId: BigNumberish): Promise<BigNumber>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| tokenId | BigNumberish | |

<b>Returns:</b>

Promise&lt;BigNumber&gt;

the total number of NFTs minted in this contract

## Remarks

This is \*\*not\*\* the sum of supply of all NFTs in the contract.

23 changes: 23 additions & 0 deletions docs/sdk.erc1155enumerable.totalcount.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@thirdweb-dev/sdk](./sdk.md) &gt; [Erc1155Enumerable](./sdk.erc1155enumerable.md) &gt; [totalCount](./sdk.erc1155enumerable.totalcount.md)

## Erc1155Enumerable.totalCount() method

Get the number of NFTs minted

<b>Signature:</b>

```typescript
totalCount(): Promise<BigNumber>;
```
<b>Returns:</b>

Promise&lt;BigNumber&gt;

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.

5 changes: 4 additions & 1 deletion etc/sdk.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,8 @@ export class ContractRoles<TContract extends IPermissionsEnumerable, TRole exten
getAll(): Promise<Record<TRole, string[]>>;
grant(role: TRole, address: string): Promise<TransactionResult>;
revoke(role: TRole, address: string): Promise<TransactionResult>;
// @internal (undocumented)
readonly roles: readonly TRole[];
setAll(rolesWithAddresses: {
[key in TRole]?: string[];
}): Promise<TransactionResult>;
Expand Down Expand Up @@ -1578,8 +1580,9 @@ export class Erc1155Enumerable implements DetectableFeature {
all(queryParams?: QueryAllParams): Promise<EditionMetadata[]>;
// (undocumented)
featureName: "ERC1155Enumerable";
getTotalCount(): Promise<BigNumber>;
owned(walletAddress?: string): Promise<EditionMetadataOwner[]>;
totalCirculatingSupply(tokenId: BigNumberish): Promise<BigNumber>;
totalCount(): Promise<BigNumber>;
}

// @public
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/edition-drop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class EditionDrop extends Erc1155<DropERC1155> {
* @public
*/
public async getTotalCount(): Promise<BigNumber> {
return this._query.getTotalCount();
return this._query.totalCount();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/edition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export class Edition extends Erc1155<TokenERC1155> {
* @public
*/
public async getTotalCount(): Promise<BigNumber> {
return this._query.getTotalCount();
return this._query.totalCount();
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/core/classes/contract-roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TContract>,
Expand Down
24 changes: 18 additions & 6 deletions src/core/classes/erc-1155-enumerable.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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()),
Expand All @@ -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<BigNumber> {
public async totalCount(): Promise<BigNumber> {
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<BigNumber> {
return await this.contractWrapper.readContract.totalSupply(tokenId);
}

/**
* Get Owned NFTs
*
Expand Down