@1001-digital/components 1.2.2 → 1.3.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.
Files changed (48) hide show
  1. package/package.json +2 -22
  2. package/src/base/components/AppShell.vue +60 -0
  3. package/src/base/components/BottomNav.vue +44 -0
  4. package/src/base/components/Sidebar.vue +282 -0
  5. package/src/index.ts +3 -3
  6. package/src/evm/assets/wallets/coinbase.svg +0 -4
  7. package/src/evm/assets/wallets/in-app.svg +0 -5
  8. package/src/evm/assets/wallets/metamask.svg +0 -1
  9. package/src/evm/assets/wallets/phantom.svg +0 -4
  10. package/src/evm/assets/wallets/rabby.svg +0 -24
  11. package/src/evm/assets/wallets/rainbow.svg +0 -59
  12. package/src/evm/assets/wallets/safe.png +0 -0
  13. package/src/evm/assets/wallets/walletconnect.svg +0 -1
  14. package/src/evm/components/EvmAccount.vue +0 -28
  15. package/src/evm/components/EvmAvatar.vue +0 -62
  16. package/src/evm/components/EvmConnect.vue +0 -303
  17. package/src/evm/components/EvmConnectDialog.vue +0 -75
  18. package/src/evm/components/EvmConnectionStatus.vue +0 -13
  19. package/src/evm/components/EvmConnectorQR.vue +0 -86
  20. package/src/evm/components/EvmInAppWalletSetup.vue +0 -251
  21. package/src/evm/components/EvmMetaMaskQR.vue +0 -34
  22. package/src/evm/components/EvmProfile.vue +0 -186
  23. package/src/evm/components/EvmSeedPhraseInput.vue +0 -193
  24. package/src/evm/components/EvmSiwe.vue +0 -190
  25. package/src/evm/components/EvmSiweDialog.vue +0 -93
  26. package/src/evm/components/EvmSwitchNetwork.vue +0 -132
  27. package/src/evm/components/EvmTransactionFlow.vue +0 -353
  28. package/src/evm/components/EvmWalletConnectQR.vue +0 -13
  29. package/src/evm/components/EvmWalletConnectWallets.vue +0 -200
  30. package/src/evm/composables/base.ts +0 -7
  31. package/src/evm/composables/chainId.ts +0 -42
  32. package/src/evm/composables/ens.ts +0 -113
  33. package/src/evm/composables/gasPrice.ts +0 -37
  34. package/src/evm/composables/priceFeed.ts +0 -116
  35. package/src/evm/composables/siwe.ts +0 -89
  36. package/src/evm/composables/uri.ts +0 -12
  37. package/src/evm/composables/walletExplorer.ts +0 -130
  38. package/src/evm/config.ts +0 -35
  39. package/src/evm/connectors/inAppWallet.ts +0 -5
  40. package/src/evm/index.ts +0 -60
  41. package/src/evm/utils/addresses.ts +0 -6
  42. package/src/evm/utils/cache.ts +0 -59
  43. package/src/evm/utils/chains.ts +0 -32
  44. package/src/evm/utils/ens.ts +0 -116
  45. package/src/evm/utils/format-eth.ts +0 -15
  46. package/src/evm/utils/price.ts +0 -17
  47. package/src/evm/utils/siwe.ts +0 -70
  48. package/src/evm/utils/uri.ts +0 -24
@@ -1,116 +0,0 @@
1
- import { isAddress, type PublicClient, type Address } from 'viem'
2
- import { normalize } from 'viem/ens'
3
- import { createCache } from './cache'
4
-
5
- // --- Types ---
6
-
7
- export interface EnsProfile {
8
- address: string
9
- ens: string | null
10
- data: {
11
- avatar: string
12
- header: string
13
- description: string
14
- links: {
15
- url: string
16
- email: string
17
- twitter: string
18
- github: string
19
- }
20
- } | null
21
- }
22
-
23
- // --- Text record keys ---
24
-
25
- const ALL_KEYS = [
26
- 'avatar',
27
- 'header',
28
- 'description',
29
- 'url',
30
- 'email',
31
- 'com.twitter',
32
- 'com.github',
33
- ] as const
34
-
35
- export const ENS_KEYS_AVATAR = ['avatar'] as const
36
- export const ENS_KEYS_PROFILE = [...ALL_KEYS]
37
-
38
- // --- Cache ---
39
-
40
- export const ensCache = createCache<EnsProfile>(5 * 60 * 1000, 500)
41
-
42
- // --- Fetchers ---
43
-
44
- export async function fetchEnsFromIndexer(
45
- identifier: string,
46
- urls: string[],
47
- ): Promise<EnsProfile> {
48
- let lastError: Error | undefined
49
-
50
- for (const url of urls) {
51
- try {
52
- const res = await fetch(`${url}/${identifier}`)
53
- if (!res.ok) throw new Error(`Indexer error: ${res.status}`)
54
- return (await res.json()) as EnsProfile
55
- } catch (err) {
56
- lastError = err as Error
57
- }
58
- }
59
-
60
- throw lastError ?? new Error('No indexer URLs provided')
61
- }
62
-
63
- export async function fetchEnsFromChain(
64
- identifier: string,
65
- client: PublicClient,
66
- keys: string[] = [],
67
- ): Promise<EnsProfile> {
68
- const isAddr = isAddress(identifier)
69
-
70
- let address: string
71
- let ens: string | null
72
-
73
- if (isAddr) {
74
- address = identifier
75
- ens = (await client.getEnsName({ address: identifier as Address })) ?? null
76
- } else {
77
- ens = identifier
78
- const resolved = await client.getEnsAddress({ name: normalize(identifier) })
79
- if (!resolved) return { address: '', ens, data: null }
80
- address = resolved
81
- }
82
-
83
- if (!ens || !keys.length) return { address, ens: ens ?? null, data: null }
84
-
85
- const name = normalize(ens)
86
- const results = await Promise.all(
87
- keys.map((key) => client.getEnsText({ name, key }).catch(() => null)),
88
- )
89
-
90
- return {
91
- address,
92
- ens,
93
- data: toProfileData(
94
- keys,
95
- results.map((r) => r || ''),
96
- ),
97
- }
98
- }
99
-
100
- // --- Helpers ---
101
-
102
- function toProfileData(keys: string[], results: string[]): EnsProfile['data'] {
103
- const get = (key: string) => results[keys.indexOf(key)] || ''
104
-
105
- return {
106
- avatar: get('avatar'),
107
- header: get('header'),
108
- description: get('description'),
109
- links: {
110
- url: get('url'),
111
- email: get('email'),
112
- twitter: get('com.twitter'),
113
- github: get('com.github'),
114
- },
115
- }
116
- }
@@ -1,15 +0,0 @@
1
- export function formatETH(
2
- value: string | number,
3
- maxDecimals: number = 3,
4
- ): string {
5
- const numberValue = typeof value === 'string' ? parseFloat(value) : value
6
-
7
- if (isNaN(numberValue)) {
8
- throw new Error('Invalid number input')
9
- }
10
-
11
- return new Intl.NumberFormat('en-US', {
12
- minimumFractionDigits: 0,
13
- maximumFractionDigits: maxDecimals,
14
- }).format(numberValue)
15
- }
@@ -1,17 +0,0 @@
1
- const replacer = (_: string, value: unknown) => {
2
- if (typeof value === 'bigint') return value.toString() + 'n'
3
- return value
4
- }
5
-
6
- const reviver = (_: string, value: unknown) => {
7
- if (typeof value === 'string' && /^\d+n$/.test(value))
8
- return BigInt(value.slice(0, -1))
9
- return value
10
- }
11
-
12
- export const stringifyJSON = (obj: unknown): string =>
13
- JSON.stringify(obj, replacer)
14
- export const parseJSON = (json: string): unknown => JSON.parse(json, reviver)
15
-
16
- export const formatPrice = (num: number, digits: number = 2) =>
17
- num?.toLocaleString('en-US', { maximumFractionDigits: digits })
@@ -1,70 +0,0 @@
1
- export interface SiweMessageParams {
2
- domain: string
3
- address: string
4
- uri: string
5
- version?: string
6
- chainId: number
7
- nonce: string
8
- issuedAt?: string
9
- expirationTime?: string
10
- notBefore?: string
11
- requestId?: string
12
- statement?: string
13
- resources?: string[]
14
- }
15
-
16
- export function createSiweMessage(params: SiweMessageParams): string {
17
- const {
18
- domain,
19
- address,
20
- uri,
21
- version = '1',
22
- chainId,
23
- nonce,
24
- issuedAt = new Date().toISOString(),
25
- expirationTime,
26
- notBefore,
27
- requestId,
28
- statement,
29
- resources,
30
- } = params
31
-
32
- const lines: string[] = [
33
- `${domain} wants you to sign in with your Ethereum account:`,
34
- address,
35
- '',
36
- ]
37
-
38
- if (statement) {
39
- lines.push(statement, '')
40
- }
41
-
42
- lines.push(
43
- `URI: ${uri}`,
44
- `Version: ${version}`,
45
- `Chain ID: ${chainId}`,
46
- `Nonce: ${nonce}`,
47
- `Issued At: ${issuedAt}`,
48
- )
49
-
50
- if (expirationTime) {
51
- lines.push(`Expiration Time: ${expirationTime}`)
52
- }
53
-
54
- if (notBefore) {
55
- lines.push(`Not Before: ${notBefore}`)
56
- }
57
-
58
- if (requestId) {
59
- lines.push(`Request ID: ${requestId}`)
60
- }
61
-
62
- if (resources?.length) {
63
- lines.push('Resources:')
64
- for (const resource of resources) {
65
- lines.push(`- ${resource}`)
66
- }
67
- }
68
-
69
- return lines.join('\n')
70
- }
@@ -1,24 +0,0 @@
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
- }