From c125ab05d7c75077b25716f6bd7b57652da02a09 Mon Sep 17 00:00:00 2001 From: Alexander Biryukov Date: Thu, 19 Sep 2024 11:56:57 +0400 Subject: [PATCH 1/2] generateGnosisSafeJson --- generate-gnosis-safe-json.js | 32 ++++++++++++++++++++++++++++++++ package.json | 19 +++++++++---------- 2 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 generate-gnosis-safe-json.js diff --git a/generate-gnosis-safe-json.js b/generate-gnosis-safe-json.js new file mode 100644 index 0000000..5c0adc7 --- /dev/null +++ b/generate-gnosis-safe-json.js @@ -0,0 +1,32 @@ +require('dotenv').config(); +const { ethers } = require('ethers'); +const {TxBuilder} = require("@morpho-labs/gnosis-tx-builder"); +const fs = require("node:fs"); + +function generateGnosisSafeJson() { + console.log("Started"); + try { + const tx = ethers.Transaction.from(process.env.RAW_TRANSACTION); + + const transactions = [ + { + to: tx.to, + value: ethers.parseUnits(process.env.VALUE_IN_ETHER, 'ether').toString(), + data: tx.data, + }, + ]; + + const batchJson = TxBuilder.batch( + process.env.SAFE_ADDRESS, + transactions, { + chainId: process.env.CHAIN_ID, + description: 'Use this JSON in Gnosis Safe Transaction Builder' + }); + fs.writeFileSync("batchTx.json", JSON.stringify(batchJson, null, 2)); + console.log('Finished'); + } catch (error) { + console.error('Error:', error); + } +} + +generateGnosisSafeJson() diff --git a/package.json b/package.json index 72bf300..1edb021 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,16 @@ { "name": "sign-and-broadcast-raw-tx", - "version": "1.0.0", - "description": "", - "main": "sign-and-broadcast-raw-tx.js", + "version": "2.0.0", + "author": "P2P Validator ", + "homepage": "https://p2p.org/", + "license": "MIT", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "test42": "node test42.js" + "generate-gnosis-safe-json": "node generate-gnosis-safe-json.js", + "sign-and-broadcast-raw-tx.js": "node sign-and-broadcast-raw-tx.js" }, - "keywords": [], - "author": "", - "license": "ISC", "dependencies": { - "ethers": "6.10.0", - "dotenv": "14.2.0" + "@morpho-labs/gnosis-tx-builder": "2.0.0", + "dotenv": "14.2.0", + "ethers": "6.13.2" } } From d57df1239aab5f5b686bfcb1e9717ff2aa53b6a3 Mon Sep 17 00:00:00 2001 From: Alexander Biryukov Date: Thu, 19 Sep 2024 12:00:27 +0400 Subject: [PATCH 2/2] package-lock.json --- package-lock.json | 139 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..78dc8fb --- /dev/null +++ b/package-lock.json @@ -0,0 +1,139 @@ +{ + "name": "sign-and-broadcast-raw-tx", + "version": "2.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "sign-and-broadcast-raw-tx", + "version": "2.0.0", + "license": "MIT", + "dependencies": { + "@morpho-labs/gnosis-tx-builder": "2.0.0", + "dotenv": "14.2.0", + "ethers": "6.13.2" + } + }, + "node_modules/@adraffy/ens-normalize": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz", + "integrity": "sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw==", + "license": "MIT" + }, + "node_modules/@morpho-labs/gnosis-tx-builder": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@morpho-labs/gnosis-tx-builder/-/gnosis-tx-builder-2.0.0.tgz", + "integrity": "sha512-1xGHIe+oBOl5+AUOQgcHFRy1sFNjB5gRe03XaNbe7Rm7KY1YklU3/D0OT6EXk0ng6BuaSNO8NIGxeJXgKMMlVQ==", + "license": "MIT", + "dependencies": { + "ethers": "^6.9.2" + }, + "engines": { + "node": ">=16.0" + }, + "peerDependencies": { + "ethers": "^6.9.2" + } + }, + "node_modules/@noble/curves": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz", + "integrity": "sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.3.2" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz", + "integrity": "sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==", + "license": "MIT", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@types/node": { + "version": "18.15.13", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.13.tgz", + "integrity": "sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q==", + "license": "MIT" + }, + "node_modules/aes-js": { + "version": "4.0.0-beta.5", + "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz", + "integrity": "sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q==", + "license": "MIT" + }, + "node_modules/dotenv": { + "version": "14.2.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-14.2.0.tgz", + "integrity": "sha512-05POuPJyPpO6jqzTNweQFfAyMSD4qa4lvsMOWyTRTdpHKy6nnnN+IYWaXF+lHivhBH/ufDKlR4IWCAN3oPnHuw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/ethers": { + "version": "6.13.2", + "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.13.2.tgz", + "integrity": "sha512-9VkriTTed+/27BGuY1s0hf441kqwHJ1wtN2edksEtiRvXx+soxRX3iSXTfFqq2+YwrOqbDoTHjIhQnjJRlzKmg==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/ethers-io/" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "license": "MIT", + "dependencies": { + "@adraffy/ens-normalize": "1.10.1", + "@noble/curves": "1.2.0", + "@noble/hashes": "1.3.2", + "@types/node": "18.15.13", + "aes-js": "4.0.0-beta.5", + "tslib": "2.4.0", + "ws": "8.17.1" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==", + "license": "0BSD" + }, + "node_modules/ws": { + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +}