Feat/verify integration (#161)
* Added verify status to auth req modal * updated deps * updated types deps * updated wc deps * updated auth client in wallet to canary for testing * updated auth client in dapp to canary for testing
This commit is contained in:
parent
34cf292b06
commit
f9c7d2388d
@ -8,13 +8,13 @@ export default function useWalletConnectEventsManager(initialized: boolean) {
|
|||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (initialized) {
|
if (initialized) {
|
||||||
// Auth client events
|
authClient.on('auth_request', ({ id, params, verifyContext }) => {
|
||||||
authClient.on('auth_request', ({ id, params }) => {
|
console.log('auth_request', { id, params, verifyContext })
|
||||||
console.log('auth_request', { id, params })
|
|
||||||
ModalStore.open('AuthenticationRequest', {
|
ModalStore.open('AuthenticationRequest', {
|
||||||
authenticationRequest: {
|
authenticationRequest: {
|
||||||
id,
|
id,
|
||||||
params
|
params,
|
||||||
|
verifyContext
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import AuthClient from '@walletconnect/auth-client'
|
import AuthClient from '@walletconnect/auth-client'
|
||||||
import pkg from '@walletconnect/auth-client/package.json'
|
import pkg from '@walletconnect/auth-client/package.json'
|
||||||
|
import { Verify } from '@walletconnect/types'
|
||||||
import { Core } from '@walletconnect/core'
|
import { Core } from '@walletconnect/core'
|
||||||
import { WalletClient } from '@walletconnect/push-client'
|
import { WalletClient } from '@walletconnect/push-client'
|
||||||
|
|
||||||
@ -57,3 +58,17 @@ export const getAndFormatNotifications = () => {
|
|||||||
|
|
||||||
return allMessagesWithSubscription
|
return allMessagesWithSubscription
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getVerifyStatus(context?: Verify.Context) {
|
||||||
|
if (!context) return ''
|
||||||
|
switch (context.verified.validation) {
|
||||||
|
case 'VALID':
|
||||||
|
return '✅'
|
||||||
|
case 'INVALID':
|
||||||
|
return '❌'
|
||||||
|
case 'UNKNOWN':
|
||||||
|
return '❓'
|
||||||
|
default:
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -4,10 +4,11 @@ import ModalStore from '@/store/ModalStore'
|
|||||||
import { Button, Col, Modal, Row, Text } from '@nextui-org/react'
|
import { Button, Col, Modal, Row, Text } from '@nextui-org/react'
|
||||||
import { createOrRestoreEIP155Wallet } from '@/utils/EIP155WalletUtil'
|
import { createOrRestoreEIP155Wallet } from '@/utils/EIP155WalletUtil'
|
||||||
import { authClient } from '@/utils/WalletConnectUtil'
|
import { authClient } from '@/utils/WalletConnectUtil'
|
||||||
|
import { getVerifyStatus } from '@/utils/WalletConnectUtil'
|
||||||
|
|
||||||
export default function AuthenticationRequestModal() {
|
export default function AuthenticationRequestModal() {
|
||||||
const authenticationRequest = ModalStore.state.data?.authenticationRequest
|
const authenticationRequest = ModalStore.state.data?.authenticationRequest
|
||||||
const { params, id } = authenticationRequest
|
const { params, id, verifyContext } = authenticationRequest
|
||||||
const [message, setMessage] = useState<string>()
|
const [message, setMessage] = useState<string>()
|
||||||
const [iss, setIss] = useState<string>()
|
const [iss, setIss] = useState<string>()
|
||||||
const { eip155Wallets, eip155Addresses } = createOrRestoreEIP155Wallet()
|
const { eip155Wallets, eip155Addresses } = createOrRestoreEIP155Wallet()
|
||||||
@ -72,7 +73,7 @@ export default function AuthenticationRequestModal() {
|
|||||||
<RequestModalContainer title="Authentication Request">
|
<RequestModalContainer title="Authentication Request">
|
||||||
<Row>
|
<Row>
|
||||||
<Col>
|
<Col>
|
||||||
<Text h5>Message</Text>
|
<Text h5>Message {getVerifyStatus(verifyContext)}</Text>
|
||||||
<Text style={{ whiteSpace: 'pre-wrap' }} color="$gray400">
|
<Text style={{ whiteSpace: 'pre-wrap' }} color="$gray400">
|
||||||
{message}
|
{message}
|
||||||
</Text>
|
</Text>
|
||||||
|
Loading…
Reference in New Issue
Block a user