diff --git a/.changeset/olive-waves-draw.md b/.changeset/olive-waves-draw.md new file mode 100644 index 00000000000..c905042c7e3 --- /dev/null +++ b/.changeset/olive-waves-draw.md @@ -0,0 +1,5 @@ +--- +"@thirdweb-dev/sdk": patch +--- + +[SDK] Improve concurrent requests on NFT-related code diff --git a/packages/sdk/src/evm/common/nft.ts b/packages/sdk/src/evm/common/nft.ts index c08a216b79b..fa4fdd9c203 100644 --- a/packages/sdk/src/evm/common/nft.ts +++ b/packages/sdk/src/evm/common/nft.ts @@ -114,8 +114,10 @@ export async function fetchTokenMetadataForContract( ERC165MetadataAbi, provider, ) as IERC165; - const isERC721 = await erc165.supportsInterface(InterfaceId_IERC721); - const isERC1155 = await erc165.supportsInterface(InterfaceId_IERC1155); + const [isERC721, isERC1155] = await Promise.all([ + erc165.supportsInterface(InterfaceId_IERC721), + erc165.supportsInterface(InterfaceId_IERC1155), + ]); if (isERC721) { const erc721 = new Contract( contractAddress, diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/nft-drop.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/nft-drop.ts index 702e3e270b8..662002668ce 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/nft-drop.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/nft-drop.ts @@ -226,8 +226,10 @@ export class NFTDrop extends StandardErc721 { * Get the total count NFTs in this drop contract, both claimed and unclaimed */ override async totalSupply() { - const claimed = await this.totalClaimedSupply(); - const unclaimed = await this.totalUnclaimedSupply(); + const [claimed, unclaimed] = await Promise.all([ + this.totalClaimedSupply(), + this.totalUnclaimedSupply(), + ]); return claimed.add(unclaimed); } diff --git a/packages/sdk/src/evm/contracts/prebuilt-implementations/signature-drop.ts b/packages/sdk/src/evm/contracts/prebuilt-implementations/signature-drop.ts index 235899f277b..db64841df41 100644 --- a/packages/sdk/src/evm/contracts/prebuilt-implementations/signature-drop.ts +++ b/packages/sdk/src/evm/contracts/prebuilt-implementations/signature-drop.ts @@ -249,8 +249,10 @@ export class SignatureDrop extends StandardErc721 { * Get the total count NFTs in this drop contract, both claimed and unclaimed */ override async totalSupply() { - const claimed = await this.totalClaimedSupply(); - const unclaimed = await this.totalUnclaimedSupply(); + const [claimed, unclaimed] = await Promise.all([ + this.totalClaimedSupply(), + this.totalUnclaimedSupply(), + ]); return claimed.add(unclaimed); }