feat: finish swap+send UI and handle transactions#23889
feat: finish swap+send UI and handle transactions#23889BZahory merged 60 commits intomb843/swap-and-sendfrom
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
572a8e7 to
0460f99
Compare
| address: PropTypes.string, | ||
| symbol: PropTypes.string, | ||
| decimals: PropTypes.number, | ||
| decimals: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), |
There was a problem hiding this comment.
What causes this to be a string? Can the value be normalized to a number on selection, before it's passed into this component?
There was a problem hiding this comment.
There's a mistype somewhere. The commit (a5a5417) was made in response to a console error (not thrown) regarding an invalid prop type being passed. Also doesn't hurt to have a bit of extra robustness anyways.
| setTokenDecimalValue(newTokenDecimalValue); | ||
| setFiatDecimalValue(newFiatDecimalValue); | ||
|
|
||
| // timeout intentionally not cleared so this always runs |
There was a problem hiding this comment.
What do you mean by this? Won't a new timeout always be created when the dependencies change anyway, assuming the component is not unmounted?
There was a problem hiding this comment.
Also, why is the timeout needed?
There was a problem hiding this comment.
If the dependencies update but Number(decimalizedHexValue) === Number(tokenDecimalValue) is true, then the timeout won't be ran after the update.
The ref doesn't update on the input state variable's (or any state variable's) cadence, so we need a delay to give the input – and its ref – time to update before checking.
ui/components/multichain/asset-picker-amount/asset-picker/asset-picker.tsx
Show resolved
Hide resolved
ui/components/multichain/asset-picker-amount/asset-picker-modal/asset-picker-modal.tsx
Outdated
Show resolved
Hide resolved
ui/components/multichain/asset-picker-amount/asset-picker-modal/asset-picker-modal.tsx
Outdated
Show resolved
Hide resolved
ui/components/multichain/asset-picker-amount/asset-picker-modal/asset-picker-modal.tsx
Outdated
Show resolved
Hide resolved
ui/components/multichain/asset-picker-amount/asset-picker-amount.tsx
Outdated
Show resolved
Hide resolved
ui/components/multichain/pages/send/components/quote-card/hooks/useEthFeeData.tsx
Outdated
Show resolved
Hide resolved
ui/components/multichain/pages/send/components/quote-card/hooks/useEthFeeData.tsx
Show resolved
Hide resolved
|
|
||
| const NATIVE_CURRENCY_DECIMALS = 18; | ||
|
|
||
| export default function useGetConversionRate() { |
There was a problem hiding this comment.
Are you adding unit tests for this?
There was a problem hiding this comment.
Yeah will do in the testing PR
| export default function useTranslatedNetworkName() { | ||
| const chainId = useSelector(getCurrentChainId); |
There was a problem hiding this comment.
Are you adding unit tests for this?
ui/components/multichain/pages/send/components/quote-card/hooks/useEthFeeData.tsx
Outdated
Show resolved
Hide resolved
ui/components/multichain/pages/send/components/quote-card/hooks/useEthFeeData.tsx
Outdated
Show resolved
Hide resolved
ui/components/multichain/pages/send/components/quote-card/hooks/useGetConversionRate.tsx
Outdated
Show resolved
Hide resolved
| draftTransactionInitialState.swapQuotesError; | ||
| draftTransaction.isSwapQuoteLoading = | ||
| draftTransactionInitialState.isSwapQuoteLoading; | ||
| draftTransaction.swapQuotesLatestRequestTimestamp = |
There was a problem hiding this comment.
Can the latestFetchTime value be derived from this?
There was a problem hiding this comment.
swapQuotesLatestRequestTimestamp is the time of the request, not the response. It's used for cleaning up multiple ongoing fetches
There was a problem hiding this comment.
is there an abort functionality we can use? similar to the AbortController in portfolio
There was a problem hiding this comment.
I tried that but the quotes kept coming through anyways sometimes IIRC
| const isSwapAndSend = | ||
| draftTransaction?.sendAsset?.details?.address !== | ||
| draftTransaction?.receiveAsset?.details?.address; |
There was a problem hiding this comment.
Selectors are created later in the file (i.e., after usage)
There was a problem hiding this comment.
Good point. Maybe an internal method then? This condition is used multiple times so that would keep them in sync and reusable
| const quotesAsArray = Object.values(quotes || {}); | ||
| if (isSwapQuoteLoading || swapQuotesError || !quotesAsArray.length) { | ||
| if (swapQuotesError || !quotesAsArray.length) { |
There was a problem hiding this comment.
Are the keys of quotes used? If not, it might make more sense to store the quotes as an array in state
There was a problem hiding this comment.
Is it fine if I revisit this once the best quote logic is finalized?
There was a problem hiding this comment.
sure, can you add it to the TODO list?
There was a problem hiding this comment.
Added in the next PR: aff8ab57c46d942cb0278ed7c42c8a59fe073eba
0460f99 to
d522fcb
Compare
Co-authored-by: micaelae <100321200+micaelae@users.noreply.github.com>
Co-authored-by: micaelae <100321200+micaelae@users.noreply.github.com>
Co-authored-by: micaelae <100321200+micaelae@users.noreply.github.com>
Co-authored-by: micaelae <100321200+micaelae@users.noreply.github.com>
Description
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist