Skip to content

Commit

Permalink
feat: initialization call
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddentao committed Aug 20, 2023
1 parent a7ba4be commit e309c14
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/cli/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,23 @@ export const command = () =>
info('No new facets need to be deployed.')
}

let initContractAddress: string = ethers.ZeroAddress
let initData: string = '0x'

if (isNewDeployment && ctx.config.diamond.init) {
info(`Deploying initialization contract...`)
info(`Deploying initialization contract: ${ctx.config.diamond.init} ...`)
const init = await deployContract(ctx, ctx.config.diamond.init, signer)
if (!init.contract.interface.getFunction('init')) {
error(`Initialization contract does not have an init() function.`)
}
initContractAddress = init.address
initData = init.contract.interface.getFunction('init')!.selector
info(` Initialization contract deployed at: ${initContractAddress}`)
}

info('Calling diamondCut() on the proxy...')
const cuts = getFinalizedFacetCuts(changes.namedCuts, facetContracts)
await execContractMethod(proxyInterface, 'diamondCut', [cuts, ethers.ZeroAddress, '0x'])
await execContractMethod(proxyInterface, 'diamondCut', [cuts, initContractAddress, initData])
}

info(`Saving deployment info...`)
Expand Down

0 comments on commit e309c14

Please sign in to comment.