@1001-digital/components 0.0.4 → 0.0.5
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 +11 -2
- package/src/base/components/Button.vue +2 -2
- package/src/base/components/Calendar.vue +227 -0
- package/src/base/components/Combobox.vue +241 -0
- package/src/base/components/ConfirmDialog.vue +33 -0
- package/src/base/components/Dialog.vue +7 -1
- package/src/base/components/FormDateField.vue +111 -0
- package/src/base/components/FormDatePicker.vue +382 -0
- package/src/base/components/FormSlider.vue +142 -0
- package/src/base/components/FormSwitch.vue +103 -0
- package/src/base/components/Globals.vue +9 -0
- package/src/base/components/Opepicon.vue +45 -0
- package/src/base/components/PinInput.vue +105 -0
- package/src/base/components/Progress.vue +66 -0
- package/src/base/components/Toasts.vue +6 -1
- package/src/base/composables/confirm.ts +29 -0
- package/src/base/composables/toast.ts +1 -0
- package/src/base/icons.ts +3 -1
- package/src/evm/components/EvmAvatar.vue +62 -0
- package/src/evm/components/EvmConnect.vue +83 -32
- package/src/evm/components/EvmConnectorQR.vue +12 -42
- package/src/evm/components/EvmProfile.vue +183 -0
- package/src/evm/components/EvmSwitchNetwork.vue +130 -0
- package/src/evm/components/EvmTransactionFlow.vue +41 -11
- package/src/evm/components/EvmWalletConnectWallets.vue +199 -0
- package/src/evm/composables/chainId.ts +2 -2
- package/src/evm/composables/uri.ts +11 -0
- package/src/evm/composables/walletExplorer.ts +130 -0
- package/src/evm/config.ts +1 -0
- package/src/evm/index.ts +9 -0
- package/src/evm/utils/uri.ts +24 -0
- package/src/index.ts +18 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ref, computed } from 'vue'
|
|
2
|
+
import { useEvmConfig } from '../config'
|
|
3
|
+
|
|
4
|
+
const EXPLORER_API = 'https://explorer-api.walletconnect.com/v3'
|
|
5
|
+
const RECENT_KEY = 'evm:recent-wallets'
|
|
6
|
+
const PAGE_SIZE = 40
|
|
7
|
+
|
|
8
|
+
export interface ExplorerWallet {
|
|
9
|
+
id: string
|
|
10
|
+
name: string
|
|
11
|
+
image_id: string
|
|
12
|
+
homepage: string
|
|
13
|
+
mobile: { native: string; universal: string }
|
|
14
|
+
desktop: { native: string; universal: string }
|
|
15
|
+
injected: { namespace: string; injected_id: string }[] | null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function useWalletExplorer() {
|
|
19
|
+
const config = useEvmConfig()
|
|
20
|
+
const projectId = computed(() => config.walletConnectProjectId || '')
|
|
21
|
+
|
|
22
|
+
const wallets = ref<ExplorerWallet[]>([])
|
|
23
|
+
const searchResults = ref<ExplorerWallet[]>([])
|
|
24
|
+
const totalCount = ref(0)
|
|
25
|
+
const page = ref(0)
|
|
26
|
+
const loading = ref(false)
|
|
27
|
+
const searching = ref(false)
|
|
28
|
+
const recentIds = ref<string[]>(loadRecent())
|
|
29
|
+
|
|
30
|
+
const recentWallets = computed(() =>
|
|
31
|
+
recentIds.value
|
|
32
|
+
.map(id => wallets.value.find(w => w.id === id))
|
|
33
|
+
.filter((w): w is ExplorerWallet => !!w)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
const hasMore = computed(() => wallets.value.length < totalCount.value)
|
|
37
|
+
|
|
38
|
+
function imageUrl(wallet: ExplorerWallet) {
|
|
39
|
+
return `${EXPLORER_API}/logo/md/${wallet.image_id}?projectId=${projectId.value}`
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function walletHref(wallet: ExplorerWallet, uri: string) {
|
|
43
|
+
const encoded = encodeURIComponent(uri)
|
|
44
|
+
|
|
45
|
+
const universal = wallet.mobile?.universal
|
|
46
|
+
if (universal) {
|
|
47
|
+
const base = universal.endsWith('/') ? universal : universal + '/'
|
|
48
|
+
return `${base}wc?uri=${encoded}`
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const native = wallet.mobile?.native
|
|
52
|
+
if (native) {
|
|
53
|
+
return `${native}wc?uri=${encoded}`
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return null
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function fetchNextPage() {
|
|
60
|
+
if (!projectId.value || loading.value) return
|
|
61
|
+
loading.value = true
|
|
62
|
+
const nextPage = page.value + 1
|
|
63
|
+
try {
|
|
64
|
+
const res = await fetch(
|
|
65
|
+
`${EXPLORER_API}/wallets?projectId=${projectId.value}&entries=${PAGE_SIZE}&page=${nextPage}&sdks=sign_v2`
|
|
66
|
+
)
|
|
67
|
+
const data = await res.json()
|
|
68
|
+
const fetched = Object.values(data.listings || {}) as ExplorerWallet[]
|
|
69
|
+
wallets.value = nextPage === 1 ? fetched : [...wallets.value, ...fetched]
|
|
70
|
+
totalCount.value = data.total || 0
|
|
71
|
+
page.value = nextPage
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.error('Failed to fetch wallets:', e)
|
|
74
|
+
} finally {
|
|
75
|
+
loading.value = false
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function search(query: string) {
|
|
80
|
+
if (!projectId.value || !query || query.length < 2) {
|
|
81
|
+
searchResults.value = []
|
|
82
|
+
return
|
|
83
|
+
}
|
|
84
|
+
searching.value = true
|
|
85
|
+
try {
|
|
86
|
+
const res = await fetch(
|
|
87
|
+
`${EXPLORER_API}/wallets?projectId=${projectId.value}&entries=${PAGE_SIZE}&page=1&search=${encodeURIComponent(query)}&sdks=sign_v2`
|
|
88
|
+
)
|
|
89
|
+
const data = await res.json()
|
|
90
|
+
searchResults.value = Object.values(data.listings || {})
|
|
91
|
+
} catch (e) {
|
|
92
|
+
console.error('Failed to search wallets:', e)
|
|
93
|
+
} finally {
|
|
94
|
+
searching.value = false
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function loadRecent(): string[] {
|
|
99
|
+
try {
|
|
100
|
+
return JSON.parse(localStorage.getItem(RECENT_KEY) || '[]')
|
|
101
|
+
} catch {
|
|
102
|
+
return []
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function addRecent(walletId: string) {
|
|
107
|
+
const ids = recentIds.value.filter(id => id !== walletId)
|
|
108
|
+
ids.unshift(walletId)
|
|
109
|
+
recentIds.value = ids.slice(0, 3)
|
|
110
|
+
try {
|
|
111
|
+
localStorage.setItem(RECENT_KEY, JSON.stringify(recentIds.value))
|
|
112
|
+
} catch {}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
wallets,
|
|
117
|
+
searchResults,
|
|
118
|
+
totalCount,
|
|
119
|
+
page,
|
|
120
|
+
loading,
|
|
121
|
+
searching,
|
|
122
|
+
recentWallets,
|
|
123
|
+
hasMore,
|
|
124
|
+
imageUrl,
|
|
125
|
+
walletHref,
|
|
126
|
+
fetchNextPage,
|
|
127
|
+
search,
|
|
128
|
+
addRecent,
|
|
129
|
+
}
|
|
130
|
+
}
|
package/src/evm/config.ts
CHANGED
package/src/evm/index.ts
CHANGED
|
@@ -16,6 +16,8 @@ export {
|
|
|
16
16
|
} from './utils/ens'
|
|
17
17
|
export type { EnsProfile } from './utils/ens'
|
|
18
18
|
export { stringifyJSON, parseJSON, formatPrice } from './utils/price'
|
|
19
|
+
export { resolveUri } from './utils/uri'
|
|
20
|
+
export type { ResolveUriOptions } from './utils/uri'
|
|
19
21
|
|
|
20
22
|
// Composables
|
|
21
23
|
export { useBaseURL } from './composables/base'
|
|
@@ -26,13 +28,20 @@ export {
|
|
|
26
28
|
useEnsureChainIdCheck,
|
|
27
29
|
} from './composables/chainId'
|
|
28
30
|
export { useEns, useEnsWithAvatar, useEnsProfile } from './composables/ens'
|
|
31
|
+
export { useResolveUri } from './composables/uri'
|
|
29
32
|
export { useGasPrice } from './composables/gasPrice'
|
|
30
33
|
export { usePriceFeed } from './composables/priceFeed'
|
|
34
|
+
export { useWalletExplorer } from './composables/walletExplorer'
|
|
35
|
+
export type { ExplorerWallet } from './composables/walletExplorer'
|
|
31
36
|
|
|
32
37
|
// Components
|
|
33
38
|
export { default as EvmAccount } from './components/EvmAccount.vue'
|
|
39
|
+
export { default as EvmAvatar } from './components/EvmAvatar.vue'
|
|
34
40
|
export { default as EvmConnect } from './components/EvmConnect.vue'
|
|
41
|
+
export { default as EvmProfile } from './components/EvmProfile.vue'
|
|
42
|
+
export { default as EvmSwitchNetwork } from './components/EvmSwitchNetwork.vue'
|
|
35
43
|
export { default as EvmConnectorQR } from './components/EvmConnectorQR.vue'
|
|
36
44
|
export { default as EvmMetaMaskQR } from './components/EvmMetaMaskQR.vue'
|
|
37
45
|
export { default as EvmWalletConnectQR } from './components/EvmWalletConnectQR.vue'
|
|
46
|
+
export { default as EvmWalletConnectWallets } from './components/EvmWalletConnectWallets.vue'
|
|
38
47
|
export { default as EvmTransactionFlow } from './components/EvmTransactionFlow.vue'
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ResolveUriOptions {
|
|
2
|
+
ipfsGateway?: string
|
|
3
|
+
arweaveGateway?: string
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const DEFAULT_IPFS_GATEWAY = 'https://ipfs.io/ipfs/'
|
|
7
|
+
const DEFAULT_ARWEAVE_GATEWAY = 'https://arweave.net/'
|
|
8
|
+
|
|
9
|
+
export const resolveUri = (
|
|
10
|
+
uri?: string,
|
|
11
|
+
options?: ResolveUriOptions,
|
|
12
|
+
): string => {
|
|
13
|
+
if (!uri) return ''
|
|
14
|
+
|
|
15
|
+
const ipfs = options?.ipfsGateway || DEFAULT_IPFS_GATEWAY
|
|
16
|
+
const ar = options?.arweaveGateway || DEFAULT_ARWEAVE_GATEWAY
|
|
17
|
+
|
|
18
|
+
if (uri.startsWith('data:')) return uri
|
|
19
|
+
if (uri.startsWith('ipfs://')) return ipfs + uri.replace('ipfs://', '')
|
|
20
|
+
if (uri.startsWith('ar://')) return ar + uri.replace('ar://', '')
|
|
21
|
+
if (uri.startsWith('Qm') || uri.startsWith('baf')) return ipfs + uri
|
|
22
|
+
|
|
23
|
+
return uri
|
|
24
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
export { default as Actions } from './base/components/Actions.vue'
|
|
3
3
|
export { default as Alert } from './base/components/Alert.vue'
|
|
4
4
|
export { default as Button } from './base/components/Button.vue'
|
|
5
|
+
export { default as Calendar } from './base/components/Calendar.vue'
|
|
5
6
|
export { default as Card } from './base/components/Card.vue'
|
|
7
|
+
export { default as Combobox } from './base/components/Combobox.vue'
|
|
8
|
+
export { default as ConfirmDialog } from './base/components/ConfirmDialog.vue'
|
|
6
9
|
export { default as CardLink } from './base/components/CardLink.vue'
|
|
7
10
|
export { default as Dialog } from './base/components/Dialog.vue'
|
|
11
|
+
export { default as Globals } from './base/components/Globals.vue'
|
|
8
12
|
export { default as Dropdown } from './base/components/Dropdown.vue'
|
|
9
13
|
export { default as DropdownCheckboxItem } from './base/components/DropdownCheckboxItem.vue'
|
|
10
14
|
export { default as DropdownGroup } from './base/components/DropdownGroup.vue'
|
|
@@ -16,6 +20,8 @@ export { default as DropdownSeparator } from './base/components/DropdownSeparato
|
|
|
16
20
|
export { default as DropdownSub } from './base/components/DropdownSub.vue'
|
|
17
21
|
export { default as Form } from './base/components/Form.vue'
|
|
18
22
|
export { default as FormCheckbox } from './base/components/FormCheckbox.vue'
|
|
23
|
+
export { default as FormDateField } from './base/components/FormDateField.vue'
|
|
24
|
+
export { default as FormDatePicker } from './base/components/FormDatePicker.vue'
|
|
19
25
|
export { default as FormGroup } from './base/components/FormGroup.vue'
|
|
20
26
|
export { default as FormInputGroup } from './base/components/FormInputGroup.vue'
|
|
21
27
|
export { default as FormItem } from './base/components/FormItem.vue'
|
|
@@ -25,13 +31,17 @@ export { default as FormSelect } from './base/components/FormSelect.vue'
|
|
|
25
31
|
export { default as FormTextarea } from './base/components/FormTextarea.vue'
|
|
26
32
|
export { default as Icon } from './base/components/Icon.vue'
|
|
27
33
|
export { default as Loading } from './base/components/Loading.vue'
|
|
34
|
+
export { default as Opepicon } from './base/components/Opepicon.vue'
|
|
28
35
|
export { default as Popover } from './base/components/Popover.vue'
|
|
36
|
+
export { default as Progress } from './base/components/Progress.vue'
|
|
29
37
|
export { default as Tag } from './base/components/Tag.vue'
|
|
30
38
|
export { default as Tags } from './base/components/Tags.vue'
|
|
31
39
|
export { default as Toasts } from './base/components/Toasts.vue'
|
|
32
40
|
export { default as Tooltip } from './base/components/Tooltip.vue'
|
|
33
41
|
|
|
34
42
|
// Composables
|
|
43
|
+
export { useConfirm } from './base/composables/confirm'
|
|
44
|
+
export type { ConfirmOptions } from './base/composables/confirm'
|
|
35
45
|
export { useToast } from './base/composables/toast'
|
|
36
46
|
export type {
|
|
37
47
|
Toast as ToastType,
|
|
@@ -59,6 +69,14 @@ export {
|
|
|
59
69
|
asUTCDate,
|
|
60
70
|
} from './base/utils/time'
|
|
61
71
|
|
|
72
|
+
// Date types
|
|
73
|
+
export {
|
|
74
|
+
CalendarDate,
|
|
75
|
+
CalendarDateTime,
|
|
76
|
+
ZonedDateTime,
|
|
77
|
+
} from '@internationalized/date'
|
|
78
|
+
export type { DateValue } from '@internationalized/date'
|
|
79
|
+
|
|
62
80
|
// Injection keys & types
|
|
63
81
|
export { IconAliasesKey, defaultIconAliases } from './base/icons'
|
|
64
82
|
export type { IconAliases } from './base/icons'
|