-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathConnection.vue
More file actions
111 lines (91 loc) · 2.72 KB
/
Connection.vue
File metadata and controls
111 lines (91 loc) · 2.72 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<script setup>
/** UI */
import Button from "@/components/ui/Button.vue"
import { Dropdown, DropdownTitle, DropdownItem, DropdownDivider } from "@/components/ui/Dropdown"
/** Services */
import amp from "@/services/amp"
import { disconnect } from "@/services/wallet"
import { arabica, mainnet, mocha } from "@/services/chains"
/** Store */
import { useAppStore } from "@/store/app.store"
import { useModalsStore } from "@/store/modals.store"
import { useNotificationsStore } from "@/store/notifications.store"
const appStore = useAppStore()
const modalsStore = useModalsStore()
const notificationsStore = useNotificationsStore()
const router = useRouter()
const { hostname } = useRequestURL()
switch (hostname) {
case "celenium.io":
appStore.network = mainnet
break
case "mocha.celenium.io":
case "mocha-4.celenium.io":
appStore.network = mocha
break
case "localhost":
appStore.network = arabica
break
default:
appStore.network = arabica
break
}
const handleConnect = async () => {
modalsStore.open("connect")
}
const handleCopy = (target) => {
window.navigator.clipboard.writeText(target)
notificationsStore.create({
notification: {
type: "info",
icon: "check",
title: "Successfully copied to clipboard",
autoDestroy: true,
},
})
}
const handleChangeWallet = () => {
modalsStore.open("connect")
}
const handleDisconnect = () => {
disconnect()
amp.log("disconnect")
appStore.address = ""
appStore.balance = 0
notificationsStore.create({
notification: {
type: "info",
icon: "check",
title: "Successfully disconnected",
autoDestroy: true,
},
})
}
</script>
<template>
<Button v-if="!appStore.address" @click="handleConnect" type="secondary" size="mini"> Connect Wallet</Button>
<Dropdown v-else>
<Button type="secondary" size="mini">
<Icon name="address" size="13" color="primary" />
{{ appStore.balance }} TIA
</Button>
<template #popup>
<DropdownTitle style="text-transform: capitalize">{{ appStore.wallet }} Wallet</DropdownTitle>
<DropdownItem @click="modalsStore.open('send')">Send TIA</DropdownItem>
<DropdownItem @click="modalsStore.open('pfb')">Submit Blob</DropdownItem>
<DropdownDivider />
<DropdownItem @click="router.push(`/address/${appStore.address}`)">
<Flex direction="column" gap="6">
<Text>Open my address</Text>
<Text size="12" color="tertiary">celestia...{{ appStore.address.slice(-4) }}</Text>
</Flex>
</DropdownItem>
<DropdownItem @click="handleCopy(appStore.address)">
<Text>Copy address</Text>
</DropdownItem>
<DropdownDivider />
<DropdownItem @click="handleChangeWallet">Change wallet</DropdownItem>
<DropdownItem @click="handleDisconnect">Disconnect</DropdownItem>
</template>
</Dropdown>
</template>