From 65d8eac63fb11c31e439ba2f8f50c513eec8fbf9 Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Mon, 2 Oct 2023 14:33:47 +0300 Subject: [PATCH] feat: add gnosisTXBuilder option for export script --- scripts/createProposal.ts | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/scripts/createProposal.ts b/scripts/createProposal.ts index 82f468966..d8cc4abd6 100644 --- a/scripts/createProposal.ts +++ b/scripts/createProposal.ts @@ -1,8 +1,17 @@ import { TxBuilder } from "@morpho-labs/gnosis-tx-builder"; +import Safe, { ContractNetworksConfig, EthersAdapter } from "@safe-global/protocol-kit"; import Ajv from "ajv"; import { BigNumber } from "ethers"; import fs from "fs/promises"; +import { ethers, network } from "hardhat"; +import { + buildMultiSigTx, + createGnosisTx, + getContractNetworks, + getSafeAddress, + loadMultisigTx, +} from "../multisig/helpers/utils"; import { loadProposal, proposeVIP } from "../src/transactions"; import { getCalldatas, proposalSchema } from "../src/utils"; @@ -16,8 +25,8 @@ let transactionType: string; function processInputs(): Promise { return new Promise(resolve => { - vipNumber = readline.question("Number of the VIP to propose => "); - transactionType = readline.question("Type of the proposal txBuilder/venusApp/bsc => "); + vipNumber = readline.question("Number of the VIP to propose (if using gnosisTXBuilder press enter to skip ) => "); + transactionType = readline.question("Type of the proposal txBuilder/venusApp/bsc/gnosisTXBuilder => "); governorAddress = readline.question("Address of the governance contract (optional, press enter to skip) => "); if (!governorAddress) { governorAddress = null; @@ -56,6 +65,18 @@ const processTxBuilder = async () => { return processJson(batchJson); }; +const processGnosisTxBuilder = async () => { + const safeAddress = getSafeAddress(network.name); + + const txName = readline.question("Name of tx file (from ./multisig/network(available)/ dir) to execute => "); + + const proposal = await loadMultisigTx(txName, network.name); + const multisigTx = await buildMultiSigTx(proposal); + const batchJson = TxBuilder.batch(safeAddress, multisigTx, { chainId: network.config.chainId }); + + return processJson(batchJson); +}; + const processVenusAppProposal = async () => { const proposal = await loadProposal(vipNumber); const validate = new Ajv().compile(proposalSchema); @@ -89,6 +110,8 @@ const createProposal = async () => { result = await processTxBuilder(); } else if (transactionType === "venusApp") { result = await processVenusAppProposal(); + } else if (transactionType === "gnosisTXBuilder") { + result = await processGnosisTxBuilder(); } else { result = await processBscProposal(); }