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

feat: walletconnect wallet #1733

Merged
merged 76 commits into from
Jul 20, 2022

Conversation

GMSteuart
Copy link
Contributor

@GMSteuart GMSteuart commented May 10, 2022

Description

Integrates WalletConnect wallet

UPDATE: Moved the provider object from hdwallet over to web since there is a scenario where the connect modal will hang indefinitely and there is no graceful way to automatically exit on behalf of the user. This indefinite situation occurs after the QR modal pops up and the user rejects the session. The reason this occurs is because the connector at the time is only listening for connect events and the only event emitted is the disconnect event; alas, the connector enters a state of waiting with no apparent end. The code of concern can be found in WalletConnect's web3-provider.

Notice

  • Have you followed the guidelines in our Contributing guide?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Pull Request Type

  • 🐛 Bug fix (Non-breaking Change: Fixes an issue)
  • 🛠️ Chore (Non-breaking Change: Doc updates, pkg upgrades, typos, etc..)
  • 💅 New Feature (Breaking/Non-breaking Change)

Issue (if applicable)

Closes #1686

Risk

  • UX exposure to WalletConnect bugs

Testing

Open a terminal for web and another for hdwallet.

# /hdwallet
yarn
yarn build
cd packages/hdwallet-walletconnect
yarn link
# hdwallet-walletconnect tests
 yarn test packages/hdwallet-walletconnect/src/walletconnect.test.ts
#  hdwallet-walletconnect integration tests
cd integration
yarn test src/walletconnect.test.ts
# /web
# clone this branch 
gh pr checkout 1733
yarn clean
yarn link "@shapeshiftoss/hdwallet-walletconnect"
# update package.json "@shapeshiftoss/hdwallet-walletconnect": "^1.21.2"
# to use filepath "@shapeshiftoss/hdwallet-walletconnect": "../hdwallet/packages/hdwallet-walletconnect"
# the above assumes your directory structure is setup like:
# .
# ├── hdwallet
# ├── lib
# └── web
yarn
open https://test.walletconnect.org/
yarn dev
  1. Sign in with some other wallet
  2. Go to flag settings
  3. Turn on WalletConnectWallet flag and save
  4. Disconnect from current wallet
  5. Go through wallet sign in process but select WalletConnect this time around

Screenshots (if applicable)

Screen Shot 2022-05-18 at 3 33 42 PM

Screen Shot 2022-05-18 at 3 34 36 PM

Screen Shot 2022-05-18 at 3 35 26 PM

@0xdef1cafe copy on pairing modal will need to be updated since a QR code pops up:

Screen Shot 2022-05-18 at 3 35 59 PM

Screen Shot 2022-05-12 at 3 41 20 PM

Screen Shot 2022-05-18 at 3 43 58 PM

On test.walletconnect.org
Screen Shot 2022-05-18 at 3 48 27 PM

Screen Shot 2022-05-18 at 3 51 06 PM

And lastly on test.walletconnect.org
Screen Shot 2022-05-18 at 3 51 53 PM

@GMSteuart
Copy link
Contributor Author

@0xdef1cafe will need product review for user flow when clicking WalletConnect option

@gomesalexandre
Copy link
Contributor

@GMSteuart I suppose this needs linking with shapeshift/hdwallet#529 for now, could you add some instructions for local testing until hdwallet-walletconnect is published?

@gomesalexandre
Copy link
Contributor

Also, seems like the diff touches many files/lines that shouldn't be modified by this PR, rebase/merge might help 👀

@GMSteuart
Copy link
Contributor Author

@GMSteuart I suppose this needs linking with shapeshift/hdwallet#529 for now, could you add some instructions for local testing until hdwallet-walletconnect is published?

Ya, I can add local testing steps, one of those will have to be running the associated hdwallet-walletconnect package that isn't published yet.

@GMSteuart
Copy link
Contributor Author

Also, seems like the diff touches many files/lines that shouldn't be modified by this PR, rebase/merge might help 👀

Oh fun. lol. Glad I'm finding out earlier in the day rather than later. Thanks for pointing that out. 🙂

@gomesalexandre
Copy link
Contributor

@GMSteuart I suppose this needs linking with shapeshift/hdwallet#529 for now, could you add some instructions for local testing until hdwallet-walletconnect is published?

Ya, I can add local testing steps, one of those will have to be running the associated hdwallet-walletconnect package that isn't published yet.

Built, linked, and ran web off the hdwallet PR branch but I'm seeing this, so I'm wondering whether or not there are more steps or something I missed:
image

package.json Outdated Show resolved Hide resolved
@sababa-2019
Copy link

bumping this, any updates here @GMSteuart ser?

@pastaghost pastaghost marked this pull request as ready for review June 3, 2022 18:26
@pastaghost pastaghost requested review from a team and 0xApotheosis as code owners June 3, 2022 18:26
@0xdef1cafe 0xdef1cafe marked this pull request as ready for review July 13, 2022 22:40
Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trust Wallet (derived ETH Account with ETH only):

  • Accounts/Account/Asset pages are properly working and showing the wallet ETH amount
  • Portfolio balance is properly shown
  • Tried an ETH self-send which properly went through, however, I'm getting a "User rejected the transaction" toast
  • Can't see any Tx history

MetaMask Wallet (derived ETH Account with ETH and ERC-20s):

  • Accounts/Account/Asset pages are properly working and showing the wallet ETH and ERC-20s amount
  • Portfolio balance is properly shown
  • Tried an ETH self-send which properly went through, however, I'm getting a "User rejected the transaction" toast
  • Can't see any Tx history

Keplr Mobile

Keplr also supports WalletConnect, and can be used to connect to e.g osmosis.zone. It isn't supported at all as the app is effectively in full skeleton mode for dashboard and has no loaded accounts in state.
Do we want to handle the case of Keplr Mobile (and Cosmos/Osmosis accounts derivation in WalletConnect) not being supported, by having some UX for it?

src/components/Modals/Send/views/Details.tsx Outdated Show resolved Hide resolved
src/components/Trade/TradeInput.tsx Outdated Show resolved Hide resolved
@pastaghost
Copy link
Collaborator

Keplr also supports WalletConnect, and can be used to connect to e.g osmosis.zone. It isn't supported at all as the app is effectively in full skeleton mode for dashboard and has no loaded accounts in state.
Do we want to handle the case of Keplr Mobile (and Cosmos/Osmosis accounts derivation in WalletConnect) not being supported, by having some UX for it?

This is because WalletConnect 1.0 (the version we've implemented in HDWallet) is ETH-only. WalletConnect 2.0 has multi-chain support but is still in beta. I'm currently looking to see if it is possible to either detect the user wallet connected on the other side of the WalletConnect bridge or to limit the set of wallets supported by the application via WalletConnect.

gomesalexandre
gomesalexandre previously approved these changes Jul 18, 2022
Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it again and managed to get connect, disconnect, and Txs (swaps/sends) working. Note that I didn't continue with actually broadcasting Txs and rejected the Tx confirm popup.

Only thing I've noticed is a little styling issue, we're missing right padding on the WalletConnect option but we can tackle it as a smallish follow-up. LGTM otherwise!

image

Approving this one even though this is still waiting for a product copy update, I'll re-stamp after. Logic looks good with the latest commits, good job ser!

🍬

@pastaghost
Copy link
Collaborator

  • Added copy to WalletConnect option in SelectModal.tsx
  • Constrained width of wallet option icons
  • Tested WalletConnect option text in all three possible configurations (no wallet active, walletConnect active, some other wallet active)

Screen Shot 2022-07-19 at 3 59 33 PM

Screen Shot 2022-07-19 at 3 59 16 PM

Screen Shot 2022-07-19 at 3 58 52 PM

gomesalexandre
gomesalexandre previously approved these changes Jul 20, 2022
Copy link
Contributor

@gomesalexandre gomesalexandre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested again with the latest changes, both the "Ethereum only" copy and WalletConnect option button look good.

🍬

@0xdef1cafe
Copy link
Collaborator

merging as previously approved by @gomesalexandre and the most recent commit was stylistic/trivial

@0xdef1cafe 0xdef1cafe merged commit dafd87d into shapeshift:develop Jul 20, 2022
stackedq pushed a commit that referenced this pull request Jul 21, 2022
* feat: init walletconnect integration

* chore: lint

* fix: wallet init

* fix: wallet init

* fix: add imagedelivery to headers

* chore: use package version

* chore: show/hide WalletConnect based on flag

* fix: headers for macos/ios safari

* fix: show feature flag nav item for alt host

* perf: add env var for better local development

* chore: remove unecessary code

* chore: remove package dep

* chore: add hdwallet-walletconnect alpha dependency

* fix: add walletconnect csp entries

* fix: utilize feature flag

* fix: add mobileEnabled field to WalletConnect config

* chore: run linter

* fix: remove usage of process.env

* chore: run linter

* fix: apply code review suggestions

* fix: use structured logging

* fix: apply code review suggestions

* fix: update csp for wallet logos

* chore: add flag to sample.env

* chore: yarn.lock

* docs: fleek info

* fix: img source csp

* chore: revert readme to develop

* fix: image fetched by walletconnect

* feat: WalletConnect rejection

* chore: lint

* chore: lint

* chore: update hdwallet-walletconnect dependency

* chore: upgrade hdwallet-walletconnect

* fix: set wc connect modal error to null on init

* chore: run linter

* fix: walletconnect refresh bug

* chore: upgrade hdwallet dependency

* chore: bump hdwallet dependencies

* fix: csp for walletconnect desktop logos

* chore: bump hdwallet package versions

* fix: disable trade max with walletconnect

* fix: disable sendmax with walletconnect

* chore: run linter

* chore: update hdwallet dependencies

* chore: run linter

* fix: hide fiat sendMax with WalletConnect

* fix: stylistic changes

* fix: typo

* feat: add copy to walletconnect option in selectmodal

* fix: constrain icon width for selectmodal options

* fix: update return value

Co-authored-by: pastaghost <[email protected]>
Co-authored-by: 0xdef1cafe <[email protected]>
0xdef1cafe added a commit that referenced this pull request Jul 25, 2022
* chore: update packages

* chore: add new headers

* feat: add new translations

* feat: add fiat market data

* feat: fetch fiat market data in app context

* chore: blacklist large things from redux store

* fix: more correct type defs and balance chart fixes

* chore: fix headers comment

* chore: consolidate to priceAtDate

* chore: only upgrade market service package

* chore: use same source of truth for mock test data as real data structure

* fix: optimizations and bug fixes

* fix: market data refetch

* chore: rename booleans for readability

* chore: tighter type def for setFiatMarketData

* chore: freeze initial price history for safety

* chore: uppercase const

* chore: consistent market data selector naming

* feat: view layer changes to support multi currency display

* feat: add currency selection to settings modal

* chore: add multi currency feature flag

* feat: balance chart changes

* chore: delete duplicate test with wrong file extension

* chore: cache fee asset selector

* Revert "chore: cache fee asset selector"

This reverts commit dfcd3d0.

* fix: revert chart loading behaviour

* fix: default fiatType to USD

* test: fix useLocaleFormatter test

* chore: delete unnecessary locale renderers

* chore: revert unnecessary changes to locale formatter

* fix: improved number formatting

* feat: currency format settings

* fix: test case fixed

* fix: improved input parsing

* chore: fix typo

* feat: walletconnect wallet (#1733)

* feat: init walletconnect integration

* chore: lint

* fix: wallet init

* fix: wallet init

* fix: add imagedelivery to headers

* chore: use package version

* chore: show/hide WalletConnect based on flag

* fix: headers for macos/ios safari

* fix: show feature flag nav item for alt host

* perf: add env var for better local development

* chore: remove unecessary code

* chore: remove package dep

* chore: add hdwallet-walletconnect alpha dependency

* fix: add walletconnect csp entries

* fix: utilize feature flag

* fix: add mobileEnabled field to WalletConnect config

* chore: run linter

* fix: remove usage of process.env

* chore: run linter

* fix: apply code review suggestions

* fix: use structured logging

* fix: apply code review suggestions

* fix: update csp for wallet logos

* chore: add flag to sample.env

* chore: yarn.lock

* docs: fleek info

* fix: img source csp

* chore: revert readme to develop

* fix: image fetched by walletconnect

* feat: WalletConnect rejection

* chore: lint

* chore: lint

* chore: update hdwallet-walletconnect dependency

* chore: upgrade hdwallet-walletconnect

* fix: set wc connect modal error to null on init

* chore: run linter

* fix: walletconnect refresh bug

* chore: upgrade hdwallet dependency

* chore: bump hdwallet dependencies

* fix: csp for walletconnect desktop logos

* chore: bump hdwallet package versions

* fix: disable trade max with walletconnect

* fix: disable sendmax with walletconnect

* chore: run linter

* chore: update hdwallet dependencies

* chore: run linter

* fix: hide fiat sendMax with WalletConnect

* fix: stylistic changes

* fix: typo

* feat: add copy to walletconnect option in selectmodal

* fix: constrain icon width for selectmodal options

* fix: update return value

Co-authored-by: pastaghost <[email protected]>
Co-authored-by: 0xdef1cafe <[email protected]>

* chore(deps): bump terser from 4.8.0 to 4.8.1 (#2197)

Bumps [terser](https://github.com/terser/terser) from 4.8.0 to 4.8.1.
- [Release notes](https://github.com/terser/terser/releases)
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/terser/terser/commits)

---
updated-dependencies:
- dependency-name: terser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

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

* feat: dogecoin (#2185)

* feat: dogecoin initial

* add dogecoin

* use p2pkh accountType for dgubs
add dogecoin else if to handleSend :(
add dogecoin case to handleSendMax :( :(

* wrap doge plugin in a feature flag

* pass chainId to utxoAccountParams

* remove reference to dogecoin testnet

* web clean up

* fix: update old utility to new caip method

* chore: add REACT_APP_FEATURE_DOGECOIN=true to sample.env

* fix: update swapper logic to pass correct param

* chore: version bump doge libs

* fix: add dogecoin label to accounts page

* fix: don't show tokens under dogecoin account

Co-authored-by: 0xdef1cafe <[email protected]>
Co-authored-by: Apotheosis <[email protected]>

* fix: typo and lodash import

* fix: conflict resolved

* feat: keeping order of fiat currencies and currency formats

* fix: applying suggested changes

Co-authored-by: stackedQ <[email protected]>
Co-authored-by: Grant Steuart <[email protected]>
Co-authored-by: pastaghost <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Adam Samere <[email protected]>
Co-authored-by: Apotheosis <[email protected]>
Co-authored-by: reallybeard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WalletConnect integration
5 participants