From 8244e3514777e354ab075ec261c42154ae3346a3 Mon Sep 17 00:00:00 2001 From: danilo neves cruz Date: Mon, 23 Oct 2023 16:06:23 -0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20scripts:=20convert=20foundry=20b?= =?UTF-8?q?roadcast=20to=20safe=20tx=20builder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/safefy.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 scripts/safefy.ts diff --git a/scripts/safefy.ts b/scripts/safefy.ts new file mode 100644 index 000000000..c1ee32064 --- /dev/null +++ b/scripts/safefy.ts @@ -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, + ), +);