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

Commit

Permalink
handle undefined merke data in claim conditions (#563)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnsdls authored Aug 27, 2022
1 parent cd8edae commit 6cddd7e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/common/claim-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,12 @@ export async function prepareClaim(
*/
export async function fetchSnapshot(
merkleRoot: string,
merkleMetadata: Record<string, string>,
merkleMetadata: Record<string, string> | undefined,
storage: IStorage,
) {
if (!merkleMetadata) {
return undefined;
}
const snapshotUri = merkleMetadata[merkleRoot];
let snapshot = undefined;
if (snapshotUri) {
Expand Down Expand Up @@ -336,10 +339,11 @@ export async function transformResultToClaimCondition(
pm: IDropClaimCondition.ClaimConditionStructOutput,
tokenDecimals: number,
provider: providers.Provider,
merkleMetadata: Record<string, string>,
merkleMetadata: Record<string, string> | undefined,
storage: IStorage,
): Promise<ClaimCondition> {
const cv = await fetchCurrencyValue(provider, pm.currency, pm.pricePerToken);

const claims = await fetchSnapshot(pm.merkleRoot, merkleMetadata, storage);
const maxClaimableSupply = convertToReadableQuantity(
pm.maxClaimableSupply,
Expand Down
1 change: 0 additions & 1 deletion src/common/feature-detection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ function extractCommentFromMetadata(
metadata: Record<string, any> | undefined,
type: "methods" | "events",
) {
// console.log(metadata?.output?.userdoc);
return (
metadata?.output?.userdoc?.[type]?.[
Object.keys(metadata?.output?.userdoc[type] || {}).find((fn) =>
Expand Down
2 changes: 1 addition & 1 deletion src/core/classes/drop-claim-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export class DropClaimConditions<
reasons.push(ClaimEligibility.NoClaimConditionSet);
return reasons;
}
console.log("failed to get active claim condition", err);
console.warn("failed to get active claim condition", err);
reasons.push(ClaimEligibility.Unknown);
return reasons;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ export class ThirdwebSDK extends RPCConnectionHandler {
try {
metadata = (await this.getContract(address)).metadata;
} catch (e) {
console.log(
console.warn(
`Couldn't get contract metadata for custom contract: ${address}`,
);
}
Expand Down

0 comments on commit 6cddd7e

Please sign in to comment.