Skip to content

Commit

Permalink
feat(bridge-ui): more informative processing fee (#13488)
Browse files Browse the repository at this point in the history
  • Loading branch information
jscriptcoder authored Mar 30, 2023
1 parent cfcf416 commit f5f7b7e
Show file tree
Hide file tree
Showing 37 changed files with 516 additions and 331 deletions.
1 change: 0 additions & 1 deletion packages/bridge-ui/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
.btn.btn-accent {
background-color: hsla(var(--af) / var(--tw-bg-opacity, 1));
border-color: hsla(var(--af) / var(--tw-bg-opacity, 1));
height: 60px;
}

.btn.btn-accent:hover {
Expand Down
17 changes: 8 additions & 9 deletions packages/bridge-ui/src/bridge/ERC20Bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,15 @@ export class ERC20Bridge implements Bridge {

if (messageStatus === MessageStatus.New) {
const proof = await this.prover.generateProof({
srcChain: opts.message.srcChainId.toNumber(),
srcChain: opts.message.srcChainId,
msgHash: opts.msgHash,
sender: opts.srcBridgeAddress,
srcBridgeAddress: opts.srcBridgeAddress,
destChain: opts.message.destChainId.toNumber(),
destChain: opts.message.destChainId,
destHeaderSyncAddress:
chains[opts.message.destChainId.toNumber()].headerSyncAddress,
chains[opts.message.destChainId].headerSyncAddress,
srcSignalServiceAddress:
chains[opts.message.srcChainId.toNumber()].signalServiceAddress,
chains[opts.message.srcChainId].signalServiceAddress,
});

if (opts.message.gasLimit.gt(BigNumber.from(2500000))) {
Expand Down Expand Up @@ -234,15 +234,14 @@ export class ERC20Bridge implements Bridge {

if (messageStatus === MessageStatus.Failed) {
const proofOpts = {
srcChain: opts.message.srcChainId.toNumber(),
srcChain: opts.message.srcChainId,
msgHash: opts.msgHash,
sender: opts.srcBridgeAddress,
destBridgeAddress: opts.destBridgeAddress,
destChain: opts.message.destChainId.toNumber(),
destChain: opts.message.destChainId,
destHeaderSyncAddress:
chains[opts.message.destChainId.toNumber()].headerSyncAddress,
srcHeaderSyncAddress:
chains[opts.message.srcChainId.toNumber()].headerSyncAddress,
chains[opts.message.destChainId].headerSyncAddress,
srcHeaderSyncAddress: chains[opts.message.srcChainId].headerSyncAddress,
};

const proof = await this.prover.generateReleaseProof(proofOpts);
Expand Down
24 changes: 11 additions & 13 deletions packages/bridge-ui/src/bridge/ETHBridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ import type {
ClaimOpts,
ReleaseOpts,
} from '../domain/bridge';
import TokenVault from '../constants/abi/TokenVault';
import type { Prover } from '../domain/proof';
import { MessageStatus } from '../domain/message';
import BridgeABI from '../constants/abi/Bridge';
import { chains } from '../chain/chains';
import { type Message, MessageStatus } from '../domain/message';

export class ETHBridge implements Bridge {
private readonly prover: Prover;
Expand All @@ -22,15 +21,15 @@ export class ETHBridge implements Bridge {

static async prepareTransaction(
opts: BridgeOpts,
): Promise<{ contract: Contract; message: any; owner: string }> {
): Promise<{ contract: Contract; message: Message; owner: string }> {
const contract: Contract = new Contract(
opts.bridgeAddress,
BridgeABI,
opts.signer,
);

const owner = await opts.signer.getAddress();
const message = {
const message: Message = {
sender: owner,
srcChainId: opts.fromChainId,
destChainId: opts.toChainId,
Expand Down Expand Up @@ -113,15 +112,15 @@ export class ETHBridge implements Bridge {

if (messageStatus === MessageStatus.New) {
const proofOpts = {
srcChain: opts.message.srcChainId.toNumber(),
srcChain: opts.message.srcChainId,
msgHash: opts.msgHash,
sender: opts.srcBridgeAddress,
srcBridgeAddress: opts.srcBridgeAddress,
destChain: opts.message.destChainId.toNumber(),
destChain: opts.message.destChainId,
destHeaderSyncAddress:
chains[opts.message.destChainId.toNumber()].headerSyncAddress,
chains[opts.message.destChainId].headerSyncAddress,
srcSignalServiceAddress:
chains[opts.message.srcChainId.toNumber()].signalServiceAddress,
chains[opts.message.srcChainId].signalServiceAddress,
};

const proof = await this.prover.generateProof(proofOpts);
Expand Down Expand Up @@ -169,15 +168,14 @@ export class ETHBridge implements Bridge {

if (messageStatus === MessageStatus.Failed) {
const proofOpts = {
srcChain: opts.message.srcChainId.toNumber(),
srcChain: opts.message.srcChainId,
msgHash: opts.msgHash,
sender: opts.srcBridgeAddress,
destBridgeAddress: opts.destBridgeAddress,
destChain: opts.message.destChainId.toNumber(),
destChain: opts.message.destChainId,
destHeaderSyncAddress:
chains[opts.message.destChainId.toNumber()].headerSyncAddress,
srcHeaderSyncAddress:
chains[opts.message.srcChainId.toNumber()].headerSyncAddress,
chains[opts.message.destChainId].headerSyncAddress,
srcHeaderSyncAddress: chains[opts.message.srcChainId].headerSyncAddress,
};

const proof = await this.prover.generateReleaseProof(proofOpts);
Expand Down
1 change: 0 additions & 1 deletion packages/bridge-ui/src/components/ChainDropdown.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts">
import { _ } from 'svelte-i18n';
import { fromChain, toChain } from '../store/chain';
import type { Chain } from '../domain/chain';
import { ethers } from 'ethers';
Expand Down
1 change: 0 additions & 1 deletion packages/bridge-ui/src/components/TaikoBanner.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script>
import { _ } from 'svelte-i18n';
import SelectChain from './form/SelectChain.svelte';
</script>

Expand Down
58 changes: 0 additions & 58 deletions packages/bridge-ui/src/components/Transactions.svelte

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import TooltipModal from './modals/TooltipModal.svelte';
import TooltipModal from '../modals/TooltipModal.svelte';
export let show: boolean;
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import TooltipModal from './modals/TooltipModal.svelte';
import { L1_CHAIN_NAME, L2_CHAIN_NAME } from '../../constants/envVars';
import TooltipModal from '../modals/TooltipModal.svelte';
export let show: boolean;
</script>
Expand All @@ -12,14 +13,9 @@
<ul class="list-disc ml-4">
<li class="mb-2">
<strong>Pending</strong>: Your asset is not ready to be bridged. Taiko
A2 => {import.meta.env
? import.meta.env.VITE_MAINNET_CHAIN_NAME
: 'Ethereum A2'} bridging can take several hours before being ready.
{import.meta.env
? import.meta.env.VITE_MAINNET_CHAIN_NAME
: 'Ethereum A2'} => {import.meta.env
? import.meta.env.VITE_TAIKO_CHAIN_NAME
: 'Taiko A2'} should be available to claim within minutes.
A2 => {L2_CHAIN_NAME} bridging can take several hours before being ready.
{L1_CHAIN_NAME} => {L2_CHAIN_NAME} should be available to claim within
minutes.
</li>
<li class="mb-2">
<strong>Claim</strong>: Your asset is ready to be claimed on the
Expand Down
Loading

0 comments on commit f5f7b7e

Please sign in to comment.