@meshconnect/uwc-react 0.8.2 → 0.8.3-snapshot.805f754
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/providers/ConnectionProvider.d.ts +3 -2
- package/dist/providers/ConnectionProvider.d.ts.map +1 -1
- package/dist/providers/ConnectionProvider.js +2 -2
- package/dist/providers/ConnectionProvider.js.map +1 -1
- package/package.json +3 -3
- package/src/providers/ConnectionProvider.singleton.test.tsx +62 -0
- package/src/providers/ConnectionProvider.tsx +7 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { UniversalWalletConnector } from '@meshconnect/uwc-core';
|
|
3
|
-
import type { Session, Network, WalletMetadata, WalletConnectConfig, TonConnectConfig } from '@meshconnect/uwc-types';
|
|
3
|
+
import type { Session, Network, WalletMetadata, WalletConnectConfig, TonConnectConfig, TronConnectorConfig } from '@meshconnect/uwc-types';
|
|
4
4
|
interface ConnectionContextValue {
|
|
5
5
|
connector: UniversalWalletConnector;
|
|
6
6
|
session: Session;
|
|
@@ -16,7 +16,8 @@ interface ConnectionProviderProps {
|
|
|
16
16
|
usingIntegratedBrowser?: boolean;
|
|
17
17
|
walletConnectConfig?: WalletConnectConfig;
|
|
18
18
|
tonConnectConfig?: TonConnectConfig;
|
|
19
|
+
tronConnectorConfig?: TronConnectorConfig;
|
|
19
20
|
}
|
|
20
|
-
export declare function ConnectionProvider({ children, networks, wallets, usingIntegratedBrowser, walletConnectConfig, tonConnectConfig }: ConnectionProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function ConnectionProvider({ children, networks, wallets, usingIntegratedBrowser, walletConnectConfig, tonConnectConfig, tronConnectorConfig }: ConnectionProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
21
22
|
export { ConnectionContext };
|
|
22
23
|
//# 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,
|
|
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"}
|
|
@@ -4,9 +4,9 @@ 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 }) {
|
|
7
|
+
export function ConnectionProvider({ children, networks, wallets, usingIntegratedBrowser = false, walletConnectConfig, tonConnectConfig, tronConnectorConfig }) {
|
|
8
8
|
if (!sharedConnector) {
|
|
9
|
-
sharedConnector = new UniversalWalletConnector(networks, wallets, usingIntegratedBrowser, walletConnectConfig, tonConnectConfig);
|
|
9
|
+
sharedConnector = new UniversalWalletConnector(networks, wallets, usingIntegratedBrowser, walletConnectConfig, tonConnectConfig, tronConnectorConfig);
|
|
10
10
|
}
|
|
11
11
|
const connector = sharedConnector;
|
|
12
12
|
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;
|
|
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,CAA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|
|
1
1
|
{
|
|
2
2
|
"name": "@meshconnect/uwc-react",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3-snapshot.805f754",
|
|
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-
|
|
20
|
-
"@meshconnect/uwc-
|
|
19
|
+
"@meshconnect/uwc-types": "0.15.1-snapshot.805f754",
|
|
20
|
+
"@meshconnect/uwc-core": "0.9.3-snapshot.805f754"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": "^18.0.0",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useContext, act } from 'react'
|
|
2
2
|
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
|
3
3
|
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import type { TronConnectorConfig } from '@meshconnect/uwc-types'
|
|
4
5
|
|
|
5
6
|
describe('ConnectionProvider singleton behavior', () => {
|
|
6
7
|
beforeEach(async () => {
|
|
@@ -95,4 +96,65 @@ describe('ConnectionProvider singleton behavior', () => {
|
|
|
95
96
|
root.unmount()
|
|
96
97
|
})
|
|
97
98
|
})
|
|
99
|
+
|
|
100
|
+
it('forwards tronConnectorConfig to the UniversalWalletConnector constructor', async () => {
|
|
101
|
+
const ctorArgs: unknown[][] = []
|
|
102
|
+
vi.doMock('@meshconnect/uwc-core', () => {
|
|
103
|
+
class UniversalWalletConnector {
|
|
104
|
+
constructor(...args: unknown[]) {
|
|
105
|
+
ctorArgs.push(args)
|
|
106
|
+
}
|
|
107
|
+
getSession() {
|
|
108
|
+
return {
|
|
109
|
+
isConnected: false,
|
|
110
|
+
walletId: undefined,
|
|
111
|
+
networkId: undefined
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
isReady() {
|
|
115
|
+
return true
|
|
116
|
+
}
|
|
117
|
+
subscribe() {
|
|
118
|
+
return () => {}
|
|
119
|
+
}
|
|
120
|
+
getWallets() {
|
|
121
|
+
return []
|
|
122
|
+
}
|
|
123
|
+
getNetworks() {
|
|
124
|
+
return []
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return { UniversalWalletConnector }
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
const { ConnectionProvider } = await import('./ConnectionProvider')
|
|
131
|
+
const tronConnectorConfig: TronConnectorConfig = {
|
|
132
|
+
enabledWallets: ['tronlink']
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const container = document.createElement('div')
|
|
136
|
+
document.body.appendChild(container)
|
|
137
|
+
const root = createRoot(container)
|
|
138
|
+
|
|
139
|
+
await act(async () => {
|
|
140
|
+
root.render(
|
|
141
|
+
<ConnectionProvider
|
|
142
|
+
networks={[]}
|
|
143
|
+
wallets={[]}
|
|
144
|
+
tronConnectorConfig={tronConnectorConfig}
|
|
145
|
+
>
|
|
146
|
+
<div />
|
|
147
|
+
</ConnectionProvider>
|
|
148
|
+
)
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
// Constructor signature: (networks, wallets, usingIntegratedBrowser,
|
|
152
|
+
// walletConnectConfig, tonConnectConfig, tronConnectorConfig)
|
|
153
|
+
expect(ctorArgs.length).toBe(1)
|
|
154
|
+
expect(ctorArgs[0]?.[5]).toBe(tronConnectorConfig)
|
|
155
|
+
|
|
156
|
+
await act(async () => {
|
|
157
|
+
root.unmount()
|
|
158
|
+
})
|
|
159
|
+
})
|
|
98
160
|
})
|
|
@@ -5,7 +5,8 @@ import type {
|
|
|
5
5
|
Network,
|
|
6
6
|
WalletMetadata,
|
|
7
7
|
WalletConnectConfig,
|
|
8
|
-
TonConnectConfig
|
|
8
|
+
TonConnectConfig,
|
|
9
|
+
TronConnectorConfig
|
|
9
10
|
} from '@meshconnect/uwc-types'
|
|
10
11
|
|
|
11
12
|
// Guard against double initialization
|
|
@@ -28,6 +29,7 @@ interface ConnectionProviderProps {
|
|
|
28
29
|
usingIntegratedBrowser?: boolean
|
|
29
30
|
walletConnectConfig?: WalletConnectConfig
|
|
30
31
|
tonConnectConfig?: TonConnectConfig
|
|
32
|
+
tronConnectorConfig?: TronConnectorConfig
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
export function ConnectionProvider({
|
|
@@ -36,7 +38,8 @@ export function ConnectionProvider({
|
|
|
36
38
|
wallets,
|
|
37
39
|
usingIntegratedBrowser = false,
|
|
38
40
|
walletConnectConfig,
|
|
39
|
-
tonConnectConfig
|
|
41
|
+
tonConnectConfig,
|
|
42
|
+
tronConnectorConfig
|
|
40
43
|
}: ConnectionProviderProps) {
|
|
41
44
|
if (!sharedConnector) {
|
|
42
45
|
sharedConnector = new UniversalWalletConnector(
|
|
@@ -44,7 +47,8 @@ export function ConnectionProvider({
|
|
|
44
47
|
wallets,
|
|
45
48
|
usingIntegratedBrowser,
|
|
46
49
|
walletConnectConfig,
|
|
47
|
-
tonConnectConfig
|
|
50
|
+
tonConnectConfig,
|
|
51
|
+
tronConnectorConfig
|
|
48
52
|
)
|
|
49
53
|
}
|
|
50
54
|
|