Skip to content

Commit

Permalink
🔨 scripts: convert foundry broadcast to safe tx builder
Browse files Browse the repository at this point in the history
  • Loading branch information
cruzdanilo committed Oct 23, 2023
1 parent 57ce649 commit 8244e35
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/safefy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { argv } from "process";
import { readFileSync } from "fs";

const file = argv[2];
if (!file) throw new Error("missing file argument");

const { chain, transactions } = JSON.parse(readFileSync(file).toString()) as {
chain: number;
transactions: { transaction: { from: string; to: string; data: string; value: string } }[];
};
console.log(
JSON.stringify(
{
chainId: String(chain),
meta: {
createdFromSafeAddress: transactions.reduce((address, { transaction: { from } }) => {
if (address && address !== from) throw new Error("multiple safe addresses");
return from;
}, ""),
},
transactions: transactions.map(({ transaction: { to, data, value } }) => ({ to, data, value })),
},
null,
2,
),
);

0 comments on commit 8244e35

Please sign in to comment.