forked from cerc-io/stack-orchestrator
2515878eeb
* Remove unnecessary todos * Set option to log commands in shell scripts * Replace fixturenet-eth dependency with wait on endpoint * Skip lighthouse node dependency check * Update all services in the stack * Use debug flag to enable shell commands logging * Add bash in op-batcher container * Update mobymask-v2 instructions * Update fixturenet-optimism instructions * Add descriptions for services * Move ts files to container-build * Take L1 RPC endpoint from the env file * Add dev mode restriction for editing env file
29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import fs from 'fs'
|
|
|
|
import { task } from 'hardhat/config'
|
|
import { hdkey } from 'ethereumjs-wallet'
|
|
import * as bip39 from 'bip39'
|
|
|
|
task('rekey-json', 'Generates a new set of keys for a test network')
|
|
.addParam('output', 'JSON file to output accounts to')
|
|
.setAction(async ({ output: outputFile }) => {
|
|
const mnemonic = bip39.generateMnemonic()
|
|
const pathPrefix = "m/44'/60'/0'/0"
|
|
const labels = ['Admin', 'Proposer', 'Batcher', 'Sequencer']
|
|
const hdwallet = hdkey.fromMasterSeed(await bip39.mnemonicToSeed(mnemonic))
|
|
|
|
const output = {}
|
|
|
|
for (let i = 0; i < labels.length; i++) {
|
|
const label = labels[i]
|
|
const wallet = hdwallet.derivePath(`${pathPrefix}/${i}`).getWallet()
|
|
const addr = '0x' + wallet.getAddress().toString('hex')
|
|
const pk = wallet.getPrivateKey().toString('hex')
|
|
|
|
output[label] = { address: addr, privateKey: pk }
|
|
}
|
|
|
|
fs.writeFileSync(outputFile, JSON.stringify(output, null, 2))
|
|
console.log(`L2 account keys written to ${outputFile}`)
|
|
})
|