Skip to content

Commit dd236a8

Browse files
committed
🔨 scripts: convert foundry broadcast to safe tx builder
1 parent 6f81e35 commit dd236a8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

scripts/safefy.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { argv } from "process";
2+
import { readFileSync } from "fs";
3+
4+
const file = argv[2];
5+
if (!file) throw new Error("missing file argument");
6+
7+
const { chain, transactions } = JSON.parse(readFileSync(file).toString()) as {
8+
chain: number;
9+
transactions: { transaction: { from: string; to: string; data: string; value: string } }[];
10+
};
11+
console.log(
12+
JSON.stringify(
13+
{
14+
chain: String(chain),
15+
meta: {
16+
createdFromSafeAddress: transactions.reduce((address, { transaction: { from } }) => {
17+
if (address && address !== from) throw new Error("multiple safe addresses");
18+
return from;
19+
}, ""),
20+
},
21+
transactions: transactions.map(({ transaction: { to, data, value } }) => ({ to, data, value })),
22+
},
23+
null,
24+
2,
25+
),
26+
);

0 commit comments

Comments
 (0)