Skip to content

Commit

Permalink
feat: add gnosisTXBuilder option for export script
Browse files Browse the repository at this point in the history
  • Loading branch information
0xlucian committed Oct 2, 2023
1 parent 3fe2655 commit 65d8eac
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions scripts/createProposal.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -16,8 +25,8 @@ let transactionType: string;

function processInputs(): Promise<void> {
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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 65d8eac

Please sign in to comment.