chore: updated @walletconnect deps (#164)
* chore: updates auth dapp * chore: updates react sign dapp * chore: updates cosmos dapp * chore: updates ethers dapp * chore: updates web3js dapp * chore: updates vue auth dapp * chore: updates auth wallet * chore: updates eip155 wallet * updates react-wallet-v2 * chore: updates web3wallet example * feat: adds optional namespaces to main example wallet * chore: eip155 example lock * chore: removes console log --------- Co-authored-by: Gancho Radkov <ganchoradkov@gmail.com>
This commit is contained in:
co-authored by
Gancho Radkov
parent
dcda7dd981
commit
d8ebe4509b
@@ -14,8 +14,8 @@
|
||||
"@walletconnect/client": "1.8.0",
|
||||
"@walletconnect/legacy-types": "2.0.0",
|
||||
"@walletconnect/web3wallet": "1.7.0",
|
||||
"@walletconnect/core": "2.7.2",
|
||||
"@walletconnect/utils": "2.7.2",
|
||||
"@walletconnect/core": "^2.7.6",
|
||||
"@walletconnect/utils": "2.7.6",
|
||||
"ethers": "5.7.2",
|
||||
"framer-motion": "9.0.2",
|
||||
"next": "13.1.6",
|
||||
@@ -28,7 +28,7 @@
|
||||
"devDependencies": {
|
||||
"@types/node": "18.13.0",
|
||||
"@types/react": "18.0.28",
|
||||
"@walletconnect/types": "2.7.2",
|
||||
"@walletconnect/types": "2.7.6",
|
||||
"eslint": "8.34.0",
|
||||
"eslint-config-next": "13.1.6",
|
||||
"eslint-config-prettier": "8.6.0",
|
||||
|
||||
@@ -3,6 +3,7 @@ import ModalStore from '@/store/ModalStore'
|
||||
import SettingsStore from '@/store/SettingsStore'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { SignClientTypes } from '@walletconnect/types'
|
||||
import { Web3WalletTypes } from '@walletconnect/web3wallet'
|
||||
import { useCallback, useEffect } from 'react'
|
||||
import { useSnapshot } from 'valtio'
|
||||
|
||||
@@ -12,43 +13,37 @@ export default function useWalletConnectEventsManager() {
|
||||
/******************************************************************************
|
||||
* 1. Open session proposal modal for confirmation / rejection
|
||||
*****************************************************************************/
|
||||
const onSessionProposal = useCallback(
|
||||
(proposal: SignClientTypes.EventArguments['session_proposal']) => {
|
||||
ModalStore.open('SessionProposalModal', { proposal })
|
||||
},
|
||||
[]
|
||||
)
|
||||
const onSessionProposal = useCallback((proposal: Web3WalletTypes.SessionProposal) => {
|
||||
ModalStore.open('SessionProposalModal', { proposal })
|
||||
}, [])
|
||||
|
||||
/******************************************************************************
|
||||
* 3. Open request handling modal based on method that was used
|
||||
*****************************************************************************/
|
||||
const onSessionRequest = useCallback(
|
||||
async (requestEvent: SignClientTypes.EventArguments['session_request']) => {
|
||||
console.log('session_request', requestEvent)
|
||||
const { topic, params } = requestEvent
|
||||
const { request } = params
|
||||
const requestSession = web3wallet.getActiveSessions()[topic]
|
||||
const onSessionRequest = useCallback(async (requestEvent: Web3WalletTypes.SessionRequest) => {
|
||||
console.log('session_request', requestEvent)
|
||||
const { topic, params } = requestEvent
|
||||
const { request } = params
|
||||
const requestSession = web3wallet.getActiveSessions()[topic]
|
||||
|
||||
switch (request.method) {
|
||||
case EIP155_SIGNING_METHODS.ETH_SIGN:
|
||||
case EIP155_SIGNING_METHODS.PERSONAL_SIGN:
|
||||
return ModalStore.open('SessionSignModal', { requestEvent, requestSession })
|
||||
switch (request.method) {
|
||||
case EIP155_SIGNING_METHODS.ETH_SIGN:
|
||||
case EIP155_SIGNING_METHODS.PERSONAL_SIGN:
|
||||
return ModalStore.open('SessionSignModal', { requestEvent, requestSession })
|
||||
|
||||
case EIP155_SIGNING_METHODS.ETH_SIGN_TYPED_DATA:
|
||||
case EIP155_SIGNING_METHODS.ETH_SIGN_TYPED_DATA_V3:
|
||||
case EIP155_SIGNING_METHODS.ETH_SIGN_TYPED_DATA_V4:
|
||||
return ModalStore.open('SessionSignTypedDataModal', { requestEvent, requestSession })
|
||||
case EIP155_SIGNING_METHODS.ETH_SIGN_TYPED_DATA:
|
||||
case EIP155_SIGNING_METHODS.ETH_SIGN_TYPED_DATA_V3:
|
||||
case EIP155_SIGNING_METHODS.ETH_SIGN_TYPED_DATA_V4:
|
||||
return ModalStore.open('SessionSignTypedDataModal', { requestEvent, requestSession })
|
||||
|
||||
case EIP155_SIGNING_METHODS.ETH_SEND_TRANSACTION:
|
||||
case EIP155_SIGNING_METHODS.ETH_SIGN_TRANSACTION:
|
||||
return ModalStore.open('SessionSendTransactionModal', { requestEvent, requestSession })
|
||||
case EIP155_SIGNING_METHODS.ETH_SEND_TRANSACTION:
|
||||
case EIP155_SIGNING_METHODS.ETH_SIGN_TRANSACTION:
|
||||
return ModalStore.open('SessionSendTransactionModal', { requestEvent, requestSession })
|
||||
|
||||
default:
|
||||
return ModalStore.open('SessionUnsuportedMethodModal', { requestEvent, requestSession })
|
||||
}
|
||||
},
|
||||
[]
|
||||
)
|
||||
default:
|
||||
return ModalStore.open('SessionUnsuportedMethodModal', { requestEvent, requestSession })
|
||||
}
|
||||
}, [])
|
||||
|
||||
/******************************************************************************
|
||||
* Set up WalletConnect event listeners
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
import { IClientMeta, IWalletConnectSession } from '@walletconnect/legacy-types'
|
||||
import { SessionTypes, SignClientTypes } from '@walletconnect/types'
|
||||
import { Web3WalletTypes } from '@walletconnect/web3wallet'
|
||||
import { proxy } from 'valtio'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface ModalData {
|
||||
proposal?: SignClientTypes.EventArguments['session_proposal']
|
||||
requestEvent?: SignClientTypes.EventArguments['session_request']
|
||||
proposal?: Web3WalletTypes.SessionProposal
|
||||
requestEvent?: Web3WalletTypes.SessionRequest
|
||||
requestSession?: SessionTypes.Struct
|
||||
legacyProposal?: {
|
||||
id: number
|
||||
|
||||
@@ -8,9 +8,10 @@ import {
|
||||
import { formatJsonRpcError, formatJsonRpcResult } from '@json-rpc-tools/utils'
|
||||
import { SignClientTypes } from '@walletconnect/types'
|
||||
import { getSdkError } from '@walletconnect/utils'
|
||||
import { Web3WalletTypes } from '@walletconnect/web3wallet'
|
||||
import { providers } from 'ethers'
|
||||
|
||||
type LegacySessionRequest = Omit<SignClientTypes.EventArguments['session_request'], 'context'>
|
||||
type LegacySessionRequest = Omit<Web3WalletTypes.SessionRequest, 'context'>
|
||||
|
||||
export async function approveEIP155Request(requestEvent: LegacySessionRequest) {
|
||||
const { params, id } = requestEvent
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user