Skip to content
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

Publish Stage #3974

Merged
merged 6 commits into from
Nov 27, 2024
Merged

Publish Stage #3974

merged 6 commits into from
Nov 27, 2024

Conversation

JoseRFelix
Copy link
Collaborator

Changes

  • Add Penumbra provider
  • Enable 1-Click Trading from swap review modal
  • Enable other fee tokens for 1-Click Trading
  • (Behind FF) Add transaction tracking for Nomic BTC withdrawals

JoseRFelix and others added 6 commits November 23, 2024 09:11
* feat: add penumbra bridge provider

* fix: build

* fix: build
…3954)

* feat: add 1click trade panel to review order

* feat: handle 1CT status change

* refactor: move formatSpendLimit into utils/formatter.ts

* feat: make 1CT remainig time translations configurable

without breaking existing usages ... :)

* feat: add active 1CT session info to review order

* feat: 1CT settings modal scaffold w/ placeholder modal

the diff is big, but the change is simple -> better to separate

* feat: use the 1CT settings modal

* docs: why 2 signs needed after enabling 1CT on swap review

* refactor: move edit into a separate component

* refactor: use consistent naming for one click trading related concerns

* refactor: move remaining spend limit fetch into hook

* refactor: move session periods translations to oneClickTrading block

these defintions are reused in the review order screens too

* feat: add optional change tracking to useOneClickTradingParams

* fix: wait for `oneClickTradingInfo` to load when using it as inital value

there can't be a 1CT session without account address
but if we return early in the `useOneClickSession`, the default value
will stop the loading flag which introduces bugs down the line

e.g. In `useSessionParams` we use the `info`/`oneClickTradingInfo` to
set the inital params for the `transaction1CTParams` which the user can
start modifying or sending

this should reflect the params that the user has set when activated with
the last session but instead it's always set to the default value

with this change we can reliably wait until the `loading` is set to
false and then start setting the inital value

* fix: use params changes for create/change/edit 1CT params flow

- with the panel the user can toggle on/off the state of the
`transaction1CTParams`
- the user can modify the params
  - for a new session: when clicking on the change button
  - for existing session: when clicking on the overview
- we should send a 1CT tx if
  - the user has turned it on/off
    - when turning on we should use
      - use the default params unless user changes them
      - the changed params if any
  - user has made changes to the params and
    - had the feature turned on and haven't turned it off
    - has the feture turned on
    - has turned on the feature

* fix: <p> shouldn't be inside <p>

* fix: keep all the changes in 1CT settings

previously the current state was overwritten by the new and only the
last change was marked with green

* feat: make trpc logs configurable in dev mode

* fix: on rollback use inital params first and current params as fallback

* fix: discard current changes on settings modal close

* fix: update user settings after removing 1CT session

the `shouldUseOneClickTrading` from account base store is used in the
calculation is `isOneClickTradingEnabled` which is the basis of the
enabled state checking for 1CT session

* refactor: use change tracking by default in `useSessionParams`

it's cheap and simplifies the code

* refactor: drop shouldShow prop

* feat: implement exceeded error state

* refactor: use static translation keys

and don't calculate them from props

* fix: linter problems

* feat: update useOneClickTradingParams to update when input changes

now we can change the session parameters in 2 places so we need the
transaction1CTParams that we receive from the hook to always reflect the
latest state

unless there are changes made to the draft value of course

* feat: disable confirm button until 1CT session start loads

* feat: close review modal after 1CT enable

otherwise the review ui starts changing and updating for the enabled 1CT
which is confusing and misleading for the user

* fix: linter happiness is important

* fix: coderabbit suggestions

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Revert "fix: coderabbit suggestions"

This reverts commit f014e48.

* fix: coderabbit suggestion

with proper syntax

* fix: add nextparam check from coderabbit

* docs: update docs to follow the api

* fix: don't use remove display on create rollback

* refactor: give price formatter with symbol a descriptive name

* fix: review comments 1st batch

* docs: info about why spreading changes is necessary

* fix: wrap sendSwapTx in callback

* fix: add signOptions to estimate-tx-fees queryKey

the gas amount needed for the tx is different when using one click
trading so we need to update the estimated tx fee

* feat: sign only once when enabling 1Ct through review order

the `useAsync` adds some delay in picking up mobx store changes so we
need to wait for it a bit for the changes to properly propagate and the
`useSwap` to update before we can start executing the actual swap tx

otherwise we either need to sign the tx manually or the broadcast will
fail

* refactor: rework mobx <> 1CT session reactivity to be push based

The useSwap hook was not updating instantly after the create1CTSession
mutation, but before the onSuccess callback. This caused the next swap
transaction to either fail or not get signed properly through 1CT.

This could be worked around with waiting for the changes to propagate,
but that solution can be error prone.

To implement a proper fix, the logic for handling updates has been moved
into the mobx store. The `useOneClickTradingSession` now uses mobx’s
reaction() to react immediately to changes and update the state as soon
as it changes. This ensures that the session info is always available
and up to date after change — eg after create1CT mutation but before the
`onSuccess` callback.

The session data is stored as regular state, so any components using
this hook can rely on react’s built-in reactivity without needing to
work with mobx observables directly.

Finally, a useEffect is used to clean up resources when the component
unmounts.

* feat: use the updated 1CT session

* feat: before sending swap tx wait for networkfee to update

when enabling 1CT through the review order modal rarely it can happen
that the networkfee is refetching when the `sendTradeTokenInTx` is
called which can result in low gas fee for the tx

this safety measure gives networkfee a 1s safety buffer with 100ms
rechecks to update

* fix: add feature flag and new wallet checks

- don't show 1CT for new wallets that are without funding
- use the feature flag from launch darkly

* feat: read 1CT over spend params from simulation error

for some high volume tokens — eg OSMO — the token value is not included
in the spend limit

the source of truth for the tokens is the contract so we need to rely on
its error when running a simulation

* feat: remove 1CT spend limit error from swap tool

handling this concern is moved to the review order modal where the user
will be able to increase the spend limit during the swap flow

note: there was no option for the user to manually sign if 1CT is
enabled and there is spend limit error (they could proceed to the review
order modal, but there the confirm button was disabled)

if they want to proceed with the swap they need to increase the spend
limit

* feat: use swap simulation result in checking if swap would exceed limit

* fix: typo

* fixup! feat: read 1CT over spend params from simulation error

* fix: rabbit haunts the past

* Revert "refactor: rework mobx <> 1CT session reactivity to be push based"

This reverts commit 2758eef.

* Revert "feat: use the updated 1CT session"

This reverts commit 747dbc3.

* fix: typo

* docs: explain the refetch flow for 1CT session

* fix: don't include `isEnabled` in changes in 1CT settings standalone mode

isEnabled as a change is requied to be tracked in the review order modal
flow but in standalone mode when the modal is opened through the profile
the enabled toggle is treated differently from other parameter changes
and has its own lifecycle

* fixup! feat: sign only once when enabling 1Ct through review order

* fix: convert uusdc to usdc from over spend error

* fix: coderabbit

* fix: coderabbit

* Revert "fix: coderabbit"

This reverts commit f8ec361.

* fix: send log event on 1CT sesssion start from review order

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…odal (#3970)

* feat: create single tx to activate 1ct from swap review modal

* feat: remove unused methods

* fix: tx type

* feat: remove unused params

* improvements: coderabbit feedback
* feat: add events when creating 1CT session

* (1CT) Split txs for Ledger in swap review modal (#3972)

* feat: split txs for Ledger

* fix: wrong override

* feat: default to non ledger behavior

* improvement: naming

* improvement: typos
* feat: add Nomic withdrawal tx tracking

* feat: update nbtc minimal denom

* improvement: update ibc hash

* fix: bump nomic in web app

* feat: display nomic transfer in recent activity

* feat: improve estimated time

* feat: add provider fee, improve address validation and increase estimated time

* fix: revert name

* fix: revert temp change

* feat: wallet acknowledgement messages
Copy link

vercel bot commented Nov 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
osmosis-frontend ✅ Ready (Inspect) Visit Preview 3 resolved Nov 27, 2024 4:08pm
osmosis-frontend-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2024 4:08pm
osmosis-testnet ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 27, 2024 4:08pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
osmosis-frontend-datadog ⬜️ Ignored (Inspect) Nov 27, 2024 4:08pm
osmosis-frontend-edgenet ⬜️ Ignored (Inspect) Nov 27, 2024 4:08pm

@JoseRFelix JoseRFelix requested review from a team November 27, 2024 16:08
@JoseRFelix JoseRFelix merged commit e5e3ff4 into master Nov 27, 2024
600 of 608 checks passed
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