Skip to content

Commit

Permalink
fix: use proper gas price for token bridge (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
spsjvc authored Oct 1, 2024
1 parent ad8dfcf commit 3525fa4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
11 changes: 4 additions & 7 deletions src/createTokenBridge-ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const L2AtomicTokenBridgeFactory__factory = NamedFactoryInstance(L2AtomicTokenBr
export type CreateTokenBridgeGetInputsResult = {
inbox: Address;
maxGasForContracts: bigint;
gasPrice: bigint;
maxGasPrice: bigint;
retryableFee: bigint;
};

Expand All @@ -53,9 +53,6 @@ export async function createTokenBridgeGetInputs<
);
const l1TokenBridgeCreator = L1AtomicTokenBridgeCreator__factory.connect(l1Provider);

//// gasPrice
const gasPrice = await l2Provider.getGasPrice();

//// run retryable estimate for deploying L2 factory
const deployFactoryGasParams = await getEstimateForDeployingFactory(
l1DeployerAddress,
Expand Down Expand Up @@ -150,8 +147,8 @@ export async function createTokenBridgeGetInputs<

const maxGasPrice =
retryableGasOverrides && retryableGasOverrides.maxGasPrice
? retryableGasOverrides.maxGasPrice
: gasPrice;
? BigNumber.from(retryableGasOverrides.maxGasPrice)
: await l2Provider.getGasPrice();

let retryableFee = maxSubmissionCostForFactory
.add(maxSubmissionCostForContracts)
Expand All @@ -164,7 +161,7 @@ export async function createTokenBridgeGetInputs<
return {
inbox: inbox as Address,
maxGasForContracts: maxGasForContracts.toBigInt(),
gasPrice: gasPrice.toBigInt(),
maxGasPrice: maxGasPrice.toBigInt(),
retryableFee: retryableFee.toBigInt(),
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/createTokenBridgePrepareTransactionRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export async function createTokenBridgePrepareTransactionRequest<
const tokenBridgeCreatorAddress =
tokenBridgeCreatorAddressOverride ?? getTokenBridgeCreatorAddress(parentChainPublicClient);

const { inbox, maxGasForContracts, gasPrice, retryableFee } = await createTokenBridgeGetInputs(
const { inbox, maxGasForContracts, maxGasPrice, retryableFee } = await createTokenBridgeGetInputs(
account,
parentChainPublicClient,
orbitChainPublicClient,
Expand All @@ -74,7 +74,7 @@ export async function createTokenBridgePrepareTransactionRequest<
data: encodeFunctionData({
abi: tokenBridgeCreatorABI,
functionName: 'createTokenBridge',
args: [inbox, params.rollupOwner, maxGasForContracts, gasPrice],
args: [inbox, params.rollupOwner, maxGasForContracts, maxGasPrice],
}),
value: chainUsesCustomFee ? 0n : retryableFee,
account: account,
Expand Down

0 comments on commit 3525fa4

Please sign in to comment.