Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
feat: allow simulating proposals that use onlyOwner
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Sep 26, 2022
1 parent ec22019 commit 3c866d5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 72 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bgd-labs/aave-tenderly-cli",
"version": "0.0.7",
"version": "0.0.8",
"description": "",
"main": "main.ts",
"private": false,
Expand All @@ -10,7 +10,7 @@
"scripts": {
"start": "npm run build && node dist/index.js",
"build": "ncc build ./main.ts -o dist --minify",
"publish:local": "npm run build && npm pack && npm i -g bgd-labs-aave-tenderly-cli-0.0.7.tgz && rm bgd-labs-aave-tenderly-cli-0.0.7.tgz"
"publish:local": "npm run build && npm pack && npm i -g bgd-labs-aave-tenderly-cli-0.0.8.tgz && rm bgd-labs-aave-tenderly-cli-0.0.8.tgz"
},
"repository": {
"type": "git",
Expand Down
18 changes: 17 additions & 1 deletion src/l2Gov.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ export async function executeL2Payload({
const payload = new Contract(
payloadAddress,
[
{
inputs: [],
name: "owner",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function",
},
{
inputs: [],
name: "execute",
Expand All @@ -73,7 +80,16 @@ export async function executeL2Payload({
provider.getSigner()
);

await payload.execute();
// sometimes payloads use ownable and onlyOwner modifier on `execute`
// therefore we check if we can fetch owner and set the owner as signer
try {
const owner = await payload.owner();
const payloadWithOwner = payload.connect(provider.getSigner(owner));
await payloadWithOwner.execute();
} catch (e) {
await payload.execute();
}

console.log("executed payload");
} catch (e: any) {
console.log(e.message);
Expand Down
69 changes: 0 additions & 69 deletions yarn-error.log

This file was deleted.

0 comments on commit 3c866d5

Please sign in to comment.