@lukso/up-connector 0.5.1 → 0.6.0-dev.5ea12c5
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/auto-setup.cjs +3 -3
- package/dist/auto-setup.js +2 -2
- package/dist/{avatar-CmUCtW_w.d.cts → avatar-CQkubMTK.d.cts} +0 -1
- package/dist/{avatar-CmUCtW_w.d.ts → avatar-CQkubMTK.d.ts} +0 -1
- package/dist/avatar.cjs +2 -2
- package/dist/avatar.d.cts +1 -1
- package/dist/avatar.d.ts +1 -1
- package/dist/avatar.js +1 -1
- package/dist/backup-modal.cjs +2 -2
- package/dist/backup-modal.js +1 -1
- package/dist/{chunk-M4UJAKZ2.cjs → chunk-3IJAXTQI.cjs} +3 -3
- package/dist/chunk-3IJAXTQI.cjs.map +1 -0
- package/dist/{chunk-ORJK2YGG.cjs → chunk-7LQ5EB2X.cjs} +22 -24
- package/dist/chunk-7LQ5EB2X.cjs.map +1 -0
- package/dist/{chunk-3SGSPHOZ.js → chunk-A5RRWZ7W.js} +6 -10
- package/dist/chunk-A5RRWZ7W.js.map +1 -0
- package/dist/{chunk-IAKQFHFD.cjs → chunk-CKVXLOXK.cjs} +6 -10
- package/dist/chunk-CKVXLOXK.cjs.map +1 -0
- package/dist/{chunk-NWCNJSG3.js → chunk-DQ663HKR.js} +7 -3
- package/dist/chunk-DQ663HKR.js.map +1 -0
- package/dist/{chunk-CN2BMW6Y.cjs → chunk-GCYDV7FB.cjs} +159 -101
- package/dist/chunk-GCYDV7FB.cjs.map +1 -0
- package/dist/{chunk-6N35TCFT.js → chunk-GKAVIDXP.js} +21 -23
- package/dist/chunk-GKAVIDXP.js.map +1 -0
- package/dist/{chunk-5P7EGEE5.js → chunk-QZ55O6GN.js} +4 -4
- package/dist/chunk-QZ55O6GN.js.map +1 -0
- package/dist/{chunk-3ME6PKYE.js → chunk-SAQWNAQ6.js} +138 -80
- package/dist/chunk-SAQWNAQ6.js.map +1 -0
- package/dist/{chunk-7ETKG6KR.cjs → chunk-ZRA7ZVHJ.cjs} +7 -3
- package/dist/chunk-ZRA7ZVHJ.cjs.map +1 -0
- package/dist/connect-modal/index.cjs +4 -2
- package/dist/connect-modal/index.cjs.map +1 -1
- package/dist/connect-modal/index.d.cts +1 -1
- package/dist/connect-modal/index.d.ts +1 -1
- package/dist/connect-modal/index.js +11 -9
- package/dist/index.cjs +39 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +40 -33
- package/dist/index.js.map +1 -1
- package/dist/restore-modal.cjs +2 -2
- package/dist/restore-modal.d.cts +2 -2
- package/dist/restore-modal.d.ts +2 -2
- package/dist/restore-modal.js +1 -1
- package/dist/{wagmi-BLnqILO_.d.cts → wagmi-DgjkdmGk.d.cts} +77 -21
- package/dist/{wagmi-BLnqILO_.d.ts → wagmi-DgjkdmGk.d.ts} +77 -21
- package/package.json +7 -7
- package/src/auto-setup.ts +0 -1
- package/src/avatar.ts +20 -23
- package/src/backup-modal.ts +6 -2
- package/src/connect-modal/components/connection-view.ts +4 -1
- package/src/connect-modal/components/eoa-connection-view.ts +4 -0
- package/src/connect-modal/connect-modal.types.ts +4 -0
- package/src/connect-modal/index.ts +6 -4
- package/src/connect-modal/services/wagmi.ts +176 -76
- package/src/connect-modal/styles/styles.css +1 -1
- package/src/connect-modal/utils/chainParams.ts +32 -0
- package/src/connector.ts +22 -20
- package/src/index.ts +6 -4
- package/src/popup-instance.ts +3 -4
- package/src/restore-modal.ts +5 -3
- package/src/styles/styles.css +1 -1
- package/dist/chunk-3ME6PKYE.js.map +0 -1
- package/dist/chunk-3SGSPHOZ.js.map +0 -1
- package/dist/chunk-5P7EGEE5.js.map +0 -1
- package/dist/chunk-6N35TCFT.js.map +0 -1
- package/dist/chunk-7ETKG6KR.cjs.map +0 -1
- package/dist/chunk-CN2BMW6Y.cjs.map +0 -1
- package/dist/chunk-IAKQFHFD.cjs.map +0 -1
- package/dist/chunk-M4UJAKZ2.cjs.map +0 -1
- package/dist/chunk-NWCNJSG3.js.map +0 -1
- package/dist/chunk-ORJK2YGG.cjs.map +0 -1
|
@@ -1,20 +1,111 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Wagmi
|
|
3
|
-
*
|
|
2
|
+
* Wagmi Service
|
|
3
|
+
* Centralized service for wagmi interactions with proxy pattern
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { getChainById } from '@lukso/core/chains'
|
|
6
7
|
import { slug } from '@lukso/core/utils'
|
|
8
|
+
import debug from 'debug'
|
|
7
9
|
import type {
|
|
8
10
|
ConnectModalSetup,
|
|
9
11
|
WagmiConnector,
|
|
10
12
|
} from '../connect-modal.types.js'
|
|
11
13
|
import type { WalletConnector } from '../index.js'
|
|
14
|
+
import { constructAddEthereumChainParameter } from '../utils/chainParams'
|
|
15
|
+
|
|
16
|
+
const logInfo = debug('connect-modal:info')
|
|
12
17
|
|
|
13
18
|
// UP Extension ID
|
|
14
19
|
const UP_EXTENSION_ID = 'cloud.universalprofile'
|
|
15
20
|
|
|
16
|
-
|
|
17
|
-
|
|
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()
|
|
18
109
|
|
|
19
110
|
/**
|
|
20
111
|
* Convert a wagmi connector to our WalletConnector format
|
|
@@ -63,6 +154,39 @@ export function fromWagmiConnector(
|
|
|
63
154
|
getProvider: connector.getProvider
|
|
64
155
|
? () => connector.getProvider()
|
|
65
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,
|
|
66
190
|
}
|
|
67
191
|
}
|
|
68
192
|
|
|
@@ -169,10 +293,10 @@ export function fromWagmiConnectors(
|
|
|
169
293
|
*
|
|
170
294
|
* @example
|
|
171
295
|
* ```typescript
|
|
172
|
-
* import {
|
|
296
|
+
* import { setupWagmi } from '@lukso/up-connector'
|
|
173
297
|
* import { wagmiConfig } from './wagmi-config'
|
|
174
298
|
*
|
|
175
|
-
*
|
|
299
|
+
* setupWagmi({
|
|
176
300
|
* wagmiConfig,
|
|
177
301
|
* chainId: 42, // Optional: LUKSO mainnet
|
|
178
302
|
* embeddedWalletConnect: async () => {
|
|
@@ -181,97 +305,73 @@ export function fromWagmiConnectors(
|
|
|
181
305
|
* })
|
|
182
306
|
* ```
|
|
183
307
|
*/
|
|
184
|
-
export function
|
|
185
|
-
|
|
308
|
+
export function setupWagmi(setup: ConnectModalSetup): void {
|
|
309
|
+
wagmiService.configure(setup)
|
|
186
310
|
}
|
|
187
311
|
|
|
188
312
|
/**
|
|
189
313
|
* Get the current wagmi setup (for internal use by connector)
|
|
190
314
|
*/
|
|
191
315
|
export function getWagmiSetup(): ConnectModalSetup | null {
|
|
192
|
-
return
|
|
316
|
+
return wagmiService.getSetup()
|
|
193
317
|
}
|
|
194
318
|
|
|
195
319
|
/**
|
|
196
|
-
* Get current wagmi
|
|
320
|
+
* Get current wagmi connection state
|
|
197
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
|
+
* ```
|
|
198
332
|
*/
|
|
199
|
-
export async function
|
|
200
|
-
|
|
201
|
-
address?: string
|
|
202
|
-
chainId?: number
|
|
203
|
-
connector?: any
|
|
204
|
-
} | null> {
|
|
205
|
-
if (!globalWagmiSetup) {
|
|
206
|
-
return null
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
try {
|
|
210
|
-
const { getConnection } = await import('@wagmi/core')
|
|
211
|
-
const connection = getConnection(globalWagmiSetup.wagmiConfig)
|
|
212
|
-
|
|
213
|
-
return {
|
|
214
|
-
isConnected: connection.status === 'connected',
|
|
215
|
-
address: connection.address,
|
|
216
|
-
chainId: connection.chainId,
|
|
217
|
-
connector: connection.connector,
|
|
218
|
-
}
|
|
219
|
-
} catch (_error) {
|
|
220
|
-
return null
|
|
221
|
-
}
|
|
333
|
+
export async function getConnection() {
|
|
334
|
+
return wagmiService.getConnection()
|
|
222
335
|
}
|
|
223
336
|
|
|
224
337
|
/**
|
|
225
|
-
*
|
|
338
|
+
* Watch for wagmi connection changes
|
|
226
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
|
+
* ```
|
|
227
351
|
*/
|
|
228
|
-
export async function
|
|
229
|
-
callback: (
|
|
230
|
-
isConnected: boolean
|
|
231
|
-
address?: string
|
|
232
|
-
chainId?: number
|
|
233
|
-
connector?: any
|
|
234
|
-
}) => void
|
|
352
|
+
export async function watchConnection(
|
|
353
|
+
callback: (connection: WagmiConnection) => void
|
|
235
354
|
): Promise<(() => void) | null> {
|
|
236
|
-
|
|
237
|
-
return null
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
try {
|
|
241
|
-
const { watchConnection } = await import('@wagmi/core')
|
|
242
|
-
|
|
243
|
-
const unsubscribe = watchConnection(globalWagmiSetup.wagmiConfig, {
|
|
244
|
-
onChange: (connection) => {
|
|
245
|
-
callback({
|
|
246
|
-
isConnected: connection.status === 'connected',
|
|
247
|
-
address: connection.address,
|
|
248
|
-
chainId: connection.chainId,
|
|
249
|
-
connector: connection.connector,
|
|
250
|
-
})
|
|
251
|
-
},
|
|
252
|
-
})
|
|
253
|
-
|
|
254
|
-
return unsubscribe
|
|
255
|
-
} catch (_error) {
|
|
256
|
-
return null
|
|
257
|
-
}
|
|
355
|
+
return wagmiService.watchConnection(callback)
|
|
258
356
|
}
|
|
259
357
|
|
|
260
358
|
/**
|
|
261
359
|
* Disconnect from wagmi
|
|
262
360
|
* Returns true if disconnect was successful
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```typescript
|
|
364
|
+
* import { disconnect } from '@lukso/up-connector'
|
|
365
|
+
*
|
|
366
|
+
* await disconnect()
|
|
367
|
+
* ```
|
|
263
368
|
*/
|
|
264
|
-
export async function
|
|
265
|
-
|
|
266
|
-
return false
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
try {
|
|
270
|
-
const { disconnect } = await import('@wagmi/core')
|
|
271
|
-
await disconnect(globalWagmiSetup.wagmiConfig)
|
|
272
|
-
return true
|
|
273
|
-
} catch (error) {
|
|
274
|
-
console.warn('Failed to disconnect from wagmi', error)
|
|
275
|
-
return false
|
|
276
|
-
}
|
|
369
|
+
export async function disconnect(): Promise<boolean> {
|
|
370
|
+
return wagmiService.disconnect()
|
|
277
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 +1 @@
|
|
|
1
|
-
@import "@lukso/web-components/
|
|
1
|
+
@import "@lukso/web-components/tools/styles/main.css";
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
}
|
package/src/connector.ts
CHANGED
|
@@ -27,15 +27,11 @@ import { setLuksoConfig } from '@lukso/transaction-view-headless'
|
|
|
27
27
|
import type { AccountModal } from './account-modal.js'
|
|
28
28
|
import type { ConnectModal, WalletConnector } from './connect-modal/index.js'
|
|
29
29
|
import {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
disconnect,
|
|
31
|
+
getConnection,
|
|
32
|
+
watchConnection,
|
|
33
33
|
} from './connect-modal/index.js'
|
|
34
|
-
import type {
|
|
35
|
-
ConnectionState,
|
|
36
|
-
ConnectorConfig,
|
|
37
|
-
WalletProvider,
|
|
38
|
-
} from './types.js'
|
|
34
|
+
import type { ConnectionState, ConnectorConfig } from './types.js'
|
|
39
35
|
|
|
40
36
|
const DEFAULT_CONFIG: Required<
|
|
41
37
|
Omit<ConnectorConfig, 'avatar' | 'modal' | 'onConnectionChange'>
|
|
@@ -52,12 +48,12 @@ export class UPConnector {
|
|
|
52
48
|
private avatar?: DraggableAvatar
|
|
53
49
|
private connectModal?: ConnectModal
|
|
54
50
|
private accountModal?: AccountModal
|
|
55
|
-
private connectors: WalletConnector[] = []
|
|
56
51
|
private connectionState: ConnectionState = 'disconnected'
|
|
57
52
|
private connectedAddress?: string
|
|
58
53
|
private connectedProvider?: any
|
|
59
54
|
private connectedChainId?: number
|
|
60
55
|
private wagmiUnsubscribe?: (() => void) | null
|
|
56
|
+
connectors: WalletConnector[] = []
|
|
61
57
|
|
|
62
58
|
constructor(config: ConnectorConfig = {}) {
|
|
63
59
|
this.config = { ...DEFAULT_CONFIG, ...config }
|
|
@@ -116,22 +112,28 @@ export class UPConnector {
|
|
|
116
112
|
private async startWagmiSync(): Promise<void> {
|
|
117
113
|
try {
|
|
118
114
|
// Check initial state first
|
|
119
|
-
const
|
|
115
|
+
const connection = await getConnection()
|
|
120
116
|
|
|
121
|
-
if (!
|
|
117
|
+
if (!connection) {
|
|
122
118
|
return
|
|
123
119
|
}
|
|
124
120
|
|
|
125
|
-
if (
|
|
121
|
+
if (connection.status === 'connected' && connection.address) {
|
|
126
122
|
this.handleConnection(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
connection.address,
|
|
124
|
+
connection.connector,
|
|
125
|
+
connection.chainId
|
|
130
126
|
)
|
|
131
127
|
}
|
|
132
128
|
|
|
133
|
-
// Subscribe to wagmi
|
|
134
|
-
this.wagmiUnsubscribe = await
|
|
129
|
+
// Subscribe to wagmi connection changes
|
|
130
|
+
this.wagmiUnsubscribe = await watchConnection((connection) => {
|
|
131
|
+
const account = {
|
|
132
|
+
isConnected: connection.status === 'connected',
|
|
133
|
+
address: connection.address,
|
|
134
|
+
chainId: connection.chainId,
|
|
135
|
+
connector: connection.connector,
|
|
136
|
+
}
|
|
135
137
|
if (account.isConnected && account.address) {
|
|
136
138
|
// Connected
|
|
137
139
|
if (
|
|
@@ -188,7 +190,7 @@ export class UPConnector {
|
|
|
188
190
|
// TODO: Replace with Lit-based account management modal
|
|
189
191
|
// Legacy createModal() method removed - was using deprecated ConnectorModal
|
|
190
192
|
|
|
191
|
-
private handleAvatarClick(
|
|
193
|
+
private handleAvatarClick(_event: MouseEvent): void {
|
|
192
194
|
if (this.connectionState === 'connected') {
|
|
193
195
|
// Show account management modal
|
|
194
196
|
this.showAccountModal()
|
|
@@ -215,7 +217,7 @@ export class UPConnector {
|
|
|
215
217
|
|
|
216
218
|
// Handle connect event
|
|
217
219
|
this.connectModal.addEventListener('connect', ((e: CustomEvent) => {
|
|
218
|
-
const
|
|
220
|
+
const _connector = e.detail.connector as WalletConnector
|
|
219
221
|
// TODO: Handle actual connection logic
|
|
220
222
|
// For now, this will be extended when wagmi/viem integration is added
|
|
221
223
|
}) as EventListener)
|
|
@@ -295,7 +297,7 @@ export class UPConnector {
|
|
|
295
297
|
|
|
296
298
|
private async handleDisconnection(): Promise<void> {
|
|
297
299
|
// Disconnect from wagmi first to ensure state is clean
|
|
298
|
-
await
|
|
300
|
+
await disconnect()
|
|
299
301
|
|
|
300
302
|
this.connectedAddress = undefined
|
|
301
303
|
this.connectedProvider = undefined
|
package/src/index.ts
CHANGED
|
@@ -21,15 +21,17 @@ export type {
|
|
|
21
21
|
ConnectionModalView,
|
|
22
22
|
ConnectModalSetup,
|
|
23
23
|
ConnectModalTheme,
|
|
24
|
+
WagmiConnection,
|
|
24
25
|
WalletConnector,
|
|
25
26
|
} from './connect-modal/index.js'
|
|
26
27
|
export {
|
|
27
28
|
ConnectModal,
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
disconnect,
|
|
30
|
+
getConnection,
|
|
30
31
|
getWagmiSetup,
|
|
31
32
|
setupConnectModal,
|
|
32
|
-
|
|
33
|
+
wagmi,
|
|
34
|
+
watchConnection,
|
|
33
35
|
} from './connect-modal/index.js'
|
|
34
36
|
// Wagmi Adapter
|
|
35
37
|
export {
|
|
@@ -61,4 +63,4 @@ export type {
|
|
|
61
63
|
WalletProvider,
|
|
62
64
|
} from './types.js'
|
|
63
65
|
// Release update
|
|
64
|
-
// build
|
|
66
|
+
// build 1
|
package/src/popup-instance.ts
CHANGED
|
@@ -53,7 +53,7 @@ class PopupEventEmitter {
|
|
|
53
53
|
if (!this.handlers.has(event)) {
|
|
54
54
|
this.handlers.set(event, new Set())
|
|
55
55
|
}
|
|
56
|
-
this.handlers.get(event)
|
|
56
|
+
this.handlers.get(event)?.add(handler)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
off(event: string, handler: (...args: any[]) => void): void {
|
|
@@ -197,7 +197,7 @@ export class ModalPopupInstance extends BasePopupInstance {
|
|
|
197
197
|
|
|
198
198
|
// Remove from DOM after animation
|
|
199
199
|
setTimeout(() => {
|
|
200
|
-
if (this.modalElement
|
|
200
|
+
if (this.modalElement?.parentNode) {
|
|
201
201
|
this.modalElement.parentNode.removeChild(this.modalElement)
|
|
202
202
|
}
|
|
203
203
|
}, 300)
|
|
@@ -212,7 +212,7 @@ export class ModalPopupInstance extends BasePopupInstance {
|
|
|
212
212
|
if (this.modalElement) {
|
|
213
213
|
this.modalElement.classList.remove('visible')
|
|
214
214
|
setTimeout(() => {
|
|
215
|
-
if (this.modalElement
|
|
215
|
+
if (this.modalElement?.parentNode) {
|
|
216
216
|
this.modalElement.parentNode.removeChild(this.modalElement)
|
|
217
217
|
}
|
|
218
218
|
}, 300)
|
|
@@ -525,7 +525,6 @@ export class WindowPopupInstance extends BasePopupInstance {
|
|
|
525
525
|
left = screenLeft + windowWidth - width - 20
|
|
526
526
|
top = screenTop + 20
|
|
527
527
|
break
|
|
528
|
-
case 'center':
|
|
529
528
|
default:
|
|
530
529
|
left = screenLeft + (windowWidth - width) / 2
|
|
531
530
|
top = screenTop + (windowHeight - height) / 2
|
package/src/restore-modal.ts
CHANGED
|
@@ -43,14 +43,14 @@ export class RestoreModal extends CoreLitElement {
|
|
|
43
43
|
@state() private password = ''
|
|
44
44
|
@state() private passwordErrors: string[] = []
|
|
45
45
|
@state() private isRestoring = false
|
|
46
|
-
@state() private walletData: WalletData | null = null
|
|
47
46
|
@state() private validationWarnings: string[] = []
|
|
48
|
-
@state() private validationInfo: string[] = []
|
|
49
47
|
@state() private controllers: Array<{
|
|
50
48
|
address: string
|
|
51
49
|
status: 'new' | 'existing'
|
|
52
50
|
}> = []
|
|
53
51
|
@state() private restoredAddresses: string[] = []
|
|
52
|
+
validationInfo: string[] = []
|
|
53
|
+
walletData: WalletData | null = null
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Public method for parent to set preview result
|
|
@@ -208,7 +208,9 @@ export class RestoreModal extends CoreLitElement {
|
|
|
208
208
|
label="Password"
|
|
209
209
|
placeholder="Enter decryption password"
|
|
210
210
|
.value=${this.password}
|
|
211
|
-
@on-input=${(e: CustomEvent) =>
|
|
211
|
+
@on-input=${(e: CustomEvent) => {
|
|
212
|
+
this.password = e.detail.value
|
|
213
|
+
}}
|
|
212
214
|
@keyup=${(e: KeyboardEvent) => e.key === 'Enter' && canProceed && this.previewRestore()}
|
|
213
215
|
is-full-width
|
|
214
216
|
autofocus
|
package/src/styles/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@import "@lukso/web-components/
|
|
1
|
+
@import "@lukso/web-components/tools/styles/main.css";
|