Skip to content

Commit

Permalink
chore(react-wallet-v2): removes legacy v1 client support 🎉 (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkrem authored Jul 4, 2023
1 parent d7c56a3 commit e0059fa
Show file tree
Hide file tree
Showing 12 changed files with 8 additions and 711 deletions.
4 changes: 1 addition & 3 deletions wallets/react-wallet-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,16 @@
"@cosmjs/amino": "0.28.4",
"@cosmjs/encoding": "0.28.4",
"@cosmjs/proto-signing": "0.28.4",
"@json-rpc-tools/utils": "1.7.6",
"@multiversx/sdk-core": "11.5.0",
"@multiversx/sdk-wallet": "4.0.0",
"@json-rpc-tools/utils": "1.7.6",
"@near-wallet-selector/wallet-utils": "^7.0.2",
"@nextui-org/react": "1.0.8-beta.5",
"@polkadot/keyring": "^10.1.2",
"@polkadot/types": "^9.3.3",
"@solana/web3.js": "1.43.0",
"@taquito/signer": "^15.1.0",
"@taquito/taquito": "^15.1.0",
"@walletconnect/client": "1.8.0",
"@walletconnect/legacy-types": "^2.0.0-rc.0",
"@walletconnect/sign-client": "2.8.6",
"@walletconnect/utils": "2.8.6",
"bs58": "5.0.0",
Expand Down
8 changes: 0 additions & 8 deletions wallets/react-wallet-v2/src/components/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import SessionSignTronModal from '@/views/SessionSignTronModal'
import SessionSignTezosModal from '@/views/SessionSignTezosModal'
import SessionSignTypedDataModal from '@/views/SessionSignTypedDataModal'
import SessionUnsuportedMethodModal from '@/views/SessionUnsuportedMethodModal'
import LegacySessionProposalModal from '@/views/LegacySessionProposalModal'
import LegacySessionSignModal from '@/views/LegacySessionSignModal'
import LegacySessionSignTypedDataModal from '@/views/LegacySessionSignTypedDataModal'
import LegacySessionSendTransactionModal from '@/views/LegacySessionSendTransactionModal'
import { Modal as NextModal } from '@nextui-org/react'
import { useSnapshot } from 'valtio'

Expand All @@ -35,10 +31,6 @@ export default function Modal() {
{view === 'SessionSignMultiversxModal' && <SessionSignMultiversxModal />}
{view === 'SessionSignTronModal' && <SessionSignTronModal />}
{view === 'SessionSignTezosModal' && <SessionSignTezosModal />}
{view === 'LegacySessionProposalModal' && <LegacySessionProposalModal />}
{view === 'LegacySessionSignModal' && <LegacySessionSignModal />}
{view === 'LegacySessionSignTypedDataModal' && <LegacySessionSignTypedDataModal />}
{view === 'LegacySessionSendTransactionModal' && <LegacySessionSendTransactionModal />}
</NextModal>
)
}
4 changes: 0 additions & 4 deletions wallets/react-wallet-v2/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import Layout from '@/components/Layout'
import Modal from '@/components/Modal'
import useInitialization from '@/hooks/useInitialization'
import useWalletConnectEventsManager from '@/hooks/useWalletConnectEventsManager'
import { createLegacySignClient } from '@/utils/LegacyWalletConnectUtil'
import { createTheme, NextUIProvider } from '@nextui-org/react'
import { AppProps } from 'next/app'
import '../../public/main.css'
Expand All @@ -14,9 +13,6 @@ export default function App({ Component, pageProps }: AppProps) {
// Step 2 - Once initialized, set up wallet connect event manager
useWalletConnectEventsManager(initialized)

// Backwards compatibility only - create a legacy v1 SignClient instance.
createLegacySignClient()

return (
<NextUIProvider theme={createTheme({ type: 'dark' })}>
<Layout initialized={initialized}>
Expand Down
13 changes: 2 additions & 11 deletions wallets/react-wallet-v2/src/pages/sessions.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import PageHeader from '@/components/PageHeader'
import SessionCard from '@/components/SessionCard'
import { legacySignClient } from '@/utils/LegacyWalletConnectUtil'
import { signClient } from '@/utils/WalletConnectUtil'
import { Text } from '@nextui-org/react'
import { Fragment, useState } from 'react'

export default function SessionsPage() {
const [sessions, setSessions] = useState(signClient.session.values)
const [legacySession, setLegacySession] = useState(legacySignClient?.session)
const [sessions] = useState(signClient.session.values)

if (!legacySession && !sessions.length) {
if (!sessions.length) {
return (
<Fragment>
<PageHeader title="Sessions" />
Expand All @@ -21,13 +19,6 @@ export default function SessionsPage() {
return (
<Fragment>
<PageHeader title="Sessions" />
{legacySession ? (
<SessionCard
name={legacySession.peerMeta?.name + ' (v1/legacy)'}
url={legacySession.peerMeta?.url}
logo={legacySession.peerMeta?.icons[0]}
/>
) : null}
{sessions.length
? sessions.map(session => {
const { name, icons, url } = session.peer.metadata
Expand Down
10 changes: 1 addition & 9 deletions wallets/react-wallet-v2/src/pages/walletconnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { parseUri } from '@walletconnect/utils'
import PageHeader from '@/components/PageHeader'
import QrReader from '@/components/QrReader'
import { signClient } from '@/utils/WalletConnectUtil'
import { createLegacySignClient } from '@/utils/LegacyWalletConnectUtil'
import { Button, Input, Loading, Text } from '@nextui-org/react'
import { Fragment, useState } from 'react'

Expand All @@ -13,14 +12,7 @@ export default function WalletConnectPage() {
async function onConnect(uri: string) {
try {
setLoading(true)
const { version } = parseUri(uri)

// Route the provided URI to the v1 SignClient if URI version indicates it, else use v2.
if (version === 1) {
createLegacySignClient({ uri })
} else {
await signClient.pair({ uri })
}
await signClient.pair({ uri })
} catch (err: unknown) {
alert(err)
} finally {
Expand Down
11 changes: 0 additions & 11 deletions wallets/react-wallet-v2/src/store/ModalStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SessionTypes, SignClientTypes } from '@walletconnect/types'
import { IClientMeta, IWalletConnectSession } from '@walletconnect/legacy-types'
import { proxy } from 'valtio'

/**
Expand All @@ -9,12 +8,6 @@ interface ModalData {
proposal?: SignClientTypes.EventArguments['session_proposal']
requestEvent?: SignClientTypes.EventArguments['session_request']
requestSession?: SessionTypes.Struct
legacyProposal?: {
id: number
params: [{ chainId: number; peerId: string; peerMeta: IClientMeta }]
}
legacyCallRequestEvent?: { id: number; method: string; params: any[] }
legacyRequestSession?: IWalletConnectSession
}

interface State {
Expand All @@ -32,10 +25,6 @@ interface State {
| 'SessionSignMultiversxModal'
| 'SessionSignTronModal'
| 'SessionSignTezosModal'
| 'LegacySessionProposalModal'
| 'LegacySessionSignModal'
| 'LegacySessionSignTypedDataModal'
| 'LegacySessionSendTransactionModal'
data?: ModalData
}

Expand Down
96 changes: 0 additions & 96 deletions wallets/react-wallet-v2/src/utils/LegacyWalletConnectUtil.ts

This file was deleted.

105 changes: 0 additions & 105 deletions wallets/react-wallet-v2/src/views/LegacySessionProposalModal.tsx

This file was deleted.

Loading

7 comments on commit e0059fa

@vercel
Copy link

@vercel vercel bot commented on e0059fa Jul 4, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on e0059fa Jul 4, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on e0059fa Jul 4, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on e0059fa Jul 4, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on e0059fa Jul 4, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on e0059fa Jul 4, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on e0059fa Jul 4, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

vue-dapp-auth – ./dapps/vue-dapp-auth

vue-dapp-auth-walletconnect1.vercel.app
vue-dapp-auth-git-main-walletconnect1.vercel.app
vue-dapp-auth.vercel.app

Please sign in to comment.