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: add wallet connection functionality #40

Merged
merged 49 commits into from
Aug 4, 2022
Merged

Conversation

kristiehuang
Copy link
Contributor

@kristiehuang kristiehuang commented Jun 21, 2022

Adding wallet connection functionality to widget! This means that every prop is now optional; a new integrator can now see a fully functional swap widget via <SwapWidget /> 😀

Remaining PRs that need reviews:

Breaking changes:

  • onConnectWallet prop changed to onConnectWalletClick
  • jsonRpcEndpoint prop changed to jsonRpcUrlMap

Other API changes:

  • new defaultChainId optional prop
  • provider prop now optional
  • new hideConnectionUI optional prop

wc

* feat: set up ui elements for wallet connect

* set up account avatar function

* structure connect wallet modal

* more ui updates for wc modal

* wip provider utils

* mm connection wip

* linter

* semi-working MM connection flow

* Implement Metamask connection

* minor alignment css

* Add WIP WC functionality

* Refactor useprovider fxn

* Add link to help center for nowallet

* Clean up useProvider

* Fix WalletConnect; need window.Buffer polyfill

* Fix WC connection

* Add mainnet RPC URL fallback constant

* Leave TODOs for readability

* Leave TODOs for readability

* Another todo

* Update yarn.lock

* Update .nvmrc for new @node/types

* Better modal layout UI

* Only use wallet if wallet is active

* Update yarn.lock

* Should only use our own flow iff provider & callbacks not given

* fix: refactor wallet connection components (#33)

* Refactor connect wallet into a separate component, and rename connect wallet callbacks

* Rename callbacks

* Fixes from PRs

* Remove fallback JSON RPC URL logic; move to separate PR

* Move web3 connection-related hooks into new folder

* Rename and move connect web3-related hooks

* fix: move updating Web3Context into hook (#34)

* wip

* Move context s.t. context is not exposed

* Clean commit

* Connect eagerly on mount

* Minor css

* Move components to Wallet

* Rename dialog buttons to wallet name

* Put network conditional back (fallback not implemented yet)

* Add back disabled prop

* Use e.preventDefault to determine opening our connection flow

* Clean up unused code

* nit

* Clean comments

* Don't deactivate other wallets before activating this one

* Update yarn.lock
@vercel
Copy link

vercel bot commented Jun 21, 2022

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

Name Status Preview Updated
widgets ✅ Ready (Inspect) Visit Preview Aug 4, 2022 at 6:02PM (UTC)

* Add useENSAvatar from interface, WIP identicon

* Only use gradient icon

* Remove broken useENSAvatar hook for now

* nit: update comments
@vercel vercel bot temporarily deployed to Preview June 22, 2022 16:00 Inactive
@vercel vercel bot temporarily deployed to Preview July 1, 2022 16:02 Inactive
…b3-react (#38)

* Add wip WC QR code; broken on second load

* wip: display_uri not fired on second load

* Clean code

* Add support for both tile & popup WalletConnect

* wip: use atom to save QR code between dialog close

* Add persisting QR code

* Update web3-react, wip handle errors

* broken:

* Add better RPC URL from props

* Clean up code

* Handle errors

* Clean up URI listeners

* Clean up code

* Update yarn.lock

* Undo force-changes to yarn.lock

* Nit

* Nit

* Address PR comments

* nit: rename useConnect handler

* remove reportError for new w3r

* add }

* Rename hooks
@vercel vercel bot temporarily deployed to Preview July 5, 2022 19:39 Inactive
* Use w3r's provider

* Use provider instead of library

* reformat

* Finalize changes

* Update useWeb3React imports

* Rename file

* PR review fixes

* Remove useConnectCallback fxn

* Revert w3r/network version
@vercel vercel bot temporarily deployed to Preview July 5, 2022 19:49 Inactive
* feat: add fallback mainnet JSON RPC endpoint

* Add better chainId support

* Clean up code

* nit: remove console .log

* PR review updates

* Remove console logs
@vercel vercel bot temporarily deployed to Preview July 5, 2022 20:02 Inactive
@vercel vercel bot temporarily deployed to Preview July 8, 2022 22:28 Inactive
@vercel vercel bot temporarily deployed to Preview July 8, 2022 22:42 Inactive
* fix: use safer QR image

* Use svg, change width

* nit

* fix: check staleness before setting state

* fix: color match qr code

* nit

Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
@vercel vercel bot temporarily deployed to Preview July 11, 2022 16:00 Inactive
@vercel vercel bot temporarily deployed to Preview July 12, 2022 23:30 Inactive
@vercel vercel bot temporarily deployed to Preview July 13, 2022 17:57 Inactive
@vercel vercel bot temporarily deployed to Preview July 13, 2022 17:59 Inactive
@vercel vercel bot temporarily deployed to Preview July 13, 2022 19:45 Inactive
@vercel vercel bot temporarily deployed to Preview July 13, 2022 19:55 Inactive
@vercel vercel bot temporarily deployed to Preview August 2, 2022 18:31 Inactive
@vercel vercel bot temporarily deployed to Preview August 2, 2022 22:36 Inactive
@@ -40,32 +42,36 @@ function getTransactionFromMap(
return
}

// SwapProps also currently includes props needed for wallet connection, since the wallet connection component exists within the Swap component
// TODO(kristiehuang): refactor WalletConnection outside of Swap component
Copy link
Member

Choose a reason for hiding this comment

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

Is this TODO still relevant?

Copy link
Contributor Author

@kristiehuang kristiehuang Aug 3, 2022

Choose a reason for hiding this comment

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

#123 - let me know if this PR makes sense

Wanted to pull wallet connection out of the Swap component since it's separate concerns -- and also makes it slightly easier to build Buy/Donate/etc widgets in the future

src/components/Widget.tsx Outdated Show resolved Hide resolved
Copy link
Member

@ianlapham ianlapham left a comment

Choose a reason for hiding this comment

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

Great work, havent gone though everything but just some small comments so far

src/state/swap.ts Outdated Show resolved Hide resolved
@vercel vercel bot temporarily deployed to Preview August 3, 2022 15:39 Inactive
@vercel vercel bot temporarily deployed to Preview August 3, 2022 16:17 Inactive
@vercel vercel bot temporarily deployed to Preview August 3, 2022 16:27 Inactive
@vercel vercel bot temporarily deployed to Preview August 3, 2022 18:58 Inactive
@vercel vercel bot temporarily deployed to Preview August 3, 2022 21:16 Inactive
Copy link
Contributor

@vm vm left a comment

Choose a reason for hiding this comment

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

this looks great to me! would wait on approvals from others

kristiehuang and others added 2 commits August 4, 2022 13:59
* wip tests; timeout?

* write tests

* Revert yarn.lock

* Update tests

* add newline

* fix: do not log failed connection after unmount

* Address PR review

* move hardhat account to const

* resolve provider toolbar flakiness

Co-authored-by: Zach Pomerantz <zzmp@uniswap.org>
@vercel vercel bot temporarily deployed to Preview August 4, 2022 18:02 Inactive
@kristiehuang kristiehuang merged commit ebe37e6 into main Aug 4, 2022
@github-actions
Copy link

github-actions bot commented Aug 9, 2022

🎉 This PR is included in version 2.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants