Skip to content

Conversation

@vyorkin
Copy link
Contributor

@vyorkin vyorkin commented Mar 9, 2025

  • paymaster transactions
  • Gasback

@vyorkin vyorkin self-assigned this Mar 9, 2025
@vyorkin vyorkin force-pushed the feature/add-native-bridge-WLT-5555 branch 2 times, most recently from 2c88d2e to 2d7eb48 Compare March 17, 2025 16:25
@vyorkin vyorkin marked this pull request as ready for review March 19, 2025 18:40
@github-actions
Copy link

github-actions bot commented Mar 19, 2025

📦 build.zip [updated at Apr 10, 3:54:04 PM UTC]

@vyorkin vyorkin requested review from everdimension and zerts March 19, 2025 21:25
Copy link
Collaborator

Choose a reason for hiding this comment

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

empty file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed ✅

import React from 'react';
import { animated, useTransition } from '@react-spring/web';

export function SlidingRectangle({
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like this component doesn't work :(

Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably because the animation works before image is loaded and shown

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, this didn't work before, so you don't need to fix it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added to the "tech debt" list, lets fix this in a separate PR

Copy link
Contributor

Choose a reason for hiding this comment

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

Uhm, what exactly isn't working? It seems to work for me in both Swap and Bridge forms

direction,
});

invariant(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check has been already made in config.ts file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks! updated ✅

}) {
const { currency } = useCurrency();

const asset = name === 'receiveInput' ? receiveAsset : spendAsset;
Copy link
Collaborator

Choose a reason for hiding this comment

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

May be it is the right time to deprecate receiveInput editing?
This feature is not well-supported and backend suggests not to use it if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wasn't aware that it isn't well-supported... It works perfectly in a swap form. Did you mean it isn't well supported only for bridge? Or in swap as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It is not well supported under the hood :(
For bridge it is not supported at all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I don't allow editing receiveInput in bridge, but regarding removing support for editing receiveInput in SwapForm... maybe lets discuss separately?

if (receiveChainInput) {
searchParams.append('output_chain', receiveChainInput);
}
if (slippage) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Slippage has been already defined on line 123 + there should be if (slippage != null) to allow 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, good catch, we always have slippagePercent (since we always have default slippage), so there is no need for this condition at all, updated ✅

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this just a copy of existing file with another props? Then we shouldn't forget to replace the previous on with this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated ✅

color: var(--neutral-500);
}

.reverseButton:focus .spinArrow {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This style triggers animation on focus, not on click. Which works with click but not with keyboard navigation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, I copied this part from webapp as is :)
I just removed :focus for now

@@ -0,0 +1,181 @@
import React from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

This state should be changed with the new pending animation. It was merged some time ago so may be is worth using here too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated ✅

title: string;
value: string;
networks: Networks | null;
openDialog: () => void;
Copy link
Collaborator

Choose a reason for hiding this comment

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

onClick or onDialogOpen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we have openDialog everywhere else (I mean in all variants of the DisclosureButton), so I decided to keep it as is

map[position.asset.asset_code] = position;
}

return { sorted, map };
Copy link
Collaborator

Choose a reason for hiding this comment

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

map: Object.fromEntries(sorted.map(position => ([position.asset.asset_code, position])));

Copy link
Collaborator

Choose a reason for hiding this comment

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

However, not important :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this code block used the for loop before I extracted the function, so I left this unchanged,
you think its worth changing to Object.fromEntries + .map? the loop should be more efficient afaik

receiverAddressInput?: string | null;
showReceiverAddressInput?: boolean;

gas?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Gas is not used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed gas field for now ✅

queryFn: () => getBridgeTokens({ inputChain, outputChain, direction }),
suspense: false,
retry: false,
enabled,
Copy link
Collaborator

Choose a reason for hiding this comment

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

May be it is better to type here enabled: Boolean(enabled) && Boolean(inputChain) && Boolean(outputChain)?
P.S. it is probably good that you restricted enabled no be not-undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, good idea, updated ✅

export class TransactionsApiError extends HTTPError {
static interpretError(parsedError: ParsedHttpError) {
if (parsedError.detail && parsedError.detail.length > 0) {
const [{ msg }] = parsedError.detail;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok, I see that this was taken from web app. Then let's hope it works correctly :))

Bridge
</UIText>
<span>
{isLoading && !quote ? (
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like we allow user to see and use quote when the loading is not done yet?
May be we need to add such check here and to the main form?

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it the point to show the progression of quotes? But we don't allow submit during isLoading

transaction={currentTransaction}
from={address}
chain={spendChain}
paymasterEligible={false}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's add // TODO: here to enable this one in the next releases

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added ✅


const positions = positionsResponse?.data ?? null;

const defaultFormValues = getDefaultFormValues({ networks, positions });
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's wrap this with useMemo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated ✅

network.id in positionDistribution
}
onChangeSourceChain={(value) =>
setUserFormState((state) => ({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do I understand right that this can be replaced with handleChange?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, thanks! updated ✅

}))
}
onChangeDestinationChain={(value) =>
setUserFormState((state) => ({
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vyorkin vyorkin force-pushed the feature/add-native-bridge-WLT-5555 branch 2 times, most recently from 5aaac0e to 6667062 Compare March 27, 2025 00:19
'spendInput',
'chainInput',
]);
const { receiveAsset, spendAsset } = swapView;
Copy link
Collaborator

Choose a reason for hiding this comment

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

these 2 vars can be extracted on line:28 :)
Not critical though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated ✅

>
<QuestionIcon
role="decoration"
role="presentation"
Copy link
Contributor Author

@vyorkin vyorkin Apr 9, 2025

Choose a reason for hiding this comment

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

changed to presentation, idk what that "decoration" role means, it is "presentation" in other places

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome thanks

explorerUrl={
hash ? networks.getExplorerTxUrlByName(spendChain, hash) : undefined
}
explorerUrl={explorerUrl ?? explorerFallbackUrl}
Copy link
Contributor Author

@vyorkin vyorkin Apr 9, 2025

Choose a reason for hiding this comment

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

as we discussed It makes more sense to display links like this when briding (instead of explorer link to the "send" (first/source) tx of only), but in case there is no explorer link available we still might want to show that fallback link

<UIText color="var(--primary)" kind="small/accent">
{quote?.estimated_seconds
? `~${formatSeconds(Number(quote.estimated_seconds))}`
{quote?.seconds_estimation
Copy link
Contributor Author

@vyorkin vyorkin Apr 9, 2025

Choose a reason for hiding this comment

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

estimated_seconds is deprecated, long live seconds_estimation

Comment on lines +442 to +445
const bridgeTransaction = useMemo(
() => (selectedQuote ? getQuoteTx(selectedQuote) : null),
[selectedQuote]
);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I extracted this getQuoteTx fn, looks like it doesn't make much sense to prepare that transaction data structure inside the useQuotes hook, it is like a separate concern...

enough_allowance?: boolean;
enough_balance: boolean;
slippage_type?: 'normal' | 'zero-slippage';
estimated_seconds?: string | null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

deprecated

output_amount_min: string;

token_spender: string;
exchanges: ExchangeWithName[] | null;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't find this field in the API docs and we don't use it

Comment on lines +38 to +39
input_asset_id: params.inputAssetId,
output_asset_id: params.outputAssetId,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

input_token and output_token parameters are deprecated and replaced with those having the _asset_id suffix

outputAssetId: receiveTokenInput,
inputPosition: spendPosition,
outputPosition: receivePosition,
sort: 'amount',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

By default we sort by the amount to prioritize the best quote

@vyorkin vyorkin force-pushed the feature/add-native-bridge-WLT-5555 branch from 0b2610d to c21d6ae Compare April 9, 2025 07:58
Comment on lines -43 to +44
width: 16,
height: 16,
width: 20,
height: 20,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is 20x20 in design

@vyorkin vyorkin force-pushed the feature/add-native-bridge-WLT-5555 branch from c21d6ae to e4b170e Compare April 9, 2025 08:04
address,
userSlippage,
primaryInput,
primaryInput: primaryInput ?? 'spend',
Copy link
Contributor Author

@vyorkin vyorkin Apr 9, 2025

Choose a reason for hiding this comment

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

There was an assumption for the primaryInput to be of type 'spend' anyway, let's make it explicit (less undefined types)

@vyorkin vyorkin force-pushed the feature/add-native-bridge-WLT-5555 branch from e4b170e to 5f89015 Compare April 9, 2025 08:11
@vyorkin vyorkin force-pushed the feature/add-native-bridge-WLT-5555 branch from b8f9340 to 4183422 Compare April 9, 2025 09:38
const { refetch: refetchQuotes } = quotesData;

const defaultQuote = quotesData.quotes?.[0] ?? null;
// TODO: add support for quote selection, useState
Copy link
Collaborator

Choose a reason for hiding this comment

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

I will have a hard merge...

position: 'relative',
width: 20,
height: 20,
// overflow: 'hidden',
Copy link
Collaborator

Choose a reason for hiding this comment

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

delete?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted ✅ thanks

transaction: bridgeTransaction,
quote,
refetch: refetchQuotes,
} = quotesData;
Copy link
Collaborator

@zerts zerts Apr 10, 2025

Choose a reason for hiding this comment

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

tbh, I think, I'll move quote selection logic inside quotesData when it is done. Just to avoid doubling the logic in swap/bridge ¯\_(ツ)_/¯

Comment on lines 73 to 75
if (params.refetchHash) {
searchParams.append('refetchId', params.refetchHash.toString());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed ✅ I don't even remember where I get this lines from

maxFee?: string;
sourceId?: string;
sort?: QuoteSortType;
refetchHash?: number;
Copy link
Contributor

Choose a reason for hiding this comment

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

rm?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 222 to 225
const { slippagePercent } = getSlippageOptions({
chain,
userSlippage,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

can be oneline

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vyorkin vyorkin merged commit 51aa48d into main Apr 10, 2025
3 checks passed
@vyorkin vyorkin deleted the feature/add-native-bridge-WLT-5555 branch April 10, 2025 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants