Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit 6cddd7e

Browse files
authored
handle undefined merke data in claim conditions (#563)
1 parent cd8edae commit 6cddd7e

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/common/claim-conditions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,12 @@ export async function prepareClaim(
119119
*/
120120
export async function fetchSnapshot(
121121
merkleRoot: string,
122-
merkleMetadata: Record<string, string>,
122+
merkleMetadata: Record<string, string> | undefined,
123123
storage: IStorage,
124124
) {
125+
if (!merkleMetadata) {
126+
return undefined;
127+
}
125128
const snapshotUri = merkleMetadata[merkleRoot];
126129
let snapshot = undefined;
127130
if (snapshotUri) {
@@ -336,10 +339,11 @@ export async function transformResultToClaimCondition(
336339
pm: IDropClaimCondition.ClaimConditionStructOutput,
337340
tokenDecimals: number,
338341
provider: providers.Provider,
339-
merkleMetadata: Record<string, string>,
342+
merkleMetadata: Record<string, string> | undefined,
340343
storage: IStorage,
341344
): Promise<ClaimCondition> {
342345
const cv = await fetchCurrencyValue(provider, pm.currency, pm.pricePerToken);
346+
343347
const claims = await fetchSnapshot(pm.merkleRoot, merkleMetadata, storage);
344348
const maxClaimableSupply = convertToReadableQuantity(
345349
pm.maxClaimableSupply,

src/common/feature-detection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ function extractCommentFromMetadata(
8787
metadata: Record<string, any> | undefined,
8888
type: "methods" | "events",
8989
) {
90-
// console.log(metadata?.output?.userdoc);
9190
return (
9291
metadata?.output?.userdoc?.[type]?.[
9392
Object.keys(metadata?.output?.userdoc[type] || {}).find((fn) =>

src/core/classes/drop-claim-conditions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ export class DropClaimConditions<
206206
reasons.push(ClaimEligibility.NoClaimConditionSet);
207207
return reasons;
208208
}
209-
console.log("failed to get active claim condition", err);
209+
console.warn("failed to get active claim condition", err);
210210
reasons.push(ClaimEligibility.Unknown);
211211
return reasons;
212212
}

src/core/sdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ export class ThirdwebSDK extends RPCConnectionHandler {
378378
try {
379379
metadata = (await this.getContract(address)).metadata;
380380
} catch (e) {
381-
console.log(
381+
console.warn(
382382
`Couldn't get contract metadata for custom contract: ${address}`,
383383
);
384384
}

0 commit comments

Comments
 (0)