-
Notifications
You must be signed in to change notification settings - Fork 2
/
app.vue
61 lines (53 loc) · 1.52 KB
/
app.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<script lang="ts" setup>
import { BrowserWalletConnector } from '@vue-dapp/core'
import { VueDappModal, useVueDappModal } from '@vue-dapp/modal'
import '@vue-dapp/modal/dist/style.css'
import { WalletConnectConnector } from '@vue-dapp/walletconnect'
import { CoinbaseWalletConnector } from '@vue-dapp/coinbase'
const { isConnected, wallet, disconnect, addConnectors } = useVueDapp()
function onClickConnectBtn() {
if (isConnected.value) {
disconnect()
} else {
const { open } = useVueDappModal()
open()
}
}
if (process.client) {
addConnectors([
new BrowserWalletConnector(),
new WalletConnectConnector({
projectId: '3f3c98042b194264687bf59e104c534a',
chains: [1],
showQrModal: true,
qrModalOptions: {
themeMode: 'dark',
themeVariables: undefined,
desktopWallets: undefined,
walletImages: undefined,
mobileWallets: undefined,
enableExplorer: true,
privacyPolicyUrl: undefined,
termsOfServiceUrl: undefined,
},
}),
new CoinbaseWalletConnector({
appName: 'Vue Dapp',
jsonRpcUrl: `https://mainnet.infura.io/v3/ff6a249a74e048f1b413cba715f98d07`,
}),
])
}
</script>
<template>
<div>
<button @click="onClickConnectBtn">{{ isConnected ? 'Disconnect' : 'Connect' }}</button>
<div>status: {{ wallet.status }}</div>
<div>isConnected: {{ isConnected }}</div>
<div>error: {{ wallet.error }}</div>
<div v-if="isConnected">
<div>chainId: {{ wallet.chainId }}</div>
<div>address: {{ wallet.address }}</div>
</div>
<VueDappModal dark auto-connect />
</div>
</template>