Skip to content

Commit

Permalink
update scripts for set stages to handle multiple ids (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
raymond-me authored Oct 7, 2024
1 parent b7cd554 commit 44cb22e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
33 changes: 19 additions & 14 deletions scripts/set1155Stages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { MerkleTree } from 'merkletreejs';
import fs from 'fs';
import { ContractDetails } from './common/constants';
import { cleanVariableWalletLimit, cleanWhitelist, estimateGas } from './utils/helper';
import { cleanVariableWalletLimit, cleanWhitelist, ensureArray, estimateGas } from './utils/helper';
import { Overrides } from 'ethers';

export interface ISet1155StagesParams {
Expand All @@ -14,12 +14,12 @@ export interface ISet1155StagesParams {
}

interface StageConfig {
price: string;
mintFee?: string;
price: string | string[];
mintFee?: string | string[];
startDate: number;
endDate: number;
walletLimit?: number;
maxSupply?: number;
walletLimit?: number | number[];
maxSupply?: number | number[];
whitelistPath?: string;
variableWalletLimitPath?: string;
}
Expand Down Expand Up @@ -91,15 +91,20 @@ export const set1155Stages = async (
}),
);

const stages = stagesConfig.map((s, i) => ({
price: [ethers.utils.parseEther(s.price)],
mintFee: [s.mintFee ? ethers.utils.parseEther(s.mintFee) : 0],
maxStageSupply: [s.maxSupply ?? 0],
walletLimit: [s.walletLimit ?? 0],
merkleRoot: [merkleRoots[i]],
startTimeUnixSeconds: Math.floor(new Date(s.startDate).getTime() / 1000),
endTimeUnixSeconds: Math.floor(new Date(s.endDate).getTime() / 1000),
}));
const stages = stagesConfig.map((s, i) => {
const price = ensureArray(s.price).map(p => ethers.utils.parseEther(p));
const tokenCount = price.length;

return {
price,
mintFee: s.mintFee ? ensureArray(s.mintFee).map(f => ethers.utils.parseEther(f)) : Array(tokenCount).fill(0),
maxStageSupply: s.maxSupply ? ensureArray(s.maxSupply) : Array(tokenCount).fill(0),
walletLimit: s.walletLimit ? ensureArray(s.walletLimit) : Array(tokenCount).fill(0),
merkleRoot: Array(tokenCount).fill(merkleRoots[i]),
startTimeUnixSeconds: Math.floor(new Date(s.startDate).getTime() / 1000),
endTimeUnixSeconds: Math.floor(new Date(s.endDate).getTime() / 1000),
};
});

console.log(
`Stage params: `,
Expand Down
4 changes: 3 additions & 1 deletion scripts/utils/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,6 @@ export const cleanWhitelist = async (whitelistPath: string, writeToFile: boolean
}
console.log(`=========================================`);
return wallets;
}
}

export const ensureArray = (value: any) => Array.isArray(value) ? value : [value];

0 comments on commit 44cb22e

Please sign in to comment.