|
|
@ -177,7 +177,6 @@ async function main() { |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
contextFunders = []; |
|
|
|
|
|
|
|
const contexts = Object.keys(argv.contextsAndRoles) as Contexts[]; |
|
|
|
const contexts = Object.keys(argv.contextsAndRoles) as Contexts[]; |
|
|
|
contextFunders = await Promise.all( |
|
|
|
contextFunders = await Promise.all( |
|
|
|
contexts.map((context) => |
|
|
|
contexts.map((context) => |
|
|
@ -192,10 +191,7 @@ async function main() { |
|
|
|
|
|
|
|
|
|
|
|
let failureOccurred = false; |
|
|
|
let failureOccurred = false; |
|
|
|
for (const funder of contextFunders) { |
|
|
|
for (const funder of contextFunders) { |
|
|
|
const failure = await funder.fund(); |
|
|
|
failureOccurred ||= await funder.fund(); |
|
|
|
if (failure) { |
|
|
|
|
|
|
|
failureOccurred = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await submitMetrics(metricsRegister, 'key-funder'); |
|
|
|
await submitMetrics(metricsRegister, 'key-funder'); |
|
|
@ -296,18 +292,25 @@ class ContextFunder { |
|
|
|
async fund(): Promise<boolean> { |
|
|
|
async fund(): Promise<boolean> { |
|
|
|
let failureOccurred = false; |
|
|
|
let failureOccurred = false; |
|
|
|
|
|
|
|
|
|
|
|
const chainKeys = this.getChainKeys(); |
|
|
|
const promises = Object.entries(this.getChainKeys()).map( |
|
|
|
await Promise.all( |
|
|
|
async ([chain, keys]) => { |
|
|
|
Object.entries(chainKeys).map(async ([chain, keys]) => { |
|
|
|
|
|
|
|
if (keys.length > 0) { |
|
|
|
if (keys.length > 0) { |
|
|
|
await this.bridgeIfL2(chain as ChainName); |
|
|
|
await this.bridgeIfL2(chain as ChainName); |
|
|
|
} |
|
|
|
} |
|
|
|
keys.forEach(async (key) => { |
|
|
|
for (const key of keys) { |
|
|
|
const failure = await this.attemptToFundKey(key, chain as ChainName); |
|
|
|
const failure = await this.attemptToFundKey(key, chain as ChainName); |
|
|
|
failureOccurred = failureOccurred || failure; |
|
|
|
failureOccurred ||= failure; |
|
|
|
}); |
|
|
|
} |
|
|
|
}), |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
await Promise.all(promises); |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
|
|
|
|
error('Unhandled error when funding key', { error: format(e) }); |
|
|
|
|
|
|
|
failureOccurred = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return failureOccurred; |
|
|
|
return failureOccurred; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -381,7 +384,6 @@ class ContextFunder { |
|
|
|
// on L1 gas.
|
|
|
|
// on L1 gas.
|
|
|
|
const bridgeAmount = await this.getFundingAmount( |
|
|
|
const bridgeAmount = await this.getFundingAmount( |
|
|
|
chainConnection, |
|
|
|
chainConnection, |
|
|
|
chain, |
|
|
|
|
|
|
|
funderAddress, |
|
|
|
funderAddress, |
|
|
|
desiredBalanceEther.mul(10), |
|
|
|
desiredBalanceEther.mul(10), |
|
|
|
); |
|
|
|
); |
|
|
@ -393,7 +395,6 @@ class ContextFunder { |
|
|
|
|
|
|
|
|
|
|
|
private async getFundingAmount( |
|
|
|
private async getFundingAmount( |
|
|
|
chainConnection: ChainConnection, |
|
|
|
chainConnection: ChainConnection, |
|
|
|
chain: ChainName, |
|
|
|
|
|
|
|
address: string, |
|
|
|
address: string, |
|
|
|
desiredBalance: BigNumber, |
|
|
|
desiredBalance: BigNumber, |
|
|
|
): Promise<BigNumber> { |
|
|
|
): Promise<BigNumber> { |
|
|
@ -419,7 +420,6 @@ class ContextFunder { |
|
|
|
); |
|
|
|
); |
|
|
|
const fundingAmount = await this.getFundingAmount( |
|
|
|
const fundingAmount = await this.getFundingAmount( |
|
|
|
chainConnection, |
|
|
|
chainConnection, |
|
|
|
chain, |
|
|
|
|
|
|
|
key.address, |
|
|
|
key.address, |
|
|
|
desiredBalanceEther, |
|
|
|
desiredBalanceEther, |
|
|
|
); |
|
|
|
); |
|
|
|