@getpara/evm-wallet-connectors 2.0.0-fc.2 → 2.0.0-fc.3
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/ParaEvmContext.js +45 -41
- package/package.json +5 -5
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "../chunk-MMUBH76A.js";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
10
|
-
import { createConfig, WagmiProvider } from "wagmi";
|
|
10
|
+
import { createConfig as createWagmiConfig, WagmiProvider } from "wagmi";
|
|
11
11
|
import { connectorsForWallets } from "../wallets/connectorsForWallets.js";
|
|
12
12
|
import { http } from "viem";
|
|
13
13
|
import { computeWalletConnectMetaData } from "../utils/computeWalletConnectMetaData.js";
|
|
@@ -30,16 +30,14 @@ function ParaEvmProvider({
|
|
|
30
30
|
config: _config,
|
|
31
31
|
wagmiProviderProps
|
|
32
32
|
}) {
|
|
33
|
-
const prevWallets = useRef(null);
|
|
34
33
|
const para = internalConfig.para;
|
|
35
|
-
const [config, setConfig] = useState(null);
|
|
36
34
|
const _a = _config, {
|
|
37
35
|
projectId,
|
|
38
36
|
appName,
|
|
39
37
|
appDescription,
|
|
40
38
|
appIcon,
|
|
41
39
|
appUrl,
|
|
42
|
-
wallets,
|
|
40
|
+
wallets: propsWallets,
|
|
43
41
|
chains,
|
|
44
42
|
transports,
|
|
45
43
|
paraConnectorOptions
|
|
@@ -54,6 +52,10 @@ function ParaEvmProvider({
|
|
|
54
52
|
"transports",
|
|
55
53
|
"paraConnectorOptions"
|
|
56
54
|
]);
|
|
55
|
+
const propsWalletList = useMemo(() => {
|
|
56
|
+
return resolveWalletList(propsWallets != null ? propsWallets : []);
|
|
57
|
+
}, [propsWallets]);
|
|
58
|
+
const prevWallets = useRef(propsWalletList);
|
|
57
59
|
const paraConnectorInstance = useMemo(() => {
|
|
58
60
|
return paraConnector({
|
|
59
61
|
para,
|
|
@@ -63,52 +65,54 @@ function ParaEvmProvider({
|
|
|
63
65
|
options: paraConnectorOptions != null ? paraConnectorOptions : {}
|
|
64
66
|
});
|
|
65
67
|
}, [para]);
|
|
68
|
+
const createConfig = (walletList, createFarcasterConnector) => {
|
|
69
|
+
const existing = getWagmiConfig();
|
|
70
|
+
if (existing && prevWallets.current === walletList) {
|
|
71
|
+
return existing;
|
|
72
|
+
}
|
|
73
|
+
prevWallets.current = walletList;
|
|
74
|
+
const wcMetadata = computeWalletConnectMetaData({ appName, appDescription, appUrl, appIcon });
|
|
75
|
+
const baseConnectors = connectorsForWallets(walletList, {
|
|
76
|
+
para,
|
|
77
|
+
createFarcasterConnector,
|
|
78
|
+
projectId,
|
|
79
|
+
appName,
|
|
80
|
+
appDescription,
|
|
81
|
+
appUrl,
|
|
82
|
+
appIcon,
|
|
83
|
+
walletConnectParameters: { metadata: wcMetadata }
|
|
84
|
+
});
|
|
85
|
+
const allConnectors = [...baseConnectors, paraConnectorInstance];
|
|
86
|
+
const createdConfig = createWagmiConfig(__spreadProps(__spreadValues({
|
|
87
|
+
ssr: true
|
|
88
|
+
}, wagmiConfigParams), {
|
|
89
|
+
chains,
|
|
90
|
+
transports: transports || createDefaultTransports(chains),
|
|
91
|
+
connectors: allConnectors
|
|
92
|
+
}));
|
|
93
|
+
setWagmiConfig(createdConfig);
|
|
94
|
+
return createdConfig;
|
|
95
|
+
};
|
|
96
|
+
const [config, setConfig] = useState(null);
|
|
66
97
|
useEffect(() => {
|
|
67
|
-
|
|
98
|
+
if (!para.isReady) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const initializeConfig = () => __async(this, null, function* () {
|
|
68
102
|
var _a2;
|
|
69
|
-
let createFarcasterConnector = null;
|
|
70
103
|
if (para.isFarcasterMiniApp) {
|
|
104
|
+
let createFarcasterConnector = null;
|
|
71
105
|
try {
|
|
72
106
|
createFarcasterConnector = (_a2 = (yield import("@farcaster/miniapp-wagmi-connector")).farcasterMiniApp) != null ? _a2 : void 0;
|
|
73
107
|
} catch (e) {
|
|
74
108
|
}
|
|
109
|
+
setConfig(createConfig([...propsWalletList, farcasterWallet], createFarcasterConnector));
|
|
110
|
+
} else {
|
|
111
|
+
setConfig(createConfig([...propsWalletList]));
|
|
75
112
|
}
|
|
76
|
-
if (!prevWallets.current) {
|
|
77
|
-
prevWallets.current = wallets;
|
|
78
|
-
}
|
|
79
|
-
const existing = getWagmiConfig();
|
|
80
|
-
if (existing && prevWallets.current === wallets) return existing;
|
|
81
|
-
const wcMetadata = computeWalletConnectMetaData({ appName, appDescription, appUrl, appIcon });
|
|
82
|
-
const walletFactories = resolveWalletList(wallets);
|
|
83
|
-
const baseConnectors = connectorsForWallets(
|
|
84
|
-
[...walletFactories, ...createFarcasterConnector ? [farcasterWallet] : []],
|
|
85
|
-
{
|
|
86
|
-
para,
|
|
87
|
-
createFarcasterConnector,
|
|
88
|
-
projectId,
|
|
89
|
-
appName,
|
|
90
|
-
appDescription,
|
|
91
|
-
appUrl,
|
|
92
|
-
appIcon,
|
|
93
|
-
walletConnectParameters: { metadata: wcMetadata }
|
|
94
|
-
}
|
|
95
|
-
);
|
|
96
|
-
const allConnectors = [...baseConnectors, paraConnectorInstance];
|
|
97
|
-
const createdConfig = createConfig(__spreadProps(__spreadValues({
|
|
98
|
-
ssr: true
|
|
99
|
-
}, wagmiConfigParams), {
|
|
100
|
-
chains,
|
|
101
|
-
transports: transports || createDefaultTransports(chains),
|
|
102
|
-
connectors: allConnectors
|
|
103
|
-
}));
|
|
104
|
-
setWagmiConfig(createdConfig);
|
|
105
|
-
setConfig(createdConfig);
|
|
106
|
-
prevWallets.current = wallets;
|
|
107
113
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
}, [wallets, para.isReady, para.isFarcasterMiniApp, paraConnectorInstance]);
|
|
114
|
+
initializeConfig();
|
|
115
|
+
}, [para.isFarcasterMiniApp, para.isReady, propsWalletList]);
|
|
112
116
|
if (!config) {
|
|
113
117
|
return null;
|
|
114
118
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/evm-wallet-connectors",
|
|
3
|
-
"version": "2.0.0-fc.
|
|
3
|
+
"version": "2.0.0-fc.3",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@coinbase/wallet-sdk": "4.3.0",
|
|
6
|
-
"@getpara/wagmi-v2-connector": "2.0.0-fc.
|
|
7
|
-
"@getpara/web-sdk": "2.0.0-fc.
|
|
6
|
+
"@getpara/wagmi-v2-connector": "2.0.0-fc.3",
|
|
7
|
+
"@getpara/web-sdk": "2.0.0-fc.3",
|
|
8
8
|
"zustand": "^4.5.2",
|
|
9
9
|
"zustand-sync-tabs": "^0.2.2"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@getpara/react-common": "2.0.0-fc.
|
|
12
|
+
"@getpara/react-common": "2.0.0-fc.3",
|
|
13
13
|
"@tanstack/react-query": "^5.74.0",
|
|
14
14
|
"@types/react": "^18.0.31",
|
|
15
15
|
"@types/react-dom": "^18.2.7",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist",
|
|
26
26
|
"package.json"
|
|
27
27
|
],
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "5ba068331384bed874c0da0d3d0e1fed6bf03ff9",
|
|
29
29
|
"main": "dist/index.js",
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@farcaster/miniapp-wagmi-connector": "^1.0.0",
|