Skip to content

Commit

Permalink
feat(protocol): merge alpha 2 to main (#13369)
Browse files Browse the repository at this point in the history
Co-authored-by: shadab-taiko <108871478+shadab-taiko@users.noreply.github.com>
Co-authored-by: Francisco Ramos <jscriptcoder@gmail.com>
  • Loading branch information
3 people authored Mar 20, 2023
1 parent 4cabf1b commit 2b9cc64
Show file tree
Hide file tree
Showing 51 changed files with 1,074 additions and 738 deletions.
23 changes: 11 additions & 12 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/cyberhorsey/errors v0.0.0-20220929234051-087d6d8bb841
github.com/cyberhorsey/webutils v0.0.0-20230314183728-56890c6ddbe7
github.com/ethereum/go-ethereum v1.10.26
github.com/ethereum/go-ethereum v1.11.4
github.com/joho/godotenv v1.4.0
github.com/labstack/echo-contrib v0.13.0
github.com/labstack/echo/v4 v4.9.1
Expand Down Expand Up @@ -35,22 +35,23 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/containerd/cgroups v1.0.4 // indirect
github.com/containerd/containerd v1.6.12 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set v1.8.0 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v20.10.17+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.17.0 // indirect
github.com/go-playground/validator/v10 v10.4.0 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/golang-jwt/jwt/v4 v4.4.3 // indirect
Expand All @@ -65,8 +66,8 @@ require (
github.com/klauspost/compress v1.16.3 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/microcosm-cc/bluemonday v1.0.20 // indirect
github.com/moby/sys/mount v0.3.3 // indirect
Expand All @@ -80,22 +81,20 @@ require (
github.com/opencontainers/runc v1.1.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rjeczalik/notify v0.9.1 // indirect
github.com/prometheus/common v0.39.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // 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.1 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/net v0.5.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.6.0 // indirect
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
google.golang.org/grpc v1.48.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
Expand Down
142 changes: 40 additions & 102 deletions go.sum

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions packages/bridge-ui/.eslintignore

This file was deleted.

80 changes: 0 additions & 80 deletions packages/bridge-ui/.eslintrc.cjs

This file was deleted.

31 changes: 15 additions & 16 deletions packages/bridge-ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,31 @@ You can use the following values in the `.env` file to spin up the Bridge UI loc

```
VITE_NODE_ENV=dev
VITE_L1_RPC_URL=<sepolia_rpc>
VITE_L2_RPC_URL="https://rpc.a2.taiko.xyz/"
VITE_L1_RPC_URL="https://l1rpc.internal.taiko.xyz/"
VITE_L2_RPC_URL="https://l2rpc.internal.taiko.xyz/"
VITE_L1_EXPLORER_URL="https://sepolia.etherscan.io/"
VITE_L2_EXPLORER_URL="https://explorer.a2.taiko.xyz/"
VITE_L1_EXPLORER_URL="https://l1explorer.internal.taiko.xyz/"
VITE_L2_EXPLORER_URL="https://l2explorer.internal.taiko.xyz/"
VITE_RELAYER_URL="https://relayer.a2.taiko.xyz/"
VITE_RELAYER_URL="https://relayer.internal.taiko.xyz/"
VITE_MAINNET_CHAIN_ID=11155111
VITE_TAIKO_CHAIN_ID=167004
VITE_TEST_ERC20=[{"address": "0x3435A6180fBB1BAEc87bDC49915282BfBC328C70", "symbol": "BLL", "name": "Bull Token"}, {"address": "0xAED64948E0d09f4eb07d8B76A65Cd3d517c6Fb15", "symbol": "HORSE", "name": "Horse Token"}]
VITE_MAINNET_CHAIN_ID=31336
VITE_TAIKO_CHAIN_ID=167001
VITE_MAINNET_CHAIN_NAME="Ethereum A2"
VITE_MAINNET_CHAIN_NAME="Sepolia"
VITE_TAIKO_CHAIN_NAME="Taiko A2"
VITE_MAINNET_TOKEN_VAULT_ADDRESS="0x5E506e2E0EaD3Ff9d93859A5879cAA02582f77c3"
VITE_MAINNET_TOKEN_VAULT_ADDRESS="0x4284890d4AcD0bcb017eCE481B96fD4Cb457CAc8"
VITE_TAIKO_TOKEN_VAULT_ADDRESS="0x0000777700000000000000000000000000000002"
VITE_MAINNET_HEADER_SYNC_ADDRESS="0x9b557777Be33A8A2fE6aF93E017A0d139B439E5D"
VITE_MAINNET_HEADER_SYNC_ADDRESS="0xAC9251ee97Ed8beF31706354310C6b020C35d87b"
VITE_TAIKO_HEADER_SYNC_ADDRESS="0x0000777700000000000000000000000000000001"
VITE_MAINNET_BRIDGE_ADDRESS="0xAE4C9bD0f7AE5398Df05043079596E2BF0079CE9"
VITE_MAINNET_BRIDGE_ADDRESS="0x2aB7C0ab9AB47fcF370d13058BfEE28f2Ec0940c"
VITE_TAIKO_BRIDGE_ADDRESS="0x0000777700000000000000000000000000000004"
VITE_MAINNET_SIGNAL_SERVICE_ADDRESS="0x162A36c9821eadeCFF9669A3940b7f72d055Cd1c"
VITE_TAIKO_SIGNAL_SERVICE_ADDRESS="0x0000777700000000000000000000000000000007"
VITE_MAINNET_SIGNAL_SERVICE_ADDRESS="0x07130410064Ab5C32486CC36904fb219ae97156F"
VITE_TAIKO_SIGNAL_SERVICE_ADDRESS="0xbB203a6f73F805E44E97dcC0c894eFe0fAf72498"
VITE_TEST_ERC20=[{"address": "0x5B9fEDd37f0B92E7E282B19cEbCF06F57B77C604", "symbol": "BLL", "name": "Bull Token"}, {"address": "0x1E8C104D068F22D351859cdBfE41A697A98E6EA2", "symbol": "HORSE", "name": "Horse Token"}]
```
4 changes: 2 additions & 2 deletions packages/bridge-ui/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ export default {
],
coverageThreshold: {
global: {
statements: 94,
statements: 92,
branches: 72,
functions: 88,
lines: 95,
lines: 92,
},
},
modulePathIgnorePatterns: ['<rootDir>/public/build/'],
Expand Down
10 changes: 4 additions & 6 deletions packages/bridge-ui/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import { MessageStatus } from './domain/message';
import BridgeABI from './constants/abi/Bridge';
import { providers } from './store/providers';
import HeaderAnnouncement from './components/HeaderAnnouncement.svelte';
import type { TokenService } from './domain/token';
import { CustomTokenService } from './storage/CustomTokenService';
import { userTokens, tokenService } from './store/userToken';
Expand Down Expand Up @@ -140,13 +139,13 @@
if (store) {
const userAddress = await store.getAddress();
const apiTxs = await $relayerApi.GetAllByAddress(userAddress);
const apiTxs = await $relayerApi.GetAllBridgeTransactionByAddress(
userAddress,
);
const blockInfoMap = await $relayerApi.GetBlockInfo();
relayerBlockInfoMap.set(blockInfoMap);
const txs = await $transactioner.GetAllByAddress(userAddress);
// const hashToApiTxsMap = new Map(apiTxs.map((tx) => {
// return [tx.hash, tx];
// }))
Expand All @@ -160,7 +159,7 @@
const updatedStorageTxs: BridgeTransaction[] = txs.filter((tx) => {
const blockInfo = blockInfoMap.get(tx.fromChainId);
if (blockInfo?.latestProcessedBlock >= tx.receipt.blockNumber) {
if (blockInfo?.latestProcessedBlock >= tx.receipt?.blockNumber) {
return false;
}
return true;
Expand Down Expand Up @@ -254,7 +253,6 @@

<QueryProvider>
<main>
<HeaderAnnouncement />
<Navbar />
<Router {routes} />
</main>
Expand Down
4 changes: 2 additions & 2 deletions packages/bridge-ui/src/bridge/ERC20Bridge.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ describe('bridge tests', () => {
'0x',
opts.tokenAddress,
opts.amountInWei,
BigNumber.from(2640000),
BigNumber.from(3140000),
opts.processingFeeInWei,
'0xfake',
opts.memo,
Expand Down Expand Up @@ -234,7 +234,7 @@ describe('bridge tests', () => {
'0xfake',
opts.tokenAddress,
opts.amountInWei,
BigNumber.from(2500000),
BigNumber.from(3000000),
BigNumber.from(0),
'0xfake',
'',
Expand Down
22 changes: 19 additions & 3 deletions packages/bridge-ui/src/bridge/ERC20Bridge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BigNumber, Contract, Signer } from 'ethers';
import { BigNumber, Contract, ethers, Signer } from 'ethers';
import type { Transaction } from 'ethers';
import type {
ApproveOpts,
Expand Down Expand Up @@ -46,7 +46,7 @@ export class ERC20Bridge implements Bridge {
};

if (!opts.isBridgedTokenAlreadyDeployed) {
message.gasLimit = message.gasLimit.add(BigNumber.from(2500000));
message.gasLimit = message.gasLimit.add(BigNumber.from(3000000));
}

return { contract, owner, message };
Expand Down Expand Up @@ -190,7 +190,23 @@ export class ERC20Bridge implements Bridge {
});
}

return await contract.processMessage(opts.message, proof);
let processMessageTx;
try {
processMessageTx = await contract.processMessage(opts.message, proof);
} catch (error) {
if (error.code === ethers.errors.UNPREDICTABLE_GAS_LIMIT) {
processMessageTx = await contract.processMessage(
opts.message,
proof,
{
gasLimit: 1e6,
},
);
} else {
throw new Error(error);
}
}
return processMessageTx;
} else {
return await contract.retryMessage(opts.message, false);
}
Expand Down
21 changes: 18 additions & 3 deletions packages/bridge-ui/src/bridge/ETHBridge.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BigNumber, Contract } from 'ethers';
import { BigNumber, Contract, ethers } from 'ethers';
import type { Transaction } from 'ethers';
import type {
ApproveOpts,
Expand Down Expand Up @@ -133,8 +133,23 @@ export class ETHBridge implements Bridge {
};

const proof = await this.prover.GenerateProof(proofOpts);

return await contract.processMessage(opts.message, proof);
let processMessageTx;
try {
processMessageTx = await contract.processMessage(opts.message, proof);
} catch (error) {
if (error.code === ethers.errors.UNPREDICTABLE_GAS_LIMIT) {
processMessageTx = await contract.processMessage(
opts.message,
proof,
{
gasLimit: 1e6,
},
);
} else {
throw new Error(error);
}
}
return processMessageTx;
} else {
return await contract.retryMessage(opts.message, true);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script lang="ts">
import TooltipModal from './modals/TooltipModal.svelte';
export let show: boolean;
</script>

<TooltipModal title="Insufficient Balance" bind:isOpen={show}>
<span slot="body">
<div class="text-left">
You have insufficient balance to claim this transaction. Please wait for
the relayer to claim the transaction for you.
</div>
</span>
</TooltipModal>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ul class="list-disc ml-4">
<li class="mb-2">
<strong>Pending</strong>: Your asset is not ready to be bridged. Taiko
A1 => {import.meta.env
A2 => {import.meta.env
? import.meta.env.VITE_MAINNET_CHAIN_NAME
: 'Ethereum A2'} bridging can take several hours before being ready.
{import.meta.env
Expand Down
Loading

0 comments on commit 2b9cc64

Please sign in to comment.