refactor: updated sign
to web3wallet
(#294)
* chore: removes web3wallet example * refactor: updates sign-client to web3wallet * feat: implements auth * fix: resolves bug preventing approving only optional namespaces * chore: removes redundant commented code --------- Co-authored-by: Gancho Radkov <ganchoradkov@gmail.com>
@ -24,8 +24,7 @@
|
||||
"@solana/web3.js": "1.78.4",
|
||||
"@taquito/signer": "^15.1.0",
|
||||
"@taquito/taquito": "^15.1.0",
|
||||
"@walletconnect/sign-client": "2.10.0",
|
||||
"@walletconnect/utils": "2.10.0",
|
||||
"@walletconnect/web3wallet": "1.9.1",
|
||||
"bs58": "5.0.0",
|
||||
"cosmos-wallet": "1.2.0",
|
||||
"ethers": "5.7.2",
|
||||
@ -45,7 +44,6 @@
|
||||
"devDependencies": {
|
||||
"@types/node": "17.0.35",
|
||||
"@types/react": "18.0.9",
|
||||
"@walletconnect/types": "2.10.0",
|
||||
"eslint": "8.15.0",
|
||||
"eslint-config-next": "12.1.6",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
|
@ -15,6 +15,7 @@ import SessionUnsuportedMethodModal from '@/views/SessionUnsuportedMethodModal'
|
||||
import { Modal as NextModal } from '@nextui-org/react'
|
||||
import { useSnapshot } from 'valtio'
|
||||
import { useCallback } from 'react'
|
||||
import AuthRequestModal from '@/views/AuthRequestModal'
|
||||
|
||||
export default function Modal() {
|
||||
const { open, view } = useSnapshot(ModalStore.state)
|
||||
@ -45,6 +46,7 @@ export default function Modal() {
|
||||
{view === 'SessionSignTronModal' && <SessionSignTronModal />}
|
||||
{view === 'SessionSignTezosModal' && <SessionSignTezosModal />}
|
||||
{view === 'SessionSignKadenaModal' && <SessionSignKadenaModal />}
|
||||
{view === 'AuthRequestModal' && <AuthRequestModal />}
|
||||
</NextModal>
|
||||
)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import { createOrRestoreNearWallet } from '@/utils/NearWalletUtil'
|
||||
import { createOrRestoreMultiversxWallet } from '@/utils/MultiversxWalletUtil'
|
||||
import { createOrRestoreTronWallet } from '@/utils/TronWalletUtil'
|
||||
import { createOrRestoreTezosWallet } from '@/utils/TezosWalletUtil'
|
||||
import { createSignClient, signClient } from '@/utils/WalletConnectUtil'
|
||||
import { createWeb3Wallet, web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { createOrRestoreKadenaWallet } from '@/utils/KadenaWalletUtil'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useSnapshot } from 'valtio'
|
||||
@ -39,7 +39,7 @@ export default function useInitialization() {
|
||||
SettingsStore.setTronAddress(tronAddresses[0])
|
||||
SettingsStore.setTezosAddress(tezosAddresses[0])
|
||||
SettingsStore.setKadenaAddress(kadenaAddresses[0])
|
||||
await createSignClient(relayerRegionURL)
|
||||
await createWeb3Wallet(relayerRegionURL)
|
||||
setInitialized(true)
|
||||
} catch (err: unknown) {
|
||||
alert(err)
|
||||
@ -49,7 +49,7 @@ export default function useInitialization() {
|
||||
// restart transport if relayer region changes
|
||||
const onRelayerRegionChange = useCallback(() => {
|
||||
try {
|
||||
signClient.core.relayer.restartTransport(relayerRegionURL)
|
||||
web3wallet.core.relayer.restartTransport(relayerRegionURL)
|
||||
prevRelayerURLValue.current = relayerRegionURL
|
||||
} catch (err: unknown) {
|
||||
alert(err)
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { Web3WalletTypes } from '@walletconnect/web3wallet'
|
||||
import { COSMOS_SIGNING_METHODS } from '@/data/COSMOSData'
|
||||
import { EIP155_SIGNING_METHODS } from '@/data/EIP155Data'
|
||||
import { SOLANA_SIGNING_METHODS } from '@/data/SolanaData'
|
||||
@ -6,8 +7,7 @@ import { MULTIVERSX_SIGNING_METHODS } from '@/data/MultiversxData'
|
||||
import { TRON_SIGNING_METHODS } from '@/data/TronData'
|
||||
import ModalStore from '@/store/ModalStore'
|
||||
import SettingsStore from '@/store/SettingsStore'
|
||||
import { useSnapshot } from 'valtio'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { SignClientTypes } from '@walletconnect/types'
|
||||
import { useCallback, useEffect } from 'react'
|
||||
import { NEAR_SIGNING_METHODS } from '@/data/NEARData'
|
||||
@ -27,6 +27,12 @@ export default function useWalletConnectEventsManager(initialized: boolean) {
|
||||
},
|
||||
[]
|
||||
)
|
||||
/******************************************************************************
|
||||
* 2. Open Auth modal for confirmation / rejection
|
||||
*****************************************************************************/
|
||||
const onAuthRequest = useCallback((request: Web3WalletTypes.AuthRequest) => {
|
||||
ModalStore.open('AuthRequestModal', { request })
|
||||
}, [])
|
||||
|
||||
/******************************************************************************
|
||||
* 3. Open request handling modal based on method that was used
|
||||
@ -36,7 +42,7 @@ export default function useWalletConnectEventsManager(initialized: boolean) {
|
||||
console.log('session_request', requestEvent)
|
||||
const { topic, params, verifyContext } = requestEvent
|
||||
const { request } = params
|
||||
const requestSession = signClient.session.get(topic)
|
||||
const requestSession = web3wallet.engine.signClient.session.get(topic)
|
||||
// set the verify context so it can be displayed in the projectInfoCard
|
||||
SettingsStore.setCurrentRequestVerifyContext(verifyContext)
|
||||
|
||||
@ -83,7 +89,7 @@ export default function useWalletConnectEventsManager(initialized: boolean) {
|
||||
return ModalStore.open('SessionSignMultiversxModal', { requestEvent, requestSession })
|
||||
|
||||
case NEAR_SIGNING_METHODS.NEAR_GET_ACCOUNTS:
|
||||
return signClient.respond({
|
||||
return web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response: await approveNearRequest(requestEvent)
|
||||
})
|
||||
@ -111,13 +117,14 @@ export default function useWalletConnectEventsManager(initialized: boolean) {
|
||||
*****************************************************************************/
|
||||
useEffect(() => {
|
||||
if (initialized) {
|
||||
signClient.on('session_proposal', onSessionProposal)
|
||||
signClient.on('session_request', onSessionRequest)
|
||||
//sign
|
||||
web3wallet.on('session_proposal', onSessionProposal)
|
||||
web3wallet.on('session_request', onSessionRequest)
|
||||
// auth
|
||||
web3wallet.on('auth_request', onAuthRequest)
|
||||
// TODOs
|
||||
signClient.on('session_ping', data => console.log('ping', data))
|
||||
signClient.on('session_event', data => console.log('event', data))
|
||||
signClient.on('session_update', data => console.log('update', data))
|
||||
signClient.on('session_delete', data => console.log('delete', data))
|
||||
web3wallet.engine.signClient.events.on('session_ping', data => console.log('ping', data))
|
||||
web3wallet.on('session_delete', data => console.log('delete', data))
|
||||
}
|
||||
}, [initialized, onSessionProposal, onSessionRequest])
|
||||
}, [initialized, onAuthRequest, onSessionProposal, onSessionRequest])
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
} from 'near-api-js'
|
||||
import { AccessKeyView } from 'near-api-js/lib/providers/provider'
|
||||
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
|
||||
|
||||
const MAX_ACCOUNTS = 2
|
||||
@ -131,7 +131,7 @@ export class NearWallet {
|
||||
}
|
||||
|
||||
private isAccountsValid(topic: string, accounts: Array<{ accountId: string }>) {
|
||||
const session = signClient.session.get(topic)
|
||||
const session = web3wallet.engine.signClient.session.get(topic)
|
||||
const validAccountIds = session.namespaces.near.accounts.map(accountId => {
|
||||
return accountId.split(':')[2]
|
||||
})
|
||||
@ -190,8 +190,7 @@ export class NearWallet {
|
||||
}
|
||||
|
||||
async getAccounts({ topic }: GetAccountsParams): Promise<Array<Account>> {
|
||||
const session = signClient.session.get(topic)
|
||||
|
||||
const session = web3wallet.engine.signClient.session.get(topic)
|
||||
return Promise.all(
|
||||
session.namespaces.near.accounts.map(async account => {
|
||||
const accountId = account.split(':')[2]
|
||||
|
@ -6,7 +6,7 @@ import Layout from '@/components/Layout'
|
||||
import Modal from '@/components/Modal'
|
||||
import useInitialization from '@/hooks/useInitialization'
|
||||
import useWalletConnectEventsManager from '@/hooks/useWalletConnectEventsManager'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { RELAYER_EVENTS } from '@walletconnect/core'
|
||||
import { AppProps } from 'next/app'
|
||||
import '../../public/main.css'
|
||||
@ -20,11 +20,11 @@ export default function App({ Component, pageProps }: AppProps) {
|
||||
useWalletConnectEventsManager(initialized)
|
||||
useEffect(() => {
|
||||
if (!initialized) return
|
||||
signClient.core.relayer.on(RELAYER_EVENTS.connect, () => {
|
||||
web3wallet.core.relayer.on(RELAYER_EVENTS.connect, () => {
|
||||
styledToast('Network connection is restored!', 'success')
|
||||
})
|
||||
|
||||
signClient.core.relayer.on(RELAYER_EVENTS.disconnect, () => {
|
||||
web3wallet.core.relayer.on(RELAYER_EVENTS.disconnect, () => {
|
||||
styledToast('Network connection lost.', 'error')
|
||||
})
|
||||
}, [initialized])
|
||||
|
@ -1,15 +1,15 @@
|
||||
import PageHeader from '@/components/PageHeader'
|
||||
import PairingCard from '@/components/PairingCard'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Text } from '@nextui-org/react'
|
||||
import { getSdkError } from '@walletconnect/utils'
|
||||
import { Fragment, useState } from 'react'
|
||||
|
||||
export default function PairingsPage() {
|
||||
const [pairings, setPairings] = useState(signClient.pairing.values)
|
||||
const [pairings, setPairings] = useState(web3wallet.core.pairing.getPairings())
|
||||
|
||||
async function onDelete(topic: string) {
|
||||
await signClient.disconnect({ topic, reason: getSdkError('USER_DISCONNECTED') })
|
||||
await web3wallet.disconnectSession({ topic, reason: getSdkError('USER_DISCONNECTED') })
|
||||
const newPairings = pairings.filter(pairing => pairing.topic !== topic)
|
||||
setPairings(newPairings)
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ import PageHeader from '@/components/PageHeader'
|
||||
import ProjectInfoCard from '@/components/ProjectInfoCard'
|
||||
import SessionChainCard from '@/components/SessionChainCard'
|
||||
import SettingsStore from '@/store/SettingsStore'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Divider, Loading, Row, Text } from '@nextui-org/react'
|
||||
import { getSdkError } from '@walletconnect/utils'
|
||||
import { useRouter } from 'next/router'
|
||||
@ -18,7 +18,7 @@ export default function SessionPage() {
|
||||
const { query, replace } = useRouter()
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
const { activeChainId } = useSnapshot(SettingsStore.state);
|
||||
const { activeChainId } = useSnapshot(SettingsStore.state)
|
||||
|
||||
useEffect(() => {
|
||||
if (query?.topic) {
|
||||
@ -26,7 +26,7 @@ export default function SessionPage() {
|
||||
}
|
||||
}, [query])
|
||||
|
||||
const session = signClient.session.values.find(s => s.topic === topic)
|
||||
const session = web3wallet.engine.signClient.session.values.find(s => s.topic === topic)
|
||||
|
||||
if (!session) {
|
||||
return null
|
||||
@ -39,20 +39,20 @@ export default function SessionPage() {
|
||||
// Handle deletion of a session
|
||||
async function onDeleteSession() {
|
||||
setLoading(true)
|
||||
await signClient.disconnect({ topic, reason: getSdkError('USER_DISCONNECTED') })
|
||||
await web3wallet.disconnectSession({ topic, reason: getSdkError('USER_DISCONNECTED') })
|
||||
replace('/sessions')
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
async function onSessionPing() {
|
||||
setLoading(true)
|
||||
await signClient.ping({ topic })
|
||||
await web3wallet.engine.signClient.ping({ topic })
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
async function onSessionEmit() {
|
||||
setLoading(true)
|
||||
await signClient.emit({
|
||||
await web3wallet.emitSessionEvent({
|
||||
topic,
|
||||
event: { name: 'chainChanged', data: 'Hello World' },
|
||||
chainId: activeChainId.toString() // chainId: 'eip155:1'
|
||||
@ -62,11 +62,11 @@ export default function SessionPage() {
|
||||
|
||||
async function onSessionUpdate() {
|
||||
setLoading(true)
|
||||
const session = signClient.session.get(topic)
|
||||
const session = web3wallet.engine.signClient.session.get(topic)
|
||||
const baseAddress = '0x70012948c348CBF00806A3C79E3c5DAdFaAa347'
|
||||
const namespaceKeyToUpdate = Object.keys(session?.namespaces)[0]
|
||||
const namespaceToUpdate = session?.namespaces[namespaceKeyToUpdate]
|
||||
const { acknowledged } = await signClient.update({
|
||||
await web3wallet.updateSession({
|
||||
topic,
|
||||
namespaces: {
|
||||
...session?.namespaces,
|
||||
@ -80,7 +80,6 @@ export default function SessionPage() {
|
||||
}
|
||||
}
|
||||
})
|
||||
await acknowledged()
|
||||
setUpdated(new Date())
|
||||
setLoading(false)
|
||||
}
|
||||
@ -128,8 +127,10 @@ export default function SessionPage() {
|
||||
return (
|
||||
<Fragment key={chain}>
|
||||
<Text h4 css={{ marginBottom: '$5' }}>{`Review ${chain} permissions`}</Text>
|
||||
<SessionChainCard namespace={namespaces[chain]} data-testid={'session-card' + namespaces[chain]} />
|
||||
{/* {renderAccountSelection(chain)} */}
|
||||
<SessionChainCard
|
||||
namespace={namespaces[chain]}
|
||||
data-testid={'session-card' + namespaces[chain]}
|
||||
/>
|
||||
<Divider y={2} />
|
||||
</Fragment>
|
||||
)
|
||||
@ -146,25 +147,49 @@ export default function SessionPage() {
|
||||
</Row>
|
||||
|
||||
<Row css={{ marginTop: '$10' }}>
|
||||
<Button flat css={{ width: '100%' }} color="error" onClick={onDeleteSession} data-testid='session-delete-button'>
|
||||
<Button
|
||||
flat
|
||||
css={{ width: '100%' }}
|
||||
color="error"
|
||||
onClick={onDeleteSession}
|
||||
data-testid="session-delete-button"
|
||||
>
|
||||
{loading ? <Loading size="sm" color="error" /> : 'Delete'}
|
||||
</Button>
|
||||
</Row>
|
||||
|
||||
<Row css={{ marginTop: '$10' }}>
|
||||
<Button flat css={{ width: '100%' }} color="primary" onClick={onSessionPing} data-testid='session-ping-button'>
|
||||
<Button
|
||||
flat
|
||||
css={{ width: '100%' }}
|
||||
color="primary"
|
||||
onClick={onSessionPing}
|
||||
data-testid="session-ping-button"
|
||||
>
|
||||
{loading ? <Loading size="sm" color="primary" /> : 'Ping'}
|
||||
</Button>
|
||||
</Row>
|
||||
|
||||
<Row css={{ marginTop: '$10' }}>
|
||||
<Button flat css={{ width: '100%' }} color="secondary" onClick={onSessionEmit} data-testid='session-emit-button'>
|
||||
<Button
|
||||
flat
|
||||
css={{ width: '100%' }}
|
||||
color="secondary"
|
||||
onClick={onSessionEmit}
|
||||
data-testid="session-emit-button"
|
||||
>
|
||||
{loading ? <Loading size="sm" color="secondary" /> : 'Emit'}
|
||||
</Button>
|
||||
</Row>
|
||||
|
||||
<Row css={{ marginTop: '$10' }}>
|
||||
<Button flat css={{ width: '100%' }} color="warning" onClick={onSessionUpdate} data-testid='session-update-button'>
|
||||
<Button
|
||||
flat
|
||||
css={{ width: '100%' }}
|
||||
color="warning"
|
||||
onClick={onSessionUpdate}
|
||||
data-testid="session-update-button"
|
||||
>
|
||||
{loading ? <Loading size="sm" color="warning" /> : 'Update'}
|
||||
</Button>
|
||||
</Row>
|
||||
|
@ -1,11 +1,11 @@
|
||||
import PageHeader from '@/components/PageHeader'
|
||||
import SessionCard from '@/components/SessionCard'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Text } from '@nextui-org/react'
|
||||
import { Fragment, useState } from 'react'
|
||||
|
||||
export default function SessionsPage() {
|
||||
const [sessions] = useState(signClient.session.values)
|
||||
const [sessions] = useState(Object.values(web3wallet.getActiveSessions()))
|
||||
|
||||
if (!sessions.length) {
|
||||
return (
|
||||
|
@ -34,15 +34,7 @@ export default function SettingsPage() {
|
||||
</Text>
|
||||
<Row justify="space-between" align="center">
|
||||
<Text color="$gray400">@walletconnect/sign-client</Text>
|
||||
<Text color="$gray400">{packageJSON.dependencies['@walletconnect/sign-client']}</Text>
|
||||
</Row>
|
||||
<Row justify="space-between" align="center">
|
||||
<Text color="$gray400">@walletconnect/utils</Text>
|
||||
<Text color="$gray400">{packageJSON.dependencies['@walletconnect/utils']}</Text>
|
||||
</Row>
|
||||
<Row justify="space-between" align="center">
|
||||
<Text color="$gray400">@walletconnect/types</Text>
|
||||
<Text color="$gray400">{packageJSON.devDependencies['@walletconnect/types']}</Text>
|
||||
<Text color="$gray400">{packageJSON.dependencies['@walletconnect/web3wallet']}</Text>
|
||||
</Row>
|
||||
|
||||
<Divider y={2} />
|
||||
@ -51,7 +43,11 @@ export default function SettingsPage() {
|
||||
Testnets
|
||||
</Text>
|
||||
<Row justify="space-between" align="center">
|
||||
<Switch checked={testNets} onChange={SettingsStore.toggleTestNets} data-testid="settings-toggle-testnets"/>
|
||||
<Switch
|
||||
checked={testNets}
|
||||
onChange={SettingsStore.toggleTestNets}
|
||||
data-testid="settings-toggle-testnets"
|
||||
/>
|
||||
<Text>{testNets ? 'Enabled' : 'Disabled'}</Text>
|
||||
</Row>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { parseUri } from '@walletconnect/utils'
|
||||
import PageHeader from '@/components/PageHeader'
|
||||
import QrReader from '@/components/QrReader'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Input, Loading, Text } from '@nextui-org/react'
|
||||
import { Fragment, useState } from 'react'
|
||||
import { styledToast } from '@/utils/HelperUtil'
|
||||
@ -13,7 +13,7 @@ export default function WalletConnectPage() {
|
||||
async function onConnect(uri: string) {
|
||||
try {
|
||||
setLoading(true)
|
||||
await signClient.pair({ uri })
|
||||
await web3wallet.pair({ uri })
|
||||
} catch (error) {
|
||||
styledToast((error as Error).message, 'error')
|
||||
} finally {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { SessionTypes, SignClientTypes } from '@walletconnect/types'
|
||||
import { Web3WalletTypes } from '@walletconnect/web3wallet'
|
||||
import { proxy } from 'valtio'
|
||||
|
||||
/**
|
||||
@ -8,6 +9,7 @@ interface ModalData {
|
||||
proposal?: SignClientTypes.EventArguments['session_proposal']
|
||||
requestEvent?: SignClientTypes.EventArguments['session_request']
|
||||
requestSession?: SessionTypes.Struct
|
||||
request?: Web3WalletTypes.AuthRequest
|
||||
}
|
||||
|
||||
interface State {
|
||||
@ -26,6 +28,7 @@ interface State {
|
||||
| 'SessionSignTronModal'
|
||||
| 'SessionSignTezosModal'
|
||||
| 'SessionSignKadenaModal'
|
||||
| 'AuthRequestModal'
|
||||
data?: ModalData
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,16 @@
|
||||
import SignClient from '@walletconnect/sign-client'
|
||||
export let signClient: SignClient
|
||||
import { Web3Wallet, IWeb3Wallet } from '@walletconnect/web3wallet'
|
||||
import { Core } from '@walletconnect/core'
|
||||
export let web3wallet: IWeb3Wallet
|
||||
|
||||
export async function createSignClient(relayerRegionURL: string) {
|
||||
signClient = await SignClient.init({
|
||||
logger: 'debug',
|
||||
export async function createWeb3Wallet(relayerRegionURL: string) {
|
||||
const core = new Core({
|
||||
projectId: process.env.NEXT_PUBLIC_PROJECT_ID,
|
||||
relayUrl: relayerRegionURL ?? process.env.NEXT_PUBLIC_RELAY_URL,
|
||||
relayUrl: relayerRegionURL ?? process.env.NEXT_PUBLIC_RELAY_URL
|
||||
})
|
||||
web3wallet = await Web3Wallet.init({
|
||||
core,
|
||||
metadata: {
|
||||
name: 'React Wallet',
|
||||
name: 'React Wallet Example',
|
||||
description: 'React Wallet for WalletConnect',
|
||||
url: 'https://walletconnect.com/',
|
||||
icons: ['https://avatars.githubusercontent.com/u/37784886']
|
||||
@ -15,7 +18,7 @@ export async function createSignClient(relayerRegionURL: string) {
|
||||
})
|
||||
|
||||
try {
|
||||
const clientId = await signClient.core.crypto.getClientId()
|
||||
const clientId = await web3wallet.engine.signClient.core.crypto.getClientId()
|
||||
console.log('WalletConnect ClientID: ', clientId)
|
||||
localStorage.setItem('WALLETCONNECT_CLIENT_ID', clientId)
|
||||
} catch (error) {
|
||||
@ -26,11 +29,11 @@ export async function createSignClient(relayerRegionURL: string) {
|
||||
export async function updateSignClientChainId(chainId: string, address: string) {
|
||||
console.log('chainId', chainId, address)
|
||||
// get most recent session
|
||||
const sessions = signClient.session.getAll()
|
||||
const sessions = web3wallet.getActiveSessions()
|
||||
if (!sessions) return
|
||||
const namespace = chainId.split(':')[0]
|
||||
sessions.forEach(async session => {
|
||||
await signClient.update({
|
||||
Object.values(sessions).forEach(async session => {
|
||||
await web3wallet.updateSession({
|
||||
topic: session.topic,
|
||||
namespaces: {
|
||||
...session.namespaces,
|
||||
@ -66,7 +69,7 @@ export async function updateSignClientChainId(chainId: string, address: string)
|
||||
},
|
||||
chainId
|
||||
}
|
||||
await signClient.emit(chainChanged)
|
||||
await signClient.emit(accountsChanged)
|
||||
await web3wallet.emitSessionEvent(chainChanged)
|
||||
await web3wallet.emitSessionEvent(accountsChanged)
|
||||
})
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import {
|
||||
styledToast
|
||||
} from '@/utils/HelperUtil'
|
||||
import { solanaAddresses } from '@/utils/SolanaWalletUtil'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
||||
import { SessionTypes } from '@walletconnect/types'
|
||||
import { getSdkError, mergeArrays } from '@walletconnect/utils'
|
||||
@ -101,9 +101,9 @@ export default function SessionProposalModal() {
|
||||
namespaces[key] = {
|
||||
...namespaces[key],
|
||||
accounts,
|
||||
methods: mergeArrays(namespaces[key].methods, optionalNamespaces[key].methods),
|
||||
events: mergeArrays(namespaces[key].events, optionalNamespaces[key].events),
|
||||
chains: mergeArrays(namespaces[key].chains, optionalNamespaces[key].chains)
|
||||
methods: mergeArrays(namespaces[key]?.methods, optionalNamespaces[key].methods),
|
||||
events: mergeArrays(namespaces[key]?.events, optionalNamespaces[key].events),
|
||||
chains: mergeArrays(namespaces[key]?.chains, optionalNamespaces[key].chains)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -111,7 +111,7 @@ export default function SessionProposalModal() {
|
||||
console.log('approving namespaces:', namespaces)
|
||||
|
||||
try {
|
||||
await signClient.approve({
|
||||
await web3wallet.approveSession({
|
||||
id,
|
||||
relayProtocol: relays[0].protocol,
|
||||
namespaces
|
||||
@ -128,7 +128,7 @@ export default function SessionProposalModal() {
|
||||
async function onReject() {
|
||||
if (proposal) {
|
||||
try {
|
||||
await signClient.reject({
|
||||
await web3wallet.rejectSession({
|
||||
id,
|
||||
reason: getSdkError('USER_REJECTED_METHODS')
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ import RequestModalContainer from '@/components/RequestModalContainer'
|
||||
import ModalStore from '@/store/ModalStore'
|
||||
import { approveEIP155Request, rejectEIP155Request } from '@/utils/EIP155RequestHandlerUtil'
|
||||
import { styledToast } from '@/utils/HelperUtil'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Divider, Loading, Modal, Text } from '@nextui-org/react'
|
||||
import { Fragment, useState } from 'react'
|
||||
|
||||
@ -34,7 +34,7 @@ export default function SessionSendTransactionModal() {
|
||||
setLoading(true)
|
||||
try {
|
||||
const response = await approveEIP155Request(requestEvent)
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
@ -51,7 +51,7 @@ export default function SessionSendTransactionModal() {
|
||||
if (requestEvent) {
|
||||
const response = rejectEIP155Request(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ import RequestModalContainer from '@/components/RequestModalContainer'
|
||||
import ModalStore from '@/store/ModalStore'
|
||||
import { approveCosmosRequest, rejectCosmosRequest } from '@/utils/CosmosRequestHandler'
|
||||
import { styledToast } from '@/utils/HelperUtil'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
||||
import { Fragment } from 'react'
|
||||
|
||||
@ -29,7 +29,7 @@ export default function SessionSignCosmosModal() {
|
||||
if (requestEvent) {
|
||||
const response = await approveCosmosRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
@ -46,7 +46,7 @@ export default function SessionSignCosmosModal() {
|
||||
if (requestEvent) {
|
||||
const response = rejectCosmosRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ import RequestModalContainer from '@/components/RequestModalContainer'
|
||||
import ModalStore from '@/store/ModalStore'
|
||||
import { convertHexToUtf8, getSignParamsMessage, styledToast } from '@/utils/HelperUtil'
|
||||
import { approveKadenaRequest, rejectKadenaRequest } from '@/utils/KadenaRequestHandlerUtil'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Col, Divider, Modal, Row, Text } from '@nextui-org/react'
|
||||
import { Fragment } from 'react'
|
||||
|
||||
@ -32,7 +32,7 @@ export default function SessionSignKadenaModal() {
|
||||
if (requestEvent) {
|
||||
const response = await approveKadenaRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
@ -49,7 +49,7 @@ export default function SessionSignKadenaModal() {
|
||||
if (requestEvent) {
|
||||
const response = rejectKadenaRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
|
@ -5,7 +5,7 @@ import RequestModalContainer from '@/components/RequestModalContainer'
|
||||
import ModalStore from '@/store/ModalStore'
|
||||
import { approveEIP155Request, rejectEIP155Request } from '@/utils/EIP155RequestHandlerUtil'
|
||||
import { getSignParamsMessage, styledToast } from '@/utils/HelperUtil'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Col, Divider, Modal, Row, Text } from '@nextui-org/react'
|
||||
import { Fragment } from 'react'
|
||||
|
||||
@ -31,7 +31,7 @@ export default function SessionSignModal() {
|
||||
if (requestEvent) {
|
||||
const response = await approveEIP155Request(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
@ -48,7 +48,7 @@ export default function SessionSignModal() {
|
||||
if (requestEvent) {
|
||||
const response = rejectEIP155Request(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
|
@ -9,7 +9,7 @@ import {
|
||||
approveMultiversxRequest,
|
||||
rejectMultiversxRequest
|
||||
} from '@/utils/MultiversxRequestHandlerUtil'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
||||
import { Fragment } from 'react'
|
||||
|
||||
@ -32,7 +32,7 @@ export default function SessionSignMultiversxModal() {
|
||||
if (requestEvent) {
|
||||
const response = await approveMultiversxRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
@ -49,7 +49,7 @@ export default function SessionSignMultiversxModal() {
|
||||
if (requestEvent) {
|
||||
const response = rejectMultiversxRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
|
@ -5,7 +5,7 @@ import RequestMethodCard from '@/components/RequestMethodCard'
|
||||
import RequestModalContainer from '@/components/RequestModalContainer'
|
||||
import ModalStore from '@/store/ModalStore'
|
||||
import { approveNearRequest, rejectNearRequest } from '@/utils/NearRequestHandlerUtil'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { NEAR_SIGNING_METHODS } from '@/data/NEARData'
|
||||
import { transactions } from 'near-api-js'
|
||||
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
||||
@ -142,7 +142,7 @@ export default function SessionSignNearModal() {
|
||||
if (requestEvent) {
|
||||
const response = await approveNearRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
@ -159,7 +159,7 @@ export default function SessionSignNearModal() {
|
||||
if (requestEvent) {
|
||||
const response = rejectNearRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ import RequestModalContainer from '@/components/RequestModalContainer'
|
||||
import ModalStore from '@/store/ModalStore'
|
||||
import { styledToast } from '@/utils/HelperUtil'
|
||||
import { approvePolkadotRequest, rejectPolkadotRequest } from '@/utils/PolkadotRequestHandlerUtil'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
||||
import { Fragment } from 'react'
|
||||
|
||||
@ -29,7 +29,7 @@ export default function SessionSignPolkadotModal() {
|
||||
if (requestEvent) {
|
||||
const response = await approvePolkadotRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
@ -46,7 +46,7 @@ export default function SessionSignPolkadotModal() {
|
||||
if (requestEvent) {
|
||||
const response = rejectPolkadotRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ import RequestModalContainer from '@/components/RequestModalContainer'
|
||||
import ModalStore from '@/store/ModalStore'
|
||||
import { styledToast } from '@/utils/HelperUtil'
|
||||
import { approveSolanaRequest, rejectSolanaRequest } from '@/utils/SolanaRequestHandlerUtil'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
||||
import { Fragment } from 'react'
|
||||
|
||||
@ -29,7 +29,7 @@ export default function SessionSignSolanaModal() {
|
||||
if (requestEvent) {
|
||||
const response = await approveSolanaRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
@ -46,7 +46,7 @@ export default function SessionSignSolanaModal() {
|
||||
if (requestEvent) {
|
||||
const response = rejectSolanaRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ import RequestModalContainer from '@/components/RequestModalContainer'
|
||||
import ModalStore from '@/store/ModalStore'
|
||||
import { styledToast } from '@/utils/HelperUtil'
|
||||
import { approveTezosRequest, rejectTezosRequest } from '@/utils/TezosRequestHandlerUtil'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
||||
import { Fragment } from 'react'
|
||||
|
||||
@ -29,7 +29,7 @@ export default function SessionSignTezosModal() {
|
||||
if (requestEvent) {
|
||||
const response = await approveTezosRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
@ -46,7 +46,7 @@ export default function SessionSignTezosModal() {
|
||||
if (requestEvent) {
|
||||
const response = rejectTezosRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ import RequestModalContainer from '@/components/RequestModalContainer'
|
||||
import ModalStore from '@/store/ModalStore'
|
||||
import { styledToast } from '@/utils/HelperUtil'
|
||||
import { approveTronRequest, rejectTronRequest } from '@/utils/TronRequestHandlerUtil'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
||||
import { Fragment } from 'react'
|
||||
|
||||
@ -29,7 +29,7 @@ export default function SessionSignTronModal() {
|
||||
if (requestEvent) {
|
||||
const response = await approveTronRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
@ -46,7 +46,7 @@ export default function SessionSignTronModal() {
|
||||
if (requestEvent) {
|
||||
const response = rejectTronRequest(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
|
@ -6,7 +6,7 @@ import RequestModalContainer from '@/components/RequestModalContainer'
|
||||
import ModalStore from '@/store/ModalStore'
|
||||
import { approveEIP155Request, rejectEIP155Request } from '@/utils/EIP155RequestHandlerUtil'
|
||||
import { getSignTypedDataParamsData, styledToast } from '@/utils/HelperUtil'
|
||||
import { signClient } from '@/utils/WalletConnectUtil'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Divider, Modal, Text } from '@nextui-org/react'
|
||||
import { Fragment } from 'react'
|
||||
|
||||
@ -32,7 +32,7 @@ export default function SessionSignTypedDataModal() {
|
||||
if (requestEvent) {
|
||||
const response = await approveEIP155Request(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
@ -49,7 +49,7 @@ export default function SessionSignTypedDataModal() {
|
||||
if (requestEvent) {
|
||||
const response = rejectEIP155Request(requestEvent)
|
||||
try {
|
||||
await signClient.respond({
|
||||
await web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response
|
||||
})
|
||||
|
@ -1903,7 +1903,7 @@
|
||||
"@stablelib/constant-time" "^1.0.1"
|
||||
"@stablelib/wipe" "^1.0.1"
|
||||
|
||||
"@stablelib/sha256@1.0.1":
|
||||
"@stablelib/sha256@1.0.1", "@stablelib/sha256@^1.0.1":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.npmjs.org/@stablelib/sha256/-/sha256-1.0.1.tgz"
|
||||
integrity sha512-GIIH3e6KH+91FqGV42Kcj71Uefd/QEe7Dy42sBTeqppXV95ggCcxLTk39bEr+lZfJmp+ghsR07J++ORkRELsBQ==
|
||||
@ -2184,10 +2184,29 @@
|
||||
version "0.3.1"
|
||||
resolved "https://codeload.github.com/ecadlabs/axios-fetch-adapter/tar.gz/167684f522e90343b9f3439d9a43ac571e2396f6"
|
||||
|
||||
"@walletconnect/core@2.10.0":
|
||||
version "2.10.0"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.10.0.tgz#b659de4dfb374becd938964abd4f2150d410e617"
|
||||
integrity sha512-Z8pdorfIMueuiBXLdnf7yloiO9JIiobuxN3j0OTal+MYc4q5/2O7d+jdD1DAXbLi1taJx3x60UXT/FPVkjIqIQ==
|
||||
"@walletconnect/auth-client@2.1.2":
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/auth-client/-/auth-client-2.1.2.tgz#cee304fb0cdca76f6bf4aafac96ef9301862a7e8"
|
||||
integrity sha512-ubJLn+vGb8sTdBFX6xAh4kjR5idrtS3RBngQWaJJJpEPBQmxMb8pM2q0FIRs8Is4K6jKy+uEhusMV+7ZBmTzjw==
|
||||
dependencies:
|
||||
"@ethersproject/hash" "^5.7.0"
|
||||
"@ethersproject/transactions" "^5.7.0"
|
||||
"@stablelib/random" "^1.0.2"
|
||||
"@stablelib/sha256" "^1.0.1"
|
||||
"@walletconnect/core" "^2.10.1"
|
||||
"@walletconnect/events" "^1.0.1"
|
||||
"@walletconnect/heartbeat" "^1.2.1"
|
||||
"@walletconnect/jsonrpc-utils" "^1.0.8"
|
||||
"@walletconnect/logger" "^2.0.1"
|
||||
"@walletconnect/time" "^1.0.2"
|
||||
"@walletconnect/utils" "^2.10.1"
|
||||
events "^3.3.0"
|
||||
isomorphic-unfetch "^3.1.0"
|
||||
|
||||
"@walletconnect/core@2.10.1", "@walletconnect/core@^2.10.1":
|
||||
version "2.10.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/core/-/core-2.10.1.tgz#d1fb442bd77424666bacdb0f5a07f7708fb3d984"
|
||||
integrity sha512-WAoXfmj+Zy5q48TnrKUjmHXJCBahzKwbul+noepRZf7JDtUAZ9IOWpUjg+UPRbfK5EiWZ0TF42S6SXidf7EHoQ==
|
||||
dependencies:
|
||||
"@walletconnect/heartbeat" "1.2.1"
|
||||
"@walletconnect/jsonrpc-provider" "1.0.13"
|
||||
@ -2200,8 +2219,8 @@
|
||||
"@walletconnect/relay-auth" "^1.0.4"
|
||||
"@walletconnect/safe-json" "^1.0.2"
|
||||
"@walletconnect/time" "^1.0.2"
|
||||
"@walletconnect/types" "2.10.0"
|
||||
"@walletconnect/utils" "2.10.0"
|
||||
"@walletconnect/types" "2.10.1"
|
||||
"@walletconnect/utils" "2.10.1"
|
||||
events "^3.3.0"
|
||||
lodash.isequal "4.5.0"
|
||||
uint8arrays "^3.1.0"
|
||||
@ -2221,7 +2240,7 @@
|
||||
keyvaluestorage-interface "^1.0.0"
|
||||
tslib "1.14.1"
|
||||
|
||||
"@walletconnect/heartbeat@1.2.1":
|
||||
"@walletconnect/heartbeat@1.2.1", "@walletconnect/heartbeat@^1.2.1":
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/heartbeat/-/heartbeat-1.2.1.tgz#afaa3a53232ae182d7c9cff41c1084472d8f32e9"
|
||||
integrity sha512-yVzws616xsDLJxuG/28FqtZ5rzrTA4gUjdEMTbWB5Y8V1XHRmqq4efAxCw5ie7WjbXFSUyBHaWlMR+2/CpQC5Q==
|
||||
@ -2275,7 +2294,7 @@
|
||||
safe-json-utils "^1.1.1"
|
||||
tslib "1.14.1"
|
||||
|
||||
"@walletconnect/logger@^2.0.1":
|
||||
"@walletconnect/logger@2.0.1", "@walletconnect/logger@^2.0.1":
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/logger/-/logger-2.0.1.tgz#7f489b96e9a1ff6bf3e58f0fbd6d69718bf844a8"
|
||||
integrity sha512-SsTKdsgWm+oDTBeNE/zHxxr5eJfZmE9/5yp/Ku+zJtcTAjELb3DXueWkDXmE9h8uHIbJzIb5wj5lPdzyrjT6hQ==
|
||||
@ -2310,19 +2329,19 @@
|
||||
dependencies:
|
||||
tslib "1.14.1"
|
||||
|
||||
"@walletconnect/sign-client@2.10.0":
|
||||
version "2.10.0"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.10.0.tgz#0fee8f12821e37783099f0c7bd64e6efdfbd9d86"
|
||||
integrity sha512-hbDljDS53kR/It3oXD91UkcOsT6diNnW5+Zzksm0YEfwww5dop/YfNlcdnc8+jKUhWOL/YDPNQCjzsCSNlVzbw==
|
||||
"@walletconnect/sign-client@2.10.1":
|
||||
version "2.10.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/sign-client/-/sign-client-2.10.1.tgz#db60bc9400cd79f0cb2380067343512b21ee4749"
|
||||
integrity sha512-iG3eJGi1yXeG3xGeVSSMf8wDFyx239B0prLQfy1uYDtYFb2ynnH/09oqAZyKn96W5nfQzUgM2Mz157PVdloH3Q==
|
||||
dependencies:
|
||||
"@walletconnect/core" "2.10.0"
|
||||
"@walletconnect/core" "2.10.1"
|
||||
"@walletconnect/events" "^1.0.1"
|
||||
"@walletconnect/heartbeat" "1.2.1"
|
||||
"@walletconnect/jsonrpc-utils" "1.0.8"
|
||||
"@walletconnect/logger" "^2.0.1"
|
||||
"@walletconnect/time" "^1.0.2"
|
||||
"@walletconnect/types" "2.10.0"
|
||||
"@walletconnect/utils" "2.10.0"
|
||||
"@walletconnect/types" "2.10.1"
|
||||
"@walletconnect/utils" "2.10.1"
|
||||
events "^3.3.0"
|
||||
|
||||
"@walletconnect/time@^1.0.2":
|
||||
@ -2332,10 +2351,10 @@
|
||||
dependencies:
|
||||
tslib "1.14.1"
|
||||
|
||||
"@walletconnect/types@2.10.0":
|
||||
version "2.10.0"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.10.0.tgz#5d63235b49e03d609521402a4b49627dbc4ed514"
|
||||
integrity sha512-kSTA/WZnbKdEbvbXSW16Ty6dOSzOZCHnGg6JH7q1MuraalD2HuNg00lVVu7QAZ/Rj1Gn9DAkrgP5Wd5a8Xq//Q==
|
||||
"@walletconnect/types@2.10.1":
|
||||
version "2.10.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/types/-/types-2.10.1.tgz#1355bce236f3eef575716ea3efe4beed98a873ef"
|
||||
integrity sha512-7pccAhajQdiH2kYywjE1XI64IqRI+4ioyGy0wvz8d0UFQ/DSG3MLKR8jHf5aTOafQQ/HRLz6xvlzN4a7gIVkUQ==
|
||||
dependencies:
|
||||
"@walletconnect/events" "^1.0.1"
|
||||
"@walletconnect/heartbeat" "1.2.1"
|
||||
@ -2344,10 +2363,10 @@
|
||||
"@walletconnect/logger" "^2.0.1"
|
||||
events "^3.3.0"
|
||||
|
||||
"@walletconnect/utils@2.10.0":
|
||||
version "2.10.0"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.10.0.tgz#6918d12180d797b8bd4a19fb2ff128e394e181d6"
|
||||
integrity sha512-9GRyEz/7CJW+G04RvrjPET5k7hOEsB9b3fF9cWDk/iDCxSWpbkU/hv/urRB36C+gvQMAZgIZYX3dHfzJWkY/2g==
|
||||
"@walletconnect/utils@2.10.1", "@walletconnect/utils@^2.10.1":
|
||||
version "2.10.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/utils/-/utils-2.10.1.tgz#65b37c9800eb0e80a08385b6987471fb46e1e22e"
|
||||
integrity sha512-DM0dKgm9O58l7VqJEyV2OVv16XRePhDAReI23let6WdW1dSpw/Y/A89Lp99ZJOjLm2FxyblMRF3YRaZtHwBffw==
|
||||
dependencies:
|
||||
"@stablelib/chacha20poly1305" "1.0.1"
|
||||
"@stablelib/hkdf" "1.0.1"
|
||||
@ -2357,13 +2376,27 @@
|
||||
"@walletconnect/relay-api" "^1.0.9"
|
||||
"@walletconnect/safe-json" "^1.0.2"
|
||||
"@walletconnect/time" "^1.0.2"
|
||||
"@walletconnect/types" "2.10.0"
|
||||
"@walletconnect/types" "2.10.1"
|
||||
"@walletconnect/window-getters" "^1.0.1"
|
||||
"@walletconnect/window-metadata" "^1.0.1"
|
||||
detect-browser "5.3.0"
|
||||
query-string "7.1.3"
|
||||
uint8arrays "^3.1.0"
|
||||
|
||||
"@walletconnect/web3wallet@1.9.1":
|
||||
version "1.9.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/web3wallet/-/web3wallet-1.9.1.tgz#578967c1dc572ef52d9407e604e07324e04aa3da"
|
||||
integrity sha512-amijU+dK8zhDTxbJqxQvBlysFEroHUbE9HyMGKp6HSba5k5fXI0F+mvxeidDkOXur+ZsCj86rPQqSuPrTkPySg==
|
||||
dependencies:
|
||||
"@walletconnect/auth-client" "2.1.2"
|
||||
"@walletconnect/core" "2.10.1"
|
||||
"@walletconnect/jsonrpc-provider" "1.0.13"
|
||||
"@walletconnect/jsonrpc-utils" "1.0.8"
|
||||
"@walletconnect/logger" "2.0.1"
|
||||
"@walletconnect/sign-client" "2.10.1"
|
||||
"@walletconnect/types" "2.10.1"
|
||||
"@walletconnect/utils" "2.10.1"
|
||||
|
||||
"@walletconnect/window-getters@^1.0.1":
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/window-getters/-/window-getters-1.0.1.tgz#f36d1c72558a7f6b87ecc4451fc8bd44f63cbbdc"
|
||||
@ -4203,6 +4236,14 @@ isexe@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
|
||||
integrity sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==
|
||||
|
||||
isomorphic-unfetch@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/isomorphic-unfetch/-/isomorphic-unfetch-3.1.0.tgz#87341d5f4f7b63843d468438128cb087b7c3e98f"
|
||||
integrity sha512-geDJjpoZ8N0kWexiwkX8F9NkTsXhetLPVbZFQ+JTW239QNOwvB0gniuR1Wc6f0AMTn7/mFGyXvHTifrCp/GH8Q==
|
||||
dependencies:
|
||||
node-fetch "^2.6.1"
|
||||
unfetch "^4.2.0"
|
||||
|
||||
isomorphic-ws@^4.0.1:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz"
|
||||
@ -5709,6 +5750,11 @@ unbox-primitive@^1.0.2:
|
||||
has-symbols "^1.0.3"
|
||||
which-boxed-primitive "^1.0.2"
|
||||
|
||||
unfetch@^4.2.0:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/unfetch/-/unfetch-4.2.0.tgz#7e21b0ef7d363d8d9af0fb929a5555f6ef97a3be"
|
||||
integrity sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA==
|
||||
|
||||
uri-js@^4.2.2:
|
||||
version "4.4.1"
|
||||
resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e"
|
||||
|
@ -1,3 +0,0 @@
|
||||
NEXT_PUBLIC_PROJECT_ID=...
|
||||
NEXT_PUBLIC_RELAY_URL=wss://relay.walletconnect.com
|
||||
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"extends": "next/core-web-vitals",
|
||||
"ignorePatterns": ["next.config.js"]
|
||||
}
|
37
wallets/react-web3wallet/.gitignore
vendored
@ -1,37 +0,0 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
.DS_Store
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# local env files
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# vercel
|
||||
.vercel
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"arrowParens": "avoid",
|
||||
"parser": "typescript",
|
||||
"printWidth": 100,
|
||||
"singleQuote": true,
|
||||
"tabWidth": 2,
|
||||
"trailingComma": "none",
|
||||
"semi": false
|
||||
}
|
@ -1,254 +0,0 @@
|
||||
# Web3Wallet Example (React, Typescript, Ethers, NextJS, Cosmos)
|
||||
|
||||
This example aims to demonstrate basic and advanced use cases enabled by WalletConnect's Web3Wallet SDK.
|
||||
|
||||
**This Web3Wallet example implementation** is to serve as a reference for wallet developers.
|
||||
|
||||
Please only use this for reference and development purposes, otherwise you are at risk of losing your funds.
|
||||
|
||||
# Useful links
|
||||
|
||||
🔗 Live Web3Wallet app - https://react-web3wallet.vercel.app <br />
|
||||
🔗 Live dapp - `Sign` - https://react-app.walletconnect.com <br />
|
||||
🔗 Live dapp - `Auth` - https://react-auth-dapp.walletconnect.com/ <br />
|
||||
📚 WalletConnect docs - https://docs.walletconnect.com/2.0
|
||||
|
||||
## Getting started
|
||||
|
||||
Example is built atop of [NextJS](https://nextjs.org/) in order to abstract complexity of setting up bundlers, routing etc. So there are few steps you need to follow in order to set everything up
|
||||
|
||||
1. Go to [WalletConnect Cloud](https://cloud.walletconnect.com/sign-in) and obtain a project id
|
||||
|
||||
2. Add your project details in [WalletConnectUtil.ts](https://github.com/WalletConnect/web-examples/blob/main/wallets/react-wallet-v2/src/utils/WalletConnectUtil.ts) file
|
||||
|
||||
3. Install dependencies `yarn install` or `npm install`
|
||||
|
||||
4. Setup your environment variables
|
||||
|
||||
```bash
|
||||
cp .env.local.example .env.local
|
||||
```
|
||||
|
||||
Your `.env.local` now contains the following environment variables:
|
||||
|
||||
- `NEXT_PUBLIC_PROJECT_ID` (placeholder) - You can generate your own ProjectId at https://cloud.walletconnect.com
|
||||
- `NEXT_PUBLIC_RELAY_URL` (already set)
|
||||
|
||||
5. Run `yarn dev` or `npm run dev` to start local development
|
||||
|
||||
|
||||
## Migrate from `sign-client` to `Web3Wallet`
|
||||
|
||||
1. Initialization
|
||||
```javascript
|
||||
// metadata of your app
|
||||
const metadata = {
|
||||
name: "Demo app",
|
||||
description: "Demo Client as Wallet/Peer",
|
||||
url: "www.walletconnect.com",
|
||||
icons: [],
|
||||
};
|
||||
|
||||
/* old */
|
||||
import { SignClient } from "@walletconnect/sign-client";
|
||||
|
||||
const signClient = await SignClient.init({
|
||||
projectId: process.env.NEXT_PUBLIC_PROJECT_ID,
|
||||
metadata,
|
||||
})
|
||||
|
||||
/* new */
|
||||
import { Core } from "@walletconnect/core";
|
||||
import { Web3Wallet } from "@walletconnect/web3wallet";
|
||||
|
||||
const core = new Core({
|
||||
projectId: process.env.NEXT_PUBLIC_PROJECT_ID,
|
||||
})
|
||||
|
||||
const web3wallet = await Web3Wallet.init({
|
||||
core, // <- pass the shared `core` instance
|
||||
metadata
|
||||
})
|
||||
```
|
||||
2. Pair with a dapp
|
||||
|
||||
```javascript
|
||||
/* old */
|
||||
signClient.on("session_proposal", async (proposal) => {
|
||||
const { acknowledged } = await signClient.approve({
|
||||
id: proposal.id,
|
||||
namespaces,
|
||||
});
|
||||
const session = await acknowledged();
|
||||
});
|
||||
await signClient.pair({ uri });
|
||||
|
||||
/* new */
|
||||
web3wallet.on("session_proposal", async (proposal) => {
|
||||
const session = await web3wallet.approveSession({
|
||||
id: proposal.id,
|
||||
namespaces,
|
||||
});
|
||||
});
|
||||
await web3wallet.core.pairing.pair({ uri })
|
||||
```
|
||||
3. Responding to session requests
|
||||
|
||||
```javascript
|
||||
/* old */
|
||||
signClient.on("session_request", async (event) => {
|
||||
// process the request
|
||||
const params = ...
|
||||
// respond
|
||||
await signClient.respond({ params })
|
||||
});
|
||||
|
||||
/* new */
|
||||
web3wallet.on("session_request", async (event) => {
|
||||
// process the request
|
||||
const params = ...
|
||||
// respond
|
||||
await web3wallet.respondSessionRequest({ params })
|
||||
});
|
||||
```
|
||||
4. Emit session events
|
||||
|
||||
```javascript
|
||||
// emit events such as "chainChanged", "accountsChanged", etc.
|
||||
|
||||
/* old */
|
||||
await signClient.emit({ params })
|
||||
|
||||
/* new */
|
||||
await web3wallet.emitSessionEvent({ params })
|
||||
```
|
||||
|
||||
5. Extend a session
|
||||
|
||||
```javascript
|
||||
/* old */
|
||||
await signClient.extend({ topic });
|
||||
|
||||
/* new */
|
||||
await web3wallet.extendSession({ topic });
|
||||
```
|
||||
|
||||
6. Disconnect from a session
|
||||
|
||||
```javascript
|
||||
/* old */
|
||||
await signClient.disconnect({
|
||||
topic,
|
||||
reason: getSdkError("USER_DISCONNECTED"),
|
||||
});
|
||||
|
||||
/* new */
|
||||
await web3wallet.disconnectSession({
|
||||
topic,
|
||||
reason: getSdkError("USER_DISCONNECTED"),
|
||||
});
|
||||
```
|
||||
|
||||
7. Events
|
||||
|
||||
```javascript
|
||||
/* old */
|
||||
signClient.on("session_proposal", handler)
|
||||
signClient.on("session_request", handler)
|
||||
|
||||
/* new */
|
||||
web3wallet.on("session_proposal", handler)
|
||||
web3wallet.on("session_request", handler)
|
||||
```
|
||||
|
||||
## Migrate from `auth-client` to `Web3Wallet`
|
||||
|
||||
1. Initialization
|
||||
|
||||
```javascript
|
||||
|
||||
// metadata of your app
|
||||
const metadata = {
|
||||
name: "Demo app",
|
||||
description: "Demo Client as Wallet/Peer",
|
||||
url: "www.walletconnect.com",
|
||||
icons: [],
|
||||
};
|
||||
|
||||
/* old */
|
||||
import { AuthClient } from "@walletconnect/auth-client";
|
||||
|
||||
const authClient = await AuthClient.init({
|
||||
projectId: process.env.NEXT_PUBLIC_PROJECT_ID,
|
||||
metadata,
|
||||
})
|
||||
|
||||
/* new */
|
||||
import { Core } from "@walletconnect/core";
|
||||
import { Web3Wallet } from "@walletconnect/web3wallet";
|
||||
|
||||
const core = new Core({
|
||||
projectId: process.env.NEXT_PUBLIC_PROJECT_ID,
|
||||
})
|
||||
|
||||
const web3wallet = await Web3Wallet.init({
|
||||
core, // <- pass the shared `core` instance
|
||||
metadata
|
||||
})
|
||||
```
|
||||
2. Authenticate with a dapp
|
||||
|
||||
```javascript
|
||||
/* old */
|
||||
const iss = `did:pkh:eip155:1:${address}`;
|
||||
authClient.on("auth_request", async (event) => {
|
||||
// format the payload
|
||||
const message = authClient.formatMessage(event.params.cacaoPayload, iss);
|
||||
// prompt the user to sign the message
|
||||
const signature = await wallet.signMessage(message);
|
||||
// respond
|
||||
await authClient.respond(
|
||||
{
|
||||
id: args.id,
|
||||
signature: {
|
||||
s: signature,
|
||||
t: "eip191",
|
||||
},
|
||||
},
|
||||
iss,
|
||||
);
|
||||
});
|
||||
|
||||
await authClient.core.pairing.pair({ uri, activatePairing: true });
|
||||
|
||||
/* new */
|
||||
const iss = `did:pkh:eip155:1:${address}`;
|
||||
web3wallet.on("auth_request", async (event) => {
|
||||
// format the payload
|
||||
const message = web3wallet.formatMessage(event.params.cacaoPayload, iss);
|
||||
// prompt the user to sign the message
|
||||
const signature = await wallet.signMessage(message);
|
||||
// respond
|
||||
await web3wallet.respondAuthRequest(
|
||||
{
|
||||
id: args.id,
|
||||
signature: {
|
||||
s: signature,
|
||||
t: "eip191",
|
||||
},
|
||||
},
|
||||
iss,
|
||||
);
|
||||
})
|
||||
|
||||
await web3wallet.core.pairing.pair({ uri: request.uri, activatePairing: true })
|
||||
```
|
||||
|
||||
3. Events
|
||||
|
||||
```javascript
|
||||
/* old */
|
||||
authClient.on("auth_request", handler)
|
||||
/* new */
|
||||
web3wallet.on("auth_request", handler)
|
||||
```
|
5
wallets/react-web3wallet/next-env.d.ts
vendored
@ -1,5 +0,0 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
@ -1,11 +0,0 @@
|
||||
module.exports = {
|
||||
reactStrictMode: true,
|
||||
webpack(config) {
|
||||
config.resolve.fallback = {
|
||||
...config.resolve.fallback,
|
||||
fs: false
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
{
|
||||
"name": "react-web3wallet",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -p 3001",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint",
|
||||
"prettier:write": "prettier --write '**/*.{js,ts,jsx,tsx}'"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cosmjs/amino": "0.31.1",
|
||||
"@cosmjs/encoding": "0.31.1",
|
||||
"@cosmjs/proto-signing": "0.31.1",
|
||||
"@multiversx/sdk-core": "12.8.0",
|
||||
"@multiversx/sdk-wallet": "4.2.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.78.4",
|
||||
"@walletconnect/utils": "2.10.0",
|
||||
"@walletconnect/web3wallet": "1.9.0",
|
||||
"bs58": "5.0.0",
|
||||
"cosmos-wallet": "1.2.0",
|
||||
"ethers": "5.7.2",
|
||||
"framer-motion": "6.3.3",
|
||||
"mnemonic-keyring": "1.4.0",
|
||||
"near-api-js": "^0.45.0",
|
||||
"next": "12.1.5",
|
||||
"react": "17.0.2",
|
||||
"react-code-blocks": "0.0.9-0",
|
||||
"react-dom": "17.0.2",
|
||||
"react-qr-reader-es6": "2.2.1-2",
|
||||
"solana-wallet": "^1.0.2",
|
||||
"valtio": "1.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "17.0.35",
|
||||
"@types/react": "18.0.9",
|
||||
"@walletconnect/types": "2.10.0",
|
||||
"eslint": "8.15.0",
|
||||
"eslint-config-next": "12.1.6",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
"prettier": "2.6.2",
|
||||
"typescript": "4.6.4"
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 3.1 KiB |
@ -1,5 +0,0 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M0 64C0 28.6538 28.6538 0 64 0H448C483.346 0 512 28.6538 512 64V448C512 483.346 483.346 512 448 512H64C28.6538 512 0 483.346 0 448V64Z" fill="#F2F2F2"/>
|
||||
<path d="M160 128L32 256L160 384V288L288 192H160V128Z" fill="black"/>
|
||||
<path d="M480 256L352 128V224L224 320H352V384L480 256Z" fill="black"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 410 B |
Before Width: | Height: | Size: 4.9 KiB |
@ -1,4 +0,0 @@
|
||||
<svg width="300" height="300" viewBox="0 0 300 300" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="300" height="300" rx="150" fill="black"/>
|
||||
<path d="M158.482 149.928L228.714 112.529L216.919 90L152.575 115.854C150.923 116.523 149.077 116.523 147.425 115.854L83.0814 90L71.25 112.602L141.482 150L71.25 187.398L83.0814 210L147.425 183.948C149.077 183.279 150.923 183.279 152.575 183.948L216.919 209.874L228.75 187.272L158.482 149.928Z" fill="#23F7DD"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 472 B |
Before Width: | Height: | Size: 3.8 KiB |
@ -1,9 +0,0 @@
|
||||
<svg width="800" height="800" viewBox="0 0 800 800" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<rect width="800" height="800" rx="400" fill="#E6007A"/>
|
||||
<path d="M400.072 246.038C452.666 246.038 495.302 221.181 495.302 190.519C495.302 159.857 452.666 135 400.072 135C347.478 135 304.843 159.857 304.843 190.519C304.843 221.181 347.478 246.038 400.072 246.038Z" fill="white"/>
|
||||
<path d="M400.072 664.364C452.666 664.364 495.302 639.507 495.302 608.845C495.302 578.183 452.666 553.326 400.072 553.326C347.478 553.326 304.843 578.183 304.843 608.845C304.843 639.507 347.478 664.364 400.072 664.364Z" fill="white"/>
|
||||
<path d="M267.363 322.89C293.66 277.233 293.489 227.785 266.982 212.443C240.475 197.102 197.668 221.677 171.371 267.333C145.074 312.989 145.245 362.438 171.753 377.779C198.26 393.121 241.066 368.546 267.363 322.89Z" fill="white"/>
|
||||
<path d="M628.731 532.027C655.028 486.371 654.872 436.931 628.382 421.6C601.893 406.269 559.101 430.852 532.804 476.508C506.507 522.165 506.663 571.605 533.153 586.936C559.643 602.267 602.434 577.684 628.731 532.027Z" fill="white"/>
|
||||
<path d="M266.996 586.923C293.503 571.582 293.674 522.133 267.377 476.477C241.08 430.821 198.274 406.246 171.766 421.587C145.259 436.929 145.088 486.377 171.385 532.034C197.682 577.69 240.488 602.265 266.996 586.923Z" fill="white"/>
|
||||
<path d="M628.405 377.792C654.894 362.461 655.051 313.02 628.754 267.364C602.457 221.708 559.665 197.124 533.175 212.455C506.686 227.787 506.53 277.227 532.827 322.883C559.124 368.539 601.915 393.123 628.405 377.792Z" fill="white"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 25 KiB |
@ -1,24 +0,0 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M160 368H448M160 144H448H160ZM160 256H448H160Z" stroke="url(#paint0_linear_46_13)" stroke-width="48" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M80 160C88.8366 160 96 152.837 96 144C96 135.163 88.8366 128 80 128C71.1634 128 64 135.163 64 144C64 152.837 71.1634 160 80 160Z" stroke="url(#paint1_linear_46_13)" stroke-width="32" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M80 272C88.8366 272 96 264.837 96 256C96 247.163 88.8366 240 80 240C71.1634 240 64 247.163 64 256C64 264.837 71.1634 272 80 272Z" stroke="url(#paint2_linear_46_13)" stroke-width="32" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M80 384C88.8366 384 96 376.837 96 368C96 359.163 88.8366 352 80 352C71.1634 352 64 359.163 64 368C64 376.837 71.1634 384 80 384Z" stroke="url(#paint3_linear_46_13)" stroke-width="32" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_46_13" x1="160" y1="144.018" x2="380.191" y2="421.745" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#A562D5"/>
|
||||
<stop offset="1" stop-color="#306FEB"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_46_13" x1="64" y1="128.003" x2="96.3014" y2="159.69" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#A562D5"/>
|
||||
<stop offset="1" stop-color="#306FEB"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_46_13" x1="64" y1="240.003" x2="96.3014" y2="271.69" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#A562D5"/>
|
||||
<stop offset="1" stop-color="#306FEB"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint3_linear_46_13" x1="64" y1="352.003" x2="96.3014" y2="383.69" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#A562D5"/>
|
||||
<stop offset="1" stop-color="#306FEB"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.8 KiB |
@ -1,3 +0,0 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M112 184L256 328L400 184" stroke="white" stroke-width="48" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 224 B |
@ -1,3 +0,0 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M184 112L328 256L184 400" stroke="white" stroke-width="48" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 224 B |
@ -1,3 +0,0 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M416 128L192 384L96 288" stroke="white" stroke-width="32" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 223 B |
@ -1,4 +0,0 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M336 64H368C380.73 64 392.939 69.0571 401.941 78.0589C410.943 87.0606 416 99.2696 416 112V432C416 444.73 410.943 456.939 401.941 465.941C392.939 474.943 380.73 480 368 480H144C131.27 480 119.061 474.943 110.059 465.941C101.057 456.939 96 444.73 96 432V112C96 99.2696 101.057 87.0606 110.059 78.0589C119.061 69.0571 131.27 64 144 64H176" stroke="white" stroke-width="32" stroke-linejoin="round"/>
|
||||
<path d="M309.87 32H202.13C187.699 32 176 43.6988 176 58.13V69.87C176 84.3012 187.699 96 202.13 96H309.87C324.301 96 336 84.3012 336 69.87V58.13C336 43.6988 324.301 32 309.87 32Z" stroke="white" stroke-width="32" stroke-linejoin="round"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 751 B |
@ -1,6 +0,0 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M112 112L132 432C132.95 450.49 146.4 464 164 464H348C365.67 464 378.87 450.49 380 432L400 112" stroke="#F21361" stroke-width="32" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M80 112H432Z" fill="#F21361"/>
|
||||
<path d="M80 112H432" stroke="#F21361" stroke-width="32" stroke-miterlimit="10" stroke-linecap="round"/>
|
||||
<path d="M328 176L320 400M192 112V72.0001C191.991 68.8458 192.605 65.7208 193.808 62.8048C195.011 59.8888 196.778 57.2394 199.009 55.0089C201.239 52.7785 203.889 51.011 206.805 49.8082C209.721 48.6053 212.846 47.9909 216 48.0001H296C299.154 47.9909 302.279 48.6053 305.195 49.8082C308.111 51.011 310.761 52.7785 312.991 55.0089C315.222 57.2394 316.989 59.8888 318.192 62.8048C319.395 65.7208 320.009 68.8458 320 72.0001V112H192ZM256 176V400V176ZM184 176L192 400L184 176Z" stroke="#F21361" stroke-width="32" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 996 B |
@ -1,9 +0,0 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M208 352H144C118.539 352 94.1212 341.886 76.1178 323.882C58.1143 305.879 48 281.461 48 256C48 230.539 58.1143 206.121 76.1178 188.118C94.1212 170.114 118.539 160 144 160H208M304 160H368C393.461 160 417.879 170.114 435.882 188.118C453.886 206.121 464 230.539 464 256C464 281.461 453.886 305.879 435.882 323.882C417.879 341.886 393.461 352 368 352H304M163.29 256H350.71" stroke="url(#paint0_linear_112_7)" stroke-width="36" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_112_7" x1="48.0001" y1="160.015" x2="197.341" y2="477.442" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#A562D5"/>
|
||||
<stop offset="1" stop-color="#306FEB"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
Before Width: | Height: | Size: 814 B |
@ -1,13 +0,0 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M408 336H344C339.582 336 336 339.582 336 344V408C336 412.418 339.582 416 344 416H408C412.418 416 416 412.418 416 408V344C416 339.582 412.418 336 408 336Z" fill="#8B8B8B"/>
|
||||
<path d="M328 272H280C275.582 272 272 275.582 272 280V328C272 332.418 275.582 336 280 336H328C332.418 336 336 332.418 336 328V280C336 275.582 332.418 272 328 272Z" fill="#8B8B8B"/>
|
||||
<path d="M472 416H424C419.582 416 416 419.582 416 424V472C416 476.418 419.582 480 424 480H472C476.418 480 480 476.418 480 472V424C480 419.582 476.418 416 472 416Z" fill="#8B8B8B"/>
|
||||
<path d="M472 272H440C435.582 272 432 275.582 432 280V312C432 316.418 435.582 320 440 320H472C476.418 320 480 316.418 480 312V280C480 275.582 476.418 272 472 272Z" fill="#8B8B8B"/>
|
||||
<path d="M312 432H280C275.582 432 272 435.582 272 440V472C272 476.418 275.582 480 280 480H312C316.418 480 320 476.418 320 472V440C320 435.582 316.418 432 312 432Z" fill="#8B8B8B"/>
|
||||
<path d="M408 96H344C339.582 96 336 99.5817 336 104V168C336 172.418 339.582 176 344 176H408C412.418 176 416 172.418 416 168V104C416 99.5817 412.418 96 408 96Z" fill="#8B8B8B"/>
|
||||
<path d="M448 48H304C295.163 48 288 55.1634 288 64V208C288 216.837 295.163 224 304 224H448C456.837 224 464 216.837 464 208V64C464 55.1634 456.837 48 448 48Z" stroke="#8B8B8B" stroke-width="32" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M168 96H104C99.5817 96 96 99.5817 96 104V168C96 172.418 99.5817 176 104 176H168C172.418 176 176 172.418 176 168V104C176 99.5817 172.418 96 168 96Z" fill="#8B8B8B"/>
|
||||
<path d="M208 48H64C55.1634 48 48 55.1634 48 64V208C48 216.837 55.1634 224 64 224H208C216.837 224 224 216.837 224 208V64C224 55.1634 216.837 48 208 48Z" stroke="#8B8B8B" stroke-width="32" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M168 336H104C99.5817 336 96 339.582 96 344V408C96 412.418 99.5817 416 104 416H168C172.418 416 176 412.418 176 408V344C176 339.582 172.418 336 168 336Z" fill="#8B8B8B"/>
|
||||
<path d="M208 288H64C55.1634 288 48 295.163 48 304V448C48 456.837 55.1634 464 64 464H208C216.837 464 224 456.837 224 448V304C224 295.163 216.837 288 208 288Z" stroke="#8B8B8B" stroke-width="32" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 2.2 KiB |
@ -1,19 +0,0 @@
|
||||
<svg width="512" height="512" viewBox="0 0 512 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M320 120L368 168L320 216" stroke="url(#paint0_linear_101_17)" stroke-width="32" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M352 168H144C122.802 168.063 102.491 176.512 87.5014 191.501C72.5122 206.491 64.0633 226.802 64 248V264M192 392L144 344L192 296" stroke="url(#paint1_linear_101_17)" stroke-width="32" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M160 344H368C389.198 343.937 409.509 335.488 424.499 320.499C439.488 305.509 447.937 285.198 448 264V248" stroke="url(#paint2_linear_101_17)" stroke-width="32" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<defs>
|
||||
<linearGradient id="paint0_linear_101_17" x1="320" y1="120.008" x2="396.642" y2="157.601" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#A562D5"/>
|
||||
<stop offset="1" stop-color="#306FEB"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint1_linear_101_17" x1="64.0001" y1="168.018" x2="284.191" y2="445.745" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#A562D5"/>
|
||||
<stop offset="1" stop-color="#306FEB"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="paint2_linear_101_17" x1="160" y1="248.008" x2="219.048" y2="421.788" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#A562D5"/>
|
||||
<stop offset="1" stop-color="#306FEB"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 9.8 KiB |
@ -1,86 +0,0 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
-ms-overflow-style: none;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.routeTransition {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 100%;
|
||||
height: calc(100% - 220px);
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.qrVideoMask {
|
||||
width: 100%;
|
||||
border-radius: 15px;
|
||||
overflow: hidden !important;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.qrPlaceholder {
|
||||
border: 2px rgba(139, 139, 139, 0.4) dashed;
|
||||
width: 100%;
|
||||
border-radius: 15px;
|
||||
padding: 50px;
|
||||
}
|
||||
|
||||
.qrIcon {
|
||||
opacity: 0.3;
|
||||
}
|
||||
|
||||
.codeBlock code {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.codeBlock span {
|
||||
background-color: transparent !important;
|
||||
overflow: scroll;
|
||||
}
|
||||
|
||||
.navLink {
|
||||
transition: ease-in-out .2s opacity;
|
||||
}
|
||||
|
||||
.navLink:hover {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
select {
|
||||
background-color: rgba(139, 139, 139, 0.2);
|
||||
background-image: url(/icons/arrow-down-icon.svg);
|
||||
background-size: 15px 15px;
|
||||
background-position: right 10px center;
|
||||
background-repeat: no-repeat;
|
||||
padding: 5px 30px 6px 10px;
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
border: none;
|
||||
appearance: none;
|
||||
transition: .2s ease-in-out background-color;
|
||||
font-family: var(--nextui-fonts-sans);
|
||||
font-weight: var(--nextui-fontWeights-light);
|
||||
border: 1px solid rgba(139, 139, 139, 0.25);
|
||||
}
|
||||
|
||||
select:hover {
|
||||
background-color: rgba(139, 139, 139, 0.35);
|
||||
}
|
||||
|
||||
i {
|
||||
margin-top: -5px !important;
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
<svg width="283" height="64" viewBox="0 0 283 64" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M141.04 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.46 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM248.72 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.45 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM200.24 34c0 6 3.92 10 10 10 4.12 0 7.21-1.87 8.8-4.92l7.68 4.43c-3.18 5.3-9.14 8.49-16.48 8.49-11.05 0-19-7.2-19-18s7.96-18 19-18c7.34 0 13.29 3.19 16.48 8.49l-7.68 4.43c-1.59-3.05-4.68-4.92-8.8-4.92-6.07 0-10 4-10 10zm82.48-29v46h-9V5h9zM36.95 0L73.9 64H0L36.95 0zm92.38 5l-27.71 48L73.91 5H84.3l17.32 30 17.32-30h10.39zm58.91 12v9.69c-1-.29-2.06-.49-3.2-.49-5.81 0-10 4-10 10V51h-9V17h9v9.2c0-5.08 5.91-9.2 13.2-9.2z" fill="#000"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.1 KiB |
@ -1,3 +0,0 @@
|
||||
<svg width="388" height="238" viewBox="0 0 388 238" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M79.4993 46.539C142.716 -15.355 245.209 -15.355 308.426 46.539L316.034 53.988C319.195 57.0827 319.195 62.1002 316.034 65.1949L290.008 90.6766C288.427 92.2239 285.865 92.2239 284.285 90.6766L273.815 80.4258C229.714 37.247 158.211 37.247 114.11 80.4258L102.898 91.4035C101.317 92.9509 98.7551 92.9509 97.1747 91.4035L71.1486 65.9219C67.9878 62.8272 67.9878 57.8096 71.1486 54.715L79.4993 46.539ZM362.25 99.2378L385.413 121.917C388.574 125.011 388.574 130.029 385.413 133.123L280.969 235.385C277.808 238.48 272.683 238.48 269.522 235.385C269.522 235.385 269.522 235.385 269.522 235.385L195.394 162.807C194.604 162.033 193.322 162.033 192.532 162.807C192.532 162.807 192.532 162.807 192.532 162.807L118.405 235.385C115.244 238.48 110.12 238.48 106.959 235.385C106.959 235.385 106.959 235.385 106.959 235.385L2.51129 133.122C-0.649517 130.027 -0.649517 125.01 2.51129 121.915L25.6746 99.2365C28.8354 96.1418 33.9601 96.1418 37.1209 99.2365L111.25 171.816C112.041 172.589 113.322 172.589 114.112 171.816C114.112 171.816 114.112 171.815 114.112 171.815L188.238 99.2365C191.399 96.1417 196.523 96.1416 199.684 99.2362C199.684 99.2362 199.684 99.2363 199.684 99.2363L273.814 171.815C274.604 172.589 275.885 172.589 276.675 171.815L350.804 99.2378C353.964 96.1431 359.089 96.1431 362.25 99.2378Z" fill="white"/>
|
||||
</svg>
|
Before Width: | Height: | Size: 1.4 KiB |
@ -1,51 +0,0 @@
|
||||
import ChainCard from '@/components/ChainCard'
|
||||
import { truncate } from '@/utils/HelperUtil'
|
||||
import { Avatar, Button, Text, Tooltip } from '@nextui-org/react'
|
||||
import Image from 'next/image'
|
||||
import { useState } from 'react'
|
||||
|
||||
interface Props {
|
||||
name: string
|
||||
logo: string
|
||||
rgb: string
|
||||
address: string
|
||||
}
|
||||
|
||||
export default function AccountCard({ name, logo, rgb, address }: Props) {
|
||||
const [copied, setCopied] = useState(false)
|
||||
|
||||
function onCopy() {
|
||||
navigator?.clipboard?.writeText(address)
|
||||
setCopied(true)
|
||||
setTimeout(() => setCopied(false), 1500)
|
||||
}
|
||||
|
||||
return (
|
||||
<ChainCard rgb={rgb} flexDirection="row" alignItems="center">
|
||||
<Avatar src={logo} />
|
||||
<div style={{ flex: 1 }}>
|
||||
<Text h5 css={{ marginLeft: '$9' }}>
|
||||
{name}
|
||||
</Text>
|
||||
<Text weight="light" size={13} css={{ marginLeft: '$9' }}>
|
||||
{truncate(address, 19)}
|
||||
</Text>
|
||||
</div>
|
||||
|
||||
<Tooltip content={copied ? 'Copied!' : 'Copy'} placement="left">
|
||||
<Button
|
||||
size="sm"
|
||||
css={{ minWidth: 'auto', backgroundColor: 'rgba(255, 255, 255, 0.15)' }}
|
||||
onClick={onCopy}
|
||||
>
|
||||
<Image
|
||||
src={copied ? '/icons/checkmark-icon.svg' : '/icons/copy-icon.svg'}
|
||||
width={15}
|
||||
height={15}
|
||||
alt="copy icon"
|
||||
/>
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</ChainCard>
|
||||
)
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
import SettingsStore from '@/store/SettingsStore'
|
||||
import { cosmosAddresses } from '@/utils/CosmosWalletUtil'
|
||||
import { eip155Addresses } from '@/utils/EIP155WalletUtil'
|
||||
import { nearAddresses } from '@/utils/NearWalletUtil'
|
||||
import { solanaAddresses } from '@/utils/SolanaWalletUtil'
|
||||
import { multiversxAddresses } from '@/utils/MultiversxWalletUtil'
|
||||
import { useSnapshot } from 'valtio'
|
||||
|
||||
export default function AccountPicker() {
|
||||
const { account } = useSnapshot(SettingsStore.state)
|
||||
|
||||
function onSelect(value: string) {
|
||||
const account = Number(value)
|
||||
SettingsStore.setAccount(account)
|
||||
SettingsStore.setEIP155Address(eip155Addresses[account])
|
||||
SettingsStore.setCosmosAddress(cosmosAddresses[account])
|
||||
SettingsStore.setSolanaAddress(solanaAddresses[account])
|
||||
SettingsStore.setNearAddress(nearAddresses[account])
|
||||
SettingsStore.setMultiversxAddress(multiversxAddresses[account])
|
||||
}
|
||||
|
||||
return (
|
||||
<select value={account} onChange={e => onSelect(e.currentTarget.value)} aria-label="addresses">
|
||||
<option value={0}>Account 1</option>
|
||||
<option value={1}>Account 2</option>
|
||||
</select>
|
||||
)
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
import { truncate } from '@/utils/HelperUtil'
|
||||
import { Card, Checkbox, Row, Text } from '@nextui-org/react'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IProps {
|
||||
address: string
|
||||
index: number
|
||||
selected: boolean
|
||||
onSelect: () => void
|
||||
}
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default function AccountSelectCard({ address, selected, index, onSelect }: IProps) {
|
||||
return (
|
||||
<Card
|
||||
onClick={onSelect}
|
||||
clickable
|
||||
key={address}
|
||||
css={{
|
||||
marginTop: '$5',
|
||||
backgroundColor: selected ? 'rgba(23, 200, 100, 0.2)' : '$accents2'
|
||||
}}
|
||||
>
|
||||
<Row justify="space-between" align="center">
|
||||
<Checkbox size="lg" color="success" checked={selected} />
|
||||
|
||||
<Text>{`${truncate(address, 14)} - Account ${index + 1}`} </Text>
|
||||
</Row>
|
||||
</Card>
|
||||
)
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
import { Card } from '@nextui-org/react'
|
||||
import { ReactNode } from 'react'
|
||||
|
||||
interface Props {
|
||||
children: ReactNode | ReactNode[]
|
||||
rgb: string
|
||||
flexDirection: 'row' | 'col'
|
||||
alignItems: 'center' | 'flex-start'
|
||||
}
|
||||
|
||||
export default function ChainCard({ rgb, children, flexDirection, alignItems }: Props) {
|
||||
return (
|
||||
<Card
|
||||
bordered
|
||||
borderWeight="light"
|
||||
css={{
|
||||
borderColor: `rgba(${rgb}, 0.4)`,
|
||||
boxShadow: `0 0 10px 0 rgba(${rgb}, 0.15)`,
|
||||
backgroundColor: `rgba(${rgb}, 0.25)`,
|
||||
marginBottom: '$6',
|
||||
minHeight: '70px'
|
||||
}}
|
||||
>
|
||||
<Card.Body
|
||||
css={{
|
||||
flexDirection,
|
||||
alignItems,
|
||||
justifyContent: 'space-between',
|
||||
overflow: 'hidden'
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</Card.Body>
|
||||
</Card>
|
||||
)
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
import Navigation from '@/components/Navigation'
|
||||
import RouteTransition from '@/components/RouteTransition'
|
||||
import { Card, Container, Loading } from '@nextui-org/react'
|
||||
import { Fragment, ReactNode } from 'react'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface Props {
|
||||
initialized: boolean
|
||||
children: ReactNode | ReactNode[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Container
|
||||
*/
|
||||
export default function Layout({ children, initialized }: Props) {
|
||||
return (
|
||||
<Container
|
||||
display="flex"
|
||||
justify="center"
|
||||
alignItems="center"
|
||||
css={{
|
||||
width: '100vw',
|
||||
height: '100vh',
|
||||
paddingLeft: 0,
|
||||
paddingRight: 0
|
||||
}}
|
||||
>
|
||||
<Card
|
||||
bordered={{ '@initial': false, '@xs': true }}
|
||||
borderWeight={{ '@initial': 'light', '@xs': 'light' }}
|
||||
css={{
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
justifyContent: initialized ? 'normal' : 'center',
|
||||
alignItems: initialized ? 'normal' : 'center',
|
||||
borderRadius: 0,
|
||||
paddingBottom: 5,
|
||||
'@xs': {
|
||||
borderRadius: '$lg',
|
||||
height: '95vh',
|
||||
maxWidth: '450px'
|
||||
}
|
||||
}}
|
||||
>
|
||||
{initialized ? (
|
||||
<Fragment>
|
||||
<RouteTransition>
|
||||
<Card.Body
|
||||
css={{
|
||||
display: 'block',
|
||||
paddingLeft: 2,
|
||||
paddingRight: 2,
|
||||
paddingBottom: '40px',
|
||||
'@xs': {
|
||||
padding: '20px',
|
||||
paddingBottom: '40px'
|
||||
}
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</Card.Body>
|
||||
</RouteTransition>
|
||||
|
||||
<Card.Footer
|
||||
css={{
|
||||
height: '85px',
|
||||
minHeight: '85px',
|
||||
position: 'sticky',
|
||||
justifyContent: 'flex-end',
|
||||
alignItems: 'flex-end',
|
||||
boxShadow: '0 -30px 20px #111111',
|
||||
backgroundColor: '#111111',
|
||||
zIndex: 200,
|
||||
bottom: 0,
|
||||
left: 0
|
||||
}}
|
||||
>
|
||||
<Navigation />
|
||||
</Card.Footer>
|
||||
</Fragment>
|
||||
) : (
|
||||
<Loading />
|
||||
)}
|
||||
</Card>
|
||||
</Container>
|
||||
)
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
import ModalStore from '@/store/ModalStore'
|
||||
import SessionProposalModal from '@/views/SessionProposalModal'
|
||||
import SessionSendTransactionModal from '@/views/SessionSendTransactionModal'
|
||||
import SessionSignCosmosModal from '@/views/SessionSignCosmosModal'
|
||||
import SessionRequestModal from '@/views/SessionSignModal'
|
||||
import SessionSignNearModal from '@/views/SessionSignNearModal'
|
||||
import SessionSignPolkadotModal from '@/views/SessionSignPolkadotModal'
|
||||
import SessionSignSolanaModal from '@/views/SessionSignSolanaModal'
|
||||
import SessionSignMultiversxModal from '@/views/SessionSignMultiversxModal'
|
||||
import SessionSignTypedDataModal from '@/views/SessionSignTypedDataModal'
|
||||
import SessionUnsuportedMethodModal from '@/views/SessionUnsuportedMethodModal'
|
||||
import { Modal as NextModal } from '@nextui-org/react'
|
||||
import { useSnapshot } from 'valtio'
|
||||
import AuthRequestModal from '@/views/AuthRequestModal'
|
||||
|
||||
export default function Modal() {
|
||||
const { open, view } = useSnapshot(ModalStore.state)
|
||||
|
||||
return (
|
||||
<NextModal blur open={open} style={{ border: '1px solid rgba(139, 139, 139, 0.4)' }}>
|
||||
{view === 'SessionProposalModal' && <SessionProposalModal />}
|
||||
{view === 'SessionSignModal' && <SessionRequestModal />}
|
||||
{view === 'SessionSignTypedDataModal' && <SessionSignTypedDataModal />}
|
||||
{view === 'SessionSendTransactionModal' && <SessionSendTransactionModal />}
|
||||
{view === 'SessionUnsuportedMethodModal' && <SessionUnsuportedMethodModal />}
|
||||
{view === 'SessionSignCosmosModal' && <SessionSignCosmosModal />}
|
||||
{view === 'SessionSignSolanaModal' && <SessionSignSolanaModal />}
|
||||
{view === 'SessionSignPolkadotModal' && <SessionSignPolkadotModal />}
|
||||
{view === 'SessionSignNearModal' && <SessionSignNearModal />}
|
||||
{view === 'SessionSignMultiversxModal' && <SessionSignMultiversxModal />}
|
||||
{view === 'AuthRequestModal' && <AuthRequestModal />}
|
||||
</NextModal>
|
||||
)
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
import { Avatar, Row } from '@nextui-org/react'
|
||||
import Image from 'next/image'
|
||||
import Link from 'next/link'
|
||||
|
||||
export default function Navigation() {
|
||||
return (
|
||||
<Row justify="space-between" align="center">
|
||||
<Link href="/" passHref>
|
||||
<a className="navLink">
|
||||
<Image alt="accounts icon" src="/icons/accounts-icon.svg" width={27} height={27} />
|
||||
</a>
|
||||
</Link>
|
||||
|
||||
<Link href="/sessions" passHref>
|
||||
<a className="navLink">
|
||||
<Image alt="sessions icon" src="/icons/sessions-icon.svg" width={27} height={27} />
|
||||
</a>
|
||||
</Link>
|
||||
|
||||
<Link href="/walletconnect" passHref>
|
||||
<a className="navLink">
|
||||
<Avatar
|
||||
size="lg"
|
||||
css={{ cursor: 'pointer' }}
|
||||
color="gradient"
|
||||
icon={
|
||||
<Image
|
||||
alt="wallet connect icon"
|
||||
src="/wallet-connect-logo.svg"
|
||||
width={30}
|
||||
height={30}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</a>
|
||||
</Link>
|
||||
|
||||
<Link href="/pairings" passHref>
|
||||
<a className="navLink">
|
||||
<Image alt="pairings icon" src="/icons/pairings-icon.svg" width={25} height={25} />
|
||||
</a>
|
||||
</Link>
|
||||
|
||||
<Link href="/settings" passHref>
|
||||
<a className="navLink">
|
||||
<Image alt="settings icon" src="/icons/settings-icon.svg" width={27} height={27} />
|
||||
</a>
|
||||
</Link>
|
||||
</Row>
|
||||
)
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
import { Col, Divider, Row, Text } from '@nextui-org/react'
|
||||
import { Fragment, ReactNode } from 'react'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface Props {
|
||||
children?: ReactNode | ReactNode[]
|
||||
title: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default function PageHeader({ title, children }: Props) {
|
||||
return (
|
||||
<Fragment>
|
||||
<Row css={{ marginBottom: '$5', width: '100%' }} justify="space-between" align="center">
|
||||
<Col>
|
||||
<Text
|
||||
h3
|
||||
weight="bold"
|
||||
css={{
|
||||
textGradient: '90deg, $secondary, $primary 30%'
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</Text>
|
||||
</Col>
|
||||
{children ? <Col css={{ flex: 1 }}>{children}</Col> : null}
|
||||
</Row>
|
||||
|
||||
<Divider css={{ marginBottom: '$10' }} />
|
||||
</Fragment>
|
||||
)
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
import { truncate } from '@/utils/HelperUtil'
|
||||
import { Avatar, Button, Card, Link, Text, Tooltip } from '@nextui-org/react'
|
||||
import Image from 'next/image'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IProps {
|
||||
logo?: string
|
||||
name?: string
|
||||
url?: string
|
||||
onDelete: () => Promise<void>
|
||||
}
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default function PairingCard({ logo, name, url, onDelete }: IProps) {
|
||||
return (
|
||||
<Card
|
||||
bordered
|
||||
borderWeight="light"
|
||||
css={{
|
||||
position: 'relative',
|
||||
marginBottom: '$6',
|
||||
minHeight: '70px'
|
||||
}}
|
||||
>
|
||||
<Card.Body
|
||||
css={{
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
overflow: 'hidden'
|
||||
}}
|
||||
>
|
||||
<Avatar src={logo} />
|
||||
<div style={{ flex: 1 }}>
|
||||
<Text h5 css={{ marginLeft: '$9' }}>
|
||||
{name}
|
||||
</Text>
|
||||
<Link href={url} css={{ marginLeft: '$9' }}>
|
||||
{truncate(url?.split('https://')[1] ?? 'Unknown', 23)}
|
||||
</Link>
|
||||
</div>
|
||||
<Tooltip content="Delete" placement="left">
|
||||
<Button size="sm" color="error" flat onClick={onDelete} css={{ minWidth: 'auto' }}>
|
||||
<Image src={'/icons/delete-icon.svg'} width={15} height={15} alt="delete icon" />
|
||||
</Button>
|
||||
</Tooltip>
|
||||
</Card.Body>
|
||||
</Card>
|
||||
)
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
import { Avatar, Col, Link, Row, Text } from '@nextui-org/react'
|
||||
import { SignClientTypes } from '@walletconnect/types'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IProps {
|
||||
metadata: SignClientTypes.Metadata
|
||||
}
|
||||
|
||||
/**
|
||||
* Components
|
||||
*/
|
||||
export default function ProjectInfoCard({ metadata }: IProps) {
|
||||
const { icons, name, url } = metadata
|
||||
|
||||
return (
|
||||
<Row align="center">
|
||||
<Col span={3}>
|
||||
<Avatar src={icons[0]} />
|
||||
</Col>
|
||||
<Col span={14}>
|
||||
<Text h5>{name}</Text>
|
||||
<Link href={url}>{url}</Link>
|
||||
</Col>
|
||||
</Row>
|
||||
)
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
import AccountSelectCard from '@/components/AccountSelectCard'
|
||||
import { Col, Row, Text } from '@nextui-org/react'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IProps {
|
||||
chain: string
|
||||
addresses: string[]
|
||||
selectedAddresses: string[] | undefined
|
||||
onSelect: (chain: string, address: string) => void
|
||||
}
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default function ProposalSelectSection({
|
||||
addresses,
|
||||
selectedAddresses,
|
||||
chain,
|
||||
onSelect
|
||||
}: IProps) {
|
||||
return (
|
||||
<Row>
|
||||
<Col>
|
||||
<Text h4 css={{ marginTop: '$5' }}>{`Choose ${chain} accounts`}</Text>
|
||||
{addresses.map((address, index) => (
|
||||
<AccountSelectCard
|
||||
key={address}
|
||||
address={address}
|
||||
index={index}
|
||||
onSelect={() => onSelect(chain, address)}
|
||||
selected={selectedAddresses?.includes(address) ?? false}
|
||||
/>
|
||||
))}
|
||||
</Col>
|
||||
</Row>
|
||||
)
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
import { Button, Loading } from '@nextui-org/react'
|
||||
import dynamic from 'next/dynamic'
|
||||
import Image from 'next/image'
|
||||
import { Fragment, useState } from 'react'
|
||||
|
||||
/**
|
||||
* You can use normal import if you are not within next / ssr environment
|
||||
* @info https://nextjs.org/docs/advanced-features/dynamic-import
|
||||
*/
|
||||
const ReactQrReader = dynamic(() => import('react-qr-reader-es6'), { ssr: false })
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IProps {
|
||||
onConnect: (uri: string) => Promise<void>
|
||||
}
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default function QrReader({ onConnect }: IProps) {
|
||||
const [show, setShow] = useState(false)
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
function onError() {
|
||||
setShow(false)
|
||||
}
|
||||
|
||||
async function onScan(data: string | null) {
|
||||
if (data) {
|
||||
await onConnect(data)
|
||||
setShow(false)
|
||||
}
|
||||
}
|
||||
|
||||
function onShowScanner() {
|
||||
setLoading(true)
|
||||
setShow(true)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="container">
|
||||
{show ? (
|
||||
<Fragment>
|
||||
{loading && <Loading css={{ position: 'absolute' }} />}
|
||||
<div className="qrVideoMask">
|
||||
<ReactQrReader
|
||||
onLoad={() => setLoading(false)}
|
||||
showViewFinder={false}
|
||||
onError={onError}
|
||||
onScan={onScan}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
</Fragment>
|
||||
) : (
|
||||
<div className="container qrPlaceholder">
|
||||
<Image
|
||||
src="/icons/qr-icon.svg"
|
||||
width={100}
|
||||
height={100}
|
||||
alt="qr code icon"
|
||||
className="qrIcon"
|
||||
/>
|
||||
<Button
|
||||
color="gradient"
|
||||
css={{ marginTop: '$10', width: '100%' }}
|
||||
onClick={onShowScanner}
|
||||
>
|
||||
Scan QR code
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
import { REGIONALIZED_RELAYER_ENDPOINTS } from '@/data/RelayerRegions'
|
||||
import SettingsStore from '@/store/SettingsStore'
|
||||
import { useSnapshot } from 'valtio'
|
||||
|
||||
export default function AccountPicker() {
|
||||
const { relayerRegionURL } = useSnapshot(SettingsStore.state)
|
||||
|
||||
function onSelect(value: string) {
|
||||
SettingsStore.setRelayerRegionURL(value)
|
||||
}
|
||||
|
||||
return (
|
||||
<select
|
||||
value={relayerRegionURL}
|
||||
onChange={e => onSelect(e.currentTarget.value)}
|
||||
aria-label="relayerRegions"
|
||||
>
|
||||
{REGIONALIZED_RELAYER_ENDPOINTS.map((endpoint, index) => {
|
||||
return (
|
||||
<option key={index} value={endpoint.value}>
|
||||
{endpoint.label}
|
||||
</option>
|
||||
)
|
||||
})}
|
||||
</select>
|
||||
)
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
import { Col, Row, Text } from '@nextui-org/react'
|
||||
import { CodeBlock, codepen } from 'react-code-blocks'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IProps {
|
||||
data: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default function RequestDataCard({ data }: IProps) {
|
||||
return (
|
||||
<Row>
|
||||
<Col>
|
||||
<Text h5>Data</Text>
|
||||
<CodeBlock
|
||||
showLineNumbers={false}
|
||||
text={JSON.stringify(data, null, 2)}
|
||||
theme={codepen}
|
||||
language="json"
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
)
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
import { COSMOS_MAINNET_CHAINS, TCosmosChain } from '@/data/COSMOSData'
|
||||
import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data'
|
||||
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
|
||||
import { SOLANA_CHAINS, TSolanaChain } from '@/data/SolanaData'
|
||||
import { MULTIVERSX_CHAINS, TMultiversxChain } from '@/data/MultiversxData'
|
||||
import { Col, Divider, Row, Text } from '@nextui-org/react'
|
||||
import { Fragment } from 'react'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IProps {
|
||||
chains: string[]
|
||||
protocol: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default function RequesDetailsCard({ chains, protocol }: IProps) {
|
||||
return (
|
||||
<Fragment>
|
||||
<Row>
|
||||
<Col>
|
||||
<Text h5>Blockchain(s)</Text>
|
||||
<Text color="$gray400">
|
||||
{chains
|
||||
.map(
|
||||
chain =>
|
||||
EIP155_CHAINS[chain as TEIP155Chain]?.name ??
|
||||
COSMOS_MAINNET_CHAINS[chain as TCosmosChain]?.name ??
|
||||
SOLANA_CHAINS[chain as TSolanaChain]?.name ??
|
||||
NEAR_TEST_CHAINS[chain as TNearChain]?.name ??
|
||||
MULTIVERSX_CHAINS[chain as TMultiversxChain]?.name ??
|
||||
chain
|
||||
)
|
||||
.join(', ')}
|
||||
</Text>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Divider y={2} />
|
||||
|
||||
<Row>
|
||||
<Col>
|
||||
<Text h5>Relay Protocol</Text>
|
||||
<Text color="$gray400">{protocol}</Text>
|
||||
</Col>
|
||||
</Row>
|
||||
</Fragment>
|
||||
)
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
import { Col, Row, Text } from '@nextui-org/react'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IProps {
|
||||
methods: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default function RequestMethodCard({ methods }: IProps) {
|
||||
return (
|
||||
<Row>
|
||||
<Col>
|
||||
<Text h5>Methods</Text>
|
||||
<Text color="$gray400">{methods.map(method => method).join(', ')}</Text>
|
||||
</Col>
|
||||
</Row>
|
||||
)
|
||||
}
|
@ -1,27 +0,0 @@
|
||||
import { Container, Modal, Text } from '@nextui-org/react'
|
||||
import { Fragment, ReactNode } from 'react'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IProps {
|
||||
title: string
|
||||
children: ReactNode | ReactNode[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default function RequestModalContainer({ children, title }: IProps) {
|
||||
return (
|
||||
<Fragment>
|
||||
<Modal.Header>
|
||||
<Text h3>{title}</Text>
|
||||
</Modal.Header>
|
||||
|
||||
<Modal.Body>
|
||||
<Container css={{ padding: 0 }}>{children}</Container>
|
||||
</Modal.Body>
|
||||
</Fragment>
|
||||
)
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
import { AnimatePresence, motion } from 'framer-motion'
|
||||
import { useRouter } from 'next/router'
|
||||
import { ReactNode } from 'react'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IProps {
|
||||
children: ReactNode | ReactNode[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Components
|
||||
*/
|
||||
export default function RouteTransition({ children }: IProps) {
|
||||
const { pathname } = useRouter()
|
||||
|
||||
return (
|
||||
<AnimatePresence exitBeforeEnter>
|
||||
<motion.div
|
||||
className="routeTransition"
|
||||
key={pathname}
|
||||
initial={{ opacity: 0, translateY: 7 }}
|
||||
animate={{ opacity: 1, translateY: 0 }}
|
||||
exit={{ opacity: 0, translateY: 7 }}
|
||||
transition={{ duration: 0.18 }}
|
||||
>
|
||||
{children}
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
)
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
import { truncate } from '@/utils/HelperUtil'
|
||||
import { Avatar, Card, Link, Text } from '@nextui-org/react'
|
||||
import Image from 'next/image'
|
||||
import NextLink from 'next/link'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IProps {
|
||||
topic?: string
|
||||
logo?: string
|
||||
name?: string
|
||||
url?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default function SessionCard({ logo, name, url, topic }: IProps) {
|
||||
return (
|
||||
<NextLink href={topic ? `/session?topic=${topic}` : '#'} passHref>
|
||||
<Card
|
||||
clickable
|
||||
bordered
|
||||
borderWeight="light"
|
||||
css={{
|
||||
position: 'relative',
|
||||
marginBottom: '$6',
|
||||
minHeight: '70px'
|
||||
}}
|
||||
>
|
||||
<Card.Body
|
||||
css={{
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
overflow: 'hidden'
|
||||
}}
|
||||
>
|
||||
<Avatar src={logo} />
|
||||
<div style={{ flex: 1 }}>
|
||||
<Text h5 css={{ marginLeft: '$9' }}>
|
||||
{name}
|
||||
</Text>
|
||||
<Link href={url} css={{ marginLeft: '$9' }}>
|
||||
{truncate(url?.split('https://')[1] ?? 'Unknown', 23)}
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<Image src={'/icons/arrow-right-icon.svg'} width={20} height={20} alt="session icon" />
|
||||
</Card.Body>
|
||||
</Card>
|
||||
</NextLink>
|
||||
)
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
import ChainCard from '@/components/ChainCard'
|
||||
import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
|
||||
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
||||
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
|
||||
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
||||
import { MULTIVERSX_MAINNET_CHAINS, MULTIVERSX_TEST_CHAINS } from '@/data/MultiversxData'
|
||||
import { formatChainName } from '@/utils/HelperUtil'
|
||||
import { Col, Row, Text } from '@nextui-org/react'
|
||||
import { SessionTypes } from '@walletconnect/types'
|
||||
import { Fragment } from 'react'
|
||||
|
||||
/**
|
||||
* Utilities
|
||||
*/
|
||||
const CHAIN_METADATA = {
|
||||
...COSMOS_MAINNET_CHAINS,
|
||||
...SOLANA_MAINNET_CHAINS,
|
||||
...MULTIVERSX_MAINNET_CHAINS,
|
||||
...EIP155_MAINNET_CHAINS,
|
||||
...EIP155_TEST_CHAINS,
|
||||
...SOLANA_TEST_CHAINS,
|
||||
...NEAR_TEST_CHAINS,
|
||||
...MULTIVERSX_TEST_CHAINS
|
||||
}
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IProps {
|
||||
namespace: SessionTypes.Namespace
|
||||
}
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default function SessionChainCard({ namespace }: IProps) {
|
||||
const chains: string[] = []
|
||||
|
||||
// WIP
|
||||
|
||||
namespace.accounts.forEach(account => {
|
||||
const [type, chain] = account.split(':')
|
||||
const chainId = `${type}:${chain}`
|
||||
chains.push(chainId)
|
||||
})
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
{chains.map(chainId => {
|
||||
const extensionMethods: SessionTypes.Namespace['methods'] = []
|
||||
const extensionEvents: SessionTypes.Namespace['events'] = []
|
||||
const allMethods = [...namespace.methods, ...extensionMethods]
|
||||
const allEvents = [...namespace.events, ...extensionEvents]
|
||||
// @ts-expect-error
|
||||
const rgb = CHAIN_METADATA[chainId]?.rgb
|
||||
|
||||
return (
|
||||
<ChainCard key={chainId} rgb={rgb ?? ''} flexDirection="col" alignItems="flex-start">
|
||||
<Text h5 css={{ marginBottom: '$5' }}>
|
||||
{formatChainName(chainId)}
|
||||
</Text>
|
||||
<Row>
|
||||
<Col>
|
||||
<Text h6>Methods</Text>
|
||||
<Text color="$gray300">{allMethods.length ? allMethods.join(', ') : '-'}</Text>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row css={{ marginTop: '$5' }}>
|
||||
<Col>
|
||||
<Text h6>Events</Text>
|
||||
<Text color="$gray300">{allEvents.length ? allEvents.join(', ') : '-'}</Text>
|
||||
</Col>
|
||||
</Row>
|
||||
</ChainCard>
|
||||
)
|
||||
})}
|
||||
</Fragment>
|
||||
)
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
import ChainCard from '@/components/ChainCard'
|
||||
import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
|
||||
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
||||
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
|
||||
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
||||
import { MULTIVERSX_MAINNET_CHAINS, MULTIVERSX_TEST_CHAINS } from '@/data/MultiversxData'
|
||||
import { formatChainName } from '@/utils/HelperUtil'
|
||||
import { Col, Row, Text } from '@nextui-org/react'
|
||||
import { ProposalTypes } from '@walletconnect/types'
|
||||
import { Fragment } from 'react'
|
||||
|
||||
/**
|
||||
* Utilities
|
||||
*/
|
||||
const CHAIN_METADATA = {
|
||||
...COSMOS_MAINNET_CHAINS,
|
||||
...SOLANA_MAINNET_CHAINS,
|
||||
...MULTIVERSX_MAINNET_CHAINS,
|
||||
...EIP155_MAINNET_CHAINS,
|
||||
...EIP155_TEST_CHAINS,
|
||||
...SOLANA_TEST_CHAINS,
|
||||
...NEAR_TEST_CHAINS,
|
||||
...MULTIVERSX_TEST_CHAINS
|
||||
}
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IProps {
|
||||
requiredNamespace: ProposalTypes.RequiredNamespace
|
||||
}
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default function SessionProposalChainCard({ requiredNamespace }: IProps) {
|
||||
return (
|
||||
<Fragment>
|
||||
{requiredNamespace.chains?.map(chainId => {
|
||||
const allMethods = requiredNamespace.methods
|
||||
const allEvents = requiredNamespace.events
|
||||
// @ts-expect-error
|
||||
const rgb = CHAIN_METADATA[chainId]?.rgb
|
||||
|
||||
return (
|
||||
<ChainCard key={chainId} rgb={rgb ?? ''} flexDirection="col" alignItems="flex-start">
|
||||
<Text h5 css={{ marginBottom: '$5' }}>
|
||||
{formatChainName(chainId)}
|
||||
</Text>
|
||||
<Row>
|
||||
<Col>
|
||||
<Text h6>Methods</Text>
|
||||
<Text color="$gray300">{allMethods.length ? allMethods.join(', ') : '-'}</Text>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row css={{ marginTop: '$5' }}>
|
||||
<Col>
|
||||
<Text h6>Events</Text>
|
||||
<Text color="$gray300">{allEvents.length ? allEvents.join(', ') : '-'}</Text>
|
||||
</Col>
|
||||
</Row>
|
||||
</ChainCard>
|
||||
)
|
||||
})}
|
||||
</Fragment>
|
||||
)
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
export type TCosmosChain = keyof typeof COSMOS_MAINNET_CHAINS
|
||||
|
||||
/**
|
||||
* Chains
|
||||
*/
|
||||
export const COSMOS_MAINNET_CHAINS = {
|
||||
'cosmos:cosmoshub-4': {
|
||||
chainId: 'cosmoshub-4',
|
||||
name: 'Cosmos Hub',
|
||||
logo: '/chain-logos/cosmos-cosmoshub-4.png',
|
||||
rgb: '107, 111, 147',
|
||||
rpc: ''
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Methods
|
||||
*/
|
||||
export const COSMOS_SIGNING_METHODS = {
|
||||
COSMOS_SIGN_DIRECT: 'cosmos_signDirect',
|
||||
COSMOS_SIGN_AMINO: 'cosmos_signAmino'
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
/**
|
||||
* @desc Refference list of eip155 chains
|
||||
* @url https://chainlist.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
export type TEIP155Chain = keyof typeof EIP155_CHAINS
|
||||
|
||||
/**
|
||||
* Chains
|
||||
*/
|
||||
export const EIP155_MAINNET_CHAINS = {
|
||||
'eip155:1': {
|
||||
chainId: 1,
|
||||
name: 'Ethereum',
|
||||
logo: '/chain-logos/eip155-1.png',
|
||||
rgb: '99, 125, 234',
|
||||
rpc: 'https://cloudflare-eth.com/'
|
||||
},
|
||||
'eip155:43114': {
|
||||
chainId: 43114,
|
||||
name: 'Avalanche C-Chain',
|
||||
logo: '/chain-logos/eip155-43113.png',
|
||||
rgb: '232, 65, 66',
|
||||
rpc: 'https://api.avax.network/ext/bc/C/rpc'
|
||||
},
|
||||
'eip155:137': {
|
||||
chainId: 137,
|
||||
name: 'Polygon',
|
||||
logo: '/chain-logos/eip155-137.png',
|
||||
rgb: '130, 71, 229',
|
||||
rpc: 'https://polygon-rpc.com/'
|
||||
},
|
||||
'eip155:10': {
|
||||
chainId: 10,
|
||||
name: 'Optimism',
|
||||
logo: '/chain-logos/eip155-10.png',
|
||||
rgb: '235, 0, 25',
|
||||
rpc: 'https://mainnet.optimism.io'
|
||||
},
|
||||
'eip155:324': {
|
||||
chainId: 324,
|
||||
name: 'zkSync Era',
|
||||
logo: '/chain-logos/eip155-324.svg',
|
||||
rgb: '242, 242, 242',
|
||||
rpc: 'https://mainnet.era.zksync.io/'
|
||||
}
|
||||
}
|
||||
|
||||
export const EIP155_TEST_CHAINS = {
|
||||
'eip155:5': {
|
||||
chainId: 5,
|
||||
name: 'Ethereum Goerli',
|
||||
logo: '/chain-logos/eip155-1.png',
|
||||
rgb: '99, 125, 234',
|
||||
rpc: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161'
|
||||
},
|
||||
'eip155:43113': {
|
||||
chainId: 43113,
|
||||
name: 'Avalanche Fuji',
|
||||
logo: '/chain-logos/eip155-43113.png',
|
||||
rgb: '232, 65, 66',
|
||||
rpc: 'https://api.avax-test.network/ext/bc/C/rpc'
|
||||
},
|
||||
'eip155:80001': {
|
||||
chainId: 80001,
|
||||
name: 'Polygon Mumbai',
|
||||
logo: '/chain-logos/eip155-137.png',
|
||||
rgb: '130, 71, 229',
|
||||
rpc: 'https://matic-mumbai.chainstacklabs.com'
|
||||
},
|
||||
'eip155:420': {
|
||||
chainId: 420,
|
||||
name: 'Optimism Goerli',
|
||||
logo: '/chain-logos/eip155-10.png',
|
||||
rgb: '235, 0, 25',
|
||||
rpc: 'https://goerli.optimism.io'
|
||||
},
|
||||
'eip155:280': {
|
||||
chainId: 280,
|
||||
name: 'zkSync Era Testnet',
|
||||
logo: '/chain-logos/eip155-324.svg',
|
||||
rgb: '242, 242, 242',
|
||||
rpc: 'https://testnet.era.zksync.dev/'
|
||||
}
|
||||
}
|
||||
|
||||
export const EIP155_CHAINS = { ...EIP155_MAINNET_CHAINS, ...EIP155_TEST_CHAINS }
|
||||
|
||||
/**
|
||||
* Methods
|
||||
*/
|
||||
export const EIP155_SIGNING_METHODS = {
|
||||
PERSONAL_SIGN: 'personal_sign',
|
||||
ETH_SIGN: 'eth_sign',
|
||||
ETH_SIGN_TRANSACTION: 'eth_signTransaction',
|
||||
ETH_SIGN_TYPED_DATA: 'eth_signTypedData',
|
||||
ETH_SIGN_TYPED_DATA_V3: 'eth_signTypedData_v3',
|
||||
ETH_SIGN_TYPED_DATA_V4: 'eth_signTypedData_v4',
|
||||
ETH_SEND_TRANSACTION: 'eth_sendTransaction'
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
export type TMultiversxChain = keyof typeof MULTIVERSX_MAINNET_CHAINS
|
||||
|
||||
/**
|
||||
* Chains
|
||||
*/
|
||||
export const MULTIVERSX_MAINNET_CHAINS = {
|
||||
'mvx:1': {
|
||||
chainId: '1',
|
||||
name: 'MultiversX',
|
||||
logo: '/chain-logos/multiversx-1.svg',
|
||||
rgb: '43, 45, 46',
|
||||
rpc: ''
|
||||
}
|
||||
}
|
||||
|
||||
export const MULTIVERSX_TEST_CHAINS = {
|
||||
'mvx:D': {
|
||||
chainId: 'D',
|
||||
name: 'MultiversX Devnet',
|
||||
logo: '/chain-logos/multiversx-1.svg',
|
||||
rgb: '43, 45, 46',
|
||||
rpc: ''
|
||||
}
|
||||
// Keep only one Test Chain visible
|
||||
// 'mvx:T': {
|
||||
// chainId: 'T',
|
||||
// name: 'MultiversX Testnet',
|
||||
// logo: '/chain-logos/multiversx-1.svg',
|
||||
// rgb: '43, 45, 46',
|
||||
// rpc: ''
|
||||
// }
|
||||
}
|
||||
|
||||
export const MULTIVERSX_CHAINS = { ...MULTIVERSX_MAINNET_CHAINS, ...MULTIVERSX_TEST_CHAINS }
|
||||
|
||||
/**
|
||||
* Methods
|
||||
*/
|
||||
export const MULTIVERSX_SIGNING_METHODS = {
|
||||
MULTIVERSX_SIGN_TRANSACTION: 'mvx_signTransaction',
|
||||
MULTIVERSX_SIGN_TRANSACTIONS: 'mvx_signTransactions',
|
||||
MULTIVERSX_SIGN_MESSAGE: 'mvx_signMessage',
|
||||
MULTIVERSX_SIGN_LOGIN_TOKEN: 'mvx_signLoginToken',
|
||||
MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN: 'mvx_signNativeAuthToken'
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
/**
|
||||
* @desc Reference list of NEAR chains
|
||||
* @url https://chainlist.org
|
||||
*/
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
export type TNearChain = keyof typeof NEAR_TEST_CHAINS
|
||||
|
||||
/**
|
||||
* Chains
|
||||
*/
|
||||
export const NEAR_MAINNET_CHAINS = {
|
||||
// TODO: Dev account creation isn't supported on NEAR Mainnet.
|
||||
}
|
||||
|
||||
interface NearTestChains {
|
||||
[key: string]: ChainMetadata
|
||||
}
|
||||
|
||||
type ChainMetadata = {
|
||||
chainId: string
|
||||
name: string
|
||||
logo: string
|
||||
rgb: string
|
||||
rpc: string
|
||||
}
|
||||
|
||||
export const NEAR_TEST_CHAINS: NearTestChains = {
|
||||
'near:testnet': {
|
||||
chainId: 'testnet',
|
||||
name: 'NEAR Testnet',
|
||||
logo: '/chain-logos/near.png',
|
||||
rgb: '99, 125, 234',
|
||||
rpc: 'https://rpc.testnet.near.org'
|
||||
}
|
||||
}
|
||||
|
||||
export const NEAR_CHAINS = { ...NEAR_MAINNET_CHAINS, ...NEAR_TEST_CHAINS }
|
||||
|
||||
/**
|
||||
* Methods
|
||||
*/
|
||||
export const NEAR_SIGNING_METHODS = {
|
||||
NEAR_SIGN_IN: 'near_signIn',
|
||||
NEAR_SIGN_OUT: 'near_signOut',
|
||||
NEAR_GET_ACCOUNTS: 'near_getAccounts',
|
||||
NEAR_SIGN_TRANSACTION: 'near_signTransaction',
|
||||
NEAR_SIGN_AND_SEND_TRANSACTION: 'near_signAndSendTransaction',
|
||||
NEAR_SIGN_TRANSACTIONS: 'near_signTransactions',
|
||||
NEAR_SIGN_AND_SEND_TRANSACTIONS: 'near_signAndSendTransactions',
|
||||
NEAR_VERIFY_OWNER: 'near_verifyOwner'
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
export type TPolkadotChain = keyof typeof POLKADOT_MAINNET_CHAINS
|
||||
|
||||
/**
|
||||
* Chains
|
||||
*/
|
||||
export const POLKADOT_MAINNET_CHAINS = {
|
||||
'polkadot:91b171bb158e2d3848fa23a9f1c25182': {
|
||||
chainId: '91b171bb158e2d3848fa23a9f1c25182',
|
||||
name: 'Polkadot',
|
||||
logo: '/chain-logos/polkadot.svg',
|
||||
rgb: '230, 1, 122',
|
||||
rpc: ''
|
||||
}
|
||||
}
|
||||
|
||||
export const POLKADOT_TEST_CHAINS = {
|
||||
'polkadot:e143f23803ac50e8f6f8e62695d1ce9e': {
|
||||
chainId: 'e143f23803ac50e8f6f8e62695d1ce9e',
|
||||
name: 'Polkadot Westend',
|
||||
logo: '/chain-logos/westend.svg',
|
||||
rgb: '218, 104, 167',
|
||||
rpc: ''
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Methods
|
||||
*/
|
||||
export const POLKADOT_SIGNING_METHODS = {
|
||||
POLKADOT_SIGN_TRANSACTION: 'polkadot_signTransaction',
|
||||
POLKADOT_SIGN_MESSAGE: 'polkadot_signMessage'
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
|
||||
type RelayerType = {
|
||||
value: string
|
||||
label: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Relayer Regions
|
||||
*/
|
||||
export const REGIONALIZED_RELAYER_ENDPOINTS: RelayerType[] = [
|
||||
{
|
||||
value: 'wss://relay.walletconnect.com',
|
||||
label: 'Default'
|
||||
},
|
||||
|
||||
{
|
||||
value: 'wss://us-east-1.relay.walletconnect.com/',
|
||||
label: 'US'
|
||||
},
|
||||
{
|
||||
value: 'wss://eu-central-1.relay.walletconnect.com/',
|
||||
label: 'EU'
|
||||
},
|
||||
{
|
||||
value: 'wss://ap-southeast-1.relay.walletconnect.com/',
|
||||
label: 'Asia Pacific'
|
||||
}
|
||||
]
|
@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
export type TSolanaChain = keyof typeof SOLANA_MAINNET_CHAINS
|
||||
|
||||
/**
|
||||
* Chains
|
||||
*/
|
||||
export const SOLANA_MAINNET_CHAINS = {
|
||||
'solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ': {
|
||||
chainId: '4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ',
|
||||
name: 'Solana',
|
||||
logo: '/chain-logos/solana-4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ.png',
|
||||
rgb: '30, 240, 166',
|
||||
rpc: ''
|
||||
}
|
||||
}
|
||||
|
||||
export const SOLANA_TEST_CHAINS = {
|
||||
'solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K': {
|
||||
chainId: '8E9rvCKLFQia2Y35HXjjpWzj8weVo44K',
|
||||
name: 'Solana Devnet',
|
||||
logo: '/chain-logos/solana-4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ.png',
|
||||
rgb: '30, 240, 166',
|
||||
rpc: ''
|
||||
}
|
||||
}
|
||||
|
||||
export const SOLANA_CHAINS = { ...SOLANA_MAINNET_CHAINS, ...SOLANA_TEST_CHAINS }
|
||||
|
||||
/**
|
||||
* Methods
|
||||
*/
|
||||
export const SOLANA_SIGNING_METHODS = {
|
||||
SOLANA_SIGN_TRANSACTION: 'solana_signTransaction',
|
||||
SOLANA_SIGN_MESSAGE: 'solana_signMessage'
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
import SettingsStore from '@/store/SettingsStore'
|
||||
import { createOrRestoreCosmosWallet } from '@/utils/CosmosWalletUtil'
|
||||
import { createOrRestoreEIP155Wallet } from '@/utils/EIP155WalletUtil'
|
||||
import { createOrRestoreSolanaWallet } from '@/utils/SolanaWalletUtil'
|
||||
import { createOrRestorePolkadotWallet } from '@/utils/PolkadotWalletUtil'
|
||||
import { createOrRestoreMultiversxWallet } from '@/utils/MultiversxWalletUtil'
|
||||
import { createWeb3Wallet } from '@/utils/WalletConnectUtil'
|
||||
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||
import { useSnapshot } from 'valtio'
|
||||
import { createOrRestoreNearWallet } from '@/utils/NearWalletUtil'
|
||||
|
||||
export default function useInitialization() {
|
||||
const [initialized, setInitialized] = useState(false)
|
||||
const prevRelayerURLValue = useRef<string>('')
|
||||
|
||||
const { relayerRegionURL } = useSnapshot(SettingsStore.state)
|
||||
|
||||
const onInitialize = useCallback(async () => {
|
||||
try {
|
||||
const { eip155Addresses } = createOrRestoreEIP155Wallet()
|
||||
const { cosmosAddresses } = await createOrRestoreCosmosWallet()
|
||||
const { solanaAddresses } = await createOrRestoreSolanaWallet()
|
||||
const { polkadotAddresses } = await createOrRestorePolkadotWallet()
|
||||
const { nearAddresses } = await createOrRestoreNearWallet()
|
||||
const { multiversxAddresses } = await createOrRestoreMultiversxWallet()
|
||||
|
||||
SettingsStore.setEIP155Address(eip155Addresses[0])
|
||||
SettingsStore.setCosmosAddress(cosmosAddresses[0])
|
||||
SettingsStore.setSolanaAddress(solanaAddresses[0])
|
||||
SettingsStore.setPolkadotAddress(polkadotAddresses[0])
|
||||
SettingsStore.setNearAddress(nearAddresses[0])
|
||||
SettingsStore.setMultiversxAddress(multiversxAddresses[0])
|
||||
prevRelayerURLValue.current = relayerRegionURL
|
||||
|
||||
await createWeb3Wallet(relayerRegionURL)
|
||||
|
||||
setInitialized(true)
|
||||
} catch (err: unknown) {
|
||||
alert(err)
|
||||
}
|
||||
}, [relayerRegionURL])
|
||||
|
||||
useEffect(() => {
|
||||
if (!initialized) {
|
||||
onInitialize()
|
||||
}
|
||||
if (prevRelayerURLValue.current !== relayerRegionURL) {
|
||||
setInitialized(false)
|
||||
onInitialize()
|
||||
}
|
||||
}, [initialized, onInitialize, relayerRegionURL])
|
||||
|
||||
return initialized
|
||||
}
|
@ -1,112 +0,0 @@
|
||||
import { COSMOS_SIGNING_METHODS } from '@/data/COSMOSData'
|
||||
import { EIP155_SIGNING_METHODS } from '@/data/EIP155Data'
|
||||
import { SOLANA_SIGNING_METHODS } from '@/data/SolanaData'
|
||||
import { POLKADOT_SIGNING_METHODS } from '@/data/PolkadotData'
|
||||
import { MULTIVERSX_SIGNING_METHODS } from '@/data/MultiversxData'
|
||||
import ModalStore from '@/store/ModalStore'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { SignClientTypes } from '@walletconnect/types'
|
||||
import { useCallback, useEffect } from 'react'
|
||||
import { NEAR_SIGNING_METHODS } from '@/data/NEARData'
|
||||
import { approveNearRequest } from '@/utils/NearRequestHandlerUtil'
|
||||
import { Web3WalletTypes } from '@walletconnect/web3wallet'
|
||||
|
||||
export default function useWalletConnectEventsManager(initialized: boolean) {
|
||||
/******************************************************************************
|
||||
* 1. Open session proposal modal for confirmation / rejection
|
||||
*****************************************************************************/
|
||||
const onSessionProposal = useCallback(
|
||||
(proposal: SignClientTypes.EventArguments['session_proposal']) => {
|
||||
ModalStore.open('SessionProposalModal', { proposal })
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
const onAuthRequest = useCallback((request: Web3WalletTypes.AuthRequest) => {
|
||||
ModalStore.open('AuthRequestModal', { request })
|
||||
}, [])
|
||||
|
||||
/******************************************************************************
|
||||
* 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 = signClient.session.get(topic)
|
||||
const requestSession = web3wallet.engine.signClient.session.get(topic)
|
||||
|
||||
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_SEND_TRANSACTION:
|
||||
case EIP155_SIGNING_METHODS.ETH_SIGN_TRANSACTION:
|
||||
return ModalStore.open('SessionSendTransactionModal', { requestEvent, requestSession })
|
||||
|
||||
case COSMOS_SIGNING_METHODS.COSMOS_SIGN_DIRECT:
|
||||
case COSMOS_SIGNING_METHODS.COSMOS_SIGN_AMINO:
|
||||
return ModalStore.open('SessionSignCosmosModal', { requestEvent, requestSession })
|
||||
|
||||
case SOLANA_SIGNING_METHODS.SOLANA_SIGN_MESSAGE:
|
||||
case SOLANA_SIGNING_METHODS.SOLANA_SIGN_TRANSACTION:
|
||||
return ModalStore.open('SessionSignSolanaModal', { requestEvent, requestSession })
|
||||
|
||||
case POLKADOT_SIGNING_METHODS.POLKADOT_SIGN_MESSAGE:
|
||||
case POLKADOT_SIGNING_METHODS.POLKADOT_SIGN_TRANSACTION:
|
||||
return ModalStore.open('SessionSignPolkadotModal', { requestEvent, requestSession })
|
||||
|
||||
case NEAR_SIGNING_METHODS.NEAR_SIGN_IN:
|
||||
case NEAR_SIGNING_METHODS.NEAR_SIGN_OUT:
|
||||
case NEAR_SIGNING_METHODS.NEAR_SIGN_TRANSACTION:
|
||||
case NEAR_SIGNING_METHODS.NEAR_SIGN_AND_SEND_TRANSACTION:
|
||||
case NEAR_SIGNING_METHODS.NEAR_SIGN_TRANSACTIONS:
|
||||
case NEAR_SIGNING_METHODS.NEAR_SIGN_AND_SEND_TRANSACTIONS:
|
||||
case NEAR_SIGNING_METHODS.NEAR_VERIFY_OWNER:
|
||||
return ModalStore.open('SessionSignNearModal', { requestEvent, requestSession })
|
||||
|
||||
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_MESSAGE:
|
||||
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTION:
|
||||
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_TRANSACTIONS:
|
||||
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_LOGIN_TOKEN:
|
||||
case MULTIVERSX_SIGNING_METHODS.MULTIVERSX_SIGN_NATIVE_AUTH_TOKEN:
|
||||
return ModalStore.open('SessionSignMultiversxModal', { requestEvent, requestSession })
|
||||
|
||||
case NEAR_SIGNING_METHODS.NEAR_GET_ACCOUNTS:
|
||||
return web3wallet.respondSessionRequest({
|
||||
topic,
|
||||
response: await approveNearRequest(requestEvent)
|
||||
})
|
||||
default:
|
||||
return ModalStore.open('SessionUnsuportedMethodModal', { requestEvent, requestSession })
|
||||
}
|
||||
},
|
||||
[]
|
||||
)
|
||||
|
||||
/******************************************************************************
|
||||
* Set up WalletConnect event listeners
|
||||
*****************************************************************************/
|
||||
useEffect(() => {
|
||||
if (initialized) {
|
||||
// sign
|
||||
web3wallet.on('session_proposal', onSessionProposal)
|
||||
web3wallet.on('session_request', onSessionRequest)
|
||||
// auth
|
||||
web3wallet.on('auth_request', onAuthRequest)
|
||||
|
||||
// TODOs
|
||||
// signClient.on('session_ping', data => console.log('ping', data))
|
||||
// signClient.on('session_event', data => console.log('event', data))
|
||||
// signClient.on('session_update', data => console.log('update', data))
|
||||
// signClient.on('session_delete', data => console.log('delete', data))
|
||||
}
|
||||
}, [initialized, onSessionProposal, onSessionRequest, onAuthRequest])
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
import { Secp256k1Wallet, StdSignDoc } from '@cosmjs/amino'
|
||||
import { fromHex } from '@cosmjs/encoding'
|
||||
import { DirectSecp256k1Wallet } from '@cosmjs/proto-signing'
|
||||
// @ts-expect-error
|
||||
import { SignDoc } from '@cosmjs/proto-signing/build/codec/cosmos/tx/v1beta1/tx'
|
||||
import Keyring from 'mnemonic-keyring'
|
||||
|
||||
/**
|
||||
* Constants
|
||||
*/
|
||||
const DEFAULT_PATH = "m/44'/118'/0'/0/0"
|
||||
const DEFAULT_PREFIX = 'cosmos'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IInitArguments {
|
||||
mnemonic?: string
|
||||
path?: string
|
||||
prefix?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Library
|
||||
*/
|
||||
export default class CosmosLib {
|
||||
private keyring: Keyring
|
||||
private directSigner: DirectSecp256k1Wallet
|
||||
private aminoSigner: Secp256k1Wallet
|
||||
|
||||
constructor(keyring: Keyring, directSigner: DirectSecp256k1Wallet, aminoSigner: Secp256k1Wallet) {
|
||||
this.directSigner = directSigner
|
||||
this.keyring = keyring
|
||||
this.aminoSigner = aminoSigner
|
||||
}
|
||||
|
||||
static async init({ mnemonic, path, prefix }: IInitArguments) {
|
||||
const keyring = await Keyring.init({ mnemonic: mnemonic ?? Keyring.generateMnemonic() })
|
||||
const privateKey = fromHex(keyring.getPrivateKey(path ?? DEFAULT_PATH))
|
||||
const directSigner = await DirectSecp256k1Wallet.fromKey(privateKey, prefix ?? DEFAULT_PREFIX)
|
||||
const aminoSigner = await Secp256k1Wallet.fromKey(privateKey, prefix ?? DEFAULT_PREFIX)
|
||||
|
||||
return new CosmosLib(keyring, directSigner, aminoSigner)
|
||||
}
|
||||
|
||||
public getMnemonic() {
|
||||
return this.keyring.mnemonic
|
||||
}
|
||||
|
||||
public async getAddress() {
|
||||
const account = await this.directSigner.getAccounts()
|
||||
|
||||
return account[0].address
|
||||
}
|
||||
|
||||
public async signDirect(address: string, signDoc: SignDoc) {
|
||||
return await this.directSigner.signDirect(address, signDoc)
|
||||
}
|
||||
|
||||
public async signAmino(address: string, signDoc: StdSignDoc) {
|
||||
return await this.aminoSigner.signAmino(address, signDoc)
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
import { providers, Wallet } from 'ethers'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IInitArgs {
|
||||
mnemonic?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Library
|
||||
*/
|
||||
export default class EIP155Lib {
|
||||
wallet: Wallet
|
||||
|
||||
constructor(wallet: Wallet) {
|
||||
this.wallet = wallet
|
||||
}
|
||||
|
||||
static init({ mnemonic }: IInitArgs) {
|
||||
const wallet = mnemonic ? Wallet.fromMnemonic(mnemonic) : Wallet.createRandom()
|
||||
|
||||
return new EIP155Lib(wallet)
|
||||
}
|
||||
|
||||
getMnemonic() {
|
||||
return this.wallet.mnemonic.phrase
|
||||
}
|
||||
|
||||
getAddress() {
|
||||
return this.wallet.address
|
||||
}
|
||||
|
||||
signMessage(message: string) {
|
||||
return this.wallet.signMessage(message)
|
||||
}
|
||||
|
||||
_signTypedData(domain: any, types: any, data: any) {
|
||||
return this.wallet._signTypedData(domain, types, data)
|
||||
}
|
||||
|
||||
connect(provider: providers.JsonRpcProvider) {
|
||||
return this.wallet.connect(provider)
|
||||
}
|
||||
|
||||
signTransaction(transaction: providers.TransactionRequest) {
|
||||
return this.wallet.signTransaction(transaction)
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
import { Transaction, SignableMessage } from '@multiversx/sdk-core'
|
||||
import { Mnemonic, UserSecretKey, UserWallet, UserSigner } from '@multiversx/sdk-wallet'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IInitArgs {
|
||||
mnemonic?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Library
|
||||
*/
|
||||
export default class MultiversxLib {
|
||||
wallet: UserWallet
|
||||
mnemonic: Mnemonic
|
||||
password: string
|
||||
|
||||
constructor(mnemonic: Mnemonic) {
|
||||
this.mnemonic = mnemonic
|
||||
this.password = 'password' // test purposes only
|
||||
|
||||
this.wallet = UserWallet.fromMnemonic({
|
||||
password: this.password,
|
||||
mnemonic: mnemonic.toString()
|
||||
})
|
||||
}
|
||||
|
||||
static init({ mnemonic }: IInitArgs) {
|
||||
const mnemonicObj = mnemonic ? Mnemonic.fromString(mnemonic) : Mnemonic.generate()
|
||||
|
||||
return new MultiversxLib(mnemonicObj)
|
||||
}
|
||||
|
||||
getMnemonic() {
|
||||
const secretKey = this.mnemonic.getWords().join(' ')
|
||||
|
||||
return secretKey
|
||||
}
|
||||
|
||||
getAddress() {
|
||||
const secretKey = UserWallet.decryptSecretKey(this.wallet.toJSON(), this.password)
|
||||
const address = secretKey.generatePublicKey().toAddress().bech32()
|
||||
|
||||
return address
|
||||
}
|
||||
|
||||
async signMessage(message: string) {
|
||||
const secretKey = UserWallet.decryptSecretKey(this.wallet.toJSON(), this.password)
|
||||
const secretKeyHex = secretKey.hex()
|
||||
|
||||
const signMessage = new SignableMessage({
|
||||
message: Buffer.from(message)
|
||||
})
|
||||
|
||||
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
||||
const signature = await signer.sign(signMessage.serializeForSigning())
|
||||
|
||||
return { signature: signature.toString('hex') }
|
||||
}
|
||||
|
||||
async signTransaction(transaction: any) {
|
||||
const secretKey = UserWallet.decryptSecretKey(this.wallet.toJSON(), this.password)
|
||||
const secretKeyHex = secretKey.hex()
|
||||
|
||||
const signTransaction = Transaction.fromPlainObject(transaction)
|
||||
|
||||
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
||||
const signature = await signer.sign(signTransaction.serializeForSigning())
|
||||
|
||||
return { signature: signature.toString('hex') }
|
||||
}
|
||||
|
||||
async signTransactions(transactions: any[]) {
|
||||
const secretKey = UserWallet.decryptSecretKey(this.wallet.toJSON(), this.password)
|
||||
const secretKeyHex = secretKey.hex()
|
||||
|
||||
const signatures = await Promise.all(
|
||||
transactions.map(async (transaction: any): Promise<any> => {
|
||||
const signTransaction = Transaction.fromPlainObject(transaction)
|
||||
const signer = new UserSigner(UserSecretKey.fromString(secretKeyHex))
|
||||
const signature = await signer.sign(signTransaction.serializeForSigning())
|
||||
|
||||
return { signature: signature.toString('hex') }
|
||||
})
|
||||
)
|
||||
|
||||
return { signatures }
|
||||
}
|
||||
}
|
@ -1,348 +0,0 @@
|
||||
import {
|
||||
InMemorySigner,
|
||||
providers,
|
||||
keyStores as nearKeyStores,
|
||||
transactions as nearTransactions,
|
||||
utils
|
||||
} from 'near-api-js'
|
||||
import { AccessKeyView } from 'near-api-js/lib/providers/provider'
|
||||
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { NEAR_TEST_CHAINS, TNearChain } from '@/data/NEARData'
|
||||
|
||||
const MAX_ACCOUNTS = 2
|
||||
|
||||
interface Account {
|
||||
accountId: string
|
||||
publicKey: string
|
||||
}
|
||||
|
||||
interface Transaction {
|
||||
signerId: string
|
||||
receiverId: string
|
||||
actions: Array<nearTransactions.Action>
|
||||
}
|
||||
|
||||
interface CreateTransactionsParams {
|
||||
chainId: string
|
||||
transactions: Array<Transaction>
|
||||
}
|
||||
|
||||
interface GetAccountsParams {
|
||||
topic: string
|
||||
}
|
||||
|
||||
interface SignInParams {
|
||||
chainId: string
|
||||
topic: string
|
||||
permission: nearTransactions.FunctionCallPermission
|
||||
accounts: Array<Account>
|
||||
}
|
||||
|
||||
interface SignOutParams {
|
||||
chainId: string
|
||||
topic: string
|
||||
accounts: Array<Account>
|
||||
}
|
||||
|
||||
interface SignTransactionsParams {
|
||||
chainId: string
|
||||
topic: string
|
||||
transactions: Array<nearTransactions.Transaction>
|
||||
}
|
||||
|
||||
interface SignAndSendTransactionParams {
|
||||
chainId: string
|
||||
topic: string
|
||||
transaction: nearTransactions.Transaction
|
||||
}
|
||||
|
||||
interface SignAndSendTransactionsParams {
|
||||
chainId: string
|
||||
topic: string
|
||||
transactions: Array<nearTransactions.Transaction>
|
||||
}
|
||||
|
||||
export class NearWallet {
|
||||
private networkId: string
|
||||
private keyStore: nearKeyStores.KeyStore
|
||||
|
||||
static async init(networkId: string) {
|
||||
const keyStore = new nearKeyStores.BrowserLocalStorageKeyStore()
|
||||
const accounts = await keyStore.getAccounts(networkId)
|
||||
|
||||
for (let i = 0; i < Math.max(MAX_ACCOUNTS - accounts.length, 0); i += 1) {
|
||||
const { accountId, keyPair } = await NearWallet.createDevAccount()
|
||||
|
||||
await keyStore.setKey(networkId, accountId, keyPair)
|
||||
}
|
||||
|
||||
return new NearWallet(networkId, keyStore)
|
||||
}
|
||||
|
||||
static async createDevAccount() {
|
||||
const keyPair = utils.KeyPair.fromRandom('ed25519')
|
||||
const randomNumber = Math.floor(
|
||||
Math.random() * (99999999999999 - 10000000000000) + 10000000000000
|
||||
)
|
||||
const accountId = `dev-${Date.now()}-${randomNumber}`
|
||||
const publicKey = keyPair.getPublicKey().toString()
|
||||
|
||||
return fetch(`https://helper.testnet.near.org/account`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
newAccountId: accountId,
|
||||
newAccountPublicKey: publicKey
|
||||
})
|
||||
}).then(res => {
|
||||
if (res.ok) {
|
||||
return {
|
||||
accountId,
|
||||
keyPair
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('Failed to create NEAR dev account')
|
||||
})
|
||||
}
|
||||
|
||||
private constructor(networkId: string, keyStore: nearKeyStores.KeyStore) {
|
||||
this.networkId = networkId
|
||||
this.keyStore = keyStore
|
||||
}
|
||||
|
||||
getKeyStore() {
|
||||
return this.keyStore
|
||||
}
|
||||
|
||||
// Retrieve all imported accounts from wallet.
|
||||
async getAllAccounts(): Promise<Array<Account>> {
|
||||
const accountIds = await this.keyStore.getAccounts(this.networkId)
|
||||
|
||||
return Promise.all(
|
||||
accountIds.map(async accountId => {
|
||||
const keyPair = await this.keyStore.getKey(this.networkId, accountId)
|
||||
|
||||
return {
|
||||
accountId,
|
||||
publicKey: keyPair.getPublicKey().toString()
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
private isAccountsValid(topic: string, accounts: Array<{ accountId: string }>) {
|
||||
const session = web3wallet.engine.signClient.session.get(topic)
|
||||
const validAccountIds = session.namespaces.near.accounts.map(accountId => {
|
||||
return accountId.split(':')[2]
|
||||
})
|
||||
|
||||
return accounts.every(({ accountId }) => {
|
||||
return validAccountIds.includes(accountId)
|
||||
})
|
||||
}
|
||||
|
||||
private isTransactionsValid(topic: string, transactions: Array<nearTransactions.Transaction>) {
|
||||
const accounts = transactions.map(({ signerId }) => ({ accountId: signerId }))
|
||||
|
||||
return this.isAccountsValid(topic, accounts)
|
||||
}
|
||||
|
||||
async createTransactions({
|
||||
chainId,
|
||||
transactions
|
||||
}: CreateTransactionsParams): Promise<Array<nearTransactions.Transaction>> {
|
||||
const provider = new providers.JsonRpcProvider(NEAR_TEST_CHAINS[chainId as TNearChain].rpc)
|
||||
const txs: Array<nearTransactions.Transaction> = []
|
||||
|
||||
const [block, accounts] = await Promise.all([
|
||||
provider.block({ finality: 'final' }),
|
||||
this.getAllAccounts()
|
||||
])
|
||||
|
||||
for (let i = 0; i < transactions.length; i += 1) {
|
||||
const transaction = transactions[i]
|
||||
const account = accounts.find(x => x.accountId === transaction.signerId)
|
||||
|
||||
if (!account) {
|
||||
throw new Error('Invalid signer id')
|
||||
}
|
||||
|
||||
const accessKey = await provider.query<AccessKeyView>({
|
||||
request_type: 'view_access_key',
|
||||
finality: 'final',
|
||||
account_id: transaction.signerId,
|
||||
public_key: account.publicKey
|
||||
})
|
||||
|
||||
txs.push(
|
||||
nearTransactions.createTransaction(
|
||||
transaction.signerId,
|
||||
utils.PublicKey.from(account.publicKey),
|
||||
transaction.receiverId,
|
||||
accessKey.nonce + i + 1,
|
||||
transaction.actions,
|
||||
utils.serialize.base_decode(block.header.hash)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
return txs
|
||||
}
|
||||
|
||||
async getAccounts({ topic }: GetAccountsParams): Promise<Array<Account>> {
|
||||
const session = web3wallet.engine.signClient.session.get(topic)
|
||||
|
||||
return Promise.all(
|
||||
session.namespaces.near.accounts.map(async account => {
|
||||
const accountId = account.split(':')[2]
|
||||
const keyPair = await this.keyStore.getKey(this.networkId, accountId)
|
||||
|
||||
return {
|
||||
accountId,
|
||||
publicKey: keyPair.getPublicKey().toString()
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
async signIn({ chainId, topic, permission, accounts }: SignInParams): Promise<Array<Account>> {
|
||||
if (!this.isAccountsValid(topic, accounts)) {
|
||||
throw new Error('Invalid accounts')
|
||||
}
|
||||
|
||||
const result: Array<Account> = []
|
||||
|
||||
for (let i = 0; i < accounts.length; i += 1) {
|
||||
const account = accounts[i]
|
||||
|
||||
try {
|
||||
const [transaction] = await this.createTransactions({
|
||||
chainId,
|
||||
transactions: [
|
||||
{
|
||||
signerId: account.accountId,
|
||||
receiverId: account.accountId,
|
||||
actions: [
|
||||
nearTransactions.addKey(
|
||||
utils.PublicKey.from(account.publicKey),
|
||||
nearTransactions.functionCallAccessKey(
|
||||
permission.receiverId,
|
||||
permission.methodNames,
|
||||
permission.allowance
|
||||
)
|
||||
)
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
await this.signAndSendTransaction({ chainId, topic, transaction })
|
||||
|
||||
result.push(account)
|
||||
} catch (err) {
|
||||
console.log(`Failed to create FunctionCall access key for ${account.accountId}`)
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
async signOut({ chainId, topic, accounts }: SignOutParams): Promise<Array<Account>> {
|
||||
if (!this.isAccountsValid(topic, accounts)) {
|
||||
throw new Error('Invalid accounts')
|
||||
}
|
||||
|
||||
const result: Array<Account> = []
|
||||
|
||||
for (let i = 0; i < accounts.length; i += 1) {
|
||||
const account = accounts[i]
|
||||
|
||||
try {
|
||||
const [transaction] = await this.createTransactions({
|
||||
chainId,
|
||||
transactions: [
|
||||
{
|
||||
signerId: account.accountId,
|
||||
receiverId: account.accountId,
|
||||
actions: [nearTransactions.deleteKey(utils.PublicKey.from(account.publicKey))]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
await this.signAndSendTransaction({ chainId, topic, transaction })
|
||||
} catch (err) {
|
||||
console.log(`Failed to remove FunctionCall access key for ${account.accountId}`)
|
||||
console.error(err)
|
||||
|
||||
result.push(account)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
async signTransactions({
|
||||
chainId,
|
||||
topic,
|
||||
transactions
|
||||
}: SignTransactionsParams): Promise<Array<nearTransactions.SignedTransaction>> {
|
||||
const networkId = chainId.split(':')[1]
|
||||
const signer = new InMemorySigner(this.keyStore)
|
||||
const signedTxs: Array<nearTransactions.SignedTransaction> = []
|
||||
|
||||
if (!this.isTransactionsValid(topic, transactions)) {
|
||||
throw new Error('Invalid transactions')
|
||||
}
|
||||
|
||||
for (let i = 0; i < transactions.length; i += 1) {
|
||||
const transaction = transactions[i]
|
||||
|
||||
const [, signedTx] = await nearTransactions.signTransaction(
|
||||
transaction,
|
||||
signer,
|
||||
transaction.signerId,
|
||||
networkId
|
||||
)
|
||||
|
||||
signedTxs.push(signedTx)
|
||||
}
|
||||
|
||||
return signedTxs
|
||||
}
|
||||
|
||||
async signAndSendTransaction({
|
||||
chainId,
|
||||
topic,
|
||||
transaction
|
||||
}: SignAndSendTransactionParams): Promise<providers.FinalExecutionOutcome> {
|
||||
const provider = new providers.JsonRpcProvider(NEAR_TEST_CHAINS[chainId as TNearChain].rpc)
|
||||
const [signedTx] = await this.signTransactions({
|
||||
chainId,
|
||||
topic,
|
||||
transactions: [transaction]
|
||||
})
|
||||
|
||||
return provider.sendTransaction(signedTx)
|
||||
}
|
||||
|
||||
async signAndSendTransactions({
|
||||
chainId,
|
||||
topic,
|
||||
transactions
|
||||
}: SignAndSendTransactionsParams): Promise<Array<providers.FinalExecutionOutcome>> {
|
||||
const provider = new providers.JsonRpcProvider(NEAR_TEST_CHAINS[chainId as TNearChain].rpc)
|
||||
const signedTxs = await this.signTransactions({ chainId, topic, transactions })
|
||||
const results: Array<providers.FinalExecutionOutcome> = []
|
||||
|
||||
for (let i = 0; i < signedTxs.length; i += 1) {
|
||||
const signedTx = signedTxs[i]
|
||||
|
||||
results.push(await provider.sendTransaction(signedTx))
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
}
|
@ -1,65 +0,0 @@
|
||||
import { Keyring } from '@polkadot/keyring'
|
||||
import { cryptoWaitReady, mnemonicGenerate } from '@polkadot/util-crypto'
|
||||
import { KeyringPair } from '@polkadot/keyring/types'
|
||||
import { u8aToHex } from '@polkadot/util'
|
||||
import { SignerPayloadJSON } from '@polkadot/types/types'
|
||||
import { TypeRegistry } from '@polkadot/types'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IInitArguments {
|
||||
mnemonic?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Library
|
||||
*/
|
||||
export default class PolkadotLib {
|
||||
keypair: KeyringPair
|
||||
mnemonic: string
|
||||
registry: TypeRegistry
|
||||
|
||||
constructor(keypair: KeyringPair, mnemonic: string) {
|
||||
this.keypair = keypair
|
||||
this.mnemonic = mnemonic
|
||||
this.registry = new TypeRegistry()
|
||||
}
|
||||
|
||||
static async init({ mnemonic }: IInitArguments) {
|
||||
// wait till WASM is initialized, in case it is not initialized already (WASM is required for 'sr25519').
|
||||
await cryptoWaitReady()
|
||||
|
||||
// create a keyring to load the account.
|
||||
const keyring = new Keyring({ type: 'sr25519', ss58Format: 1 })
|
||||
|
||||
mnemonic = mnemonic || mnemonicGenerate()
|
||||
const keypair = keyring.createFromUri(mnemonic)
|
||||
|
||||
return new PolkadotLib(keypair, mnemonic)
|
||||
}
|
||||
|
||||
public getAddress() {
|
||||
return this.keypair.address
|
||||
}
|
||||
|
||||
public getMnemonic() {
|
||||
return this.mnemonic
|
||||
}
|
||||
|
||||
public async signMessage(message: string) {
|
||||
return {
|
||||
signature: u8aToHex(this.keypair.sign(message))
|
||||
}
|
||||
}
|
||||
|
||||
public async signTransaction(payload: SignerPayloadJSON) {
|
||||
this.registry.setSignedExtensions(payload.signedExtensions)
|
||||
const txPayload = this.registry.createType('ExtrinsicPayload', payload, {
|
||||
version: payload.version
|
||||
})
|
||||
|
||||
const { signature } = txPayload.sign(this.keypair)
|
||||
return { signature }
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
import { Keypair } from '@solana/web3.js'
|
||||
import bs58 from 'bs58'
|
||||
import nacl from 'tweetnacl'
|
||||
import SolanaWallet, { SolanaSignTransaction } from 'solana-wallet'
|
||||
|
||||
/**
|
||||
* Types
|
||||
*/
|
||||
interface IInitArguments {
|
||||
secretKey?: Uint8Array
|
||||
}
|
||||
|
||||
/**
|
||||
* Library
|
||||
*/
|
||||
export default class SolanaLib {
|
||||
keypair: Keypair
|
||||
solanaWallet: SolanaWallet
|
||||
|
||||
constructor(keypair: Keypair) {
|
||||
this.keypair = keypair
|
||||
this.solanaWallet = new SolanaWallet(Buffer.from(keypair.secretKey))
|
||||
}
|
||||
|
||||
static init({ secretKey }: IInitArguments) {
|
||||
const keypair = secretKey ? Keypair.fromSecretKey(secretKey) : Keypair.generate()
|
||||
|
||||
return new SolanaLib(keypair)
|
||||
}
|
||||
|
||||
public async getAddress() {
|
||||
return await this.keypair.publicKey.toBase58()
|
||||
}
|
||||
|
||||
public getSecretKey() {
|
||||
return this.keypair.secretKey.toString()
|
||||
}
|
||||
|
||||
public async signMessage(message: string) {
|
||||
const signature = nacl.sign.detached(bs58.decode(message), this.keypair.secretKey)
|
||||
const bs58Signature = bs58.encode(signature)
|
||||
|
||||
return { signature: bs58Signature }
|
||||
}
|
||||
|
||||
public async signTransaction(
|
||||
feePayer: SolanaSignTransaction['feePayer'],
|
||||
recentBlockhash: SolanaSignTransaction['recentBlockhash'],
|
||||
instructions: SolanaSignTransaction['instructions'],
|
||||
partialSignatures?: SolanaSignTransaction['partialSignatures']
|
||||
) {
|
||||
const { signature } = await this.solanaWallet.signTransaction(feePayer, {
|
||||
feePayer,
|
||||
instructions,
|
||||
recentBlockhash,
|
||||
partialSignatures: partialSignatures ?? []
|
||||
})
|
||||
|
||||
return { signature }
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
import Layout from '@/components/Layout'
|
||||
import Modal from '@/components/Modal'
|
||||
import useInitialization from '@/hooks/useInitialization'
|
||||
import useWalletConnectEventsManager from '@/hooks/useWalletConnectEventsManager'
|
||||
import { createTheme, NextUIProvider } from '@nextui-org/react'
|
||||
import { AppProps } from 'next/app'
|
||||
import '../../public/main.css'
|
||||
|
||||
export default function App({ Component, pageProps }: AppProps) {
|
||||
// Step 1 - Initialize wallets and wallet connect client
|
||||
const initialized = useInitialization()
|
||||
|
||||
// Step 2 - Once initialized, set up wallet connect event manager
|
||||
useWalletConnectEventsManager(initialized)
|
||||
|
||||
// render app
|
||||
return (
|
||||
<NextUIProvider theme={createTheme({ type: 'dark' })}>
|
||||
<Layout initialized={initialized}>
|
||||
<Component {...pageProps} />
|
||||
</Layout>
|
||||
|
||||
<Modal />
|
||||
</NextUIProvider>
|
||||
)
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
import AccountCard from '@/components/AccountCard'
|
||||
import AccountPicker from '@/components/AccountPicker'
|
||||
import PageHeader from '@/components/PageHeader'
|
||||
import { COSMOS_MAINNET_CHAINS } from '@/data/COSMOSData'
|
||||
import { EIP155_MAINNET_CHAINS, EIP155_TEST_CHAINS } from '@/data/EIP155Data'
|
||||
import { SOLANA_MAINNET_CHAINS, SOLANA_TEST_CHAINS } from '@/data/SolanaData'
|
||||
import { POLKADOT_MAINNET_CHAINS, POLKADOT_TEST_CHAINS } from '@/data/PolkadotData'
|
||||
import { MULTIVERSX_MAINNET_CHAINS, MULTIVERSX_TEST_CHAINS } from '@/data/MultiversxData'
|
||||
import SettingsStore from '@/store/SettingsStore'
|
||||
import { Text } from '@nextui-org/react'
|
||||
import { Fragment } from 'react'
|
||||
import { useSnapshot } from 'valtio'
|
||||
import { NEAR_TEST_CHAINS } from '@/data/NEARData'
|
||||
|
||||
export default function HomePage() {
|
||||
const {
|
||||
testNets,
|
||||
eip155Address,
|
||||
cosmosAddress,
|
||||
solanaAddress,
|
||||
polkadotAddress,
|
||||
nearAddress,
|
||||
multiversxAddress
|
||||
} = useSnapshot(SettingsStore.state)
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<PageHeader title="Accounts">
|
||||
<AccountPicker />
|
||||
</PageHeader>
|
||||
<Text h4 css={{ marginBottom: '$5' }}>
|
||||
Mainnets
|
||||
</Text>
|
||||
{Object.values(EIP155_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
|
||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={eip155Address} />
|
||||
))}
|
||||
{Object.values(COSMOS_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
|
||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={cosmosAddress} />
|
||||
))}
|
||||
{Object.values(SOLANA_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
|
||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={solanaAddress} />
|
||||
))}
|
||||
{Object.values(POLKADOT_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
|
||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={polkadotAddress} />
|
||||
))}
|
||||
{Object.values(MULTIVERSX_MAINNET_CHAINS).map(({ name, logo, rgb }) => (
|
||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={multiversxAddress} />
|
||||
))}
|
||||
|
||||
{testNets ? (
|
||||
<Fragment>
|
||||
<Text h4 css={{ marginBottom: '$5' }}>
|
||||
Testnets
|
||||
</Text>
|
||||
{Object.values(EIP155_TEST_CHAINS).map(({ name, logo, rgb }) => (
|
||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={eip155Address} />
|
||||
))}
|
||||
{Object.values(SOLANA_TEST_CHAINS).map(({ name, logo, rgb }) => (
|
||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={solanaAddress} />
|
||||
))}
|
||||
{Object.values(POLKADOT_TEST_CHAINS).map(({ name, logo, rgb }) => (
|
||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={polkadotAddress} />
|
||||
))}
|
||||
{Object.values(NEAR_TEST_CHAINS).map(({ name, logo, rgb }) => (
|
||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={nearAddress} />
|
||||
))}
|
||||
{Object.values(MULTIVERSX_TEST_CHAINS).map(({ name, logo, rgb }) => (
|
||||
<AccountCard key={name} name={name} logo={logo} rgb={rgb} address={multiversxAddress} />
|
||||
))}
|
||||
</Fragment>
|
||||
) : null}
|
||||
</Fragment>
|
||||
)
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
import PageHeader from '@/components/PageHeader'
|
||||
import PairingCard from '@/components/PairingCard'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Text } from '@nextui-org/react'
|
||||
import { getSdkError } from '@walletconnect/utils'
|
||||
import { Fragment, useState } from 'react'
|
||||
|
||||
export default function PairingsPage() {
|
||||
const [pairings, setPairings] = useState(
|
||||
web3wallet.engine.signClient.core.pairing.pairings.values
|
||||
)
|
||||
|
||||
async function onDelete(topic: string) {
|
||||
await web3wallet.disconnectSession({ topic, reason: getSdkError('USER_DISCONNECTED') })
|
||||
const newPairings = pairings.filter(pairing => pairing.topic !== topic)
|
||||
setPairings(newPairings)
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<PageHeader title="Pairings" />
|
||||
{pairings.length ? (
|
||||
pairings.map(pairing => {
|
||||
const { peerMetadata } = pairing
|
||||
|
||||
return (
|
||||
<PairingCard
|
||||
key={pairing.topic}
|
||||
logo={peerMetadata?.icons[0]}
|
||||
url={peerMetadata?.url}
|
||||
name={peerMetadata?.name}
|
||||
onDelete={() => onDelete(pairing.topic)}
|
||||
/>
|
||||
)
|
||||
})
|
||||
) : (
|
||||
<Text css={{ opacity: '0.5', textAlign: 'center', marginTop: '$20' }}>No pairings</Text>
|
||||
)}
|
||||
</Fragment>
|
||||
)
|
||||
}
|
@ -1,132 +0,0 @@
|
||||
import PageHeader from '@/components/PageHeader'
|
||||
import ProjectInfoCard from '@/components/ProjectInfoCard'
|
||||
import SessionChainCard from '@/components/SessionChainCard'
|
||||
import { web3wallet } from '@/utils/WalletConnectUtil'
|
||||
import { Button, Divider, Loading, Row, Text } from '@nextui-org/react'
|
||||
import { getSdkError } from '@walletconnect/utils'
|
||||
import { useRouter } from 'next/router'
|
||||
import { Fragment, useEffect, useState } from 'react'
|
||||
|
||||
/**
|
||||
* Component
|
||||
*/
|
||||
export default function SessionPage() {
|
||||
const [topic, setTopic] = useState('')
|
||||
const [updated, setUpdated] = useState(new Date())
|
||||
const { query, replace } = useRouter()
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (query?.topic) {
|
||||
setTopic(query.topic as string)
|
||||
}
|
||||
}, [query])
|
||||
|
||||
const session = web3wallet.getActiveSessions()[topic]
|
||||
|
||||
if (!session) {
|
||||
return null
|
||||
}
|
||||
|
||||
// Get necessary data from session
|
||||
const expiryDate = new Date(session.expiry * 1000)
|
||||
const { namespaces } = session
|
||||
|
||||
// Handle deletion of a session
|
||||
async function onDeleteSession() {
|
||||
setLoading(true)
|
||||
await web3wallet.disconnectSession({ topic, reason: getSdkError('USER_DISCONNECTED') })
|
||||
replace('/sessions')
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
async function onSessionPing() {
|
||||
setLoading(true)
|
||||
await web3wallet.engine.signClient.ping({ topic })
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
async function onSessionEmit() {
|
||||
setLoading(true)
|
||||
console.log('baleg')
|
||||
await web3wallet.emitSessionEvent({
|
||||
topic,
|
||||
event: { name: 'chainChanged', data: 'Hello World' },
|
||||
chainId: 'eip155:1'
|
||||
})
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
const newNs = {
|
||||
eip155: {
|
||||
accounts: [
|
||||
'eip155:1:0x70012948c348CBF00806A3C79E3c5DAdFaAa347B',
|
||||
'eip155:137:0x70012948c348CBF00806A3C79E3c5DAdFaAa347B'
|
||||
],
|
||||
methods: ['personal_sign', 'eth_signTypedData', 'eth_sendTransaction'],
|
||||
events: []
|
||||
}
|
||||
}
|
||||
|
||||
async function onSessionUpdate() {
|
||||
setLoading(true)
|
||||
await web3wallet.updateSession({ topic, namespaces: newNs })
|
||||
setUpdated(new Date())
|
||||
setLoading(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<PageHeader title="Session Details" />
|
||||
|
||||
<ProjectInfoCard metadata={session.peer.metadata} />
|
||||
|
||||
<Divider y={2} />
|
||||
|
||||
{Object.keys(namespaces).map(chain => {
|
||||
return (
|
||||
<Fragment key={chain}>
|
||||
<Text h4 css={{ marginBottom: '$5' }}>{`Review ${chain} permissions`}</Text>
|
||||
<SessionChainCard namespace={namespaces[chain]} />
|
||||
{/* {renderAccountSelection(chain)} */}
|
||||
<Divider y={2} />
|
||||
</Fragment>
|
||||
)
|
||||
})}
|
||||
|
||||
<Row justify="space-between">
|
||||
<Text h5>Expiry</Text>
|
||||
<Text css={{ color: '$gray400' }}>{expiryDate.toDateString()}</Text>
|
||||
</Row>
|
||||
|
||||
<Row justify="space-between">
|
||||
<Text h5>Last Updated</Text>
|
||||
<Text css={{ color: '$gray400' }}>{updated.toDateString()}</Text>
|
||||
</Row>
|
||||
|
||||
<Row css={{ marginTop: '$10' }}>
|
||||
<Button flat css={{ width: '100%' }} color="error" onClick={onDeleteSession}>
|
||||
{loading ? <Loading size="sm" color="error" /> : 'Delete'}
|
||||
</Button>
|
||||
</Row>
|
||||
|
||||
<Row css={{ marginTop: '$10' }}>
|
||||
<Button flat css={{ width: '100%' }} color="primary" onClick={onSessionPing}>
|
||||
{loading ? <Loading size="sm" color="primary" /> : 'Ping'}
|
||||
</Button>
|
||||
</Row>
|
||||
|
||||
<Row css={{ marginTop: '$10' }}>
|
||||
<Button flat css={{ width: '100%' }} color="secondary" onClick={onSessionEmit}>
|
||||
{loading ? <Loading size="sm" color="secondary" /> : 'Emit'}
|
||||
</Button>
|
||||
</Row>
|
||||
|
||||
<Row css={{ marginTop: '$10' }}>
|
||||
<Button flat css={{ width: '100%' }} color="warning" onClick={onSessionUpdate}>
|
||||
{loading ? <Loading size="sm" color="warning" /> : 'Update'}
|
||||
</Button>
|
||||
</Row>
|
||||
</Fragment>
|
||||
)
|
||||
}
|