-
Notifications
You must be signed in to change notification settings - Fork 177
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: thorchain streaming swap progress bar #5192
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
eba708a
to
027c0f7
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.
Code-wise looking good, will do a functional pass now.
src/components/MultiHopTrade/hooks/useThorStreamingProgress/useThorStreamingProgress.tsx
Outdated
Show resolved
Hide resolved
src/components/MultiHopTrade/hooks/useThorStreamingProgress/useThorStreamingProgress.tsx
Outdated
Show resolved
Hide resolved
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.
isAnimated: !isComplete, | ||
colorScheme: isComplete ? 'green' : 'blue', | ||
}, | ||
attemptedSwaps: count ?? 0, |
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.
Wondering if this is the best vernacular, these were not attempted but actually completed internal swaps?
src/components/MultiHopTrade/hooks/useThorStreamingProgress/useThorStreamingProgress.tsx
Outdated
Show resolved
Hide resolved
src/components/MultiHopTrade/hooks/useThorStreamingProgress/useThorStreamingProgress.tsx
Show resolved
Hide resolved
Tangentially, is this monkey patched? Such a small swap should obviously not show up as a streaming swap option |
quantity?: number | ||
count?: number |
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.
These seem undefined for non-streaming swaps, can we perhaps use them as discriminator on whether or not to use the progress bar / "Loading" copy?
Waited a few minutes to ensure the Tx status is properly picked by the THOR node and still got the same response.
This might be an edge case, but may be nice to tackle regardless 🙏🏽
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.
In this case I erred on the side of safety and used the schema from the swagger docs to define them as optional or required, and it seems there are no required fields defined for this response.
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.
Tested locally, LGTM minus a few naming/types comments and a possible improvement of the flow. Didn't test the actual progress bar with a large swap because something something testing funds, will leave this for ops testing.
Non-streaming swap
- Such regular swaps correctly have no "Loading" nor progress bar
Streaming swaps
Tested with the following monkey-patch
diff --git a/src/lib/swapper/swappers/ThorchainSwapper/getThorTradeQuote/getTradeQuote.ts b/src/lib/swapper/swappers/ThorchainSwapper/getThorTradeQuote/getTradeQuote.ts
index a2e8e57910..708f7d8d21 100644
--- a/src/lib/swapper/swappers/ThorchainSwapper/getThorTradeQuote/getTradeQuote.ts
+++ b/src/lib/swapper/swappers/ThorchainSwapper/getThorTradeQuote/getTradeQuote.ts
@@ -160,9 +160,7 @@ export const getThorTradeQuote = async (
const perRouteValues = [getRouteValues(swapQuote, false)]
- streamingSwapQuote &&
- swapQuote.expected_amount_out !== streamingSwapQuote.expected_amount_out &&
- perRouteValues.push(getRouteValues(streamingSwapQuote, true))
+ streamingSwapQuote && perRouteValues.push(getRouteValues(streamingSwapQuote, true))
const getRouteRate = (expectedAmountOutThorBaseUnit: string) => {
const THOR_PRECISION = 8
Can confirm the flow stated by @0xApotheosis above, though I believe this to be an inherent issue of testing this with a monkey-patched streaming swaps for small amounts that aren't actually streaming. Added a possible fix for it in https://github.com/shapeshift/web/pull/5192/files#r1312857963
Yep, she was indeed monkey patched! |
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.
Approved as the current issues are intended. Address the suggestions at your discretion.
For reference some of the quirks are noted here for fix in follow-up 🙂 |
1cd9b07
to
6fd8856
Compare
Description
This adds a progress bar to thorchain streaming swaps.
Includes progress bar and ability to convey the concept of partial fulfilment with reasons for each failure - a value add over viewblock and other interfaces.
Pull Request Type
Issue (if applicable)
closes #5191
Risk
Risk of broken trade confirmation UI
Testing
Engineering
☝️
Operations
☝️
Screenshots (if applicable)
Before confirmation
On confirmation
On streaming data loaded
On send tx confirmed
Progress increasing, matches viewblock
Streaming complete