@1001-digital/components 1.1.10 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,131 +1,102 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
v-if="
|
|
4
|
-
@
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
<EvmInAppWalletSetup
|
|
3
|
+
v-if="showInAppSetup"
|
|
4
|
+
@connected="onInAppConnected"
|
|
5
|
+
@back="showInAppSetup = false"
|
|
6
|
+
/>
|
|
7
|
+
<template v-else-if="errorMessage">
|
|
8
|
+
<Alert type="error">
|
|
9
|
+
{{ errorMessage }}
|
|
10
|
+
</Alert>
|
|
11
|
+
<Button
|
|
12
|
+
class="link muted small"
|
|
13
|
+
@click="resetConnection"
|
|
14
|
+
>
|
|
15
|
+
<Icon type="chevron-left" />
|
|
16
|
+
<span>Back</span>
|
|
17
|
+
</Button>
|
|
18
|
+
</template>
|
|
19
|
+
<EvmMetaMaskQR
|
|
20
|
+
v-else-if="metaMaskUri"
|
|
21
|
+
:uri="metaMaskUri"
|
|
22
|
+
@back="resetConnection"
|
|
23
|
+
/>
|
|
24
|
+
<EvmWalletConnectWallets
|
|
25
|
+
v-else-if="walletConnectUri"
|
|
26
|
+
:uri="walletConnectUri"
|
|
27
|
+
@back="resetConnection"
|
|
28
|
+
/>
|
|
29
|
+
<template v-else-if="isConnecting">
|
|
30
|
+
<Loading
|
|
31
|
+
:txt="`Waiting for ${connectingWallet} confirmation...`"
|
|
32
|
+
spinner
|
|
33
|
+
stacked
|
|
34
|
+
/>
|
|
35
|
+
</template>
|
|
36
|
+
<div
|
|
10
37
|
v-else
|
|
11
|
-
|
|
12
|
-
:address="address"
|
|
38
|
+
class="wallet-options"
|
|
13
39
|
>
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<template v-else-if="errorMessage">
|
|
29
|
-
<Alert type="error">
|
|
30
|
-
{{ errorMessage }}
|
|
31
|
-
</Alert>
|
|
32
|
-
<Button
|
|
33
|
-
class="link muted small"
|
|
34
|
-
@click="resetConnection"
|
|
40
|
+
<Button
|
|
41
|
+
v-for="connector in shownConnectors"
|
|
42
|
+
:key="connector.uid"
|
|
43
|
+
@click="() => login(connector)"
|
|
44
|
+
class="block choose-connector"
|
|
45
|
+
>
|
|
46
|
+
<img
|
|
47
|
+
v-if="ICONS[connector.name] || connector.icon"
|
|
48
|
+
:src="ICONS[connector.name] || connector.icon"
|
|
49
|
+
:alt="connector.name"
|
|
50
|
+
/>
|
|
51
|
+
<div
|
|
52
|
+
v-else
|
|
53
|
+
class="default-wallet-icon"
|
|
35
54
|
>
|
|
36
|
-
<Icon type="
|
|
37
|
-
|
|
38
|
-
</
|
|
39
|
-
</
|
|
40
|
-
<
|
|
41
|
-
v-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
@back="resetConnection"
|
|
49
|
-
/>
|
|
50
|
-
<template v-else-if="isConnecting">
|
|
51
|
-
<Loading
|
|
52
|
-
:txt="`Waiting for ${connectingWallet} confirmation...`"
|
|
53
|
-
spinner
|
|
54
|
-
stacked
|
|
55
|
+
<Icon type="wallet" />
|
|
56
|
+
</div>
|
|
57
|
+
<span>{{ connector.name }}</span>
|
|
58
|
+
</Button>
|
|
59
|
+
<Button
|
|
60
|
+
v-if="wcConnector"
|
|
61
|
+
@click="loginWithSafe"
|
|
62
|
+
class="block choose-connector"
|
|
63
|
+
>
|
|
64
|
+
<img
|
|
65
|
+
:src="safeIcon"
|
|
66
|
+
alt="Safe"
|
|
55
67
|
/>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
68
|
+
<span>Safe</span>
|
|
69
|
+
</Button>
|
|
70
|
+
<Button
|
|
71
|
+
v-if="inAppConnector"
|
|
72
|
+
@click="showInAppSetup = true"
|
|
73
|
+
class="block choose-connector"
|
|
60
74
|
>
|
|
61
|
-
<
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
<Icon type="wallet" />
|
|
77
|
-
</div>
|
|
78
|
-
<span>{{ connector.name }}</span>
|
|
79
|
-
</Button>
|
|
80
|
-
<Button
|
|
81
|
-
v-if="wcConnector"
|
|
82
|
-
@click="loginWithSafe"
|
|
83
|
-
class="block choose-connector"
|
|
84
|
-
>
|
|
85
|
-
<img
|
|
86
|
-
:src="safeIcon"
|
|
87
|
-
alt="Safe"
|
|
88
|
-
/>
|
|
89
|
-
<span>Safe</span>
|
|
90
|
-
</Button>
|
|
91
|
-
<Button
|
|
92
|
-
v-if="inAppConnector"
|
|
93
|
-
@click="showInAppSetup = true"
|
|
94
|
-
class="block choose-connector"
|
|
95
|
-
>
|
|
96
|
-
<img
|
|
97
|
-
:src="inAppIcon"
|
|
98
|
-
alt="Seed Phrase"
|
|
99
|
-
/>
|
|
100
|
-
<span>In App</span>
|
|
101
|
-
</Button>
|
|
102
|
-
<Button
|
|
103
|
-
to="https://ethereum.org/wallets/"
|
|
104
|
-
target="_blank"
|
|
105
|
-
class="link muted small"
|
|
106
|
-
>
|
|
107
|
-
<Icon type="help" />
|
|
108
|
-
<span>New to wallets?</span>
|
|
109
|
-
</Button>
|
|
110
|
-
</div>
|
|
111
|
-
</Dialog>
|
|
75
|
+
<img
|
|
76
|
+
:src="inAppIcon"
|
|
77
|
+
alt="Seed Phrase"
|
|
78
|
+
/>
|
|
79
|
+
<span>In App</span>
|
|
80
|
+
</Button>
|
|
81
|
+
<Button
|
|
82
|
+
to="https://ethereum.org/wallets/"
|
|
83
|
+
target="_blank"
|
|
84
|
+
class="link muted small"
|
|
85
|
+
>
|
|
86
|
+
<Icon type="help" />
|
|
87
|
+
<span>New to wallets?</span>
|
|
88
|
+
</Button>
|
|
89
|
+
</div>
|
|
112
90
|
</template>
|
|
113
91
|
|
|
114
92
|
<script setup lang="ts">
|
|
115
|
-
import { ref, computed
|
|
93
|
+
import { ref, computed } from 'vue'
|
|
116
94
|
import type { Connector } from '@wagmi/vue'
|
|
117
|
-
import {
|
|
118
|
-
useConnection,
|
|
119
|
-
useConnect,
|
|
120
|
-
useConnectors,
|
|
121
|
-
useChainId,
|
|
122
|
-
} from '@wagmi/vue'
|
|
95
|
+
import { useConnect, useConnectors, useChainId } from '@wagmi/vue'
|
|
123
96
|
import Button from '../../base/components/Button.vue'
|
|
124
|
-
import Dialog from '../../base/components/Dialog.vue'
|
|
125
97
|
import Icon from '../../base/components/Icon.vue'
|
|
126
98
|
import Alert from '../../base/components/Alert.vue'
|
|
127
99
|
import Loading from '../../base/components/Loading.vue'
|
|
128
|
-
import EvmAccount from './EvmAccount.vue'
|
|
129
100
|
import EvmMetaMaskQR from './EvmMetaMaskQR.vue'
|
|
130
101
|
import EvmWalletConnectWallets from './EvmWalletConnectWallets.vue'
|
|
131
102
|
import EvmInAppWalletSetup from './EvmInAppWalletSetup.vue'
|
|
@@ -155,24 +126,19 @@ const PRIORITY: Record<string, number> = {
|
|
|
155
126
|
'Base Account': 10,
|
|
156
127
|
}
|
|
157
128
|
|
|
158
|
-
defineProps<{
|
|
159
|
-
className?: string
|
|
160
|
-
}>()
|
|
161
129
|
const emit = defineEmits<{
|
|
162
|
-
connected: [
|
|
163
|
-
disconnected: []
|
|
130
|
+
connected: []
|
|
164
131
|
}>()
|
|
132
|
+
|
|
165
133
|
const chainId = useChainId()
|
|
166
134
|
const connectors = useConnectors()
|
|
167
135
|
const { mutateAsync: connectAsync } = useConnect()
|
|
168
|
-
const { address, isConnected } = useConnection()
|
|
169
136
|
|
|
170
137
|
const inAppConnector = computed(() =>
|
|
171
138
|
connectors.value.find((c) => c.type === 'inAppWallet'),
|
|
172
139
|
)
|
|
173
140
|
const showInAppSetup = ref(false)
|
|
174
141
|
|
|
175
|
-
const showConnect = computed(() => !isConnected.value)
|
|
176
142
|
const shownConnectors = computed(() => {
|
|
177
143
|
const unique = Array.from(
|
|
178
144
|
new Map(
|
|
@@ -199,7 +165,6 @@ const wcConnector = computed(() =>
|
|
|
199
165
|
connectors.value.find((c) => c.id === 'walletConnect'),
|
|
200
166
|
)
|
|
201
167
|
|
|
202
|
-
const chooseModalOpen = ref(false)
|
|
203
168
|
const errorMessage = ref('')
|
|
204
169
|
const isConnecting = ref(false)
|
|
205
170
|
const connectingWallet = ref('')
|
|
@@ -250,11 +215,8 @@ const login = async (connector: Connector) => {
|
|
|
250
215
|
await connectAsync({ connector, chainId: chainId.value })
|
|
251
216
|
|
|
252
217
|
setTimeout(() => {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
metaMaskUri.value = ''
|
|
256
|
-
walletConnectUri.value = ''
|
|
257
|
-
safeDeepLink.value = false
|
|
218
|
+
resetConnection()
|
|
219
|
+
emit('connected')
|
|
258
220
|
}, 100)
|
|
259
221
|
} catch (error: unknown) {
|
|
260
222
|
isConnecting.value = false
|
|
@@ -262,18 +224,15 @@ const login = async (connector: Connector) => {
|
|
|
262
224
|
walletConnectUri.value = ''
|
|
263
225
|
safeDeepLink.value = false
|
|
264
226
|
|
|
265
|
-
|
|
266
|
-
if (
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
} else {
|
|
275
|
-
errorMessage.value = 'Failed to connect. Please try again.'
|
|
276
|
-
}
|
|
227
|
+
const errorMsg = error instanceof Error ? error.message : ''
|
|
228
|
+
if (
|
|
229
|
+
errorMsg.includes('User rejected') ||
|
|
230
|
+
errorMsg.includes('rejected') ||
|
|
231
|
+
errorMsg.includes('denied')
|
|
232
|
+
) {
|
|
233
|
+
errorMessage.value = 'Connection cancelled. Please try again.'
|
|
234
|
+
} else {
|
|
235
|
+
errorMessage.value = 'Failed to connect. Please try again.'
|
|
277
236
|
}
|
|
278
237
|
console.error('Wallet connection error:', error)
|
|
279
238
|
} finally {
|
|
@@ -295,25 +254,16 @@ const resetConnection = () => {
|
|
|
295
254
|
}
|
|
296
255
|
|
|
297
256
|
const onInAppConnected = () => {
|
|
298
|
-
chooseModalOpen.value = false
|
|
299
257
|
showInAppSetup.value = false
|
|
258
|
+
emit('connected')
|
|
300
259
|
}
|
|
301
260
|
|
|
302
|
-
const
|
|
303
|
-
chooseModalOpen.value = false
|
|
261
|
+
const reset = () => {
|
|
304
262
|
resetConnection()
|
|
305
263
|
showInAppSetup.value = false
|
|
306
264
|
}
|
|
307
265
|
|
|
308
|
-
|
|
309
|
-
isConnected.value
|
|
310
|
-
? emit('connected', { address: address.value })
|
|
311
|
-
: emit('disconnected')
|
|
312
|
-
watch(isConnected, () => {
|
|
313
|
-
check()
|
|
314
|
-
if (!isConnected.value) onModalClosed()
|
|
315
|
-
})
|
|
316
|
-
onMounted(() => check())
|
|
266
|
+
defineExpose({ reset })
|
|
317
267
|
</script>
|
|
318
268
|
|
|
319
269
|
<style scoped>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Button
|
|
3
|
+
v-if="showConnect"
|
|
4
|
+
@click="open = true"
|
|
5
|
+
:class="className"
|
|
6
|
+
>
|
|
7
|
+
<slot>Connect Wallet</slot>
|
|
8
|
+
</Button>
|
|
9
|
+
<slot
|
|
10
|
+
v-else-if="isConnected"
|
|
11
|
+
name="connected"
|
|
12
|
+
:address="address"
|
|
13
|
+
>
|
|
14
|
+
<EvmAccount :address="address" />
|
|
15
|
+
</slot>
|
|
16
|
+
|
|
17
|
+
<Dialog
|
|
18
|
+
v-if="showConnect"
|
|
19
|
+
title="Connect Wallet"
|
|
20
|
+
v-model:open="open"
|
|
21
|
+
@closed="onClosed"
|
|
22
|
+
>
|
|
23
|
+
<EvmConnect
|
|
24
|
+
ref="connectRef"
|
|
25
|
+
@connected="onConnected"
|
|
26
|
+
/>
|
|
27
|
+
</Dialog>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script setup lang="ts">
|
|
31
|
+
import { ref, computed, watch, onMounted } from 'vue'
|
|
32
|
+
import { useConnection } from '@wagmi/vue'
|
|
33
|
+
import Button from '../../base/components/Button.vue'
|
|
34
|
+
import Dialog from '../../base/components/Dialog.vue'
|
|
35
|
+
import EvmAccount from './EvmAccount.vue'
|
|
36
|
+
import EvmConnect from './EvmConnect.vue'
|
|
37
|
+
|
|
38
|
+
defineProps<{
|
|
39
|
+
className?: string
|
|
40
|
+
}>()
|
|
41
|
+
|
|
42
|
+
const emit = defineEmits<{
|
|
43
|
+
connected: [{ address: `0x${string}` | undefined }]
|
|
44
|
+
disconnected: []
|
|
45
|
+
}>()
|
|
46
|
+
|
|
47
|
+
const { address, isConnected } = useConnection()
|
|
48
|
+
|
|
49
|
+
const showConnect = computed(() => !isConnected.value)
|
|
50
|
+
const open = ref(false)
|
|
51
|
+
const connectRef = ref<InstanceType<typeof EvmConnect> | null>(null)
|
|
52
|
+
|
|
53
|
+
const onConnected = () => {
|
|
54
|
+
open.value = false
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const onClosed = () => {
|
|
58
|
+
connectRef.value?.reset()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const check = () =>
|
|
62
|
+
isConnected.value
|
|
63
|
+
? emit('connected', { address: address.value })
|
|
64
|
+
: emit('disconnected')
|
|
65
|
+
|
|
66
|
+
watch(isConnected, () => {
|
|
67
|
+
check()
|
|
68
|
+
if (!isConnected.value) {
|
|
69
|
+
open.value = false
|
|
70
|
+
connectRef.value?.reset()
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
onMounted(() => check())
|
|
75
|
+
</script>
|
package/src/evm/index.ts
CHANGED
|
@@ -41,6 +41,8 @@ export { inAppWallet, prepareInAppWallet } from './connectors/inAppWallet'
|
|
|
41
41
|
export { default as EvmAccount } from './components/EvmAccount.vue'
|
|
42
42
|
export { default as EvmAvatar } from './components/EvmAvatar.vue'
|
|
43
43
|
export { default as EvmConnect } from './components/EvmConnect.vue'
|
|
44
|
+
export { default as EvmConnectDialog } from './components/EvmConnectDialog.vue'
|
|
45
|
+
export { default as EvmConnectionStatus } from './components/EvmConnectionStatus.vue'
|
|
44
46
|
export { default as EvmProfile } from './components/EvmProfile.vue'
|
|
45
47
|
export { default as EvmSwitchNetwork } from './components/EvmSwitchNetwork.vue'
|
|
46
48
|
export { default as EvmConnectorQR } from './components/EvmConnectorQR.vue'
|