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
8 changes: 4 additions & 4 deletions etc/sdk.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,7 @@ export const CompilerMetadataFetchedSchema: z.ZodObject<{
details?: string | undefined;
notice?: string | undefined;
}>;
licenses: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
licenses: z.ZodEffects<z.ZodDefault<z.ZodArray<z.ZodOptional<z.ZodString>, "many">>, string[], (string | undefined)[] | undefined>;
}, "strip", z.ZodTypeAny, {
name: string;
metadata: Record<string, any>;
Expand Down Expand Up @@ -1096,7 +1096,7 @@ export const CompilerMetadataFetchedSchema: z.ZodObject<{
};
licenses: string[];
}, {
licenses?: string[] | undefined;
licenses?: (string | undefined)[] | undefined;
name: string;
metadata: Record<string, any>;
abi: {
Expand Down Expand Up @@ -4463,7 +4463,7 @@ export const PreDeployMetadataFetchedSchema: z.ZodObject<z.extendShape<z.extendS
details?: string | undefined;
notice?: string | undefined;
}>;
licenses: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
licenses: z.ZodEffects<z.ZodDefault<z.ZodArray<z.ZodOptional<z.ZodString>, "many">>, string[], (string | undefined)[] | undefined>;
}>, {
bytecode: z.ZodString;
}>, "strip", z.ZodAny, {
Expand Down Expand Up @@ -4510,7 +4510,7 @@ export const PreDeployMetadataFetchedSchema: z.ZodObject<z.extendShape<z.extendS
bytecode: string;
}, {
[x: string]: any;
licenses?: string[] | undefined;
licenses?: (string | undefined)[] | undefined;
analytics?: any;
name: string;
metadataUri: string;
Expand Down
1 change: 1 addition & 0 deletions src/core/classes/drop-claim-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ export class DropClaimConditions<
): Promise<TransactionResult> {
let claimConditionsProcessed = claimConditionInputs;
if (this.isSinglePhaseDropContract(this.contractWrapper)) {
resetClaimEligibilityForAll = true;
if (claimConditionInputs.length === 0) {
claimConditionsProcessed = [
{
Expand Down
28 changes: 26 additions & 2 deletions src/core/classes/drop-erc1155-claim-conditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
IERC20,
IERC20__factory,
} from "contracts";
import { BigNumber, BigNumberish, constants, ethers } from "ethers";
import { BigNumber, BigNumberish, constants, ethers, utils } from "ethers";
import { isNativeToken } from "../../common/currency";
import { ContractWrapper } from "./contract-wrapper";
import {
Expand All @@ -31,6 +31,7 @@ import { hasFunction } from "../../common/feature-detection";
import { isNode } from "../../common/utils";
import { BaseClaimConditionERC1155 } from "../../types/eips";
import { IDropClaimCondition } from "contracts/DropERC1155";
import { NATIVE_TOKEN_ADDRESS } from "../../constants/index";

/**
* Manages claim conditions for Edition Drop contracts
Expand Down Expand Up @@ -427,10 +428,33 @@ export class DropErc1155ClaimConditions<
const merkleInfo: { [key: string]: string } = {};
const processedClaimConditions = await Promise.all(
claimConditionsForToken.map(async ({ tokenId, claimConditions }) => {
// sanitize for single phase deletions
let claimConditionsProcessed = claimConditions;
if (this.isSinglePhaseDropContract(this.contractWrapper)) {
resetClaimEligibilityForAll = true;
if (claimConditions.length === 0) {
claimConditionsProcessed = [
{
startTime: new Date(0),
currencyAddress: NATIVE_TOKEN_ADDRESS,
price: 0,
maxQuantity: 0,
quantityLimitPerTransaction: 0,
waitInSeconds: 0,
merkleRootHash: utils.hexZeroPad([0], 32),
snapshot: [],
},
];
} else if (claimConditions.length > 1) {
throw new Error(
"Single phase drop contract cannot have multiple claim conditions, only one is allowed",
);
}
}
// process inputs
const { snapshotInfos, sortedConditions } =
await processClaimConditionInputs(
claimConditions,
claimConditionsProcessed,
0,
this.contractWrapper.getProvider(),
this.storage,
Expand Down
7 changes: 6 additions & 1 deletion src/schema/contracts/custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,12 @@ export const CompilerMetadataFetchedSchema = z.object({
abi: AbiSchema,
metadata: z.record(z.string(), z.any()),
info: ContractInfoSchema,
licenses: z.array(z.string()).default([]),
licenses: z
.array(z.string().optional())
.default([])
.transform((v) => {
return v.filter((license) => license !== undefined) as string[];
}),
});

/**
Expand Down