How to use the @celo/contractkit/lib/governance/proposals.proposalToHash function in @celo/contractkit

To help you get started, we’ve selected a few @celo/contractkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github celo-org / celo-monorepo / packages / celotool / src / cmds / deploy / upgrade / hotfix.ts View on Github external
const proposalBuilder = new ProposalBuilder(kit)

    // Example A
    // proposalBuilder.addJsonTx({
    //   contract: CeloContract.Attestations,
    //   function: 'setAttestationExpiryBlocks',
    //   // @ts-ignore
    //   args: [728],
    //   value: '0',
    // })

    // Example B
    proposalBuilder.addProxyRepointingTx(validatorsProxyAddress, desiredImplementationAddress)

    const proposal = await proposalBuilder.build()
    const proposalHash = proposalToHash(kit, proposal)

    // If your proposal is just made of ContractKit methods, you can print it out
    // console.info('Proposal: ', await proposalToJSON(kit, proposal))

    console.info(`Proposal Hash: ${proposalHash.toString('hex')}`)

    console.info('\nWhitelist the hotfix')
    await concurrentMap(25, addresses, async (address, index) => {
      try {
        await governance.whitelistHotfix(proposalHash).sendAndWaitForReceipt({ from: address })
      } catch (error) {
        console.error(`Error whitelisting for validator ${index} (${address}): ${error}`)
      }
    })

    let hotfixRecord = await governance.getHotfixRecord(proposalHash)