feat(infra): Add script to create safes and add safe addresses for new chains (#4127)
### Description <!-- What's included in this PR? --> - Add an infra script to create a safe on specific chain using the `safeSigners.json` config where the safe signers are defined ### Drive-by changes <!-- Are there any minor or drive-by changes also included? --> ### Related issues <!-- - Fixes #[issue number here] --> ### Backward compatibility <!-- Are these changes backward compatible? Are there any infrastructure implications, e.g. changes that would prohibit deploying older commits using this infra tooling? Yes/No --> ### Testing <!-- What kind of testing have these changes undergone? None/Manual/Unit Tests --> Manualpull/4176/head
parent
97588b6fc1
commit
944b2f65e1
@ -0,0 +1,13 @@ |
||||
{ |
||||
"signers": [ |
||||
"0xa7ECcdb9Be08178f896c26b7BbD8C3D4E844d9Ba", |
||||
"0xc3E966E79eF1aA4751221F55fB8A36589C24C0cA", |
||||
"0x3b7f8f68A4FD0420FeA2F42a1eFc53422f205599", |
||||
"0x88436919fAa2310d32A36D20d13E0a441D24fAc3", |
||||
"0x003DDD9eEAb62013b7332Ab4CC6B10077a8ca961", |
||||
"0xd00d6A31485C93c597D1d8231eeeE0ed17B9844B", |
||||
"0x483fd7284A696343FEc0819DDF2cf7E06E8A06E5", |
||||
"0x5b73A98165778BCCE72979B4EE3faCdb31728b8E", |
||||
"0x5dd9a0814022A61777938263308EBB336174f13D" |
||||
] |
||||
} |
@ -0,0 +1,79 @@ |
||||
import { SafeFactory } from '@safe-global/protocol-kit'; |
||||
import { SafeAccountConfig } from '@safe-global/protocol-kit'; |
||||
|
||||
import { Contexts } from '../../config/contexts.js'; |
||||
import { getChain } from '../../config/registry.js'; |
||||
import { Role } from '../../src/roles.js'; |
||||
import { readJSONAtPath } from '../../src/utils/utils.js'; |
||||
import { |
||||
getArgs, |
||||
getKeyForRole, |
||||
withChainRequired, |
||||
withSafeTxServiceUrlRequired, |
||||
withThreshold, |
||||
} from '../agent-utils.js'; |
||||
|
||||
const OWNERS_FILE_PATH = 'config/environments/mainnet3/safe/safeSigners.json'; |
||||
|
||||
async function main() { |
||||
const { chain, safeTxServiceUrl, threshold } = await withThreshold( |
||||
withSafeTxServiceUrlRequired(withChainRequired(getArgs())), |
||||
).argv; |
||||
|
||||
const chainMetadata = await getChain(chain); |
||||
const rpcUrls = chainMetadata.rpcUrls; |
||||
const deployerPrivateKey = await getDeployerPrivateKey(); |
||||
|
||||
let safeFactory; |
||||
try { |
||||
safeFactory = await SafeFactory.init({ |
||||
provider: rpcUrls[0].http, |
||||
signer: deployerPrivateKey, |
||||
}); |
||||
} catch (e) { |
||||
console.error(`Error initializing SafeFactory: ${e}`); |
||||
process.exit(1); |
||||
} |
||||
|
||||
const ownersConfig = readJSONAtPath(OWNERS_FILE_PATH); |
||||
const owners = ownersConfig.signers; |
||||
|
||||
const safeAccountConfig: SafeAccountConfig = { |
||||
owners, |
||||
threshold, |
||||
}; |
||||
|
||||
let safe; |
||||
try { |
||||
safe = await safeFactory.deploySafe({ safeAccountConfig }); |
||||
} catch (e) { |
||||
console.error(`Error deploying Safe: ${e}`); |
||||
process.exit(1); |
||||
} |
||||
|
||||
const safeAddress = await safe.getAddress(); |
||||
|
||||
console.log(`Safe address: ${safeAddress}`); |
||||
console.log( |
||||
`Safe url: ${safeTxServiceUrl}/home?safe=${chain}:${safeAddress}`, |
||||
); |
||||
console.log('url may not be correct, please check by following the link'); |
||||
} |
||||
|
||||
const getDeployerPrivateKey = async () => { |
||||
const key = await getKeyForRole( |
||||
'mainnet3', |
||||
Contexts.Hyperlane, |
||||
Role.Deployer, |
||||
); |
||||
await key.fetch(); |
||||
|
||||
return key.privateKey; |
||||
}; |
||||
|
||||
main() |
||||
.then() |
||||
.catch((e) => { |
||||
console.error(e); |
||||
process.exit(1); |
||||
}); |
Loading…
Reference in new issue