Integrate wallet-connect and add functionality to configure networks #3

Merged
ashwin merged 64 commits from wallet-connect-integration into main 2024-04-25 12:16:12 +00:00
Member

Part of WalletConnect Integration and Send txs in react app using laconic-wallet

  • Connect wallet to a dApp using WalletConnect
    • Add functionality to scan QR while connecting wallet
  • Sign message with cosmos accounts using signAmino and signDirect methods
  • Display active sessions on WalletConnect page
  • Add support for eth_sendTransaction method
  • Add WalletConnect method to send cosmos tokens
  • Support SIWE using selected account
  • Add functionality to configure networks
    • Once new network is added, one new account for the network is automatically generated
    • Auto populate chain details based on entered chain id
  • Update keystore data structure
    • Update data structure to store addresses for all the added chains
    • Send back selected network data in namespaces object if no namespaces is requested from dApp
    • Updated data structure
  • Fix intents to use namespace and chain ID
  • Add functionality to remove configured networks
  • Add functionality to edit networks
  • Use simulated gas for cosmos transactions
  • Take gas limit and fee values from user while approving transaction
Part of [WalletConnect Integration](https://www.notion.so/WalletConnect-integration-84b2f7377d514d7ead698bebd84f1e31) and [Send txs in react app using laconic-wallet](https://www.notion.so/Send-txs-in-react-app-using-laconic-wallet-a1a19d320f704e069477f172285c08cd) - Connect wallet to a dApp using WalletConnect - Add functionality to scan QR while connecting wallet - Sign message with cosmos accounts using `signAmino` and `signDirect` methods - Display active sessions on WalletConnect page - Add support for `eth_sendTransaction` method - Add WalletConnect method to send cosmos tokens - Support SIWE using selected account - Add functionality to configure networks - Once new network is added, one new account for the network is automatically generated - Auto populate chain details based on entered chain id - Update keystore data structure - Update data structure to store addresses for all the added chains - Send back selected network data in namespaces object if no namespaces is requested from dApp - [Updated data structure](https://gist.github.com/shreerang6921/71644e73c4bb4d68029a4ff72b85207c) - Fix intents to use namespace and chain ID - Add functionality to remove configured networks - Add functionality to edit networks - Use simulated gas for cosmos transactions - Take gas limit and fee values from user while approving transaction
nabarun added 64 commits 2024-04-25 11:57:43 +00:00
* Add page for scanning qr code

* Refactor code

* Ask for permission to use camera

* Change Qr to QR

* Seperate imports

* QR instead of Qr

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Connect with dapp using WalletConnect

* Pair dapp with wallet

* Sign message taken from dapp and return the signature

* Add todos

* Move wallet connect functions to seperate screen

* Change ui

* Change ui for wc modals

* Add styles

* Remove border radius at the bottom

* Make review changes

* Add dependancy to useEffect

* Move pairing modal methods

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Use existing accounts while pairing with dapp

* Listen for events emitted from dapp on every render

* Handle review changes
* Connect with dapp using WalletConnect

* Pair dapp with wallet

* Sign message taken from dapp and return the signature

* Add todos

* Move wallet connect functions to seperate screen

* Change ui for wc modals

* Make review changes

* Add dependancy to useEffect

* Move pairing modal methods

* Integrate QR in walletconnect page

* Move styles

* Add currentEthAddresses

* Handle review changes

---------

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Use context for maintaining accounts state

* Remove custom hook from context
* Use sign request page instead of modal

* Fix context

* Remove multiple if statements

* Change metadata

* Remove sign modal

* Make review changes

* Remove state

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Change button position

* Add check for counterId

* Display complete uri

* Update readme

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Add qr-code scanner button in homescreen header

* Display dapp details on sign request page

* Center details coming from dapp

* Remove request event state from request context
* Remove QRScanner component

* Remove unused variables

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Add toast on session_approval

* Handle case where request icon is null

* Change camera permission message

* Fix comments

* Fix import order

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
Part of https://www.notion.so/WalletConnect-integration-84b2f7377d514d7ead698bebd84f1e31

- Update intent URL to https://wallet.laconic.com/
- Move navigation to index.js

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
Reviewed-on: #2
Part of https://www.notion.so/WalletConnect-integration-84b2f7377d514d7ead698bebd84f1e31

- Use `react-native-config` library

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Reviewed-on: #1
* Add function to disconnect session

* Replace QR icon with WC logo

* Use separate page for walletconnect

* Change screen title

* Make review changes

* Make walletconnect page empty

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Add functionality to use cosmos accounts while pairing

* Sign message using cosmos accounts using signAmino method

* Add todo to debug signDirect

* Use cosmos wallet amino method directly

* Add back displaying wallet connect data while pairing

* Reset state for wallet connect data on closing pairing modal
* Sign message using signDirect method with cosmos accounts

* Add explaination for signDirect method

* Use existing utility function to convert hex string to uint8array

* Handle review changes
* Replace QR icon with WC logo

* Change screen title

* Display active sessions

* Change title

* Display sessions on WalletConnect page

* Display session topic in list item

* Fix types

* Add line

* Change message

* Move useEffect to WalletConnectContext

* Disconnect sessions on resetting wallet

* Review changes

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Display decoded message received while using signDirect method

* Fix permission dialog not exiting after clicking outside

* Handle review changes

* Remove optional chaining in while checking for signDirect method
* Replace QR icon with WC logo

* Change screen title

* Change title

* Display session topic in list item

* Move useEffect to WalletConnectContext

* Disconnect sessions on resetting wallet

* Update dapp session on adding account

* Update sessions inside useEffect

* Remove button from toast

* Clean up code

* Remove question mark

* Remove label from snackbar

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Replace QR icon with WC logo

* Change screen title

* Change title

* Display session topic in list item

* Move useEffect to WalletConnectContext

* Disconnect sessions on resetting wallet

* Update dapp session on adding account

* Update sessions inside useEffect

* Clean up code

* Remove question mark

* Handle all dapps getting updated

* Remove index from map

* Move hook to different folder

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Remove any type for requestEvent parameter

* Handle review changes
* Disconnect pairing request when app is reset

* Move files to respective folders

* Add comments to describe flow

* Add new line

* remove request session context

* Fix imports

* Move hook to folder

* Add undefined type

* Move types to src

* Move util functions to correct files

* Remove typeroots from tsconfig

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Add scrolling to pairing modal

* Set wallet connect state empty before populating

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Add support for eth send transaction method

* Add reference to eip155 data file
* Display funds on signRequest page

* Format balance value

* Display upto 18 digits

* Use useMemo for provider

* Display balance in wei

* Make UI changes

* Make review changes

* Add page to approve eth transactions

* Update approve transaction page ui

* Update balance unit display

---------

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
* Refactor method in account utils

* Make container height auto

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Add support to send cosmos tokens

* Fix approve transaction page ui

* Take gas amount from dApp

* Handle review changes

* Add check while creating stargate client

* Remove unnecessary checks

* Remove unnecessary states

* Fix balance showing undefined while loading
* Sign in using selected address

* Use optional namespace

* Merge namespaces and use combined namespace

* Add todo for lodash merge

* Use walletConnect util buildApprovedNamespaces while approving sessions

* Lint fixes

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
* Add spinner for tx

* Change text color
* Rebase ui branch

* Fix scrollview (#69)

* Add loading prop to button

* Change function reference

* Remove fragment

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
Co-authored-by: IshaVenikar <145848618+IshaVenikar@users.noreply.github.com>
* Add support for SVG images

* Fix imports

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Buttons outside scroll

* Fix ui for signRequest page

* Remove todo
* Configure EVM networks

* Display added EVM networks in network drop down

* Add network for configured networks
* Navigate to homescreen on approving sign request

* Add spinner to button on approve

---------

Co-authored-by: Adw8 <adwait@deepstacksoft.com>
* Add default values to networksData state

* Handle review changes

* Get default chains data from constants file
* Add support to configure cosmos networks

* Fix intents functionality for configured networks

* Add address prefix while initializing stargate client

* Remove unnecessary functions

* Update style for add network page

* Handle review changes

* Fix eth accounts not showing up on configured eth chain
* Update namespace

* Add eth accounts

* Add isSubmitted

* Send namespace to dApp based on selected network while pairing

* Send transactions on configured chain

* Fix modal UI

* Use namespace by default for chainId

* Use ethereum mainnet as default chain

* Use method names from constants file

* Combine required and optional namespaces

* Fix chainId

* Fix networksData

* Remove cosmos denom

* Remove todo

* Use lowercase denom

---------

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
* Store new network data

* Store default networks in keystore (#86)

* Add default nws in keystore

* Fix duplicate networks

* Display correct currency symbols for eth and cosmos tx

* Fix currency display

* Use wei for eth
* Update keystore data structure (#83)

* Update create wallet and retrieve accounts functionality for updated data structure

* Refactor accounts state

* Use constant variable for cosmos

* Update add accounts incrementally and with custom HD path for updated data structure (#85)

* Change data structure

* Reset wallet change

* Fix signEthMessage

* Fix sign request

* Fix pairing with laconic pay dApp and sending tokens

* Add accounts to configured networks

* Update add account from hd path flow

* Handle review changes

---------

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>

* Remove network type state

* Refactor create wallet code (#89)

* Refactor create wallet code

* Create cosmos accounts with correct address prefix

* Use networks data from state while creating wallet

* Refactor code and add network id in types (#91)

* Refactor add new networks component

* Add selected network state in context

* Remove returning account from create wallet

---------

Co-authored-by: IshaVenikar <145848618+IshaVenikar@users.noreply.github.com>
* Send networks data to dapp

* Reflect switching tabs in dapp dropdown

* Fix current network name not showing in Dapp

* Modify variable names

* Modify method and variable names

* Modify networks type

* Use selectedNetwork state and networkId

* Fix networks context states

* Add separate file for network methods
* Set current network to ethereum after removing network

* Display confirm dialog after deleting network

---------

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
* Autplopulate cosmos chain details from chain id

* Display rpc url

* Remove assert

* Make review changes

* Use watch to trigger function

* Use usewatch
* Auto-populate eth data from json file

* Modify variable names

* Clear fields if chainId is not found

* Format code

* Fix indentation

* Use reset to clear values

* Exclude chain id while resetting

* Make review changes

* Fix format
* Refactor pairing modal code

* Refactor update session code

* Reset state after session proposal is approved

* Refactor approve and update session

* Remove unused helper methods

* Remove completed todos
* Reset form upon switching nws

* Modify gitignore

* Fix undefined field error

* Add env steps in readme

* Remove .env file

* Fix indentation in readme

* Disable buttons while loading (#99)

* Disable buttons while loading

* Disable pairing modal button

* Format code
* Use configured coin type for creating accounts

* Resolve eslint warnings
* Use zod for validation

* Return to index 0 after deleting network

* Make url optional

* Use form schema according to the selected nw

* Fix type for networks data

* Accept numeric value for coin type

* Fix form type issue
* Fix spinner not showing up on starting wallet

* Remove unnecessary dependancies
* Check for unsupported namespace

* Add check for common walletchains and networks chains

* Format code

* Display unsupported chains

* Display Dapp info in modal

* Refactor code

* Reject request if chains are not supported

* Reject sessions

* Remove isVisible state
* Fix empty fields and url error msg

* Use constants for error msgs
* Add details to setup wallet connect in readme

* Add hyperlinks for wallet connect terms

* Handle review changes

* Add keystore data structure and troubleshooting steps in readme

* Update readme

* Add pre-commit lint hook

* Resolve linter warnings

* Handle review changes

* Fix heading level in readme
* Add edit network form

* Set selected network when networks are updated

* Disable buttons and add spinner after submitting

* Display previous values in Edit network form

* Use error msgs form constants file

* Reset default networks on reset
* Make block explorer url optional

* Make review changes

* Remove log
* Take gas limit and fees from user

* Update text input ui

* Use gasPrice from networks data

* Use default gas limit from env

* Use default gas price if not found in registry

* Remove appended denom in gas price

* Use gas limit from env

* Show error dialog when transaction fails

* Calculate gas limit and gas price if not received from dapp

* Update example env

* Improve syntax

---------

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
* Simulate gas limit for cosmos transactions

* Reject request if funds are not sufficient

* Fix submit button disable condition

* Dont estimate gas if funds are not sufficient for evm chains

* Handle review changes
* Fix gas limit type for evm chains

* Handle incorrect rpc url error

* Fix edit network form not working for evm chains
* Fix readme

* Remove fullstops and colons

* Don't link .env
* Make eth gas limit and gas price editable on approve transaction

* Make max fee and max priority fee editable for EIP 1559 supported chains

* Refactor approve transaction code

* Use gas limit from dapp if sent

* Refactor regex to constants file
ashwin merged commit e98b1e1f8e into main 2024-04-25 12:16:12 +00:00
ashwin deleted branch wallet-connect-integration 2024-04-25 12:16:12 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: cerc-io/laconic-wallet#3
No description provided.