Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(protocol): merge alpha 2 to main #13369

Merged
merged 10 commits into from
Mar 20, 2023
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.

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