Skip to content

Commit

Permalink
fix: check if token bridge deployed (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
spsjvc authored Oct 1, 2024
1 parent 1084c40 commit f3893a6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/createTokenBridgePrepareTransactionRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import { Prettify } from './types/utils';
import { WithTokenBridgeCreatorAddressOverride } from './types/createTokenBridgeTypes';
import { getTokenBridgeCreatorAddress } from './utils/getTokenBridgeCreatorAddress';
import { isTokenBridgeDeployed } from './createTokenBridge';

export type TransactionRequestRetryableGasOverrides = {
maxSubmissionCostForFactory?: GasOverrideOptions;
Expand Down Expand Up @@ -50,6 +51,17 @@ export async function createTokenBridgePrepareTransactionRequest<
}: CreateTokenBridgePrepareTransactionRequestParams<TParentChain, TOrbitChain>) {
const chainId = validateParentChain(parentChainPublicClient);

const isTokenBridgeAlreadyDeployed = await isTokenBridgeDeployed({
parentChainPublicClient,
orbitChainPublicClient,
tokenBridgeCreatorAddress: tokenBridgeCreatorAddressOverride,
rollupAddress: params.rollup,
});

if (isTokenBridgeAlreadyDeployed) {
throw new Error(`Token bridge contracts for Rollup ${params.rollup} are already deployed`);
}

const tokenBridgeCreatorAddress =
tokenBridgeCreatorAddressOverride ?? getTokenBridgeCreatorAddress(parentChainPublicClient);

Expand Down

0 comments on commit f3893a6

Please sign in to comment.