Skip to content

Commit

Permalink
[SDK] Optimize claimConditions.getAll() (#1444)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquim-verges authored Aug 3, 2023
1 parent 5ec0f06 commit a5d0be9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-forks-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/sdk": patch
---

Optimize claimConditions.getAll()
13 changes: 8 additions & 5 deletions packages/sdk/src/evm/core/classes/drop-claim-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,17 @@ export class DropClaimConditions<
await this.contractWrapper.readContract.claimCondition();
const startId = currentStartId.toNumber();
const count = countBn.toNumber();
const conditions: AbstractClaimConditionContractStruct[] = [];
const conditions: Promise<AbstractClaimConditionContractStruct>[] = [];
for (let i = startId; i < startId + count; i++) {
conditions.push(await this.get(i));
conditions.push(this.get(i));
}
const metadata = await this.metadata.get();
const decimals = await this.getTokenDecimals();
const [metadata, decimals, ...fetchedConditions] = await Promise.all([
this.metadata.get(),
this.getTokenDecimals(),
...conditions,
]);
return Promise.all(
conditions.map((c) =>
fetchedConditions.map((c) =>
transformResultToClaimCondition(
c,
decimals,
Expand Down

0 comments on commit a5d0be9

Please sign in to comment.