Skip to content
This repository was archived by the owner on Oct 9, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
getForkParameters,
} from "./src/tenderly";
import {
createCalldataProposal,
createProposal,
deployPayload,
passAndExecuteProposal,
Expand Down Expand Up @@ -46,6 +47,8 @@ type CommonOptions = {
payloadAddress?: string;
enterArtifactPath: boolean;
artifactPath?: string;
enterCalldata: boolean;
calldata?: string;
//
pool: string;
userAddress?: string;
Expand Down Expand Up @@ -180,7 +183,7 @@ const questions: { [key: string]: InquirerQuestion | YargsQuestion } = {
message: "Enter the deployed payload address",
describe: "The payload address to execute",
type: "string",
when: (args) => args.enterPayloadAddress === true && !args.proposalId,
when: (args) => args.enterPayloadAddress === true,
},
enterArtifactPath: {
message: "Do you want to deploy and execute a local payload?",
Expand All @@ -193,10 +196,20 @@ const questions: { [key: string]: InquirerQuestion | YargsQuestion } = {
itemType: "file",
message: "Path to artifact.json",
describe: "The path to the artifact to execute",
when: (args) => args.enterArtifactPath === true,
},
enterCalldata: {
message: "Do you want to create and execute raw calldata?",
inquirerOnly: true,
type: "confirm",
when: (args) =>
args.enterArtifactPath === true &&
!args.proposalId &&
!args.payloadAddress,
!args.proposalId && !args.payloadAddress && !args.artifactPath,
},
calldata: {
message: "Enter the proposal creation calldata",
describe: "Proposal creation calldata",
type: "string",
when: (args) => args.enterCalldata === true,
},
// get the correct acl
pool: {
Expand Down Expand Up @@ -353,6 +366,18 @@ function getName(options: Options) {
proposalId: Number(argv.proposalId),
provider: fork.provider,
});
} else if (argv.calldata) {
// for now only supports mainnet
if (Number(argv.networkId) === ChainId.mainnet) {
const proposalId = await createCalldataProposal({
calldata: argv.calldata,
provider: fork.provider,
});
await passAndExecuteProposal({
proposalId: proposalId,
provider: fork.provider,
});
}
} else if (argv.payloadAddress) {
if (Number(argv.networkId) === ChainId.mainnet) {
const proposalId = await createProposal({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"scripts": {
"start": "yarn build && node dist/index.js",
"build": "ncc build ./main.ts -o dist --minify",
"publish:local": "yarn build && npm pack && npm i -g bgd-labs-aave-tenderly-cli-0.0.9.tgz && rm bgd-labs-aave-tenderly-cli-0.0.9.tgz",
"publish:local": "yarn build && npm pack && npm i -g bgd-labs-aave-tenderly-cli-0.0.10.tgz && rm bgd-labs-aave-tenderly-cli-0.0.10.tgz",
"ci:publish": "yarn build && npm publish --access=public"
},
"repository": {
Expand Down
25 changes: 25 additions & 0 deletions src/governance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,31 @@ export async function deployPayload({ filePath, provider }: DeployPayload) {
interface CreateProposal extends DefaultInterface {
payloadAddress: string;
}

interface CreateCalldataProposal extends DefaultInterface {
calldata: string;
}

/**
*
* @param {*} param0
* @returns proposalId
*/
export async function createCalldataProposal({
calldata,
provider,
}: CreateCalldataProposal) {
// Create the proposal
const governance = new Contract(GOV, GOV_ABI, provider.getSigner(AAVE_WHALE));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the tx sending part is not common between both methods, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm yes could be unified, will do

await provider
.getSigner(AAVE_WHALE)
.sendTransaction({ to: GOV, data: calldata });

const proposalId = (await governance.getProposalsCount()) - 1;
console.log(`Proposal created: ${proposalId}`);
return proposalId;
}

/**
*
* @param {*} param0
Expand Down