@meshconnect/uwc-react 0.9.2 → 0.9.3-snapshot.8e3fd6b

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.
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { UniversalWalletConnector } from '@meshconnect/uwc-core';
3
- import type { Session, Network, WalletMetadata, WalletConnectConfig, TonConnectConfig, TronConnectorConfig } from '@meshconnect/uwc-types';
2
+ import { UniversalWalletConnector, type UWCObserver } from '@meshconnect/uwc-core';
3
+ import type { Session, Network, WalletMetadata, WalletConnectConfig, TonConnectConfig, TronConnectorConfig, Logger, LogLevel } from '@meshconnect/uwc-types';
4
4
  interface ConnectionContextValue {
5
5
  connector: UniversalWalletConnector;
6
6
  session: Session;
@@ -17,7 +17,11 @@ interface ConnectionProviderProps {
17
17
  walletConnectConfig?: WalletConnectConfig;
18
18
  tonConnectConfig?: TonConnectConfig;
19
19
  tronConnectorConfig?: TronConnectorConfig;
20
+ observer?: UWCObserver;
21
+ logger?: Logger;
22
+ logLevel?: LogLevel;
23
+ correlationId?: string | (() => string);
20
24
  }
21
- export declare function ConnectionProvider({ children, networks, wallets, usingIntegratedBrowser, walletConnectConfig, tonConnectConfig, tronConnectorConfig }: ConnectionProviderProps): import("react/jsx-runtime").JSX.Element;
25
+ export declare function ConnectionProvider({ children, networks, wallets, usingIntegratedBrowser, walletConnectConfig, tonConnectConfig, tronConnectorConfig, observer, logger, logLevel, correlationId }: ConnectionProviderProps): import("react/jsx-runtime").JSX.Element;
22
26
  export { ConnectionContext };
23
27
  //# sourceMappingURL=ConnectionProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionProvider.d.ts","sourceRoot":"","sources":["../../src/providers/ConnectionProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAA;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,wBAAwB,CAAA;AAK/B,UAAU,sBAAsB;IAC9B,SAAS,EAAE,wBAAwB,CAAA;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,cAAc,EAAE,CAAA;IACzB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,QAAA,MAAM,iBAAiB,8CAAqD,CAAA;AAE5E,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,OAAO,EAAE,cAAc,EAAE,CAAA;IACzB,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;IACzC,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;CAC1C;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,sBAA8B,EAC9B,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACpB,EAAE,uBAAuB,2CAuCzB;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
1
+ {"version":3,"file":"ConnectionProvider.d.ts","sourceRoot":"","sources":["../../src/providers/ConnectionProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAA;AACjE,OAAO,EACL,wBAAwB,EAExB,KAAK,WAAW,EACjB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EACV,OAAO,EACP,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACT,MAAM,wBAAwB,CAAA;AAK/B,UAAU,sBAAsB;IAC9B,SAAS,EAAE,wBAAwB,CAAA;IACnC,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,cAAc,EAAE,CAAA;IACzB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,QAAA,MAAM,iBAAiB,8CAAqD,CAAA;AAE5E,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,OAAO,EAAE,cAAc,EAAE,CAAA;IACzB,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;IACzC,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,mBAAmB,CAAC,EAAE,mBAAmB,CAAA;IAEzC,QAAQ,CAAC,EAAE,WAAW,CAAA;IACtB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAA;CACxC;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,sBAA8B,EAC9B,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,aAAa,EACd,EAAE,uBAAuB,2CA0CzB;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
@@ -4,9 +4,26 @@ import { UniversalWalletConnector } from '@meshconnect/uwc-core';
4
4
  // Guard against double initialization
5
5
  let sharedConnector = null;
6
6
  const ConnectionContext = createContext(null);
7
- export function ConnectionProvider({ children, networks, wallets, usingIntegratedBrowser = false, walletConnectConfig, tonConnectConfig, tronConnectorConfig }) {
7
+ export function ConnectionProvider({ children, networks, wallets, usingIntegratedBrowser = false, walletConnectConfig, tonConnectConfig, tronConnectorConfig, observer, logger, logLevel, correlationId }) {
8
8
  if (!sharedConnector) {
9
- sharedConnector = new UniversalWalletConnector(networks, wallets, usingIntegratedBrowser, walletConnectConfig, tonConnectConfig, tronConnectorConfig);
9
+ // Build the config object conditionally — under exactOptionalPropertyTypes an
10
+ // explicit `undefined` can't be assigned to an optional field.
11
+ const config = { networks, wallets, usingIntegratedBrowser };
12
+ if (walletConnectConfig)
13
+ config.walletConnectConfig = walletConnectConfig;
14
+ if (tonConnectConfig)
15
+ config.tonConnectConfig = tonConnectConfig;
16
+ if (tronConnectorConfig)
17
+ config.tronConnectorConfig = tronConnectorConfig;
18
+ if (observer)
19
+ config.observer = observer;
20
+ if (logger)
21
+ config.logger = logger;
22
+ if (logLevel)
23
+ config.logLevel = logLevel;
24
+ if (correlationId !== undefined)
25
+ config.correlationId = correlationId;
26
+ sharedConnector = new UniversalWalletConnector(config);
10
27
  }
11
28
  const connector = sharedConnector;
12
29
  const [session, setSession] = useState(() => connector.getSession());
@@ -1 +1 @@
1
- {"version":3,"file":"ConnectionProvider.js","sourceRoot":"","sources":["../../src/providers/ConnectionProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAUhE,sCAAsC;AACtC,IAAI,eAAe,GAAoC,IAAI,CAAA;AAU3D,MAAM,iBAAiB,GAAG,aAAa,CAAgC,IAAI,CAAC,CAAA;AAY5E,MAAM,UAAU,kBAAkB,CAAC,EACjC,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,sBAAsB,GAAG,KAAK,EAC9B,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACK;IACxB,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,eAAe,GAAG,IAAI,wBAAwB,CAC5C,QAAQ,EACR,OAAO,EACP,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,CACpB,CAAA;IACH,CAAC;IAED,MAAM,SAAS,GAAG,eAA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,UAAU,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,CAAA;QACjC,CAAC,CAAC,CAAA;QAEF,OAAO,WAAW,CAAA;IACpB,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;IAEf,MAAM,KAAK,GAA2B;QACpC,SAAS;QACT,OAAO;QACP,OAAO,EAAE,SAAS,CAAC,UAAU,EAAE;QAC/B,QAAQ,EAAE,SAAS,CAAC,WAAW,EAAE;QACjC,OAAO;KACR,CAAA;IAED,OAAO,CACL,KAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YACrC,QAAQ,GACkB,CAC9B,CAAA;AACH,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshconnect/uwc-react",
3
- "version": "0.9.2",
3
+ "version": "0.9.3-snapshot.8e3fd6b",
4
4
  "description": "React hooks and components for Universal Wallet Connector",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -16,8 +16,8 @@
16
16
  "src"
17
17
  ],
18
18
  "dependencies": {
19
- "@meshconnect/uwc-core": "1.0.0",
20
- "@meshconnect/uwc-types": "0.16.1"
19
+ "@meshconnect/uwc-core": "1.0.1-snapshot.8e3fd6b",
20
+ "@meshconnect/uwc-types": "0.16.1-snapshot.8e3fd6b"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "react": "^18.0.0",
@@ -148,10 +148,65 @@ describe('ConnectionProvider singleton behavior', () => {
148
148
  )
149
149
  })
150
150
 
151
- // Constructor signature: (networks, wallets, usingIntegratedBrowser,
152
- // walletConnectConfig, tonConnectConfig, tronConnectorConfig)
151
+ // Constructor now receives a single UWCConfig object (config-object form),
152
+ // so the provider can also forward the observability fields.
153
153
  expect(ctorArgs.length).toBe(1)
154
- expect(ctorArgs[0]?.[5]).toBe(tronConnectorConfig)
154
+ expect(ctorArgs[0]?.[0]?.tronConnectorConfig).toBe(tronConnectorConfig)
155
+
156
+ await act(async () => {
157
+ root.unmount()
158
+ })
159
+ })
160
+
161
+ it('forwards the observer to the UniversalWalletConnector config', async () => {
162
+ const ctorArgs: unknown[][] = []
163
+ vi.doMock('@meshconnect/uwc-core', () => {
164
+ class UniversalWalletConnector {
165
+ constructor(...args: unknown[]) {
166
+ ctorArgs.push(args)
167
+ }
168
+ getSession() {
169
+ return {
170
+ isConnected: false,
171
+ walletId: undefined,
172
+ networkId: undefined
173
+ }
174
+ }
175
+ isReady() {
176
+ return true
177
+ }
178
+ subscribe() {
179
+ return () => {}
180
+ }
181
+ getWallets() {
182
+ return []
183
+ }
184
+ getNetworks() {
185
+ return []
186
+ }
187
+ }
188
+ return { UniversalWalletConnector }
189
+ })
190
+
191
+ const { ConnectionProvider } = await import('./ConnectionProvider')
192
+ const observer = { onEvent: () => {} }
193
+
194
+ const container = document.createElement('div')
195
+ document.body.appendChild(container)
196
+ const root = createRoot(container)
197
+
198
+ await act(async () => {
199
+ root.render(
200
+ <ConnectionProvider networks={[]} wallets={[]} observer={observer}>
201
+ <div />
202
+ </ConnectionProvider>
203
+ )
204
+ })
205
+
206
+ expect(ctorArgs.length).toBe(1)
207
+ expect((ctorArgs[0]?.[0] as { observer?: unknown })?.observer).toBe(
208
+ observer
209
+ )
155
210
 
156
211
  await act(async () => {
157
212
  root.unmount()
@@ -1,12 +1,18 @@
1
1
  import React, { createContext, useEffect, useState } from 'react'
2
- import { UniversalWalletConnector } from '@meshconnect/uwc-core'
2
+ import {
3
+ UniversalWalletConnector,
4
+ type UWCConfig,
5
+ type UWCObserver
6
+ } from '@meshconnect/uwc-core'
3
7
  import type {
4
8
  Session,
5
9
  Network,
6
10
  WalletMetadata,
7
11
  WalletConnectConfig,
8
12
  TonConnectConfig,
9
- TronConnectorConfig
13
+ TronConnectorConfig,
14
+ Logger,
15
+ LogLevel
10
16
  } from '@meshconnect/uwc-types'
11
17
 
12
18
  // Guard against double initialization
@@ -30,6 +36,11 @@ interface ConnectionProviderProps {
30
36
  walletConnectConfig?: WalletConnectConfig
31
37
  tonConnectConfig?: TonConnectConfig
32
38
  tronConnectorConfig?: TronConnectorConfig
39
+ // Observability — forwarded to the connector (see @meshconnect/uwc-core).
40
+ observer?: UWCObserver
41
+ logger?: Logger
42
+ logLevel?: LogLevel
43
+ correlationId?: string | (() => string)
33
44
  }
34
45
 
35
46
  export function ConnectionProvider({
@@ -39,17 +50,24 @@ export function ConnectionProvider({
39
50
  usingIntegratedBrowser = false,
40
51
  walletConnectConfig,
41
52
  tonConnectConfig,
42
- tronConnectorConfig
53
+ tronConnectorConfig,
54
+ observer,
55
+ logger,
56
+ logLevel,
57
+ correlationId
43
58
  }: ConnectionProviderProps) {
44
59
  if (!sharedConnector) {
45
- sharedConnector = new UniversalWalletConnector(
46
- networks,
47
- wallets,
48
- usingIntegratedBrowser,
49
- walletConnectConfig,
50
- tonConnectConfig,
51
- tronConnectorConfig
52
- )
60
+ // Build the config object conditionally — under exactOptionalPropertyTypes an
61
+ // explicit `undefined` can't be assigned to an optional field.
62
+ const config: UWCConfig = { networks, wallets, usingIntegratedBrowser }
63
+ if (walletConnectConfig) config.walletConnectConfig = walletConnectConfig
64
+ if (tonConnectConfig) config.tonConnectConfig = tonConnectConfig
65
+ if (tronConnectorConfig) config.tronConnectorConfig = tronConnectorConfig
66
+ if (observer) config.observer = observer
67
+ if (logger) config.logger = logger
68
+ if (logLevel) config.logLevel = logLevel
69
+ if (correlationId !== undefined) config.correlationId = correlationId
70
+ sharedConnector = new UniversalWalletConnector(config)
53
71
  }
54
72
 
55
73
  const connector = sharedConnector