@getpara/evm-wallet-connectors 2.0.0-dev.3 → 2.0.0-fc.1
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,8 +134,11 @@ function EvmExternalWalletProvider({
|
|
|
134
134
|
connectParaEmbedded();
|
|
135
135
|
}
|
|
136
136
|
}, [isLocalConnecting, isConnecting, isReconnecting, isConnected, connectedConnector]);
|
|
137
|
-
const
|
|
137
|
+
const disconnect = () => __async(this, null, function* () {
|
|
138
138
|
yield disconnectAsync();
|
|
139
|
+
});
|
|
140
|
+
const reset = () => __async(this, null, function* () {
|
|
141
|
+
yield disconnect();
|
|
139
142
|
yield para.logout();
|
|
140
143
|
});
|
|
141
144
|
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
|
|
10
|
+
import { createConfig, 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,14 +30,16 @@ function ParaEvmProvider({
|
|
|
30
30
|
config: _config,
|
|
31
31
|
wagmiProviderProps
|
|
32
32
|
}) {
|
|
33
|
+
const prevWallets = useRef(null);
|
|
33
34
|
const para = internalConfig.para;
|
|
35
|
+
const [config, setConfig] = useState(null);
|
|
34
36
|
const _a = _config, {
|
|
35
37
|
projectId,
|
|
36
38
|
appName,
|
|
37
39
|
appDescription,
|
|
38
40
|
appIcon,
|
|
39
41
|
appUrl,
|
|
40
|
-
wallets
|
|
42
|
+
wallets,
|
|
41
43
|
chains,
|
|
42
44
|
transports,
|
|
43
45
|
paraConnectorOptions
|
|
@@ -52,10 +54,6 @@ function ParaEvmProvider({
|
|
|
52
54
|
"transports",
|
|
53
55
|
"paraConnectorOptions"
|
|
54
56
|
]);
|
|
55
|
-
const propsWalletList = useMemo(() => {
|
|
56
|
-
return resolveWalletList(propsWallets != null ? propsWallets : []);
|
|
57
|
-
}, [propsWallets]);
|
|
58
|
-
const prevWallets = useRef(propsWalletList);
|
|
59
57
|
const paraConnectorInstance = useMemo(() => {
|
|
60
58
|
return paraConnector({
|
|
61
59
|
para,
|
|
@@ -65,54 +63,48 @@ function ParaEvmProvider({
|
|
|
65
63
|
options: paraConnectorOptions != null ? paraConnectorOptions : {}
|
|
66
64
|
});
|
|
67
65
|
}, [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);
|
|
97
66
|
useEffect(() => {
|
|
98
|
-
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
const initializeConfig = () => __async(this, null, function* () {
|
|
67
|
+
const setInitialConfig = () => __async(this, null, function* () {
|
|
102
68
|
var _a2;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
} catch (e) {
|
|
108
|
-
}
|
|
109
|
-
setConfig(createConfig([...propsWalletList, farcasterWallet], createFarcasterConnector));
|
|
110
|
-
} else {
|
|
111
|
-
setConfig(createConfig([...propsWalletList]));
|
|
69
|
+
let createFarcasterConnector = null;
|
|
70
|
+
try {
|
|
71
|
+
createFarcasterConnector = (_a2 = (yield import("@farcaster/miniapp-wagmi-connector")).farcasterMiniApp) != null ? _a2 : void 0;
|
|
72
|
+
} catch (e) {
|
|
112
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 }
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
const allConnectors = [...baseConnectors, paraConnectorInstance];
|
|
95
|
+
const createdConfig = createConfig(__spreadProps(__spreadValues({
|
|
96
|
+
ssr: true
|
|
97
|
+
}, wagmiConfigParams), {
|
|
98
|
+
chains,
|
|
99
|
+
transports: transports || createDefaultTransports(chains),
|
|
100
|
+
connectors: allConnectors
|
|
101
|
+
}));
|
|
102
|
+
setWagmiConfig(createdConfig);
|
|
103
|
+
setConfig(createdConfig);
|
|
104
|
+
prevWallets.current = wallets;
|
|
113
105
|
});
|
|
114
|
-
|
|
115
|
-
}, [
|
|
106
|
+
setInitialConfig();
|
|
107
|
+
}, [wallets, paraConnectorInstance]);
|
|
116
108
|
if (!config) {
|
|
117
109
|
return null;
|
|
118
110
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/evm-wallet-connectors",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-fc.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@coinbase/wallet-sdk": "4.3.0",
|
|
6
|
-
"@getpara/wagmi-v2-connector": "2.0.0-
|
|
7
|
-
"@getpara/web-sdk": "2.0.0-
|
|
6
|
+
"@getpara/wagmi-v2-connector": "2.0.0-fc.1",
|
|
7
|
+
"@getpara/web-sdk": "2.0.0-fc.1",
|
|
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-
|
|
12
|
+
"@getpara/react-common": "2.0.0-fc.1",
|
|
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": "1d69e4964329304db3faf32a93c0f213732d8dff",
|
|
29
29
|
"main": "dist/index.js",
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@farcaster/miniapp-wagmi-connector": "^1.0.0",
|