@lukso/up-connector 0.8.3 → 0.8.5-dev.2df3eae
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/dist/account-modal.cjs +3 -3
- package/dist/account-modal.js +2 -2
- package/dist/auto-setup.cjs +2 -3
- package/dist/auto-setup.cjs.map +1 -1
- package/dist/auto-setup.d.cts +1 -1
- package/dist/auto-setup.d.ts +1 -1
- package/dist/auto-setup.js +1 -2
- package/dist/backup-modal.cjs +3 -3
- package/dist/backup-modal.js +2 -2
- package/dist/chunk-3AIZSSEE.cjs +31 -0
- package/dist/chunk-3AIZSSEE.cjs.map +1 -0
- package/dist/{chunk-6W7FRKLF.js → chunk-43E6AVSP.js} +5 -4
- package/dist/chunk-43E6AVSP.js.map +1 -0
- package/dist/{chunk-4E7SPZWU.js → chunk-D7RI2CWB.js} +5 -4
- package/dist/chunk-D7RI2CWB.js.map +1 -0
- package/dist/{chunk-BLDF6KQ6.js → chunk-LXK6OUTM.js} +4 -7
- package/dist/chunk-LXK6OUTM.js.map +1 -0
- package/dist/{chunk-KSO3XK5R.cjs → chunk-PHRCQCEN.cjs} +5 -4
- package/dist/chunk-PHRCQCEN.cjs.map +1 -0
- package/dist/{chunk-2HIZGOPY.cjs → chunk-PPONAIJF.cjs} +5 -8
- package/dist/chunk-PPONAIJF.cjs.map +1 -0
- package/dist/{chunk-ODKUPDLA.cjs → chunk-UJDGQG6P.cjs} +5 -4
- package/dist/chunk-UJDGQG6P.cjs.map +1 -0
- package/dist/{chunk-2GXVRHI5.cjs → chunk-XCX7QWLC.cjs} +5 -4
- package/dist/chunk-XCX7QWLC.cjs.map +1 -0
- package/dist/chunk-XEZEZ62E.js +31 -0
- package/dist/chunk-XEZEZ62E.js.map +1 -0
- package/dist/{chunk-HYTGLJAK.js → chunk-XKSB6TPG.js} +5 -4
- package/dist/chunk-XKSB6TPG.js.map +1 -0
- package/dist/index.cjs +21 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +29 -19
- package/dist/index.js.map +1 -1
- package/dist/restore-modal.cjs +3 -3
- package/dist/restore-modal.js +2 -2
- package/package.json +13 -18
- package/src/account-modal.ts +3 -2
- package/src/auto-setup.ts +3 -2
- package/src/backup-modal.ts +3 -2
- package/src/connector.ts +7 -4
- package/src/index.ts +19 -19
- package/src/restore-modal.ts +3 -2
- package/dist/chunk-2GXVRHI5.cjs.map +0 -1
- package/dist/chunk-2HIZGOPY.cjs.map +0 -1
- package/dist/chunk-4E7SPZWU.js.map +0 -1
- package/dist/chunk-6W7FRKLF.js.map +0 -1
- package/dist/chunk-AE2OVY26.js +0 -1186
- package/dist/chunk-AE2OVY26.js.map +0 -1
- package/dist/chunk-BLDF6KQ6.js.map +0 -1
- package/dist/chunk-GUAUME2K.js +0 -31
- package/dist/chunk-GUAUME2K.js.map +0 -1
- package/dist/chunk-HYTGLJAK.js.map +0 -1
- package/dist/chunk-IBS6LDIM.cjs +0 -31
- package/dist/chunk-IBS6LDIM.cjs.map +0 -1
- package/dist/chunk-KSO3XK5R.cjs.map +0 -1
- package/dist/chunk-ODKUPDLA.cjs.map +0 -1
- package/dist/chunk-R4L3CREG.cjs +0 -1186
- package/dist/chunk-R4L3CREG.cjs.map +0 -1
- package/dist/connect-modal/index.cjs +0 -22
- package/dist/connect-modal/index.cjs.map +0 -1
- package/dist/connect-modal/index.d.cts +0 -3
- package/dist/connect-modal/index.d.ts +0 -3
- package/dist/connect-modal/index.js +0 -22
- package/dist/connect-modal/index.js.map +0 -1
- package/dist/index-DZolGZOk.d.cts +0 -413
- package/dist/index-DZolGZOk.d.ts +0 -413
- package/src/connect-modal/components/connection-view.ts +0 -418
- package/src/connect-modal/components/eoa-connection-view.ts +0 -418
- package/src/connect-modal/components/qr-code-view.ts +0 -86
- package/src/connect-modal/connect-modal.base.ts +0 -18
- package/src/connect-modal/connect-modal.config.ts +0 -27
- package/src/connect-modal/connect-modal.templates.ts +0 -22
- package/src/connect-modal/connect-modal.ts +0 -227
- package/src/connect-modal/connect-modal.types.ts +0 -108
- package/src/connect-modal/images/up-cube-glass.png +0 -0
- package/src/connect-modal/index.ts +0 -25
- package/src/connect-modal/services/wagmi.ts +0 -377
- package/src/connect-modal/styles/styles.css +0 -1
- package/src/connect-modal/utils/chainParams.ts +0 -32
- package/src/connect-modal/utils/walletConnectDeepLinkUrl.ts +0 -43
|
@@ -1,377 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wagmi Service
|
|
3
|
-
* Centralized service for wagmi interactions with proxy pattern
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { getChainById } from '@lukso/core/chains'
|
|
7
|
-
import { slug } from '@lukso/core/utils'
|
|
8
|
-
import debug from 'debug'
|
|
9
|
-
import type {
|
|
10
|
-
ConnectModalSetup,
|
|
11
|
-
WagmiConnector,
|
|
12
|
-
} from '../connect-modal.types.js'
|
|
13
|
-
import type { WalletConnector } from '../index.js'
|
|
14
|
-
import { constructAddEthereumChainParameter } from '../utils/chainParams'
|
|
15
|
-
|
|
16
|
-
const logInfo = debug('connect-modal:info')
|
|
17
|
-
|
|
18
|
-
// UP Extension ID
|
|
19
|
-
const UP_EXTENSION_ID = 'cloud.universalprofile'
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Wagmi connection state from getConnection/watchConnection
|
|
23
|
-
*/
|
|
24
|
-
export type WagmiConnection = {
|
|
25
|
-
address?: string
|
|
26
|
-
addresses?: readonly string[]
|
|
27
|
-
chainId?: number
|
|
28
|
-
chain?: any
|
|
29
|
-
connector?: any
|
|
30
|
-
status: 'connecting' | 'reconnecting' | 'connected' | 'disconnected'
|
|
31
|
-
isConnecting?: boolean
|
|
32
|
-
isReconnecting?: boolean
|
|
33
|
-
isConnected?: boolean
|
|
34
|
-
isDisconnected?: boolean
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Wagmi Service Class
|
|
39
|
-
* Provides centralized access to wagmi core functions
|
|
40
|
-
*/
|
|
41
|
-
class WagmiService {
|
|
42
|
-
private setup: ConnectModalSetup | null = null
|
|
43
|
-
private wagmiCore: any = null
|
|
44
|
-
|
|
45
|
-
configure(setup: ConnectModalSetup): void {
|
|
46
|
-
this.setup = setup
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
getSetup(): ConnectModalSetup | null {
|
|
50
|
-
return this.setup
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Ensure wagmi/core is loaded and return initialized state
|
|
55
|
-
* Returns { core, config } if ready, null otherwise
|
|
56
|
-
*/
|
|
57
|
-
private async init() {
|
|
58
|
-
if (!this.setup) return null
|
|
59
|
-
if (!this.wagmiCore) {
|
|
60
|
-
try {
|
|
61
|
-
this.wagmiCore = await import('@wagmi/core')
|
|
62
|
-
} catch {
|
|
63
|
-
return null
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return { core: this.wagmiCore, config: this.setup.wagmiConfig }
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
async getConnection() {
|
|
70
|
-
const wagmi = await this.init()
|
|
71
|
-
if (!wagmi) return null
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
return wagmi.core.getConnection(wagmi.config)
|
|
75
|
-
} catch {
|
|
76
|
-
return null
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async watchConnection(
|
|
81
|
-
callback: (connection: WagmiConnection) => void
|
|
82
|
-
): Promise<(() => void) | null> {
|
|
83
|
-
const wagmi = await this.init()
|
|
84
|
-
if (!wagmi) return null
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
return wagmi.core.watchConnection(wagmi.config, { onChange: callback })
|
|
88
|
-
} catch {
|
|
89
|
-
return null
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
async disconnect(): Promise<boolean> {
|
|
94
|
-
const wagmi = await this.init()
|
|
95
|
-
if (!wagmi) return false
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
await wagmi.core.disconnect(wagmi.config)
|
|
99
|
-
return true
|
|
100
|
-
} catch (error) {
|
|
101
|
-
console.warn('Failed to disconnect from wagmi', error)
|
|
102
|
-
return false
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Singleton instance
|
|
108
|
-
const wagmiService = new WagmiService()
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Convert a wagmi connector to our WalletConnector format
|
|
112
|
-
* @param connector - Wagmi connector instance
|
|
113
|
-
* @param connectFn - Function to call connect (from wagmi's useConnect)
|
|
114
|
-
* @param chainId - Optional chain ID to use for connection
|
|
115
|
-
*/
|
|
116
|
-
export function fromWagmiConnector(
|
|
117
|
-
connector: WagmiConnector,
|
|
118
|
-
connectFn: (options: {
|
|
119
|
-
connector: WagmiConnector
|
|
120
|
-
chainId?: number
|
|
121
|
-
}) => Promise<any>,
|
|
122
|
-
chainId?: number
|
|
123
|
-
): WalletConnector {
|
|
124
|
-
// Determine connector type based on connector.id
|
|
125
|
-
let type: WalletConnector['type'] = 'injected'
|
|
126
|
-
|
|
127
|
-
// Extract rdns from connector (EIP-6963 providers expose this)
|
|
128
|
-
const rdns: string | undefined = connector.id
|
|
129
|
-
|
|
130
|
-
// Map wagmi connector types to our types
|
|
131
|
-
if (connector.id === 'walletConnect' || connector.type === 'walletConnect') {
|
|
132
|
-
type = 'walletconnect'
|
|
133
|
-
} else if (connector.id === 'injected' || connector.type === 'injected') {
|
|
134
|
-
type = 'injected'
|
|
135
|
-
|
|
136
|
-
// Check if this is UP Extension via ID
|
|
137
|
-
if (
|
|
138
|
-
connector.id === UP_EXTENSION_ID ||
|
|
139
|
-
connector.id.includes(UP_EXTENSION_ID)
|
|
140
|
-
) {
|
|
141
|
-
type = 'extension'
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
return {
|
|
146
|
-
id: connector.uid || connector.id,
|
|
147
|
-
name: connector.name,
|
|
148
|
-
rdns,
|
|
149
|
-
type,
|
|
150
|
-
slug: slug(connector.name),
|
|
151
|
-
connect: async () => {
|
|
152
|
-
await connectFn({ connector, chainId })
|
|
153
|
-
},
|
|
154
|
-
getProvider: connector.getProvider
|
|
155
|
-
? () => connector.getProvider()
|
|
156
|
-
: undefined,
|
|
157
|
-
switchChain: connector.switchChain
|
|
158
|
-
? async (params: {
|
|
159
|
-
chainId?: number
|
|
160
|
-
addEthereumChainParameter?: any
|
|
161
|
-
}) => {
|
|
162
|
-
if (!params.chainId) {
|
|
163
|
-
console.warn('No chainId provided for switchChain, skipping')
|
|
164
|
-
return
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// Get the chain configuration based on chainId
|
|
168
|
-
// If addEthereumChainParameter is not provided, construct it from chain definition
|
|
169
|
-
let addEthereumChainParameter = params.addEthereumChainParameter
|
|
170
|
-
|
|
171
|
-
if (!addEthereumChainParameter) {
|
|
172
|
-
const chain = getChainById(params.chainId)
|
|
173
|
-
|
|
174
|
-
if (chain) {
|
|
175
|
-
addEthereumChainParameter =
|
|
176
|
-
constructAddEthereumChainParameter(chain)
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
await connector.switchChain({
|
|
181
|
-
chainId: params.chainId,
|
|
182
|
-
addEthereumChainParameter,
|
|
183
|
-
})
|
|
184
|
-
|
|
185
|
-
logInfo(
|
|
186
|
-
`Switched to chainId ${params.chainId} via connector "${connector.name}"`
|
|
187
|
-
)
|
|
188
|
-
}
|
|
189
|
-
: undefined,
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Convert array of wagmi connectors to WalletConnector array
|
|
195
|
-
* @param connectors - Array of wagmi connectors
|
|
196
|
-
* @param connectFn - Function to call connect (from wagmi's useConnect)
|
|
197
|
-
* @param chainId - Optional chain ID to use for connection
|
|
198
|
-
* @param embeddedWalletId - Optional embedded wallet ID to identify it (e.g., 'dev.lukso.auth')
|
|
199
|
-
*/
|
|
200
|
-
export function fromWagmiConnectors(
|
|
201
|
-
connectors: WagmiConnector[],
|
|
202
|
-
connectFn: (options: {
|
|
203
|
-
connector: WagmiConnector
|
|
204
|
-
chainId?: number
|
|
205
|
-
}) => Promise<any>,
|
|
206
|
-
chainId?: number,
|
|
207
|
-
embeddedWalletId?: string
|
|
208
|
-
): WalletConnector[] {
|
|
209
|
-
const result: WalletConnector[] = []
|
|
210
|
-
|
|
211
|
-
// 1. Find and add embedded wallet first (if ID provided)
|
|
212
|
-
// Check against original wagmi connector.id (not the converted UID)
|
|
213
|
-
let embeddedWalletConnector: WagmiConnector | undefined
|
|
214
|
-
let embeddedWallet: WalletConnector | undefined
|
|
215
|
-
if (embeddedWalletId) {
|
|
216
|
-
embeddedWalletConnector = connectors.find(
|
|
217
|
-
(connector) =>
|
|
218
|
-
connector.id === embeddedWalletId ||
|
|
219
|
-
connector.id.includes(embeddedWalletId)
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
if (embeddedWalletConnector) {
|
|
223
|
-
embeddedWallet = fromWagmiConnector(
|
|
224
|
-
embeddedWalletConnector,
|
|
225
|
-
connectFn,
|
|
226
|
-
chainId
|
|
227
|
-
)
|
|
228
|
-
|
|
229
|
-
// Customize for embedded wallet display
|
|
230
|
-
result.push({
|
|
231
|
-
...embeddedWallet,
|
|
232
|
-
type: 'embedded',
|
|
233
|
-
slug: 'passkey-wallet',
|
|
234
|
-
})
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// 2. Find and add UP Extension next (using ID)
|
|
239
|
-
const UP_EXTENSION_ID = 'cloud.universalprofile'
|
|
240
|
-
const upExtensionConnector = connectors.find(
|
|
241
|
-
(connector) =>
|
|
242
|
-
connector !== embeddedWalletConnector &&
|
|
243
|
-
(connector.id === UP_EXTENSION_ID ||
|
|
244
|
-
connector.id.includes(UP_EXTENSION_ID))
|
|
245
|
-
)
|
|
246
|
-
|
|
247
|
-
let upExtension: WalletConnector | undefined
|
|
248
|
-
if (upExtensionConnector) {
|
|
249
|
-
upExtension = fromWagmiConnector(upExtensionConnector, connectFn, chainId)
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// Convert remaining wagmi connectors
|
|
253
|
-
const walletConnectors = connectors
|
|
254
|
-
.filter(
|
|
255
|
-
(connector) =>
|
|
256
|
-
connector !== embeddedWalletConnector &&
|
|
257
|
-
connector !== upExtensionConnector
|
|
258
|
-
)
|
|
259
|
-
.map((connector) => fromWagmiConnector(connector, connectFn, chainId))
|
|
260
|
-
|
|
261
|
-
if (upExtension) {
|
|
262
|
-
result.push(upExtension)
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
// 3. Find and add WalletConnect (for mobile)
|
|
266
|
-
const walletConnect = walletConnectors.find(
|
|
267
|
-
(connector) => connector.type === 'walletconnect'
|
|
268
|
-
)
|
|
269
|
-
|
|
270
|
-
if (walletConnect) {
|
|
271
|
-
result.push({
|
|
272
|
-
...walletConnect,
|
|
273
|
-
type: 'mobile',
|
|
274
|
-
slug: 'up-mobile',
|
|
275
|
-
})
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// 4. Add other wallets
|
|
279
|
-
const others = walletConnectors.filter(
|
|
280
|
-
(connector) =>
|
|
281
|
-
connector !== embeddedWallet &&
|
|
282
|
-
connector !== upExtension &&
|
|
283
|
-
connector !== walletConnect
|
|
284
|
-
)
|
|
285
|
-
result.push(...others)
|
|
286
|
-
|
|
287
|
-
return result
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Setup wagmi for connect modal
|
|
292
|
-
* Call this once from your app initialization with wagmi config
|
|
293
|
-
*
|
|
294
|
-
* @example
|
|
295
|
-
* ```typescript
|
|
296
|
-
* import { setupWagmi } from '@lukso/up-connector'
|
|
297
|
-
* import { wagmiConfig } from './wagmi-config'
|
|
298
|
-
*
|
|
299
|
-
* setupWagmi({
|
|
300
|
-
* wagmiConfig,
|
|
301
|
-
* chainId: 42, // Optional: LUKSO mainnet
|
|
302
|
-
* embeddedWalletConnect: async () => {
|
|
303
|
-
* // Your passkey wallet logic
|
|
304
|
-
* }
|
|
305
|
-
* })
|
|
306
|
-
* ```
|
|
307
|
-
*/
|
|
308
|
-
export function setupWagmi(setup: ConnectModalSetup): void {
|
|
309
|
-
wagmiService.configure(setup)
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Get the current wagmi setup (for internal use by connector)
|
|
314
|
-
*/
|
|
315
|
-
export function getWagmiSetup(): ConnectModalSetup | null {
|
|
316
|
-
return wagmiService.getSetup()
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* Get current wagmi connection state
|
|
321
|
-
* Returns null if wagmi is not set up
|
|
322
|
-
*
|
|
323
|
-
* @example
|
|
324
|
-
* ```typescript
|
|
325
|
-
* import { getConnection } from '@lukso/up-connector'
|
|
326
|
-
*
|
|
327
|
-
* const connection = await getConnection()
|
|
328
|
-
* if (connection?.status === 'connected') {
|
|
329
|
-
* console.log(connection.address, connection.chainId)
|
|
330
|
-
* }
|
|
331
|
-
* ```
|
|
332
|
-
*/
|
|
333
|
-
export async function getConnection() {
|
|
334
|
-
return wagmiService.getConnection()
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Watch for wagmi connection changes
|
|
339
|
-
* Returns unsubscribe function
|
|
340
|
-
*
|
|
341
|
-
* @example
|
|
342
|
-
* ```typescript
|
|
343
|
-
* import { watchConnection } from '@lukso/up-connector'
|
|
344
|
-
*
|
|
345
|
-
* const unwatch = await watchConnection((connection) => {
|
|
346
|
-
* console.log('Connection changed:', connection.status, connection.address)
|
|
347
|
-
* })
|
|
348
|
-
*
|
|
349
|
-
* // Later: unwatch()
|
|
350
|
-
* ```
|
|
351
|
-
*/
|
|
352
|
-
export async function watchConnection(
|
|
353
|
-
callback: (connection: WagmiConnection) => void
|
|
354
|
-
): Promise<(() => void) | null> {
|
|
355
|
-
return wagmiService.watchConnection(callback)
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Disconnect from wagmi
|
|
360
|
-
* Returns true if disconnect was successful
|
|
361
|
-
*
|
|
362
|
-
* @example
|
|
363
|
-
* ```typescript
|
|
364
|
-
* import { disconnect } from '@lukso/up-connector'
|
|
365
|
-
*
|
|
366
|
-
* await disconnect()
|
|
367
|
-
* ```
|
|
368
|
-
*/
|
|
369
|
-
export async function disconnect(): Promise<boolean> {
|
|
370
|
-
return wagmiService.disconnect()
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Export the wagmi service for advanced usage
|
|
375
|
-
* @deprecated Use named exports (getConnection, watchConnection, disconnect) instead
|
|
376
|
-
*/
|
|
377
|
-
export { wagmiService as wagmi }
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
@import "@lukso/web-components/tools/styles/main.css";
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Chain Parameter Utilities
|
|
3
|
-
*
|
|
4
|
-
* Utilities to construct EIP-3085 addEthereumChain parameters from chain definitions
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { ChainExtended } from '@lukso/core/chains'
|
|
8
|
-
import type { AddEthereumChainParameter } from 'viem'
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Construct addEthereumChainParameter from a ChainExtended definition
|
|
12
|
-
* Following EIP-3085 format for wallet_addEthereumChain
|
|
13
|
-
*
|
|
14
|
-
* @param chain - Extended chain configuration
|
|
15
|
-
* @returns Parameters for wallet_addEthereumChain (excluding chainId which is passed separately)
|
|
16
|
-
*/
|
|
17
|
-
export function constructAddEthereumChainParameter(
|
|
18
|
-
chain: ChainExtended
|
|
19
|
-
): Omit<AddEthereumChainParameter, 'chainId'> {
|
|
20
|
-
return {
|
|
21
|
-
chainName: chain.name,
|
|
22
|
-
nativeCurrency: {
|
|
23
|
-
name: chain.nativeCurrency.name,
|
|
24
|
-
symbol: chain.nativeCurrency.symbol,
|
|
25
|
-
decimals: chain.nativeCurrency.decimals,
|
|
26
|
-
},
|
|
27
|
-
rpcUrls: [...chain.rpcUrls.default.http],
|
|
28
|
-
blockExplorerUrls: chain.blockExplorers?.default.url
|
|
29
|
-
? [chain.blockExplorers.default.url]
|
|
30
|
-
: undefined,
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { MOBILE_APP_DEEP_LINK_PREFIX } from '../connect-modal.config'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* URL to Mobile App deep link used by Wallet Connect
|
|
5
|
-
*
|
|
6
|
-
* @param data
|
|
7
|
-
*/
|
|
8
|
-
export const walletConnectDeepLinkUrl = (
|
|
9
|
-
data?: string,
|
|
10
|
-
options?: {
|
|
11
|
-
withRedirectUrl?: boolean
|
|
12
|
-
}
|
|
13
|
-
) => {
|
|
14
|
-
try {
|
|
15
|
-
if (!data || typeof data !== 'string') {
|
|
16
|
-
return ''
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const dataUrl = new URL(data)
|
|
20
|
-
|
|
21
|
-
// add redirectUrl to deep link
|
|
22
|
-
if (options?.withRedirectUrl) {
|
|
23
|
-
const redirectUrl = new URL(location.href)
|
|
24
|
-
|
|
25
|
-
// remove modal query params so we don't re-open the modal
|
|
26
|
-
redirectUrl.searchParams.delete('modalTemplate')
|
|
27
|
-
redirectUrl.searchParams.delete('modalSize')
|
|
28
|
-
|
|
29
|
-
// add redirectUrl to dataUrl
|
|
30
|
-
dataUrl.searchParams.append(
|
|
31
|
-
'redirectUrl',
|
|
32
|
-
`${redirectUrl.origin}${redirectUrl.pathname}${redirectUrl.search}`
|
|
33
|
-
)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const deepLink = `${MOBILE_APP_DEEP_LINK_PREFIX}://wallet-connect/${dataUrl.pathname}${dataUrl.search}`
|
|
37
|
-
|
|
38
|
-
return deepLink
|
|
39
|
-
} catch (error: unknown) {
|
|
40
|
-
console.warn(error)
|
|
41
|
-
return ''
|
|
42
|
-
}
|
|
43
|
-
}
|