Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
for (const [key, val] of Object.entries(requiredEnvVars)) {
if (val === null || val === undefined) {
logger.warn('Missing environment variable', {
key,
value: val,
})
exit(1)
}
}
const clearPendingTxs = requiredEnvVars.CLEAR_PENDING_TXS
const l2Provider = injectL2Context(
new JsonRpcProvider(requiredEnvVars.L2_NODE_WEB3_URL)
)
const sequencerSigner: Signer = await getSequencerSigner()
let proposerSigner: Signer = await getProposerSigner()
const sequencerAddress = await sequencerSigner.getAddress()
const proposerAddress = await proposerSigner.getAddress()
// If the sequencer & proposer are the same, use a single wallet
if (sequencerAddress === proposerAddress) {
proposerSigner = sequencerSigner
}
logger.info('Configured batch submitter addresses', {
sequencerAddress,
proposerAddress,
addressManagerAddress: requiredEnvVars.ADDRESS_MANAGER_ADDRESS,
protected async _init(): Promise {
if (!this.options.db.isOpen()) {
await this.options.db.open()
}
this.state.db = new TransportDB(this.options.db)
this.state.l1RpcProvider =
typeof this.options.l1RpcProvider === 'string'
? new JsonRpcProvider(this.options.l1RpcProvider)
: this.options.l1RpcProvider
this._initializeApp()
}
protected async _init(): Promise {
if (this.options.legacySequencerCompatibility) {
this.logger.info(
'Using legacy sync, this will be quite a bit slower than normal'
)
}
this.state.db = new TransportDB(this.options.db)
this.state.l2RpcProvider =
typeof this.options.l2RpcProvider === 'string'
? new JsonRpcProvider(this.options.l2RpcProvider)
: this.options.l2RpcProvider
}
protected async _init(): Promise {
this.state.db = new TransportDB(this.options.db)
this.state.l1RpcProvider =
typeof this.options.l1RpcProvider === 'string'
? new JsonRpcProvider(this.options.l1RpcProvider)
: this.options.l1RpcProvider
this.logger.info('Using AddressManager', {
addressManager: this.options.addressManager,
})
const Lib_AddressManager = loadContract(
'Lib_AddressManager',
this.options.addressManager,
this.state.l1RpcProvider
)
const code = await this.state.l1RpcProvider.getCode(
Lib_AddressManager.address
)
if (fromHexString(code).length === 0) {
const initialize = () => {
const provider =
window.web3 && window.web3.currentProvider
? new Web3Provider(window.web3.currentProvider)
: new FallbackProvider([
new JsonRpcProvider('https://api.mycryptoapi.com/eth'),
new InfuraProvider(),
new EtherscanProvider()
]);
handleConnect(provider);
};
const getSequencerSigner = async (): Promise => {
const l1Provider = new JsonRpcProvider(requiredEnvVars.L1_NODE_WEB3_URL)
if (useHardhat) {
if (!DEBUG_IMPERSONATE_SEQUENCER_ADDRESS) {
throw new Error('Must pass DEBUG_IMPERSONATE_SEQUENCER_ADDRESS')
}
await l1Provider.send('hardhat_impersonateAccount', [
DEBUG_IMPERSONATE_SEQUENCER_ADDRESS,
])
return l1Provider.getSigner(DEBUG_IMPERSONATE_SEQUENCER_ADDRESS)
}
if (SEQUENCER_PRIVATE_KEY) {
return new Wallet(SEQUENCER_PRIVATE_KEY, l1Provider)
} else if (SEQUENCER_MNEMONIC) {
return Wallet.fromMnemonic(SEQUENCER_MNEMONIC, SEQUENCER_HD_PATH).connect(
l1Provider