diff --git a/lib/internal/core.ts b/lib/internal/core.ts index bd03a56..6182401 100644 --- a/lib/internal/core.ts +++ b/lib/internal/core.ts @@ -132,9 +132,18 @@ export abstract class NeokingdomDAO { for (let i = nextStep; i < s.length; i++) { const context = await c(this); const step = s[i]; + if (this.config.verbose) { - console.log(`${i + 1}/${s.length}: ${step.toString()}`); + console.log( + `${i + 1}/${s.length}: ${step ? step.toString() : "step is empty"}` + ); + } + + // If a step is null, it's skipped + if (step === null) { + continue; } + let tx: TransactionResponse | null = null; try { tx = await step(context); diff --git a/lib/internal/types.ts b/lib/internal/types.ts index af3a0cd..31f5c70 100644 --- a/lib/internal/types.ts +++ b/lib/internal/types.ts @@ -45,8 +45,9 @@ export type ContractNames = keyof typeof FACTORIES; export type Contributor = { name?: string; address: string; - status: "contributor" | "board" | "investor"; - tokens: string; + status?: "contributor" | "board" | "investor"; + balance?: string; + vestingBalance?: string; }; export type Address = `0x${string}`; @@ -89,11 +90,11 @@ export type ContractContext = Context & NeokingdomContracts; export type Step = ( c: T -) => Promise; +) => Promise | null; export type StepWithExpandable = | ExpandableStep - | ((c: T) => Promise); + | ((c: T) => Promise | null); export type ExpandableStep = { expandableFunction: (c: T) => ProcessedSequence; @@ -101,7 +102,7 @@ export type ExpandableStep = { export type Sequence = StepWithExpandable[]; -export type ProcessedSequence = Step[]; +export type ProcessedSequence = (Step | null)[]; // FIXME: There Must Be A Better Way™ to do this in TypeScript export const CONTRACT_NAMES = [ diff --git a/lib/sequence/setup.ts b/lib/sequence/setup.ts index 2cd2f74..cf442b3 100644 --- a/lib/sequence/setup.ts +++ b/lib/sequence/setup.ts @@ -13,7 +13,7 @@ export const SETUP_SEQUENCE: Sequence = [ ) ), - // Set each address to contributor + // Set address status expandable((preprocessContext: SetupContext) => preprocessContext.contributors.map((contributor) => async (c) => { if (contributor.status === "contributor") { @@ -42,10 +42,25 @@ export const SETUP_SEQUENCE: Sequence = [ expandable((preprocessContext: SetupContext) => preprocessContext.contributors.map( (contributor) => (c) => - c.governanceToken.mint( - contributor.address, - BigNumber.from(contributor.tokens.toString()) - ) + contributor.balance + ? c.governanceToken.mint( + contributor.address, + BigNumber.from(contributor.balance.toString()) + ) + : null + ) + ), + + // Give each contributor vesting tokens + expandable((preprocessContext: SetupContext) => + preprocessContext.contributors.map( + (contributor) => (c) => + contributor.vestingBalance + ? c.governanceToken.mintVesting( + contributor.address, + BigNumber.from(contributor.vestingBalance.toString()) + ) + : null ) ), ];