Skip to content

Commit 92d7b4c

Browse files
authored
Merge branch 'main' into solc-0.8.24-,
2 parents 8ba8eb2 + 5d82f05 commit 92d7b4c

File tree

12 files changed

+167
-17390
lines changed

12 files changed

+167
-17390
lines changed

packages/bridge-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"@wagmi/core": "^2.6.9",
6565
"@walletconnect/ethereum-provider": "^2.12.2",
6666
"@walletconnect/modal": "^2.6.2",
67-
"@web3modal/wagmi": "^4.1.1",
67+
"@web3modal/wagmi": "^4.1.11",
6868
"@zerodevx/svelte-toast": "^0.9.5",
6969
"axios": "^1.6.7",
7070
"buffer": "^6.0.3",

packages/bridge-ui/src/abi/index.ts

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3094,16 +3094,6 @@ export const erc20Abi = [
30943094
outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
30953095
stateMutability: 'view',
30963096
},
3097-
{
3098-
type: 'function',
3099-
inputs: [
3100-
{ name: 'account', internalType: 'address', type: 'address' },
3101-
{ name: 'snapshotId', internalType: 'uint256', type: 'uint256' },
3102-
],
3103-
name: 'balanceOfAt',
3104-
outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
3105-
stateMutability: 'view',
3106-
},
31073097
{
31083098
type: 'function',
31093099
inputs: [{ name: '_amount', internalType: 'uint256', type: 'uint256' }],
@@ -3397,13 +3387,6 @@ export const erc20Abi = [
33973387
outputs: [{ name: '', internalType: 'address payable', type: 'address' }],
33983388
stateMutability: 'view',
33993389
},
3400-
{
3401-
type: 'function',
3402-
inputs: [],
3403-
name: 'snapshooter',
3404-
outputs: [{ name: '', internalType: 'address', type: 'address' }],
3405-
stateMutability: 'view',
3406-
},
34073390
{
34083391
type: 'function',
34093392
inputs: [],
@@ -3432,13 +3415,6 @@ export const erc20Abi = [
34323415
outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
34333416
stateMutability: 'view',
34343417
},
3435-
{
3436-
type: 'function',
3437-
inputs: [{ name: 'snapshotId', internalType: 'uint256', type: 'uint256' }],
3438-
name: 'totalSupplyAt',
3439-
outputs: [{ name: '', internalType: 'uint256', type: 'uint256' }],
3440-
stateMutability: 'view',
3441-
},
34423418
{
34433419
type: 'function',
34443420
inputs: [
@@ -3699,14 +3675,6 @@ export const erc20Abi = [
36993675
],
37003676
name: 'Paused',
37013677
},
3702-
{
3703-
type: 'event',
3704-
anonymous: false,
3705-
inputs: [
3706-
{ name: 'id', internalType: 'uint256', type: 'uint256', indexed: false },
3707-
],
3708-
name: 'Snapshot',
3709-
},
37103678
{
37113679
type: 'event',
37123680
anonymous: false,

packages/bridge-ui/src/app.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const processingFeeComponent = {
1515
};
1616

1717
export const pendingTransaction = {
18-
waitTimeout: 300_000,
18+
waitTimeout: 30_000,
1919
};
2020

2121
export const storageService = {

packages/bridge-ui/src/components/Bridge/SharedBridgeComponents/ConfirmationStep/ConfirmationStep.svelte

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts">
22
import { onMount } from 'svelte';
33
import { t } from 'svelte-i18n';
4-
import type { Hash } from 'viem';
4+
import type { Hash, Hex } from 'viem';
55
66
import { routingContractsMap } from '$bridgeConfig';
77
import { chainConfig } from '$chainConfig';
@@ -19,15 +19,15 @@
1919
import { BridgingStatus } from '$components/Bridge/types';
2020
import { Icon, type IconType } from '$components/Icon';
2121
import { successToast } from '$components/NotificationToast';
22-
import { infoToast } from '$components/NotificationToast/NotificationToast.svelte';
22+
import { infoToast, warningToast } from '$components/NotificationToast/NotificationToast.svelte';
2323
import Spinner from '$components/Spinner/Spinner.svelte';
2424
import { type ApproveArgs, bridges, type BridgeTransaction, MessageStatus, type NFTApproveArgs } from '$libs/bridge';
2525
import type { ERC20Bridge } from '$libs/bridge/ERC20Bridge';
2626
import type { ERC721Bridge } from '$libs/bridge/ERC721Bridge';
2727
import type { ERC1155Bridge } from '$libs/bridge/ERC1155Bridge';
2828
import { getBridgeArgs } from '$libs/bridge/getBridgeArgs';
2929
import { handleBridgeError } from '$libs/bridge/handleBridgeErrors';
30-
import { BridgePausedError } from '$libs/error';
30+
import { BridgePausedError, TransactionTimeoutError } from '$libs/error';
3131
import { bridgeTxService } from '$libs/storage';
3232
import { TokenType } from '$libs/token';
3333
import { getTokenApprovalStatus } from '$libs/token/getTokenApprovalStatus';
@@ -48,6 +48,8 @@
4848
let approving: boolean;
4949
let checking: boolean;
5050
51+
let icon: IconType;
52+
5153
$: statusTitle = '';
5254
$: statusDescription = '';
5355
@@ -56,17 +58,34 @@
5658
5759
const destinationChain = $destNetwork?.id;
5860
const userAccount = $account?.address;
59-
if (!currentChain || !destinationChain || !userAccount) return; //TODO error handling
61+
if (!currentChain || !destinationChain || !userAccount || !$selectedToken) return; //TODO error handling
6062
6163
const explorer = chainConfig[currentChain]?.blockExplorers?.default.url;
6264
63-
await pendingTransactions.add(txHash, currentChain);
64-
65-
bridgingStatus = BridgingStatus.DONE;
66-
statusTitle = $t('bridge.actions.bridge.success.title');
67-
statusDescription = $t('bridge.step.confirm.bridge.success.message', {
68-
values: { url: `${explorer}/tx/${txHash}` },
69-
});
65+
try {
66+
await pendingTransactions.add(txHash, currentChain);
67+
68+
successToast({
69+
title: $t('bridge.actions.approve.success.title'),
70+
message: $t('bridge.actions.approve.success.message', {
71+
values: {
72+
token: $selectedToken.symbol,
73+
},
74+
}),
75+
});
76+
icon = successIcon;
77+
bridgingStatus = BridgingStatus.DONE;
78+
statusTitle = $t('bridge.actions.bridge.success.title');
79+
statusDescription = $t('bridge.step.confirm.bridge.success.message', {
80+
values: { url: `${explorer}/tx/${txHash}` },
81+
});
82+
} catch (error) {
83+
if (error instanceof TransactionTimeoutError) {
84+
handleTimeout(txHash);
85+
} else {
86+
handleBridgeError(error as Error);
87+
}
88+
}
7089
7190
const bridgeTx = {
7291
hash: txHash,
@@ -85,6 +104,27 @@
85104
bridgeTxService.addTxByAddress(userAccount, bridgeTx);
86105
};
87106
107+
const handleTimeout = (txHash: Hex) => {
108+
const currentChain = $connectedSourceChain?.id;
109+
const explorer = chainConfig[currentChain]?.blockExplorers?.default.url;
110+
111+
warningToast({
112+
title: $t('bridge.actions.bridge.timeout.title'),
113+
message: $t('bridge.actions.bridge.timeout.message', {
114+
values: {
115+
url: `${explorer}/tx/${approveTxHash}`,
116+
},
117+
}),
118+
});
119+
icon = timeoutIcon;
120+
iconFill = 'fill-warning-sentiment';
121+
bridgingStatus = BridgingStatus.DONE;
122+
statusTitle = $t('bridge.actions.bridge.timeout.title');
123+
statusDescription = $t('bridge.step.confirm.bridge.timeout.message', {
124+
values: { url: `${explorer}/tx/${txHash}` },
125+
});
126+
};
127+
88128
const handleApproveTxHash = async (txHash: Hash) => {
89129
const currentChain = $connectedSourceChain?.id;
90130
@@ -197,9 +237,11 @@
197237
handleBridgeError(err as Error);
198238
}
199239
}
240+
$: iconFill = '';
200241
$: approveIcon = `approve-${$theme}` as IconType;
201242
$: bridgeIcon = `bridge-${$theme}` as IconType;
202243
$: successIcon = `success-${$theme}` as IconType;
244+
$: timeoutIcon = `exclamation-circle` as IconType;
203245
204246
onMount(() => (bridgingStatus = BridgingStatus.PENDING));
205247
</script>
@@ -208,7 +250,7 @@
208250
<section id="txStatus">
209251
<div class="flex flex-col justify-content-center items-center">
210252
{#if bridgingStatus === BridgingStatus.DONE}
211-
<Icon type={successIcon} size={160} />
253+
<Icon type={icon} size={160} fillClass={iconFill} />
212254
<div id="text" class="f-col my-[30px] text-center">
213255
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
214256
<h1>{@html statusTitle}</h1>

packages/bridge-ui/src/components/NotificationToast/NotificationToast.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// Defaults when no value was provided for closeManually
1919
success: false,
2020
error: true,
21-
warning: false,
21+
warning: true,
2222
info: false,
2323
unknown: false,
2424
};

packages/bridge-ui/src/i18n/en.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
"message": "Your funds are being prepared for claiming on Taiko.",
2525
"title": "Transaction completed"
2626
},
27+
"timeout": {
28+
"message": "It took longer than expected to process your transaction, check your wallet for the status.",
29+
"title": "Timed out"
30+
},
2731
"tx": {
2832
"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>.",
2933
"title": "Transaction sent"
@@ -154,6 +158,9 @@
154158
"bridge": {
155159
"success": {
156160
"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>."
161+
},
162+
"timeout": {
163+
"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."
157164
}
158165
},
159166
"button": {

packages/bridge-ui/src/libs/error/errors.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ export class IpfsError extends Error {
168168
export class ClientError extends Error {
169169
name = 'ClientError';
170170
}
171-
172-
export class NoDelaysForBridgeError extends Error {
173-
name = 'NoDelaysForBridgeError';
171+
export class TransactionTimeoutError extends Error {
172+
name = 'TransactionTimeoutError';
174173
}

packages/bridge-ui/src/stores/pendingTransactions.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { waitForTransactionReceipt } from '@wagmi/core';
22
import { writable } from 'svelte/store';
3-
import type { Hex, TransactionReceipt } from 'viem';
3+
import { type Hex, type TransactionReceipt, WaitForTransactionReceiptTimeoutError } from 'viem';
44

55
import { pendingTransaction } from '$config';
6-
import { FailedTransactionError } from '$libs/error';
6+
import { FailedTransactionError, TransactionTimeoutError } from '$libs/error';
77
import { refreshUserBalance } from '$libs/util/balance';
88
import { Deferred } from '$libs/util/Deferred';
99
import { getLogger } from '$libs/util/logger';
@@ -67,6 +67,9 @@ export const pendingTransactions = {
6767
})
6868
.catch((err) => {
6969
console.error(err);
70+
if (err instanceof WaitForTransactionReceiptTimeoutError) {
71+
deferred.reject(new TransactionTimeoutError(`transaction with hash "${hash}" timed out`, { cause: err }));
72+
}
7073
deferred.reject(new FailedTransactionError(`transaction with hash "${hash}" failed`, { cause: err }));
7174
})
7275
.finally(() => {

packages/protocol/contracts/L1/tiers/TierProviderV2.sol

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@ contract TierProviderV2 is EssentialContract, ITierProvider {
3030
});
3131
}
3232

33-
if (_tierId == LibTiers.TIER_SGX_ZKVM) {
34-
return ITierProvider.Tier({
35-
verifierName: LibStrings.B_TIER_SGX_ZKVM,
36-
validityBond: 500 ether, // TKO
37-
contestBond: 3280 ether, // =500TKO * 6.5625
38-
cooldownWindow: 1440, //24 hours
39-
provingWindow: 240, // 4 hours
40-
maxBlocksToVerifyPerProof: 4
41-
});
42-
}
43-
4433
if (_tierId == LibTiers.TIER_GUARDIAN_MINORITY) {
4534
return ITierProvider.Tier({
4635
verifierName: LibStrings.B_TIER_GUARDIAN_MINORITY,
@@ -68,17 +57,14 @@ contract TierProviderV2 is EssentialContract, ITierProvider {
6857

6958
/// @inheritdoc ITierProvider
7059
function getTierIds() public pure override returns (uint16[] memory tiers_) {
71-
tiers_ = new uint16[](4);
60+
tiers_ = new uint16[](3);
7261
tiers_[0] = LibTiers.TIER_SGX;
73-
tiers_[1] = LibTiers.TIER_SGX_ZKVM;
74-
tiers_[2] = LibTiers.TIER_GUARDIAN_MINORITY;
75-
tiers_[3] = LibTiers.TIER_GUARDIAN;
62+
tiers_[1] = LibTiers.TIER_GUARDIAN_MINORITY;
63+
tiers_[2] = LibTiers.TIER_GUARDIAN;
7664
}
7765

7866
/// @inheritdoc ITierProvider
7967
function getMinTier(uint256 _rand) public pure override returns (uint16) {
80-
// 0.1% require SGX + ZKVM; all others require SGX
81-
if (_rand % 1000 == 0) return LibTiers.TIER_SGX_ZKVM;
82-
else return LibTiers.TIER_SGX;
68+
return LibTiers.TIER_SGX;
8369
}
8470
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity 0.8.24;
3+
4+
import "../../common/EssentialContract.sol";
5+
import "../../common/LibStrings.sol";
6+
import "./ITierProvider.sol";
7+
8+
/// @title TierProviderV3
9+
/// @dev Labeled in AddressResolver as "tier_provider"
10+
/// @custom:security-contact [email protected]
11+
contract TierProviderV3 is EssentialContract, ITierProvider {
12+
uint256[50] private __gap;
13+
14+
/// @notice Initializes the contract.
15+
/// @param _owner The owner of this contract. msg.sender will be used if this value is zero.
16+
function init(address _owner) external initializer {
17+
__Essential_init(_owner);
18+
}
19+
20+
/// @inheritdoc ITierProvider
21+
function getTier(uint16 _tierId) public pure override returns (ITierProvider.Tier memory) {
22+
if (_tierId == LibTiers.TIER_SGX) {
23+
return ITierProvider.Tier({
24+
verifierName: LibStrings.B_TIER_SGX,
25+
validityBond: 250 ether, // TKO
26+
contestBond: 1640 ether, // =250TKO * 6.5625
27+
cooldownWindow: 1440, //24 hours
28+
provingWindow: 60, // 1 hours
29+
maxBlocksToVerifyPerProof: 8
30+
});
31+
}
32+
33+
if (_tierId == LibTiers.TIER_SGX_ZKVM) {
34+
return ITierProvider.Tier({
35+
verifierName: LibStrings.B_TIER_SGX_ZKVM,
36+
validityBond: 500 ether, // TKO
37+
contestBond: 3280 ether, // =500TKO * 6.5625
38+
cooldownWindow: 1440, //24 hours
39+
provingWindow: 240, // 4 hours
40+
maxBlocksToVerifyPerProof: 4
41+
});
42+
}
43+
44+
if (_tierId == LibTiers.TIER_GUARDIAN_MINORITY) {
45+
return ITierProvider.Tier({
46+
verifierName: LibStrings.B_TIER_GUARDIAN_MINORITY,
47+
validityBond: 500 ether, // TKO
48+
contestBond: 3280 ether, // =500TKO * 6.5625
49+
cooldownWindow: 60, //1 hours
50+
provingWindow: 2880, // 48 hours
51+
maxBlocksToVerifyPerProof: 16
52+
});
53+
}
54+
55+
if (_tierId == LibTiers.TIER_GUARDIAN) {
56+
return ITierProvider.Tier({
57+
verifierName: LibStrings.B_TIER_GUARDIAN,
58+
validityBond: 0, // must be 0 for top tier
59+
contestBond: 0, // must be 0 for top tier
60+
cooldownWindow: 60, //1 hours
61+
provingWindow: 2880, // 48 hours
62+
maxBlocksToVerifyPerProof: 16
63+
});
64+
}
65+
66+
revert TIER_NOT_FOUND();
67+
}
68+
69+
/// @inheritdoc ITierProvider
70+
function getTierIds() public pure override returns (uint16[] memory tiers_) {
71+
tiers_ = new uint16[](4);
72+
tiers_[0] = LibTiers.TIER_SGX;
73+
tiers_[1] = LibTiers.TIER_SGX_ZKVM;
74+
tiers_[2] = LibTiers.TIER_GUARDIAN_MINORITY;
75+
tiers_[3] = LibTiers.TIER_GUARDIAN;
76+
}
77+
78+
/// @inheritdoc ITierProvider
79+
function getMinTier(uint256 _rand) public pure override returns (uint16) {
80+
// 0.1% require SGX + ZKVM; all others require SGX
81+
if (_rand % 1000 == 0) return LibTiers.TIER_SGX_ZKVM;
82+
else return LibTiers.TIER_SGX;
83+
}
84+
}

0 commit comments

Comments
 (0)