Skip to content

Commit

Permalink
fix(bridge-ui): handle wrong bridge address (#13880)
Browse files Browse the repository at this point in the history
Co-authored-by: dave | d1onys1us <13951458+d1onys1us@users.noreply.github.com>
  • Loading branch information
jscriptcoder and dionysuzx authored Jun 5, 2023
1 parent 53bec14 commit fe425d9
Show file tree
Hide file tree
Showing 6 changed files with 472 additions and 210 deletions.
25 changes: 13 additions & 12 deletions packages/bridge-ui/src/components/Transactions/Transaction.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<script lang="ts">
import { Contract, ethers, type Transaction } from 'ethers';
import { UserRejectedRequestError } from '@wagmi/core';
import { Contract, errors, type Transaction,utils } from 'ethers';
import { createEventDispatcher } from 'svelte';
import { onDestroy, onMount } from 'svelte';
import { ArrowTopRightOnSquare } from 'svelte-heros-v2';
import { _ } from 'svelte-i18n';
import { bridges } from '../../bridge/bridges';
import { chains } from '../../chain/chains';
import { bridgeABI } from '../../constants/abi';
Expand Down Expand Up @@ -121,7 +122,7 @@
// during their first bridge transaction to L2
// TODO: estimate Claim transaction
const userBalance = await $signer.getBalance('latest');
if (!userBalance.gt(ethers.utils.parseEther('0.0001'))) {
if (!userBalance.gt(utils.parseEther('0.0001'))) {
// TODO: magic number 0.0001. Config?
dispatch('insufficientBalance');
return;
Expand Down Expand Up @@ -192,7 +193,8 @@
true, // dismissible
);
} else if (
[error.code, error.cause?.code].includes(ethers.errors.ACTION_REJECTED)
error instanceof UserRejectedRequestError ||
[error.code, error.cause?.code].includes(errors.ACTION_REJECTED)
) {
warningToast(`Transaction has been rejected.`);
} else if (error.cause === 'pending_tx') {
Expand Down Expand Up @@ -270,7 +272,7 @@
true, // dismissible
);
} else if (
[error.code, error.cause?.code].includes(ethers.errors.ACTION_REJECTED)
[error.code, error.cause?.code].includes(errors.ACTION_REJECTED)
) {
warningToast(`Transaction has been rejected.`);
} else if (error.cause === 'pending_tx') {
Expand Down Expand Up @@ -368,13 +370,12 @@
<span class="ml-2 hidden md:inline-block">{txToChain.name}</span>
</td>
<td>
{isETHByMessage(transaction.message)
? ethers.utils.formatEther(
transaction.message.depositValue.eq(0)
? transaction.message.callValue.toString()
: transaction.message.depositValue,
)
: ethers.utils.formatUnits(transaction.amountInWei)}
{#if Boolean(transaction.message) && isETHByMessage(transaction.message)}
{@const { depositValue, callValue } = transaction.message}
{utils.formatEther(depositValue.eq(0) ? callValue : depositValue)}
{:else}
{utils.formatUnits(transaction.amountInWei)}
{/if}
{transaction.symbol ?? 'ETH'}
</td>

Expand Down
14 changes: 7 additions & 7 deletions packages/bridge-ui/src/constants/__mocks__/envVars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const L1_RPC = 'https://l1rpc.internal.taiko.xyz';
export const L1_TOKEN_VAULT_ADDRESS =
'0xa85233C63b9Ee964Add6F2cffe00Fd84eb32338f';

export const L1_BRIDGE_ADDRESS = '0x59b670e9fA9D0A427751Af201D676719a970857b';
export const L1_BRIDGE_ADDRESS = '0xc6e7df5e7b4f2a278906862b61205850344d4e7d';

export const L1_CROSS_CHAIN_SYNC_ADDRESS =
'0x9A9f2CCfdE556A7E9Ff0848998Aa4a0CFD8863AE';
Expand All @@ -13,28 +13,28 @@ export const L1_SIGNAL_SERVICE_ADDRESS =

export const L1_CHAIN_ID = 31336;

export const L1_CHAIN_NAME = 'Ethereum A3';
export const L1_CHAIN_NAME = 'Ethereum';

export const L1_EXPLORER_URL = 'https://l1explorer.internal.taiko.xyz';

export const L2_RPC = 'https://l2rpc.internal.taiko.xyz';

export const L2_TOKEN_VAULT_ADDRESS =
'0x0000777700000000000000000000000000000002';
'0x1000777700000000000000000000000000000002';

export const L2_BRIDGE_ADDRESS =
import.meta.env?.VITE_L2_BRIDGE_ADDRESS ??
'0x0000777700000000000000000000000000000004';
'0x1000777700000000000000000000000000000004';

export const L2_CROSS_CHAIN_SYNC_ADDRESS =
'0x0000777700000000000000000000000000000001';
'0x1000777700000000000000000000000000000001';

export const L2_SIGNAL_SERVICE_ADDRESS =
'0x0000777700000000000000000000000000000007';
'0x1000777700000000000000000000000000000007';

export const L2_CHAIN_ID = 167001;

export const L2_CHAIN_NAME = 'Taiko A3';
export const L2_CHAIN_NAME = 'Taiko';

export const L2_EXPLORER_URL = 'https://l2explorer.internal.taiko.xyz';

Expand Down
2 changes: 2 additions & 0 deletions packages/bridge-ui/src/domain/relayerApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export type TransactionData = {
Data: string;
};
Raw: {
address: Address;
transactionHash: string;
transactionIndex: string;
};
};

Expand Down
Loading

0 comments on commit fe425d9

Please sign in to comment.