-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔨 scripts: convert foundry broadcast to safe tx builder
- Loading branch information
1 parent
57ce649
commit 8244e35
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
), | ||
); |