Skip to content

Commit

Permalink
fix(bridge-ui-v2): processing fee and recipient not sticking (#15125)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Wang <[email protected]>
  • Loading branch information
KorbinianK and dantaik authored Nov 12, 2023
1 parent a0b3cbe commit e9b82ea
Show file tree
Hide file tree
Showing 8 changed files with 162 additions and 181 deletions.
2 changes: 1 addition & 1 deletion packages/bridge-ui-v2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ These are the additional configuration files that have to be filled in:
| **/config/configuredBridges.json** | Defines the chains that are connected via taiko bridges and lists the contract addresses |
| **/config/configuredChains.json** | Defines some metadata for the chains, such as name, icons, explorer URL, etc. |
| **/config/configuredRelayer.json** | If chains have a relayer, the URL and the chain IDs it covers are entered here |
| **/config/configuredCustomTokens.json** | Defines a list of tokens that should be available in the token dropdowns |
| **/config/configuredCustomTokens.json** | Defines a list of tokens that should be available in the token dropdowns |

---

Expand Down
1 change: 1 addition & 0 deletions packages/bridge-ui-v2/src/components/Bridge/Amount.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
}
export async function validateAmount(token = $selectedToken, fee = $processingFee) {
if (!$network?.id) return;
$validatingAmount = true; // During validation, we disable all the actions
$insufficientBalance = false;
$insufficientAllowance = false;
Expand Down
19 changes: 15 additions & 4 deletions packages/bridge-ui-v2/src/components/Bridge/NFTBridge.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
import RecipientStep from './NFTBridgeSteps/RecipientStep.svelte';
import ReviewStep from './NFTBridgeSteps/ReviewStep.svelte';
import type { ProcessingFee } from './ProcessingFee';
import { activeBridge, destNetwork as destinationChain, selectedNFTs, selectedToken } from './state';
import {
activeBridge,
destNetwork as destinationChain,
recipientAddress,
selectedNFTs,
selectedToken,
} from './state';
import { NFTSteps } from './types';
let amountComponent: Amount;
Expand All @@ -35,6 +41,8 @@
let contractAddress: Address | string = '';
let bridgingStatus: 'pending' | 'done' = 'pending';
let hasEnoughEth: boolean = false;
function onNetworkChange(newNetwork: Network, oldNetwork: Network) {
updateForm();
activeStep = NFTSteps.CONFIRM;
Expand Down Expand Up @@ -89,12 +97,13 @@
if (amountComponent) amountComponent.clearAmount();
if (processingFeeComponent) processingFeeComponent.resetProcessingFee();
if (addressInputComponent) addressInputComponent.clearAddress();
if (recipientStepComponent) recipientStepComponent.reset();
// Update balance after bridging
if (amountComponent) amountComponent.updateBalance();
if (nftIdInputComponent) nftIdInputComponent.clearIds();
$recipientAddress = $account?.address || null;
// $processingFee = 0n;
$selectedToken = ETHToken;
importMethod === null;
scanned = false;
Expand Down Expand Up @@ -198,6 +207,8 @@
onDestroy(() => {
resetForm();
});
$: activeStep === NFTSteps.IMPORT && resetForm();
</script>

<div class="f-col">
Expand All @@ -224,10 +235,10 @@
bind:validating={validatingImport} />
<!-- REVIEW STEP -->
{:else if activeStep === NFTSteps.REVIEW}
<ReviewStep on:editTransactionDetails={handleTransactionDetailsClick} />
<ReviewStep on:editTransactionDetails={handleTransactionDetailsClick} bind:hasEnoughEth />
<!-- RECIPIENT STEP -->
{:else if activeStep === NFTSteps.RECIPIENT}
<RecipientStep bind:this={recipientStepComponent} />
<RecipientStep bind:this={recipientStepComponent} bind:hasEnoughEth />
<!-- CONFIRM STEP -->
{:else if activeStep === NFTSteps.CONFIRM}
<ConfirmationStep bind:bridgingStatus />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
export let hasEnoughEth: boolean = false;
export const reset = () => {
recipientComponent.clearRecipient();
processingFeeComponent.resetProcessingFee();
recipientComponent?.clearRecipient();
processingFeeComponent?.resetProcessingFee();
};
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
let recipientComponent: Recipient;
let processingFeeComponent: ProcessingFee;
let hasEnoughEth: boolean;
export let hasEnoughEth: boolean;
const dispatch = createEventDispatcher();
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge-ui-v2/src/components/Icon/Icon.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
class={fillClass}
fill-rule="evenodd"
clip-rule="evenodd"
d="M14.0003 0.916748C6.7746 0.916748 0.916992 6.77436 0.916992 14.0001C0.916992 21.2258 6.7746 27.0834 14.0003 27.0834C21.2261 27.0834 27.0837 21.2258 27.0837 14.0001C27.0837 6.77436 21.2261 0.916748 14.0003 0.916748ZM15.0067 9.97444C15.0067 9.41862 14.5562 8.96803 14.0003 8.96803C13.4445 8.96803 12.9939 9.41862 12.9939 9.97444V12.9937H9.97468C9.41886 12.9937 8.96828 13.4443 8.96828 14.0001C8.96828 14.5559 9.41886 15.0065 9.97468 15.0065H12.9939V18.0257C12.9939 18.5815 13.4445 19.0321 14.0003 19.0321C14.5562 19.0321 15.0067 18.5815 15.0067 18.0257V15.0065H18.026C18.5818 15.0065 19.0324 14.5559 19.0324 14.0001C19.0324 13.4443 18.5818 12.9937 18.026 12.9937H15.0067V9.97444Z" />
d="m10,1.98C5.57,1.98,1.98,5.57,1.98,10s3.59,8.02,8.02,8.02,8.02-3.59,8.02-8.02S14.43,1.98,10,1.98Zm.62,5.55c0-.34-.28-.62-.62-.62s-.62.28-.62.62v1.85h-1.85c-.34,0-.62.28-.62.62s.28.62.62.62h1.85v1.85c0,.34.28.62.62.62s.62-.28.62-.62v-1.85h1.85c.34,0,.62-.28.62-.62s-.28-.62-.62-.62h-1.85v-1.85Z" />
{:else if type === 'circle'}
<circle class={fillClass} cx="10" cy="10" r="6" />
{:else if type === 'arrow-right'}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<span class="badge badge-primary badge-outline badge-xs px-[10px] h-[24px] ml-[10px]"
><span class="text-xs">{nftsGroup[0].type}</span></span>
</div>
<div class="token-ids mt-[16px] grid gap-4 grid-3">
<div class="token-ids mt-[16px] grid gap-4 grid-cols-3">
{#each nftsGroup as nft}
{@const collectionAddress = nft.addresses[chainId]}
{#if collectionAddress === undefined}
Expand Down
Loading

1 comment on commit e9b82ea

@vercel
Copy link

@vercel vercel bot commented on e9b82ea Nov 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

bridge-ui-v2-internal – ./packages/bridge-ui-v2

bridge-ui-v2-internal-taikoxyz.vercel.app
bridge-ui-v2-internal-git-main-taikoxyz.vercel.app
bridge-ui-v2-internal.vercel.app

Please sign in to comment.