diff --git a/package-lock.json b/package-lock.json index 77627f1..58b1a6a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "lattice-cli", - "version": "0.1.0", + "version": "0.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "lattice-cli", - "version": "0.1.0", + "version": "0.1.1", "license": "ISC", "dependencies": { "@ethersproject/abi": "^5.7.0", @@ -14,7 +14,7 @@ "dotenv": "^16.0.0", "enquirer": "^2.3.6", "gridplus-sdk": "^2.4.1", - "lattice-eth2-utils": "^0.4.2", + "lattice-eth2-utils": "^0.4.3", "spinnies": "^0.5.1", "ts-node": "^10.7.0" }, @@ -3903,9 +3903,9 @@ } }, "node_modules/lattice-eth2-utils": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/lattice-eth2-utils/-/lattice-eth2-utils-0.4.2.tgz", - "integrity": "sha512-tPKlShZ1VjHb0U+1aexTrkHI2pDJPQeaaZliNIl5bo1nTjcP7qbadLQgVS0FMb8VTSYDNNI03Z5UGD7W2J6vUg==", + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/lattice-eth2-utils/-/lattice-eth2-utils-0.4.3.tgz", + "integrity": "sha512-LioMZMPCevjN7ST8MuUtxs0m/2DRw+BztZJUjn77qW011ts9pzp5+vuzLsybyM9Xkafu+HtNsEJqdc+VJjGAsQ==", "dependencies": { "@chainsafe/ssz": "^0.9.2", "@ethersproject/abi": "^5.7.0", @@ -8344,9 +8344,9 @@ "dev": true }, "lattice-eth2-utils": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/lattice-eth2-utils/-/lattice-eth2-utils-0.4.2.tgz", - "integrity": "sha512-tPKlShZ1VjHb0U+1aexTrkHI2pDJPQeaaZliNIl5bo1nTjcP7qbadLQgVS0FMb8VTSYDNNI03Z5UGD7W2J6vUg==", + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/lattice-eth2-utils/-/lattice-eth2-utils-0.4.3.tgz", + "integrity": "sha512-LioMZMPCevjN7ST8MuUtxs0m/2DRw+BztZJUjn77qW011ts9pzp5+vuzLsybyM9Xkafu+HtNsEJqdc+VJjGAsQ==", "requires": { "@chainsafe/ssz": "^0.9.2", "@ethersproject/abi": "^5.7.0", diff --git a/package.json b/package.json index bdc4c1c..dc2524d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lattice-cli", - "version": "0.1.0", + "version": "0.1.1", "description": "CLI for interacting with gridplus-sdk", "main": "./dist/lattice-cli.js", "types": "./dist/lattice-cli.d.ts", @@ -8,7 +8,7 @@ "clean": "rm -rf dist && rm -rf release", "build": "tsc -p tsconfig.json && npx pkg -c package.json dist/lattice-cli.js", "start": "ts-node ./src/lattice-cli.ts", - "release": "npm run clean && npm run build" + "release": "npm run clean && npm run build && chmod 755 release/*" }, "keywords": [], "author": "Doug Lance", @@ -19,7 +19,7 @@ "dotenv": "^16.0.0", "enquirer": "^2.3.6", "gridplus-sdk": "^2.4.1", - "lattice-eth2-utils": "^0.4.2", + "lattice-eth2-utils": "^0.4.3", "spinnies": "^0.5.1", "ts-node": "^10.7.0" }, diff --git a/src/commands/buildDepositData.ts b/src/commands/buildDepositData.ts index f11c8de..f2decc7 100644 --- a/src/commands/buildDepositData.ts +++ b/src/commands/buildDepositData.ts @@ -1,5 +1,6 @@ import { AbiCoder } from '@ethersproject/abi'; import { + chmodSync, existsSync, mkdirSync, writeFileSync, @@ -126,8 +127,6 @@ export async function cmdGenDepositData(client: Client) { // 5. Build deposit data in interactive loop while (true) { - let withdrawalKey: string; - // 5.1. Get encrypted private key for depositor const keystoreSpinner = startNewSpinner( `Exporting encrypted keystore for validator #${depositPath[2]}. This will take about 30 seconds.`, @@ -158,38 +157,6 @@ export async function cmdGenDepositData(client: Client) { } } - // 5.2. Build deposit data record - // First determine the withdrawal credentials - if (eth1Addr !== '') { - withdrawalKey = eth1Addr; - } else { - const withdrawalKeySpinner = startNewSpinner( - `Fetching BLS withdrawal key for validator #${depositPath[2]}.`, - "yellow" - ); - try { - // If no withdrawalKey was set, we will be using the defaulBLS withBIP39 draw. - // Derived according to EIP2334.al key associated with a deposit path - withdrawalKey = await getBlsWithdrawalKey(client, depositPath); - closeSpinner( - withdrawalKeySpinner, - `Fetched BLS withdrawal key for validator #${depositPath[2]}.` - ); - } catch (err) { - closeSpinner( - withdrawalKeySpinner, - `Failed to fetch BLS withdrawal key for validator #${depositPath[2]}.`, - false - ); - const shouldContinue = await promptForBool(`Try again? `); - if (!shouldContinue) { - break; - } else { - continue; - } - } - } - // Now we can generate the deposit data const depositDataSpinner = startNewSpinner( `Waiting for signature from validator #${depositPath[2]}.`, @@ -198,7 +165,7 @@ export async function cmdGenDepositData(client: Client) { try { const opts = { ...ETH2Constants.NETWORKS.MAINNET_GENESIS, // TODO: Make this configurable - withdrawalKey, + withdrawTo: eth1Addr !== '' ? eth1Addr : undefined, amountGwei: depositAmountGwei, }; if (exportCalldata) { @@ -267,10 +234,11 @@ export async function cmdGenDepositData(client: Client) { mkdirSync(fDir); } for (let i = 0; i < depositData.length; i++) { - writeFileSync( - fDir + `/keystore-m_12381_3600_${startingIdx + i}_0_0-${datetime}.json`, - keystores[i] - ); + const fPath = fDir + `/keystore-m_12381_3600_${startingIdx + i}_0_0-${datetime}.json`; + writeFileSync(fPath, keystores[i]); + // These are JSON files so they don't really need to be executable, + // but this matches the permissions from the official Ethereum Deposit CLI. + chmodSync(fPath, "710"); }; const fName = exportCalldata ? `deposit-calldata-${datetime}.json` : @@ -311,8 +279,12 @@ async function getKeystore(client: Client, depositPath: number[]): Promise