Skip to content

Commit

Permalink
fix: use forceApprove in ZkStack adapters
Browse files Browse the repository at this point in the history
Signed-off-by: bennett <[email protected]>
  • Loading branch information
bmzig committed Nov 13, 2024
1 parent 8fb3a7f commit ea59869
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion contracts/chain-adapters/ZkStack_Adapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ contract ZkStack_Adapter is AdapterInterface {
);
} else {
// An ERC20 that is not WETH.
IERC20(l1Token).safeIncreaseAllowance(SHARED_BRIDGE, amount);
IERC20(l1Token).forceApprove(SHARED_BRIDGE, amount);
txHash = BRIDGE_HUB.requestL2TransactionTwoBridges{ value: txBaseCost }(
BridgeHubInterface.L2TransactionRequestTwoBridgesOuter({
chainId: CHAIN_ID,
Expand Down
10 changes: 5 additions & 5 deletions contracts/chain-adapters/ZkStack_CustomGasToken_Adapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ contract ZkStack_CustomGasToken_Adapter is AdapterInterface {
*/
function relayMessage(address target, bytes memory message) external payable override {
uint256 txBaseCost = _pullCustomGas(L2_GAS_LIMIT);
IERC20(CUSTOM_GAS_TOKEN).safeIncreaseAllowance(SHARED_BRIDGE, txBaseCost);
IERC20(CUSTOM_GAS_TOKEN).forceApprove(SHARED_BRIDGE, txBaseCost);

// Returns the hash of the requested L2 transaction. This hash can be used to follow the transaction status.
bytes32 canonicalTxHash = BRIDGE_HUB.requestL2TransactionDirect(
Expand Down Expand Up @@ -153,7 +153,7 @@ contract ZkStack_CustomGasToken_Adapter is AdapterInterface {
// If the l1Token is WETH then unwrap it to ETH then send the ETH to the standard bridge along with the base
// cost of custom gas tokens.
L1_WETH.withdraw(amount);
IERC20(CUSTOM_GAS_TOKEN).safeIncreaseAllowance(SHARED_BRIDGE, txBaseCost);
IERC20(CUSTOM_GAS_TOKEN).forceApprove(SHARED_BRIDGE, txBaseCost);
txHash = BRIDGE_HUB.requestL2TransactionTwoBridges{ value: amount }(
BridgeHubInterface.L2TransactionRequestTwoBridgesOuter({
chainId: CHAIN_ID,
Expand All @@ -169,7 +169,7 @@ contract ZkStack_CustomGasToken_Adapter is AdapterInterface {
);
} else if (l1Token == CUSTOM_GAS_TOKEN) {
// The chain's custom gas token.
IERC20(l1Token).safeIncreaseAllowance(SHARED_BRIDGE, txBaseCost + amount);
IERC20(l1Token).forceApprove(SHARED_BRIDGE, txBaseCost + amount);
txHash = BRIDGE_HUB.requestL2TransactionDirect(
BridgeHubInterface.L2TransactionRequestDirect({
chainId: CHAIN_ID,
Expand All @@ -185,8 +185,8 @@ contract ZkStack_CustomGasToken_Adapter is AdapterInterface {
);
} else {
// An ERC20 that is not WETH and not the custom gas token.
IERC20(CUSTOM_GAS_TOKEN).safeIncreaseAllowance(SHARED_BRIDGE, txBaseCost);
IERC20(l1Token).safeIncreaseAllowance(SHARED_BRIDGE, amount);
IERC20(CUSTOM_GAS_TOKEN).forceApprove(SHARED_BRIDGE, txBaseCost);
IERC20(l1Token).forceApprove(SHARED_BRIDGE, amount);
txHash = BRIDGE_HUB.requestL2TransactionTwoBridges(
BridgeHubInterface.L2TransactionRequestTwoBridgesOuter({
chainId: CHAIN_ID,
Expand Down

0 comments on commit ea59869

Please sign in to comment.