Skip to content

Commit

Permalink
feat: register weth gateway after token bridge deployment (OffchainLa…
Browse files Browse the repository at this point in the history
  • Loading branch information
TucksonDev authored Mar 7, 2024
1 parent 24e9c59 commit e634906
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions scripts/createTokenBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {
createTokenBridgePrepareCustomFeeTokenApprovalTransactionRequest,
createTokenBridgePrepareTransactionRequest,
createTokenBridgePrepareTransactionReceipt,
createTokenBridgePrepareSetWethGatewayTransactionRequest,
createTokenBridgePrepareSetWethGatewayTransactionReceipt,
} from '@arbitrum/orbit-sdk'
import { sanitizePrivateKey } from '@arbitrum/orbit-sdk/utils'

Expand Down Expand Up @@ -199,6 +201,58 @@ export const createNewTokenBridge = async (
parentChainPublicClient,
})

// set weth gateway (only for eth-based chains)
if (nativeToken === constants.AddressZero) {
const setWethGatewayTxRequest =
await createTokenBridgePrepareSetWethGatewayTransactionRequest({
rollup: rollupAddress as Address,
parentChainPublicClient,
orbitChainPublicClient,
account: deployer.address,
retryableGasOverrides: {
gasLimit: {
percentIncrease: 200n,
},
},
})

// sign and send the transaction
const setWethGatewayTxHash =
await parentChainPublicClient.sendRawTransaction({
serializedTransaction: await deployer.signTransaction(
setWethGatewayTxRequest
),
})

// get the transaction receipt after waiting for the transaction to complete
const setWethGatewayTxReceipt =
createTokenBridgePrepareSetWethGatewayTransactionReceipt(
await parentChainPublicClient.waitForTransactionReceipt({
hash: setWethGatewayTxHash,
})
)

console.log(
`Weth gateway set in tx ${setWethGatewayTxReceipt.transactionHash}`
)

// Wait for retryables to execute
console.log(`Waiting for retryables...`)
const orbitChainSetWethGatewayRetryableReceipt =
await setWethGatewayTxReceipt.waitForRetryables({
orbitPublicClient: orbitChainPublicClient,
})
console.log(
`Retryable #1: ${orbitChainSetWethGatewayRetryableReceipt[0].transactionHash}`
)
if (orbitChainSetWethGatewayRetryableReceipt[0].status !== 'success') {
console.error(
`Retryable status is not success: ${orbitChainSetWethGatewayRetryableReceipt[0].status}. The process will continue, but you'll have to register the Weth gateway later again.`
)
}
console.log(`Done!`)
}

// fetch core contracts
const createRollupTxHash = await createRollupFetchTransactionHash({
rollup: rollupAddress as Address,
Expand Down

0 comments on commit e634906

Please sign in to comment.