@getpara/evm-wallet-connectors 2.0.0-fc.1 → 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.
|
@@ -134,11 +134,8 @@ function EvmExternalWalletProvider({
|
|
|
134
134
|
connectParaEmbedded();
|
|
135
135
|
}
|
|
136
136
|
}, [isLocalConnecting, isConnecting, isReconnecting, isConnected, connectedConnector]);
|
|
137
|
-
const disconnect = () => __async(this, null, function* () {
|
|
138
|
-
yield disconnectAsync();
|
|
139
|
-
});
|
|
140
137
|
const reset = () => __async(this, null, function* () {
|
|
141
|
-
yield
|
|
138
|
+
yield disconnectAsync();
|
|
142
139
|
yield para.logout();
|
|
143
140
|
});
|
|
144
141
|
const signMessage = (_0) => __async(this, [_0], function* ({ message, externalWallet }) {
|
|
@@ -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,48 +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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!prevWallets.current) {
|
|
75
|
-
prevWallets.current = wallets;
|
|
76
|
-
}
|
|
77
|
-
const existing = getWagmiConfig();
|
|
78
|
-
if (existing && prevWallets.current === wallets) return existing;
|
|
79
|
-
const wcMetadata = computeWalletConnectMetaData({ appName, appDescription, appUrl, appIcon });
|
|
80
|
-
const walletFactories = resolveWalletList(wallets);
|
|
81
|
-
const baseConnectors = connectorsForWallets(
|
|
82
|
-
[...walletFactories, ...createFarcasterConnector ? [farcasterWallet] : []],
|
|
83
|
-
{
|
|
84
|
-
para,
|
|
85
|
-
createFarcasterConnector,
|
|
86
|
-
projectId,
|
|
87
|
-
appName,
|
|
88
|
-
appDescription,
|
|
89
|
-
appUrl,
|
|
90
|
-
appIcon,
|
|
91
|
-
walletConnectParameters: { metadata: wcMetadata }
|
|
103
|
+
if (para.isFarcasterMiniApp) {
|
|
104
|
+
let createFarcasterConnector = null;
|
|
105
|
+
try {
|
|
106
|
+
createFarcasterConnector = (_a2 = (yield import("@farcaster/miniapp-wagmi-connector")).farcasterMiniApp) != null ? _a2 : void 0;
|
|
107
|
+
} catch (e) {
|
|
92
108
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}, wagmiConfigParams), {
|
|
98
|
-
chains,
|
|
99
|
-
transports: transports || createDefaultTransports(chains),
|
|
100
|
-
connectors: allConnectors
|
|
101
|
-
}));
|
|
102
|
-
setWagmiConfig(createdConfig);
|
|
103
|
-
setConfig(createdConfig);
|
|
104
|
-
prevWallets.current = wallets;
|
|
109
|
+
setConfig(createConfig([...propsWalletList, farcasterWallet], createFarcasterConnector));
|
|
110
|
+
} else {
|
|
111
|
+
setConfig(createConfig([...propsWalletList]));
|
|
112
|
+
}
|
|
105
113
|
});
|
|
106
|
-
|
|
107
|
-
}, [
|
|
114
|
+
initializeConfig();
|
|
115
|
+
}, [para.isFarcasterMiniApp, para.isReady, propsWalletList]);
|
|
108
116
|
if (!config) {
|
|
109
117
|
return null;
|
|
110
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",
|