Commit c70b57d1 authored by Kelvin Fichter's avatar Kelvin Fichter

maint(ctb): revamp the rekey task

The rekey task wasn't being used, so I'm commandeering it for the
Getting Started guide. This makes the task more legible for end-users.
parent c9cd1215
......@@ -6,25 +6,19 @@ task('rekey', 'Generates a new set of keys for a test network').setAction(
async () => {
const mnemonic = bip39.generateMnemonic()
const pathPrefix = "m/44'/60'/0'/0"
const labels = [
'l2OutputOracleProposer',
'proxyAdminOwner',
'optimismBaseFeeRecipient',
'optimismL1FeeRecipient',
'p2pSequencerAddress',
'l2OutputOracleChallenger',
'batchSenderAddress',
]
const labels = ['Admin', 'Proposer', 'Batcher', 'Sequencer']
const hdwallet = hdkey.fromMasterSeed(await bip39.mnemonicToSeed(mnemonic))
let i = 0
const out = {}
console.log(`Mnemonic: ${mnemonic}`)
for (const label of labels) {
for (let i = 0; i < labels.length; i++) {
const label = labels[i]
const wallet = hdwallet.derivePath(`${pathPrefix}/${i}`).getWallet()
out[label] = `0x${wallet.getAddress().toString('hex')}`
i++
const addr = '0x' + wallet.getAddress().toString('hex')
const pk = wallet.getPrivateKey().toString('hex')
console.log()
console.log(`${label}: ${addr}`)
console.log(`Private Key: ${pk}`)
}
console.log(JSON.stringify(out, null, ' '))
}
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment