Skip to content

Commit

Permalink
Add fee transfer logic to list of TXs stored into a file
Browse files Browse the repository at this point in the history
  • Loading branch information
gvladika committed Jul 31, 2024
1 parent a3a8418 commit d7e9ed4
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions scripts/usdc-bridge-deployment/deployUsdcBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,20 +485,50 @@ async function _registerGateway(
)

if (!process.env['ROLLUP_OWNER_KEY']) {
// prepare multisig transaction
// prepare multisig transaction(s)

const txs = []
if (isFeeToken) {
// prepare TX to transfer fee amount to upgrade executor
const feeTokenContract = IERC20__factory.connect(
await _getFeeToken(inbox, parentProvider),
parentProvider
)
const feeTransferData = feeTokenContract.interface.encodeFunctionData(
'transfer',
[upgradeExecutor.address, totalFee]
)
txs.push({
to: feeTokenContract.address,
value: BigNumber.from(0).toString(),
data: feeTransferData,
})

// prepare TX to approve router to spend the fee token
const approveData = feeTokenContract.interface.encodeFunctionData(
'approve',
[l1RouterAddress, totalFee]
)
txs.push({
to: upgradeExecutor.address,
value: BigNumber.from(0).toString(),
data: approveData,
})
}

const upgExecutorData = upgradeExecutor.interface.encodeFunctionData(
'executeCall',
[l1Router.address, registrationCalldata]
)
const to = upgradeExecutor.address

// store the multisig transaction to file
const multisigTx = {
txs.push({
to,
value: isFeeToken ? BigNumber.from(0).toString() : totalFee.toString(),
data: upgExecutorData,
}
fs.writeFileSync(REGISTRATION_TX_FILE, JSON.stringify(multisigTx))
})
fs.writeFileSync(REGISTRATION_TX_FILE, JSON.stringify(txs))
} else {
// load rollup owner (account with executor rights on the upgrade executor)
const rollupOwnerKey = process.env['ROLLUP_OWNER_KEY'] as string
Expand Down

0 comments on commit d7e9ed4

Please sign in to comment.