@getpara/evm-wallet-connectors 2.0.0-alpha.20 → 2.0.0-alpha.22
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/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/providers/EvmExternalWalletContext.d.ts +20 -36
- package/dist/providers/EvmExternalWalletContext.js +128 -50
- package/dist/providers/ParaEvmContext.js +10 -3
- package/dist/providers/createParaWagmiConfig.js +3 -1
- package/dist/wallets/connectors/backpack/backpack.js +1 -0
- package/dist/wallets/connectors/coinbase/coinbase.js +1 -0
- package/dist/wallets/connectors/haha/haha.js +1 -0
- package/dist/wallets/connectors/index.d.ts +2 -1
- package/dist/wallets/connectors/index.js +4 -1
- package/dist/wallets/connectors/metaMask/metaMask.js +1 -0
- package/dist/wallets/connectors/okx/okx.js +1 -0
- package/dist/wallets/connectors/phantom/phantom.d.ts +3 -0
- package/dist/wallets/connectors/phantom/phantom.js +31 -0
- package/dist/wallets/connectors/phantom/phantomIcon.d.ts +1 -0
- package/dist/wallets/connectors/phantom/phantomIcon.js +6 -0
- package/dist/wallets/connectors/rabby/rabby.js +1 -0
- package/dist/wallets/connectors/rainbow/rainbow.js +1 -0
- package/dist/wallets/connectors/safe/safe.js +1 -0
- package/dist/wallets/connectors/walletConnect/walletConnect.js +1 -0
- package/dist/wallets/connectors/zerion/zerion.js +1 -0
- package/dist/wallets/connectorsForWallets.js +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { createParaWagmiConfig } from './providers/createParaWagmiConfig.js';
|
|
2
2
|
export { EvmExternalWalletContext } from './providers/EvmExternalWalletContext.js';
|
|
3
|
-
export type
|
|
3
|
+
export { type EvmExternalWalletContextType, defaultEvmExternalWallet } from './providers/EvmExternalWalletContext.js';
|
|
4
4
|
export { ParaEvmProvider } from './providers/ParaEvmContext.js';
|
|
5
5
|
export type { ParaEvmProviderProps, ParaEvmProviderConfig, ParaWagmiProviderProps } from './providers/ParaEvmContext.js';
|
|
6
6
|
export { getWagmiConfig } from './stores/wagmiConfigStore.js';
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import "./chunk-MMUBH76A.js";
|
|
3
3
|
import { createParaWagmiConfig } from "./providers/createParaWagmiConfig.js";
|
|
4
4
|
import { EvmExternalWalletContext } from "./providers/EvmExternalWalletContext.js";
|
|
5
|
+
import { defaultEvmExternalWallet } from "./providers/EvmExternalWalletContext.js";
|
|
5
6
|
import { ParaEvmProvider } from "./providers/ParaEvmContext.js";
|
|
6
7
|
import { getWagmiConfig } from "./stores/wagmiConfigStore.js";
|
|
7
8
|
export * from "./wallets/connectors/index.js";
|
|
@@ -9,5 +10,6 @@ export {
|
|
|
9
10
|
EvmExternalWalletContext,
|
|
10
11
|
ParaEvmProvider,
|
|
11
12
|
createParaWagmiConfig,
|
|
13
|
+
defaultEvmExternalWallet,
|
|
12
14
|
getWagmiConfig
|
|
13
15
|
};
|
|
@@ -1,42 +1,26 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
import
|
|
4
|
-
export
|
|
5
|
-
wallets:
|
|
6
|
-
chains:
|
|
7
|
-
chainId
|
|
2
|
+
import type { BalanceManagement, ChainManagement, ConnectParaEmbedded, ExternalWalletContextType, ExternalWalletProviderConfigBase } from '@getpara/react-common';
|
|
3
|
+
import { ExternalWalletInfo } from '@getpara/web-sdk';
|
|
4
|
+
export declare const defaultEvmExternalWallet: {
|
|
5
|
+
wallets: any[];
|
|
6
|
+
chains: any[];
|
|
7
|
+
chainId: any;
|
|
8
|
+
username: any;
|
|
9
|
+
avatar: any;
|
|
10
|
+
balance: any;
|
|
11
|
+
disconnect: () => Promise<void>;
|
|
12
|
+
switchChain: () => Promise<void>;
|
|
13
|
+
connectParaEmbedded: () => Promise<{}>;
|
|
14
|
+
signMessage: () => Promise<{}>;
|
|
15
|
+
signVerificationMessage: () => Promise<{}>;
|
|
16
|
+
getWalletBalance: () => Promise<any>;
|
|
17
|
+
requestInfo: () => Promise<ExternalWalletInfo>;
|
|
18
|
+
disconnectBase: () => Promise<void>;
|
|
19
|
+
};
|
|
20
|
+
export type EvmExternalWalletContextType = ExternalWalletContextType & ChainManagement<number> & BalanceManagement & ConnectParaEmbedded & {
|
|
8
21
|
username?: string;
|
|
9
22
|
avatar?: string;
|
|
10
|
-
balance?: string;
|
|
11
|
-
disconnect: () => Promise<void>;
|
|
12
|
-
switchChain: (chainId: number) => Promise<{
|
|
13
|
-
error?: string[];
|
|
14
|
-
}>;
|
|
15
|
-
connectParaEmbedded: () => Promise<{
|
|
16
|
-
result?: unknown;
|
|
17
|
-
error?: string;
|
|
18
|
-
}>;
|
|
19
|
-
signMessage: (message: string) => Promise<{
|
|
20
|
-
signature?: string;
|
|
21
|
-
error?: string;
|
|
22
|
-
}>;
|
|
23
|
-
signVerificationMessage: () => Promise<{
|
|
24
|
-
address?: string;
|
|
25
|
-
signature?: string;
|
|
26
|
-
error?: string;
|
|
27
|
-
}>;
|
|
28
|
-
getWalletBalance: () => Promise<string | undefined>;
|
|
29
23
|
};
|
|
30
24
|
export declare const EvmExternalWalletContext: import("react").Context<EvmExternalWalletContextType>;
|
|
31
|
-
export type EvmExternalWalletProviderConfig =
|
|
32
|
-
onSwitchWallet?: (args: {
|
|
33
|
-
address?: string;
|
|
34
|
-
error?: string;
|
|
35
|
-
}) => void;
|
|
36
|
-
para: ParaWeb;
|
|
37
|
-
walletsWithFullAuth: TExternalWallet[];
|
|
38
|
-
includeWalletVerification?: boolean;
|
|
39
|
-
connectionOnly?: boolean;
|
|
40
|
-
connectedWallet?: Omit<Wallet, 'signer'> | null;
|
|
41
|
-
};
|
|
25
|
+
export type EvmExternalWalletProviderConfig = ExternalWalletProviderConfigBase;
|
|
42
26
|
export declare function EvmExternalWalletProvider({ children, onSwitchWallet, para, walletsWithFullAuth, connectedWallet, includeWalletVerification, connectionOnly, }: EvmExternalWalletProviderConfig & PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
@@ -32,11 +32,13 @@ const defaultEvmExternalWallet = {
|
|
|
32
32
|
avatar: void 0,
|
|
33
33
|
balance: void 0,
|
|
34
34
|
disconnect: () => Promise.resolve(),
|
|
35
|
-
switchChain: () => Promise.resolve(
|
|
35
|
+
switchChain: () => Promise.resolve(),
|
|
36
36
|
connectParaEmbedded: () => Promise.resolve({}),
|
|
37
37
|
signMessage: () => Promise.resolve({}),
|
|
38
38
|
signVerificationMessage: () => Promise.resolve({}),
|
|
39
|
-
getWalletBalance: () => Promise.resolve(void 0)
|
|
39
|
+
getWalletBalance: () => Promise.resolve(void 0),
|
|
40
|
+
requestInfo: () => Promise.resolve({}),
|
|
41
|
+
disconnectBase: () => Promise.resolve()
|
|
40
42
|
};
|
|
41
43
|
const EvmExternalWalletContext = createContext(defaultEvmExternalWallet);
|
|
42
44
|
function EvmExternalWalletProvider({
|
|
@@ -66,8 +68,12 @@ function EvmExternalWalletProvider({
|
|
|
66
68
|
name: normalize(ensName)
|
|
67
69
|
});
|
|
68
70
|
const { signMessageAsync } = useSignMessage();
|
|
71
|
+
const isLinkingAccount = useRef(false);
|
|
69
72
|
const verificationMessage = useRef();
|
|
70
73
|
const { refetch: getBalance } = useBalance({ address: wagmiAddress });
|
|
74
|
+
const connectors = untypedConnectors;
|
|
75
|
+
const connectionsRef = useRef(connections);
|
|
76
|
+
const connectorsRef = useRef(connectors);
|
|
71
77
|
const isLocalConnecting = useExternalWalletStore((state) => state.isConnecting);
|
|
72
78
|
const updateExternalWalletState = useExternalWalletStore((state) => state.updateState);
|
|
73
79
|
const getStoredExternalWallets = () => {
|
|
@@ -90,6 +96,23 @@ function EvmExternalWalletProvider({
|
|
|
90
96
|
},
|
|
91
97
|
[connections, wagmiSwitchAccount]
|
|
92
98
|
);
|
|
99
|
+
const findConnectorAndAccount = (externalWallet) => {
|
|
100
|
+
var _a;
|
|
101
|
+
let connector;
|
|
102
|
+
switch (true) {
|
|
103
|
+
case !!externalWallet.providerId:
|
|
104
|
+
{
|
|
105
|
+
connector = (_a = connectionsRef.current.find(
|
|
106
|
+
(c) => {
|
|
107
|
+
var _a2;
|
|
108
|
+
return ((_a2 = c.connector.paraDetails) == null ? void 0 : _a2.internalId) === externalWallet.providerId;
|
|
109
|
+
}
|
|
110
|
+
)) == null ? void 0 : _a.connector;
|
|
111
|
+
}
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
return { connector, account: externalWallet.address };
|
|
115
|
+
};
|
|
93
116
|
const getWalletBalance = useCallback(
|
|
94
117
|
// Format from wei to eth
|
|
95
118
|
() => __async(this, null, function* () {
|
|
@@ -100,16 +123,16 @@ function EvmExternalWalletProvider({
|
|
|
100
123
|
);
|
|
101
124
|
useEffect(() => {
|
|
102
125
|
const storedExternalWallet = getStoredExternalWallets()[wagmiAddress != null ? wagmiAddress : ""];
|
|
103
|
-
if (!isConnecting && !isReconnecting && !isLocalConnecting && !!wagmiAddress && !storedExternalWallet && (connectedConnector == null ? void 0 : connectedConnector.id) !== "para") {
|
|
126
|
+
if (!isConnecting && !isReconnecting && !isLocalConnecting && !!wagmiAddress && !storedExternalWallet && (connectedConnector == null ? void 0 : connectedConnector.id) !== "para" && !isLinkingAccount.current) {
|
|
104
127
|
reset();
|
|
105
128
|
}
|
|
106
|
-
}, [
|
|
129
|
+
}, [isConnected, isLocalConnecting, wagmiAddress, connectedConnector]);
|
|
107
130
|
useEffect(() => {
|
|
108
131
|
const storedExternalWallet = Object.values(para.externalWallets || {})[0];
|
|
109
|
-
if (!isLocalConnecting &&
|
|
132
|
+
if (!isLocalConnecting && isConnected && (storedExternalWallet == null ? void 0 : storedExternalWallet.type) === "EVM" && (storedExternalWallet == null ? void 0 : storedExternalWallet.address) !== wagmiAddress && (connectedConnector == null ? void 0 : connectedConnector.id) !== "para" && !isLinkingAccount.current) {
|
|
110
133
|
switchWallet(wagmiAddress);
|
|
111
134
|
}
|
|
112
|
-
}, [isLocalConnecting, wagmiAddress,
|
|
135
|
+
}, [isLocalConnecting, wagmiAddress, isConnected]);
|
|
113
136
|
useEffect(() => {
|
|
114
137
|
if (!isLocalConnecting && !isConnecting && !isReconnecting && connectedWallet && connectedConnector && connectedWallet.type === "EVM" && connectedConnector.name !== connectedWallet.name) {
|
|
115
138
|
switchAccount(connectedWallet.isExternal ? connectedWallet.name : "Para");
|
|
@@ -123,22 +146,27 @@ function EvmExternalWalletProvider({
|
|
|
123
146
|
connectParaEmbedded();
|
|
124
147
|
}
|
|
125
148
|
}, [isLocalConnecting, isConnecting, isReconnecting, isConnected, connectedConnector]);
|
|
126
|
-
const connectors = untypedConnectors;
|
|
127
149
|
const reset = () => __async(this, null, function* () {
|
|
128
150
|
yield disconnectAsync();
|
|
129
151
|
yield para.logout();
|
|
130
152
|
});
|
|
131
|
-
const signMessage = (
|
|
153
|
+
const signMessage = (_0) => __async(this, [_0], function* ({ message, externalWallet }) {
|
|
154
|
+
let signOpts = {};
|
|
155
|
+
if (externalWallet) {
|
|
156
|
+
signOpts = findConnectorAndAccount(externalWallet);
|
|
157
|
+
}
|
|
132
158
|
try {
|
|
133
|
-
const
|
|
159
|
+
const address = signOpts.account ? typeof signOpts.account === "string" ? signOpts.account : signOpts.account.getAddress() : wagmiAddress;
|
|
160
|
+
const signature = yield signMessageAsync(__spreadValues({
|
|
134
161
|
message,
|
|
135
|
-
account:
|
|
136
|
-
});
|
|
162
|
+
account: address
|
|
163
|
+
}, signOpts));
|
|
137
164
|
return {
|
|
138
|
-
address
|
|
165
|
+
address,
|
|
139
166
|
signature
|
|
140
167
|
};
|
|
141
168
|
} catch (e) {
|
|
169
|
+
console.error("Error signing message:", e);
|
|
142
170
|
switch (e.name) {
|
|
143
171
|
case "UserRejectedRequestError": {
|
|
144
172
|
return { error: "Signature request rejected" };
|
|
@@ -150,7 +178,7 @@ function EvmExternalWalletProvider({
|
|
|
150
178
|
}
|
|
151
179
|
});
|
|
152
180
|
const signVerificationMessage = () => __async(this, null, function* () {
|
|
153
|
-
const signature = yield signMessage(verificationMessage.current);
|
|
181
|
+
const signature = yield signMessage({ message: verificationMessage.current });
|
|
154
182
|
return signature;
|
|
155
183
|
});
|
|
156
184
|
const switchChain = (chainId2) => __async(this, null, function* () {
|
|
@@ -180,12 +208,7 @@ function EvmExternalWalletProvider({
|
|
|
180
208
|
}
|
|
181
209
|
return { error };
|
|
182
210
|
});
|
|
183
|
-
const login = (_0) => __async(this, [_0], function* ({
|
|
184
|
-
address,
|
|
185
|
-
walletId,
|
|
186
|
-
connectorName
|
|
187
|
-
}) {
|
|
188
|
-
var _a;
|
|
211
|
+
const login = (_0) => __async(this, [_0], function* ({ address, withFullParaAuth = false, providerId, provider }) {
|
|
189
212
|
try {
|
|
190
213
|
refetchEnsName();
|
|
191
214
|
refetchEnsAvatar();
|
|
@@ -193,8 +216,9 @@ function EvmExternalWalletProvider({
|
|
|
193
216
|
externalWallet: {
|
|
194
217
|
address,
|
|
195
218
|
type: "EVM",
|
|
196
|
-
provider
|
|
197
|
-
|
|
219
|
+
provider,
|
|
220
|
+
providerId,
|
|
221
|
+
withFullParaAuth,
|
|
198
222
|
ensName,
|
|
199
223
|
ensAvatar,
|
|
200
224
|
isConnectionOnly: connectionOnly,
|
|
@@ -208,7 +232,6 @@ function EvmExternalWalletProvider({
|
|
|
208
232
|
}
|
|
209
233
|
});
|
|
210
234
|
const switchWallet = (address) => __async(this, null, function* () {
|
|
211
|
-
var _a;
|
|
212
235
|
updateExternalWalletState({ isConnecting: true });
|
|
213
236
|
let error;
|
|
214
237
|
if (!address) {
|
|
@@ -218,11 +241,10 @@ function EvmExternalWalletProvider({
|
|
|
218
241
|
yield reset();
|
|
219
242
|
} else {
|
|
220
243
|
try {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
});
|
|
244
|
+
const loginInfo = getConnectorInfo(connectedConnector);
|
|
245
|
+
yield login(__spreadValues({
|
|
246
|
+
address
|
|
247
|
+
}, loginInfo));
|
|
226
248
|
} catch (err) {
|
|
227
249
|
error = err;
|
|
228
250
|
}
|
|
@@ -231,31 +253,33 @@ function EvmExternalWalletProvider({
|
|
|
231
253
|
onSwitchWallet == null ? void 0 : onSwitchWallet({ address, error });
|
|
232
254
|
updateExternalWalletState({ isConnecting: false });
|
|
233
255
|
});
|
|
234
|
-
const
|
|
256
|
+
const connectBase = (connector) => __async(this, null, function* () {
|
|
235
257
|
var _a, _b, _c, _d;
|
|
258
|
+
const walletChainId = yield connector.getChainId();
|
|
259
|
+
const data = yield connectAsync({
|
|
260
|
+
// If the wallet is already on a supported chain, use that to avoid a chain switch prompt.
|
|
261
|
+
chainId: (_c = (_a = chains.find(({ id }) => id === walletChainId)) == null ? void 0 : _a.id) != null ? _c : (
|
|
262
|
+
// Fall back to the first chain provided.
|
|
263
|
+
(_b = chains[0]) == null ? void 0 : _b.id
|
|
264
|
+
),
|
|
265
|
+
connector
|
|
266
|
+
});
|
|
267
|
+
return (_d = data.accounts) == null ? void 0 : _d[0];
|
|
268
|
+
});
|
|
269
|
+
const connect = (connector) => __async(this, null, function* () {
|
|
236
270
|
updateExternalWalletState({ isConnecting: true });
|
|
237
271
|
yield disconnectAsync();
|
|
238
|
-
const walletChainId = yield connector.getChainId();
|
|
239
272
|
let authState;
|
|
240
273
|
let address;
|
|
241
274
|
let error;
|
|
242
275
|
try {
|
|
243
|
-
|
|
244
|
-
// If the wallet is already on a supported chain, use that to avoid a chain switch prompt.
|
|
245
|
-
chainId: (_c = (_a = chains.find(({ id }) => id === walletChainId)) == null ? void 0 : _a.id) != null ? _c : (
|
|
246
|
-
// Fall back to the first chain provided.
|
|
247
|
-
(_b = chains[0]) == null ? void 0 : _b.id
|
|
248
|
-
),
|
|
249
|
-
connector
|
|
250
|
-
});
|
|
251
|
-
address = (_d = data.accounts) == null ? void 0 : _d[0];
|
|
276
|
+
address = yield connectBase(connector);
|
|
252
277
|
if (address) {
|
|
253
278
|
try {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
});
|
|
279
|
+
const loginInfo = getConnectorInfo(connector);
|
|
280
|
+
authState = yield login(__spreadValues({
|
|
281
|
+
address
|
|
282
|
+
}, loginInfo));
|
|
259
283
|
verificationMessage.current = authState.stage === "verify" ? authState.signatureVerificationMessage : void 0;
|
|
260
284
|
} catch (err) {
|
|
261
285
|
address = void 0;
|
|
@@ -269,10 +293,11 @@ function EvmExternalWalletProvider({
|
|
|
269
293
|
break;
|
|
270
294
|
}
|
|
271
295
|
case "ResourceUnavailableRpcError": {
|
|
272
|
-
`${connector.name} not detected`;
|
|
296
|
+
error = `${connector.name} not detected`;
|
|
273
297
|
break;
|
|
274
298
|
}
|
|
275
299
|
default: {
|
|
300
|
+
console.error("Wagmi connection error:", e.message);
|
|
276
301
|
error = "An unknown error occurred";
|
|
277
302
|
break;
|
|
278
303
|
}
|
|
@@ -290,6 +315,43 @@ function EvmExternalWalletProvider({
|
|
|
290
315
|
var _a;
|
|
291
316
|
return getWalletConnectUri(connector, (_a = connector.paraDetails) == null ? void 0 : _a.getUri);
|
|
292
317
|
};
|
|
318
|
+
const requestInfo = (providerId) => __async(this, null, function* () {
|
|
319
|
+
var _a, _b;
|
|
320
|
+
const connector = connectors.find((c) => {
|
|
321
|
+
var _a2;
|
|
322
|
+
return ((_a2 = c.paraDetails) == null ? void 0 : _a2.internalId) === providerId;
|
|
323
|
+
});
|
|
324
|
+
if (connector.isAuthorized) isLinkingAccount.current = true;
|
|
325
|
+
try {
|
|
326
|
+
const address = yield connectBase(connector);
|
|
327
|
+
return {
|
|
328
|
+
address,
|
|
329
|
+
type: "EVM",
|
|
330
|
+
providerId: (_a = connector.paraDetails) == null ? void 0 : _a.internalId,
|
|
331
|
+
provider: connector.name,
|
|
332
|
+
ensName,
|
|
333
|
+
ensAvatar
|
|
334
|
+
};
|
|
335
|
+
} catch (e) {
|
|
336
|
+
throw new Error((_b = e == null ? void 0 : e.message) != null ? _b : e);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
const disconnectBase = (providerId) => __async(this, null, function* () {
|
|
340
|
+
var _a;
|
|
341
|
+
if (!providerId) {
|
|
342
|
+
throw new Error("Provider ID is required to disconnect");
|
|
343
|
+
}
|
|
344
|
+
const connector = connectors.find((c) => {
|
|
345
|
+
var _a2;
|
|
346
|
+
return ((_a2 = c.paraDetails) == null ? void 0 : _a2.internalId) === providerId;
|
|
347
|
+
});
|
|
348
|
+
isLinkingAccount.current = true;
|
|
349
|
+
try {
|
|
350
|
+
yield connector.disconnect();
|
|
351
|
+
} catch (e) {
|
|
352
|
+
throw new Error((_a = e == null ? void 0 : e.message) != null ? _a : e);
|
|
353
|
+
}
|
|
354
|
+
});
|
|
293
355
|
const nonEip6963ConnectorsByRdns = {};
|
|
294
356
|
let walletConnectModalConnector;
|
|
295
357
|
connectors.filter((c) => !isEIP6963Connector(c)).forEach((c) => {
|
|
@@ -313,7 +375,7 @@ function EvmExternalWalletProvider({
|
|
|
313
375
|
const paraMetadata = nonEip6963ConnectorsByRdns[c.id];
|
|
314
376
|
return __spreadProps(__spreadValues({}, c), { paraDetails: paraMetadata });
|
|
315
377
|
}
|
|
316
|
-
if (((_c = c.paraDetails) == null ? void 0 : _c.id) === "
|
|
378
|
+
if (((_c = c.paraDetails) == null ? void 0 : _c.id) === "WALLETCONNECT" && walletConnectModalConnector) {
|
|
317
379
|
return __spreadProps(__spreadValues({}, c), { walletConnectModalConnector });
|
|
318
380
|
}
|
|
319
381
|
return c;
|
|
@@ -327,9 +389,16 @@ function EvmExternalWalletProvider({
|
|
|
327
389
|
getQrUri: getQrUri(connector)
|
|
328
390
|
});
|
|
329
391
|
});
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
|
|
392
|
+
const getConnectorInfo = (connector) => {
|
|
393
|
+
const paraDetails = connector.paraDetails;
|
|
394
|
+
const providerId = paraDetails == null ? void 0 : paraDetails.internalId;
|
|
395
|
+
const withFullParaAuth = walletsWithFullAuth == null ? void 0 : walletsWithFullAuth.includes(providerId);
|
|
396
|
+
return {
|
|
397
|
+
type: "EVM",
|
|
398
|
+
providerId,
|
|
399
|
+
provider: paraDetails == null ? void 0 : paraDetails.name,
|
|
400
|
+
withFullParaAuth
|
|
401
|
+
};
|
|
333
402
|
};
|
|
334
403
|
const formattedChains = chains.map((c) => {
|
|
335
404
|
return {
|
|
@@ -351,6 +420,12 @@ function EvmExternalWalletProvider({
|
|
|
351
420
|
return { error };
|
|
352
421
|
}
|
|
353
422
|
}), [connectors]);
|
|
423
|
+
useEffect(() => {
|
|
424
|
+
connectionsRef.current = connections;
|
|
425
|
+
}, [connections]);
|
|
426
|
+
useEffect(() => {
|
|
427
|
+
connectorsRef.current = connectors;
|
|
428
|
+
}, [connectors]);
|
|
354
429
|
return /* @__PURE__ */ jsx(
|
|
355
430
|
EvmExternalWalletContext.Provider,
|
|
356
431
|
{
|
|
@@ -365,7 +440,9 @@ function EvmExternalWalletProvider({
|
|
|
365
440
|
connectParaEmbedded,
|
|
366
441
|
signMessage,
|
|
367
442
|
signVerificationMessage,
|
|
368
|
-
getWalletBalance
|
|
443
|
+
getWalletBalance,
|
|
444
|
+
requestInfo,
|
|
445
|
+
disconnectBase
|
|
369
446
|
},
|
|
370
447
|
children
|
|
371
448
|
}
|
|
@@ -373,5 +450,6 @@ function EvmExternalWalletProvider({
|
|
|
373
450
|
}
|
|
374
451
|
export {
|
|
375
452
|
EvmExternalWalletContext,
|
|
376
|
-
EvmExternalWalletProvider
|
|
453
|
+
EvmExternalWalletProvider,
|
|
454
|
+
defaultEvmExternalWallet
|
|
377
455
|
};
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
__spreadValues
|
|
6
6
|
} from "../chunk-MMUBH76A.js";
|
|
7
7
|
import { jsx } from "react/jsx-runtime";
|
|
8
|
-
import { useMemo } from "react";
|
|
8
|
+
import { useMemo, useRef } from "react";
|
|
9
9
|
import { createConfig, WagmiProvider } from "wagmi";
|
|
10
10
|
import { connectorsForWallets } from "../wallets/connectorsForWallets.js";
|
|
11
11
|
import { http } from "viem";
|
|
@@ -28,6 +28,7 @@ function ParaEvmProvider({
|
|
|
28
28
|
config: _config,
|
|
29
29
|
wagmiProviderProps
|
|
30
30
|
}) {
|
|
31
|
+
const prevWallets = useRef(null);
|
|
31
32
|
const para = internalConfig.para;
|
|
32
33
|
const _a = _config, {
|
|
33
34
|
projectId,
|
|
@@ -60,8 +61,11 @@ function ParaEvmProvider({
|
|
|
60
61
|
});
|
|
61
62
|
}, [para]);
|
|
62
63
|
const config = useMemo(() => {
|
|
64
|
+
if (!prevWallets.current) {
|
|
65
|
+
prevWallets.current = wallets;
|
|
66
|
+
}
|
|
63
67
|
const existing = getWagmiConfig();
|
|
64
|
-
if (existing) return existing;
|
|
68
|
+
if (existing && prevWallets.current === wallets) return existing;
|
|
65
69
|
const wcMetadata = computeWalletConnectMetaData({ appName, appDescription, appUrl, appIcon });
|
|
66
70
|
const walletFactories = resolveWalletList(wallets);
|
|
67
71
|
const baseConnectors = connectorsForWallets(walletFactories, {
|
|
@@ -73,12 +77,15 @@ function ParaEvmProvider({
|
|
|
73
77
|
walletConnectParameters: { metadata: wcMetadata }
|
|
74
78
|
});
|
|
75
79
|
const allConnectors = [...baseConnectors, paraConnectorInstance];
|
|
76
|
-
const createdConfig = createConfig(__spreadProps(__spreadValues({
|
|
80
|
+
const createdConfig = createConfig(__spreadProps(__spreadValues({
|
|
81
|
+
ssr: true
|
|
82
|
+
}, wagmiConfigParams), {
|
|
77
83
|
chains,
|
|
78
84
|
transports: transports || createDefaultTransports(chains),
|
|
79
85
|
connectors: allConnectors
|
|
80
86
|
}));
|
|
81
87
|
setWagmiConfig(createdConfig);
|
|
88
|
+
prevWallets.current = wallets;
|
|
82
89
|
return createdConfig;
|
|
83
90
|
}, [wallets, paraConnectorInstance]);
|
|
84
91
|
return /* @__PURE__ */ jsx(WagmiProvider, __spreadProps(__spreadValues({ config }, wagmiProviderProps), { children: /* @__PURE__ */ jsx(EvmExternalWalletProvider, __spreadProps(__spreadValues({}, internalConfig), { children })) }));
|
|
@@ -49,7 +49,9 @@ function createParaWagmiConfig(para, cfg) {
|
|
|
49
49
|
appName,
|
|
50
50
|
options: paraConnectorOptions != null ? paraConnectorOptions : {}
|
|
51
51
|
});
|
|
52
|
-
const created = createConfig(__spreadProps(__spreadValues({
|
|
52
|
+
const created = createConfig(__spreadProps(__spreadValues({
|
|
53
|
+
ssr: true
|
|
54
|
+
}, wagmiParams), {
|
|
53
55
|
chains,
|
|
54
56
|
transports,
|
|
55
57
|
connectors: [...baseConnectors, paraConn]
|
|
@@ -8,5 +8,6 @@ import { safeWallet } from './safe/safe.js';
|
|
|
8
8
|
import { okxWallet } from './okx/okx.js';
|
|
9
9
|
import { backpackWallet } from './backpack/backpack.js';
|
|
10
10
|
import { hahaWallet } from './haha/haha.js';
|
|
11
|
-
|
|
11
|
+
import { phantomWallet } from './phantom/phantom.js';
|
|
12
|
+
export { metaMaskWallet, rainbowWallet, walletConnectWallet, coinbaseWallet, zerionWallet, rabbyWallet, safeWallet, okxWallet, backpackWallet, hahaWallet, phantomWallet, };
|
|
12
13
|
export declare const allWallets: ((({ appName, appIcon }: import("./coinbase/coinbase.js").CoinbaseWalletOptions) => import("../../types/Wallet.js").Wallet) | (({ projectId, options }: import("./walletConnect/walletConnect.js").WalletConnectWalletOptions) => import("../../types/Wallet.js").Wallet) | (({ projectId, walletConnectParameters }: import("./metaMask/metaMask.js").MetaMaskWalletOptions) => import("../../types/Wallet.js").Wallet))[];
|
|
@@ -10,6 +10,7 @@ import { safeWallet } from "./safe/safe.js";
|
|
|
10
10
|
import { okxWallet } from "./okx/okx.js";
|
|
11
11
|
import { backpackWallet } from "./backpack/backpack.js";
|
|
12
12
|
import { hahaWallet } from "./haha/haha.js";
|
|
13
|
+
import { phantomWallet } from "./phantom/phantom.js";
|
|
13
14
|
const allWallets = [
|
|
14
15
|
metaMaskWallet,
|
|
15
16
|
rainbowWallet,
|
|
@@ -20,7 +21,8 @@ const allWallets = [
|
|
|
20
21
|
safeWallet,
|
|
21
22
|
okxWallet,
|
|
22
23
|
backpackWallet,
|
|
23
|
-
hahaWallet
|
|
24
|
+
hahaWallet,
|
|
25
|
+
phantomWallet
|
|
24
26
|
];
|
|
25
27
|
export {
|
|
26
28
|
allWallets,
|
|
@@ -29,6 +31,7 @@ export {
|
|
|
29
31
|
hahaWallet,
|
|
30
32
|
metaMaskWallet,
|
|
31
33
|
okxWallet,
|
|
34
|
+
phantomWallet,
|
|
32
35
|
rabbyWallet,
|
|
33
36
|
rainbowWallet,
|
|
34
37
|
safeWallet,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
import { getInjectedConnector, hasInjectedProvider } from "../../../utils/getInjectedConnector.js";
|
|
4
|
+
import { icon } from "./phantomIcon.js";
|
|
5
|
+
import { getWalletConnectConnector } from "../../../utils/getWalletConnectConnector.js";
|
|
6
|
+
const phantomWallet = ({ projectId, walletConnectParameters }) => {
|
|
7
|
+
const isPhantomInjected = hasInjectedProvider({ namespace: "phantom.ethereum" });
|
|
8
|
+
const shouldUseWalletConnect = !isPhantomInjected;
|
|
9
|
+
const getUri = (uri) => {
|
|
10
|
+
return uri;
|
|
11
|
+
};
|
|
12
|
+
return {
|
|
13
|
+
id: "phantom",
|
|
14
|
+
internalId: "PHANTOM",
|
|
15
|
+
name: "Phantom",
|
|
16
|
+
rdns: "app.phantom",
|
|
17
|
+
iconUrl: icon,
|
|
18
|
+
installed: isPhantomInjected,
|
|
19
|
+
isExtension: true,
|
|
20
|
+
isMobile: true,
|
|
21
|
+
getUri,
|
|
22
|
+
downloadUrl: "https://phantom.app/download",
|
|
23
|
+
createConnector: shouldUseWalletConnect ? getWalletConnectConnector({
|
|
24
|
+
projectId,
|
|
25
|
+
walletConnectParameters
|
|
26
|
+
}) : getInjectedConnector({ namespace: "phantom.ethereum" })
|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cuMjkzIDY3NS40ODEgNDc5Ljg3MUM2NzUuNDgxIDQ0Mi40NDkgNjk3LjE4NSA0MjMuNzM4IDcyMi4yNTggNDIzLjczOEM3NDYuOTU2IDQyMy43MzggNzY5LjAzNSA0NDIuNDQ5IDc2OS4wMzUgNDc5Ljg3MVpNOTA5LjM2NyA0NzkuODcyQzkwOS4zNjcgNTE3LjI5NCA4ODcuMjg4IDUzNi4wMDUgODYyLjU5IDUzNi4wMDVDODM3LjUxNyA1MzYuMDA1IDgxNS44MTMgNTE3LjI5NCA4MTUuODEzIDQ3OS44NzJDODE1LjgxMyA0NDIuNDUgODM3LjUxNyA0MjMuNzQgODYyLjU5IDQyMy43NEM4ODcuMjg4IDQyMy43NCA5MDkuMzY3IDQ0Mi40NSA5MDkuMzY3IDQ3OS44NzJaIiBmaWxsPSIjRkZGREY4Ii8+CjwvZz4KPGRlZnM+CjxjbGlwUGF0aCBpZD0iY2xpcDBfMjU5Nl8xMzg1ODAiPgo8cmVjdCB5PSItMC4wMDA5NzY1NjIiIHdpZHRoPSIxMjAwIiBoZWlnaHQ9IjEyMDAiIHJ4PSI2MDAiIGZpbGw9IndoaXRlIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg==";
|
|
4
|
+
export {
|
|
5
|
+
icon
|
|
6
|
+
};
|
|
@@ -51,7 +51,7 @@ const connectorsForWallets = (walletList, { projectId, walletConnectParameters,
|
|
|
51
51
|
}), additionalParaParams ? additionalParaParams : {}))
|
|
52
52
|
};
|
|
53
53
|
};
|
|
54
|
-
const isWalletConnectConnector = walletMeta.
|
|
54
|
+
const isWalletConnectConnector = walletMeta.internalId === "WALLETCONNECT";
|
|
55
55
|
if (isWalletConnectConnector && createConnector) {
|
|
56
56
|
connectors.push(
|
|
57
57
|
createConnector(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/evm-wallet-connectors",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.22",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@coinbase/wallet-sdk": "4.3.0",
|
|
13
|
-
"@getpara/wagmi-v2-connector": "2.0.0-alpha.
|
|
14
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
13
|
+
"@getpara/wagmi-v2-connector": "2.0.0-alpha.22",
|
|
14
|
+
"@getpara/web-sdk": "2.0.0-alpha.22",
|
|
15
15
|
"viem": "^2.24.2",
|
|
16
16
|
"wagmi": "^2.14.16",
|
|
17
17
|
"zustand": "^4.5.2",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"test": "vitest run --coverage"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@getpara/react-common": "2.0.0-alpha.
|
|
26
|
+
"@getpara/react-common": "2.0.0-alpha.22",
|
|
27
27
|
"@tanstack/react-query": ">=5.0.0",
|
|
28
28
|
"@types/react": "^18.0.31",
|
|
29
29
|
"@types/react-dom": "^18.2.7",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"dist",
|
|
40
40
|
"package.json"
|
|
41
41
|
],
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "e23258f6af4d3445bf4717a9e524c63e0088e159"
|
|
43
43
|
}
|