Page MenuHomePhabricator

[Cashtab][Swap] Add swap component with SideShift integration
ClosedPublic

Authored by emack on Oct 31 2023, 06:47.

Details

Summary

T3322

For reals this time.

Adds the Swap component with SideShift being the first cab off the rank.

The SideShift button is also accessible on the Home onboarding screen when the user creates a new wallet with a zero balance.

In terms of the user closing the widget in the middle of a shift transaction (accidentally or otherwise), re-opening it via the same button will display the previous ongoing transaction for the user to complete the shift.

Test Plan
  • npm test
  • npm start
  • Create a fresh new wallet and observe the Exchange to XEC via SideShift button is rendered on the onboarding Home screen. Click it and observe successful rendering of the SideShift widget overlay.
  • Switch to an existing wallet with tx history and observe the Exchange to XEC via SideShift button is not rendered on the Home screen and instead has the expected Tx History displayed
  • Click on the hamburger menu and navigate to the Swap component. Observe the balance header is displayed and then open the SideShift dropdown and click the button to render the SideShift widget overlay
  • Start an USDT to XEC swap process Waiting for you to send USDT..., close the SideShift widget overlay, then re-click the Open SideShift button and ensure the previous incomplete swap process is still displayed.
  • Complete the USDT to XEC swap process and ensure the exchanged XEC is sent to the designated settlement eCash address.

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emack requested review of this revision.Oct 31 2023, 06:47
emack changed the visibility from "Public (No Login Required)" to "Restricted Project (Project)".Oct 31 2023, 06:47
emack planned changes to this revision.Oct 31 2023, 06:50
This comment was removed by emack.

Updated test snapshot for Home

Seems like this is as good as we can get with the widget implementation.

Are there any obstructions to doing a deeper integration using their API?

It's probably worth getting this in first, just so we have something available and can get an idea of demand. But also worth considering. If it's popular, we would want a Cashtab themed integration, and especially to pull in the user's address.

Provide overlay override as the default layout positions the close (X) button above the top browser bar

I'm not seeing this issue today. Maybe it was caused by toggling in and out of the dev panel and different frame sizes.

bytesofman added inline comments.
cashtab/src/components/Home/Home.js
157 ↗(On Diff #42867)

Should handle the case of this being undefined for whatever reason (mb the widget is broken, something has loaded improperly).

Need some kind of validation that window.sideshift is what we want it to be. If it isn't, some way to disable the button.

This revision now requires changes to proceed.Oct 31 2023, 19:33
emack marked an inline comment as done.

Added isValidSideshiftObj() along with unit tests to validation.js to check that the instantiated sideshift object contains the expected APIs. If not valid, an error is displayed in place of the button in Swap.js. This can be verified by malforming the sidieshift library url in /public/index.html header.

It's probably worth getting this in first

Yup agreed, we'll need to work in closely with their team for a deeper integration via their API. If you're thinking of Cashtab components and UI mimicing their widget then this'll be a decent chuck of work but doable.

I'm not seeing this issue today. Maybe it was caused by toggling in and out of the dev panel and different frame sizes.

I raised with the SideShift team yesterday via tg and they fixed it along with the cancel order bug.

emack changed the visibility from "Restricted Project (Project)" to "Public (No Login Required)".Nov 1 2023, 03:46

Setting the IFP address as the settlement address.

emack added inline comments.
cashtab/public/index.html
47 ↗(On Diff #42896)

@Mengerian to advise on official ABC id

I raised with the SideShift team yesterday via tg and they fixed it along with the cancel order bug.

dang very nice

  • parentAffiliatedId set to the official ABC account from Antony
  • Reverted settleAddress back to undefined otherwise the Receiving Address field will not be displayed in the widget. Whoever is managing the ABC account can just execute monthly withdrawals from the official account to the IFP address.

image.png (142×561 px, 7 KB)

bytesofman requested changes to this revision.Nov 6 2023, 22:20

image.png (169×393 px, 6 KB)

This doesn't work in the extension -- prob violates the security policy pulling in scripts from another website.

Back out the routing changes for the extension. If we implement it in the extension, will need to be with the API.

This revision now requires changes to proceed.Nov 6 2023, 22:20

Backing out extension changes

bytesofman requested changes to this revision.Nov 8 2023, 21:53
bytesofman added inline comments.
cashtab/src/components/Home/Home.js
229–231 ↗(On Diff #42967)

this should only appear if isValidSideshift(sideshift)

This revision now requires changes to proceed.Nov 8 2023, 21:53

calling 'accepted' as requested change is more of a nit

This revision is now accepted and ready to land.Nov 8 2023, 21:53