Skip to content

Commit

Permalink
Merge branch 'main' into taikoon-ui-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
bearni95 committed Apr 29, 2024
2 parents ece7ca9 + be856dd commit df0f258
Show file tree
Hide file tree
Showing 35 changed files with 13,694 additions and 876 deletions.
30 changes: 15 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ require (
github.com/cyberhorsey/errors v0.0.0-20220929234051-087d6d8bb841
github.com/cyberhorsey/webutils v0.0.0-20230314183728-56890c6ddbe7
github.com/davecgh/go-spew v1.1.1
github.com/ethereum-optimism/optimism v1.7.3
github.com/ethereum-optimism/optimism v1.7.4
github.com/ethereum/go-ethereum v1.13.14
github.com/go-git/go-git/v5 v5.12.0
github.com/gomarkdown/markdown v0.0.0-20230716120725-531d2d74bc12
github.com/gomarkdown/markdown v0.0.0-20231222211730-1d6d20845b47
github.com/google/uuid v1.6.0
github.com/joho/godotenv v1.5.1
github.com/labstack/echo-contrib v0.17.1
Expand All @@ -29,13 +29,13 @@ require (
github.com/swaggo/swag v1.16.3
github.com/testcontainers/testcontainers-go v0.30.0
github.com/urfave/cli/v2 v2.27.1
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3
golang.org/x/sync v0.7.0
gopkg.in/go-playground/assert.v1 v1.2.1
gopkg.in/yaml.v3 v3.0.1
gorm.io/datatypes v1.2.0
gorm.io/driver/mysql v1.5.6
gorm.io/gorm v1.25.9
gorm.io/gorm v1.25.10
gotest.tools v2.2.0+incompatible
)

Expand All @@ -56,7 +56,7 @@ require (
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/andybalholm/brotli v1.0.6 // indirect
github.com/andybalholm/brotli v1.1.0 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
Expand Down Expand Up @@ -116,7 +116,7 @@ require (
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/gorilla/css v1.0.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/iancoleman/strcase v0.2.0 // indirect
Expand All @@ -125,14 +125,14 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kataras/blocks v0.0.7 // indirect
github.com/kataras/golog v0.1.9 // indirect
github.com/kataras/iris/v12 v12.2.1 // indirect
github.com/kataras/pio v0.0.12 // indirect
github.com/kataras/blocks v0.0.8 // indirect
github.com/kataras/golog v0.1.11 // indirect
github.com/kataras/iris/v12 v12.2.10 // indirect
github.com/kataras/pio v0.0.13 // indirect
github.com/kataras/sitemap v0.0.6 // indirect
github.com/kataras/tunnel v0.0.4 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.2 // indirect
github.com/klauspost/compress v1.17.6 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
Expand All @@ -144,7 +144,7 @@ require (
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mfridman/interpolate v0.0.2 // indirect
github.com/microcosm-cc/bluemonday v1.0.24 // indirect
github.com/microcosm-cc/bluemonday v1.0.26 // indirect
github.com/mmcloughlin/addchain v0.4.0 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
Expand Down Expand Up @@ -175,15 +175,15 @@ require (
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220614013038-64ee5596c38a // indirect
github.com/tdewolff/minify/v2 v2.12.7 // indirect
github.com/tdewolff/parse/v2 v2.6.6 // indirect
github.com/tdewolff/minify/v2 v2.20.14 // indirect
github.com/tdewolff/parse/v2 v2.7.8 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.44.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
Expand Down
84 changes: 43 additions & 41 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.23.0",
"private": true,
"devDependencies": {
"lefthook": "^1.6.7",
"lefthook": "^1.6.10",
"prettier": "^3.2.5"
}
}
2 changes: 1 addition & 1 deletion packages/bridge-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@wagmi/core": "^2.6.9",
"@walletconnect/ethereum-provider": "^2.12.2",
"@walletconnect/modal": "^2.6.2",
"@web3modal/wagmi": "^4.1.1",
"@web3modal/wagmi": "^4.1.11",
"@zerodevx/svelte-toast": "^0.9.5",
"axios": "^1.6.7",
"buffer": "^6.0.3",
Expand Down
32 changes: 0 additions & 32 deletions packages/bridge-ui/src/abi/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3094,16 +3094,6 @@ export const erc20Abi = [
outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
stateMutability: 'view',
},
{
type: 'function',
inputs: [
{ name: 'account', internalType: 'address', type: 'address' },
{ name: 'snapshotId', internalType: 'uint256', type: 'uint256' },
],
name: 'balanceOfAt',
outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
stateMutability: 'view',
},
{
type: 'function',
inputs: [{ name: '_amount', internalType: 'uint256', type: 'uint256' }],
Expand Down Expand Up @@ -3397,13 +3387,6 @@ export const erc20Abi = [
outputs: [{ name: '', internalType: 'address payable', type: 'address' }],
stateMutability: 'view',
},
{
type: 'function',
inputs: [],
name: 'snapshooter',
outputs: [{ name: '', internalType: 'address', type: 'address' }],
stateMutability: 'view',
},
{
type: 'function',
inputs: [],
Expand Down Expand Up @@ -3432,13 +3415,6 @@ export const erc20Abi = [
outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
stateMutability: 'view',
},
{
type: 'function',
inputs: [{ name: 'snapshotId', internalType: 'uint256', type: 'uint256' }],
name: 'totalSupplyAt',
outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
stateMutability: 'view',
},
{
type: 'function',
inputs: [
Expand Down Expand Up @@ -3699,14 +3675,6 @@ export const erc20Abi = [
],
name: 'Paused',
},
{
type: 'event',
anonymous: false,
inputs: [
{ name: 'id', internalType: 'uint256', type: 'uint256', indexed: false },
],
name: 'Snapshot',
},
{
type: 'event',
anonymous: false,
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge-ui/src/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const processingFeeComponent = {
};

export const pendingTransaction = {
waitTimeout: 300_000,
waitTimeout: 30_000,
};

export const storageService = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { onMount } from 'svelte';
import { t } from 'svelte-i18n';
import type { Hash } from 'viem';
import type { Hash, Hex } from 'viem';
import { routingContractsMap } from '$bridgeConfig';
import { chainConfig } from '$chainConfig';
Expand All @@ -19,15 +19,15 @@
import { BridgingStatus } from '$components/Bridge/types';
import { Icon, type IconType } from '$components/Icon';
import { successToast } from '$components/NotificationToast';
import { infoToast } from '$components/NotificationToast/NotificationToast.svelte';
import { infoToast, warningToast } from '$components/NotificationToast/NotificationToast.svelte';
import Spinner from '$components/Spinner/Spinner.svelte';
import { type ApproveArgs, bridges, type BridgeTransaction, MessageStatus, type NFTApproveArgs } from '$libs/bridge';
import type { ERC20Bridge } from '$libs/bridge/ERC20Bridge';
import type { ERC721Bridge } from '$libs/bridge/ERC721Bridge';
import type { ERC1155Bridge } from '$libs/bridge/ERC1155Bridge';
import { getBridgeArgs } from '$libs/bridge/getBridgeArgs';
import { handleBridgeError } from '$libs/bridge/handleBridgeErrors';
import { BridgePausedError } from '$libs/error';
import { BridgePausedError, TransactionTimeoutError } from '$libs/error';
import { bridgeTxService } from '$libs/storage';
import { TokenType } from '$libs/token';
import { getTokenApprovalStatus } from '$libs/token/getTokenApprovalStatus';
Expand All @@ -48,6 +48,8 @@
let approving: boolean;
let checking: boolean;
let icon: IconType;
$: statusTitle = '';
$: statusDescription = '';
Expand All @@ -56,17 +58,34 @@
const destinationChain = $destNetwork?.id;
const userAccount = $account?.address;
if (!currentChain || !destinationChain || !userAccount) return; //TODO error handling
if (!currentChain || !destinationChain || !userAccount || !$selectedToken) return; //TODO error handling
const explorer = chainConfig[currentChain]?.blockExplorers?.default.url;
await pendingTransactions.add(txHash, currentChain);
bridgingStatus = BridgingStatus.DONE;
statusTitle = $t('bridge.actions.bridge.success.title');
statusDescription = $t('bridge.step.confirm.bridge.success.message', {
values: { url: `${explorer}/tx/${txHash}` },
});
try {
await pendingTransactions.add(txHash, currentChain);
successToast({
title: $t('bridge.actions.approve.success.title'),
message: $t('bridge.actions.approve.success.message', {
values: {
token: $selectedToken.symbol,
},
}),
});
icon = successIcon;
bridgingStatus = BridgingStatus.DONE;
statusTitle = $t('bridge.actions.bridge.success.title');
statusDescription = $t('bridge.step.confirm.bridge.success.message', {
values: { url: `${explorer}/tx/${txHash}` },
});
} catch (error) {
if (error instanceof TransactionTimeoutError) {
handleTimeout(txHash);
} else {
handleBridgeError(error as Error);
}
}
const bridgeTx = {
hash: txHash,
Expand All @@ -85,6 +104,27 @@
bridgeTxService.addTxByAddress(userAccount, bridgeTx);
};
const handleTimeout = (txHash: Hex) => {
const currentChain = $connectedSourceChain?.id;
const explorer = chainConfig[currentChain]?.blockExplorers?.default.url;
warningToast({
title: $t('bridge.actions.bridge.timeout.title'),
message: $t('bridge.actions.bridge.timeout.message', {
values: {
url: `${explorer}/tx/${approveTxHash}`,
},
}),
});
icon = timeoutIcon;
iconFill = 'fill-warning-sentiment';
bridgingStatus = BridgingStatus.DONE;
statusTitle = $t('bridge.actions.bridge.timeout.title');
statusDescription = $t('bridge.step.confirm.bridge.timeout.message', {
values: { url: `${explorer}/tx/${txHash}` },
});
};
const handleApproveTxHash = async (txHash: Hash) => {
const currentChain = $connectedSourceChain?.id;
Expand Down Expand Up @@ -197,9 +237,11 @@
handleBridgeError(err as Error);
}
}
$: iconFill = '';
$: approveIcon = `approve-${$theme}` as IconType;
$: bridgeIcon = `bridge-${$theme}` as IconType;
$: successIcon = `success-${$theme}` as IconType;
$: timeoutIcon = `exclamation-circle` as IconType;
onMount(() => (bridgingStatus = BridgingStatus.PENDING));
</script>
Expand All @@ -208,7 +250,7 @@
<section id="txStatus">
<div class="flex flex-col justify-content-center items-center">
{#if bridgingStatus === BridgingStatus.DONE}
<Icon type={successIcon} size={160} />
<Icon type={icon} size={160} fillClass={iconFill} />
<div id="text" class="f-col my-[30px] text-center">
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<h1>{@html statusTitle}</h1>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// Defaults when no value was provided for closeManually
success: false,
error: true,
warning: false,
warning: true,
info: false,
unknown: false,
};
Expand Down
7 changes: 7 additions & 0 deletions packages/bridge-ui/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
"message": "Your funds are being prepared for claiming on Taiko.",
"title": "Transaction completed"
},
"timeout": {
"message": "It took longer than expected to process your transaction, check your wallet for the status.",
"title": "Timed out"
},
"tx": {
"message": "Your bridge transaction was confirmed. The transaction can take a few minutes to complete, track it <a href=\"{url}\" target=\"_blank\" rel=\"noopener noreferrer\"><b>here</b></a>.",
"title": "Transaction sent"
Expand Down Expand Up @@ -154,6 +158,9 @@
"bridge": {
"success": {
"message": "Your bridge transaction was confirmed. The transaction can take a few minutes to complete, track it <a class='link' href=\"{url}\" target=\"_blank\" rel=\"noopener noreferrer\"><b>here</b></a>."
},
"timeout": {
"message": "The network experiences heavy load and it took longer than expected for your transaction to process. You can track the status on the <a class=\"link\" href=\\\"{url}\\\" target=\\\"_blank\\\" rel=\\\"noopener noreferrer\\\"><b>explorer</b></a> and in your wallet."
}
},
"button": {
Expand Down
5 changes: 2 additions & 3 deletions packages/bridge-ui/src/libs/error/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ export class IpfsError extends Error {
export class ClientError extends Error {
name = 'ClientError';
}

export class NoDelaysForBridgeError extends Error {
name = 'NoDelaysForBridgeError';
export class TransactionTimeoutError extends Error {
name = 'TransactionTimeoutError';
}
7 changes: 5 additions & 2 deletions packages/bridge-ui/src/stores/pendingTransactions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { waitForTransactionReceipt } from '@wagmi/core';
import { writable } from 'svelte/store';
import type { Hex, TransactionReceipt } from 'viem';
import { type Hex, type TransactionReceipt, WaitForTransactionReceiptTimeoutError } from 'viem';

import { pendingTransaction } from '$config';
import { FailedTransactionError } from '$libs/error';
import { FailedTransactionError, TransactionTimeoutError } from '$libs/error';
import { refreshUserBalance } from '$libs/util/balance';
import { Deferred } from '$libs/util/Deferred';
import { getLogger } from '$libs/util/logger';
Expand Down Expand Up @@ -67,6 +67,9 @@ export const pendingTransactions = {
})
.catch((err) => {
console.error(err);
if (err instanceof WaitForTransactionReceiptTimeoutError) {
deferred.reject(new TransactionTimeoutError(`transaction with hash "${hash}" timed out`, { cause: err }));
}
deferred.reject(new FailedTransactionError(`transaction with hash "${hash}" failed`, { cause: err }));
})
.finally(() => {
Expand Down
Loading

0 comments on commit df0f258

Please sign in to comment.