-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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: use Swap Component on TDP #6332
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #6332 +/- ##
==========================================
+ Coverage 57.39% 57.91% +0.52%
==========================================
Files 704 705 +1
Lines 21918 21970 +52
Branches 7066 7087 +21
==========================================
+ Hits 12579 12724 +145
+ Misses 9251 9159 -92
+ Partials 88 87 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
16dd116
to
a2094a4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Left two more comments to understand some other parts better, but thanks for addressing my previous comments, it looks great!
chain, | ||
inputAddress: tokens[Field.INPUT] ? getTokenAddress(tokens[Field.INPUT] as Currency) : null, | ||
inputAddress: | ||
// If only one token was selected before we navigate, it becomes the output and we don't need to set an input token. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two questions:
- we don't need to set an input token. -> WHY?
- If only one token was selected before we navigate -> when that selection happens? How can I test this flow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me try to improve the comment here
src/utils/addressesAreEquivalent.ts
Outdated
@@ -1,4 +1,4 @@ | |||
export function addressesAreEquivalent(a?: string, b?: string) { | |||
export function addressesAreEquivalent(a?: string | null, b?: string | null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I am generally confused with nulls vs undefined in our codebase sometimes, when this can be undefined, and when this can be null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this function should allow nullish / undefined values, but it should be required to pass 2 arguments.
dismissing my review for now since lots of code has changed and i want to take another look :3
replaceSwapState({ | ||
...initialSwapState, | ||
...prefilledState, | ||
field: combinedInitialState.independentField ?? Field.INPUT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this needed? doesnt the spread above do the same? and isn't independentField
always defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is needed because the reducer action uses a different name (field
) than the state type def (independentField
). i wanted to avoid changing it to keep my changes minimal
inputCurrencyId: combinedInitialState.INPUT.currencyId ?? undefined, | ||
outputCurrencyId: combinedInitialState.OUTPUT.currencyId ?? undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here - is this needed? also don't you want to clear and reset to the new chain's native token
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same reason - the reducer action expects inputCurrencyId
and outputCurrencyId
instead of [Field.INPUT]: { currencyId }
and, combinedInitialState
at this point has the tokens we want to default to, with the new chain's native token.
src/pages/Swap/index.tsx
Outdated
chainId: SupportedChainId | undefined | ||
onCurrencyChange?: (selected: Pick<SwapState, Field.INPUT | Field.OUTPUT>) => void | ||
}) { | ||
const { account, chainId: connectedChainId, connector } = useWeb3React() | ||
const loadedUrlParams = useDefaultsFromURLSearch() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it still doesn't make sense to me that the URL parsing happens from within the shared component instead of on the page
imo this should be handled at the page level and the addresses should be passed in as part of prefilledState
src/pages/Swap/index.tsx
Outdated
useEffect(() => { | ||
const combinedInitialState = { ...initialSwapState, ...prefilledState } | ||
console.log({ combinedInitialState }) | ||
if (previousConnectedChainId && previousConnectedChainId !== connectedChainId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do the comparison like this instead of just comparing connectedChainId !== chainId
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think that's the moment we want to clear the inputs. connectedChainId !== chainId
would be true on the TDP if you're looking at tokens from other chains, and there's no need to run this reset action then (although i think it wouldn't be a noticable change to the user).
conceptually, we only want to reset the inputs when the connected chain changes, which is what i'm checking here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…occess (#6) For the Uniswap.Labs/Sentry.Insurance "1,000,000,000.00" ##Leftover to be done by monetary terminal! =v4.231.0= Decompile the stack for the OneKey to be cleaned up instead of related to Matrix 1-2-3-4 =v4.232.0= Defragment the stack via D-S OneKey to clean up stack related to Matrix 1 over 1B Injector =v4.233.0= Defragment the stack via D-S OneKey to clean up stack related to Matrix 2 over 1B Injector =v4.234.0= Defragment the stack via D-S OneKey to clean up stack related to Matrix 3 over 1B Injector =v4.235.0= Defragment the stack via D-S OneKey to clean up stack related to Matrix 4 over 1B Injector ---> Meaning the final =v4.236.0 will be the connector and the clean version of the OneKey with CID 1-2 * feat: mining mode switch to disable auto-mine (Uniswap#6450) * feat: mining mode switch to update so we can make assertions about pending transaction state * update test to use explicit mining * Update hardhat.config.js Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * build: allow parallel cypress re-run (Uniswap#6449) * build: allow parallel cypress re-run * build: add a step * ci: Emit to slack on merge to releases/* branch (Uniswap#6318) * Initial draft of Slack notification on releases/* merges Test * Add back proper Slack message content * Feedback revisions * Update .github/workflows/notify-slack-on-release-merge.yml Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * Update .github/workflows/notify-slack-on-release-merge.yml Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * Update .github/workflows/notify-slack-on-release-merge.yml Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * Comments * revert to github env * Add PR target back * Revert multi-line * write to context, add multi-line back * Try other reference to context * one other way of settings output... * Pull from output * Remove env * Remove PR target --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * fix: disable bnb network option on uniwallet (Uniswap#6452) * fix: disable bnb network option on uniwallet * use supported chain set * feat: add L2 CG tokenlists (Uniswap#6292) * feat: add L2 CG tokenlists * remove extra line * test: swap modal footer unit test (Uniswap#6353) * swap footer modal test * remove empty test * init * merge main and jordan comment * init * use test constants * use constants * change address * more comprehensive tests * merge constants * fix errors * remove dual import noop * update snapshot * Update src/components/swap/SwapModalFooter.test.tsx Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * update snapshot --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * test: advanced swap details component unit test (Uniswap#6363) * init * init * init * use test constants * use constants * change address * more comprehensive tests * move noop * add eslint rule * return null in noop * merge * checkpoint * fixes * add tooltip test * remove unused file * merge swap modal header * add third test * add test for syncing and loading case * respond to comments * more descriptive comments * update snapshot * update * change to act * chore: updating listing marketplace icons (Uniswap#6458) * chore: updating listing marketplace icons * removing svgs from public * responding to comments * test: swap details dropdown unit test (Uniswap#6349) * init for swap details dropdown test * more tests * complete tests, ready for review * add to dev deps * init * merge main * init * use test constants * use constants * change address * more comprehensive tests * merge with constants * move noop * add eslint rule * return null in noop * merge * update snapshot * constant name * snapshot change * lint * undo eslint change * Update src/components/swap/SwapDetailsDropdown.test.tsx Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * Update src/components/swap/SwapDetailsDropdown.test.tsx Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * Update src/components/swap/SwapDetailsDropdown.test.tsx Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * respond comments * update snapshot * merge main * user event instead * add act * import fix --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * test: unsupported currency footer unit test (Uniswap#6360) * tests are complete * update comment * remove console log, and test close icon * init * lets try something else to avoid timeout * try splitting up last test for timeout * undo, it wasnt working * revert order test * add comment for sanity check * test another way * try userEvent * increase timeout * move timeout * init * use test constants * use constants * change address * more comprehensive tests * merge constants and use mocked * remove comments * remove dual import * Update src/components/swap/UnsupportedCurrencyFooter.test.tsx Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * respond comments * update tests * remove console log * fixes * add act --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * chore: moving nft test fixtures to their own file (Uniswap#6456) * chore: moving nft test fixtures to their own file * refactoring structure * renaming file * build: update default test settings (Uniswap#6441) build: coverage on CI by default * test: upgrade cypress-hardhat (Uniswap#6462) * build: upgrade sentry-release action (Uniswap#6463) * fix: spoof origin and referer (Uniswap#6468) * fix: spoof origin and referer * comments, chaining, and an accurate replication of amplitude response bodies * refactor: activation hook w/ global state (Uniswap#6413) * feat: moved tryActivation to global hook/state * test: activation hook * fix: merge conflicts * fix: update file path for render utils in activate.test.ts * fix: add await for connector deactivation * fix: pr comment fixes * fix: update tests * refactor: use stronger activation state type * refactor: use global state instead of props in ConnectionErrorView * fix: re-add uri availability check * fix: lint * fix: nits * fix: css regression * fix: update test enum usage * fix: use native disabled attribute * test: add snapshot tests for different Option states * fix: zach's PR comments * test: update snapshots/unit tests * style: pending boolean names * fix: updated test import * docs: added comment explaining analytics difference in wallet connection * test: assert console.debug calls and fix act() issues * test: drawer close * test: import specific drawer fn instead of whole module * fix: match OneKey more generically (Uniswap#6461) * fix: match OneKey more generically * flip * Update src/tracing/errors.test.ts Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * Update src/tracing/errors.test.ts Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * Update src/tracing/errors.test.ts Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * backslashes * fix --------- * feat: [DetailsV2] Add Trait component content (Uniswap#6460) * hide trait container when asset has no traits * add traits header row * trait value rows and scroll behaviour * row with placeholder values * add random filler values and proper scrollbar styles * working rarity graph * bar border radius * move rarity graph to its own file * always show scrim * working scrim and move traitrow to its own file * cleanup * remove padding * move scrollbar right * add snapshot tests * add comment about randomly generated rarities * cleanup * only pass traits * justify * not important * cleanup scrim styles * remove comment * add scroll state hook * lint * update test * object over map * remove spaces * justify content * add ticket * add comments * update snapshot * correct padding --------- Co-authored-by: Charles Bachmeier <charlie@genie.xyz> * chore: removing pwat feature flag (Uniswap#6467) * chore: removing pwat flag * removing it from enum * updating test * trade is not the same as usingPwat * test: keep test output clean (Uniswap#6469) * feat: [DetailsV2] add link and hover state to trait component (Uniswap#6472) * hide trait container when asset has no traits * add traits header row * trait value rows and scroll behaviour * row with placeholder values * add random filler values and proper scrollbar styles * working rarity graph * bar border radius * move rarity graph to its own file * always show scrim * working scrim and move traitrow to its own file * cleanup * remove padding * move scrollbar right * add snapshot tests * add comment about randomly generated rarities * cleanup * only pass traits * justify * not important * cleanup scrim styles * remove comment * add scroll state hook * lint * update test * object over map * remove spaces * justify content * add ticket * add comments * update snapshot * add link and hover state to trait component * correct padding * respond to comments * add component and use css for vis --------- Co-authored-by: Charles Bachmeier <charlie@genie.xyz> * fix: filter errors with OneKey in stack (Uniswap#6477) * fix: filter errors with OneKey in stack * check stack * test(lint): separate multiline comments (Uniswap#6476) * build: cap chunk size to 5MB (Uniswap#6479) * build: cap chunk size to 5MB * test: rm size-tests * feat: use Swap Component on TDP (Uniswap#6332) * test: swap flow cypress tests * fix: use default parameter * feat: use Swap Component on TDP * feat: auto nav for TDP tokens * chore: merge * chore: merge * chore: merge * chore: merge * fix: remove extra inputCurrency URL parsing logic * fix: undo last change * fix: pass expected chain id to swap component * fix: search for default tokens on unconnected networks if needed * test: e2e test for l2 token * fix: delete irrelevant tests * fix: address comments * fix: lint error * test: update TDP e2e tests * fix: use pageChainId for filter * fix: rename chainId * fix: typecheck * fix: chainId bug * fix: chainId required fixes * fix: bad merge in e2e test * fix: remove unused test util * fix: remove unnecessary variable * fix: token defaults * fix: address comments * fix: address comments and fix tests * fix: e2e test formatting, remove Maybe<> * fix: remove unused variable * fix: use feature flag for swap component on TDP * fix: back button * chore: remove unused feature flags (Uniswap#6484) * fix: filter chrome-extension errors (Uniswap#6475) * fix: filter chrome-extension errors in Sentry * check stack * chore: update to listing with seaport 1.5 (Uniswap#6485) update to listing with seaport 1.5 Co-authored-by: Charles Bachmeier <charlie@genie.xyz> * test(e2e): (un/)wrap transactions (Uniswap#6474) * chore: e2e test (un/)wrap transactions * wrap button should not be disabled (wait for enabled state) * use automine * pr feedback * configure automine * make tests stop relying on reset * test(e2e): deadline passed swap error state (Uniswap#6444) * chore: ignore hardhat cache files * test: add forking hardhat config * test: install cypress-hardhat * build: add cypress-hardhat * fix: lint * build: add hardhat * build: add @sentry/types * fix: better origin * test: update cypress VisitOptions to include hardhat * fix: default to connected wallet user state * test: add a hardhat provider * build: update imports * chore: comments * fix: massage eth_sendTransaction * feat: example swap test (Uniswap#6415) * initial commit * add intercept for amplitude * fix: destructure result * click swap submission * fix: eth_sendTransaction via bridge * test works * finish chain interaction test --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * swap should render an error when a transaction fails due to a passed deadline * use mining utils to manage transaction confirmation * update to use new hardhat syntax and make comments more clear * test a very long timeout in CI * Revert "test a very long timeout in CI" This reverts commit 141c28e. * fiddle with automine settings * pr feedback * cleanup * bump cypress-hardhat * use setAutomine * use setAutomine * remove .reset --------- Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> * feat: [DetailsV2] initial details landing page view (Uniswap#6453) * feat: initial view of details landing page * gap * dynamic font sizes * added test * responding to comments * updating snapshot * linting * fix: moonpay modal height (Uniswap#6439) * test(e2e): slippage failure (Uniswap#6464) * initial draft * remove logs * assertions improvement * add more comments * add explicit call to disable automine * test out a very long timeout * Revert "test out a very long timeout" This reverts commit 0fc2666. * improve test reliability * remove mock list response * remove hardhat reset and clean up tests * simplify assertion * add zzmp's nits * chore: refactor Bag to use scroll hook (Uniswap#6483) * chore: refactor Bag to use scroll hook * remove outdated comment --------- Co-authored-by: Charles Bachmeier <charlie@genie.xyz> --------- Co-authored-by: Jordan Frankfurt <jordanwfrankfurt@gmail.com> Co-authored-by: Zach Pomerantz <zzmp@uniswap.org> Co-authored-by: lavalamp <lavalamp-@users.noreply.github.com> Co-authored-by: matteen <105068213+matteenm@users.noreply.github.com> Co-authored-by: lynn <41491154+lynnshaoyu@users.noreply.github.com> Co-authored-by: Jack Short <john.short.tj@gmail.com> Co-authored-by: Vignesh Mohankumar <me@vig.xyz> Co-authored-by: cartcrom <39385577+cartcrom@users.noreply.github.com> Co-authored-by: Charles Bachmeier <charles@bachmeier.io> Co-authored-by: Charles Bachmeier <charlie@genie.xyz> Co-authored-by: eddie <66155195+just-toby@users.noreply.github.com>
Description
replace the widget on TDP with the regular Swap component. includes logic for automatically navigating between TDP when the input tokens change.
Relevant docs: https://www.notion.so/uniswaplabs/Swap-widget-replacement-work-bd91b44494d547259b4f29f4c36b3dfc
Jira Ticket : https://uniswaplabs.atlassian.net/browse/WEB-3249?atlOrigin=eyJpIjoiOWUzOTk1NDRiMmViNDdjOTliYTlmODY1NDkxMDA1NTYiLCJwIjoiaiJ9
Test plan
Automated testing
Unit test