@getpara/evm-wallet-connectors 2.0.0-alpha.32 → 2.0.0-alpha.34
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.
|
@@ -28,7 +28,9 @@ import {
|
|
|
28
28
|
import { isMobile } from "@getpara/web-sdk";
|
|
29
29
|
import { etherUnits, formatUnits } from "viem";
|
|
30
30
|
import { externalHooks } from "./externalHooks.js";
|
|
31
|
-
const EvmExternalWalletContext = createContext(defaultEvmExternalWallet)
|
|
31
|
+
const EvmExternalWalletContext = createContext(__spreadProps(__spreadValues({}, defaultEvmExternalWallet), {
|
|
32
|
+
farcasterStatus: void 0
|
|
33
|
+
}));
|
|
32
34
|
function EvmExternalWalletProvider({
|
|
33
35
|
children,
|
|
34
36
|
onSwitchWallet,
|
|
@@ -90,12 +92,10 @@ function EvmExternalWalletProvider({
|
|
|
90
92
|
switch (true) {
|
|
91
93
|
case !!externalWallet.providerId:
|
|
92
94
|
{
|
|
93
|
-
connector = (_a = connectionsRef.current.find(
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
)) == null ? void 0 : _a.connector;
|
|
95
|
+
connector = (_a = connectionsRef.current.find((c) => {
|
|
96
|
+
var _a2;
|
|
97
|
+
return ((_a2 = c.connector) == null ? void 0 : _a2.name) === externalWallet.providerId;
|
|
98
|
+
})) == null ? void 0 : _a.connector;
|
|
99
99
|
}
|
|
100
100
|
break;
|
|
101
101
|
}
|
|
@@ -202,6 +202,7 @@ function EvmExternalWalletProvider({
|
|
|
202
202
|
refetchEnsAvatar();
|
|
203
203
|
return yield para.loginExternalWallet({
|
|
204
204
|
externalWallet: {
|
|
205
|
+
partnerId: para.partnerId,
|
|
205
206
|
address,
|
|
206
207
|
type: "EVM",
|
|
207
208
|
provider,
|
|
@@ -300,24 +301,22 @@ function EvmExternalWalletProvider({
|
|
|
300
301
|
return yield connect(_connector);
|
|
301
302
|
});
|
|
302
303
|
const requestInfo = (providerId) => __async(this, null, function* () {
|
|
303
|
-
var _a
|
|
304
|
-
const connector = connectors.find((c) =>
|
|
305
|
-
var _a2;
|
|
306
|
-
return ((_a2 = c.paraDetails) == null ? void 0 : _a2.internalId) === providerId;
|
|
307
|
-
});
|
|
304
|
+
var _a;
|
|
305
|
+
const connector = connectors.find((c) => c.name === providerId);
|
|
308
306
|
if (connector.isAuthorized) isLinkingAccount.current = true;
|
|
309
307
|
try {
|
|
310
308
|
const address = yield connectBase(connector);
|
|
311
309
|
return {
|
|
310
|
+
partnerId: para.partnerId,
|
|
312
311
|
address,
|
|
313
312
|
type: "EVM",
|
|
314
|
-
providerId:
|
|
313
|
+
providerId: connector.name,
|
|
315
314
|
provider: connector.name,
|
|
316
315
|
ensName,
|
|
317
316
|
ensAvatar
|
|
318
317
|
};
|
|
319
318
|
} catch (e) {
|
|
320
|
-
throw new Error((
|
|
319
|
+
throw new Error((_a = e == null ? void 0 : e.message) != null ? _a : e);
|
|
321
320
|
}
|
|
322
321
|
});
|
|
323
322
|
const disconnectBase = (providerId) => __async(this, null, function* () {
|
|
@@ -325,10 +324,7 @@ function EvmExternalWalletProvider({
|
|
|
325
324
|
if (!providerId) {
|
|
326
325
|
throw new Error("Provider ID is required to disconnect");
|
|
327
326
|
}
|
|
328
|
-
const connector = connectors.find((c) =>
|
|
329
|
-
var _a2;
|
|
330
|
-
return ((_a2 = c.paraDetails) == null ? void 0 : _a2.internalId) === providerId;
|
|
331
|
-
});
|
|
327
|
+
const connector = connectors.find((c) => c.id === providerId);
|
|
332
328
|
isLinkingAccount.current = true;
|
|
333
329
|
try {
|
|
334
330
|
yield connector.disconnect();
|
|
@@ -346,32 +342,45 @@ function EvmExternalWalletProvider({
|
|
|
346
342
|
}
|
|
347
343
|
}
|
|
348
344
|
});
|
|
349
|
-
const
|
|
345
|
+
const eip6963Names = connectors.filter((c) => isEIP6963Connector(c)).map((c) => c.name);
|
|
350
346
|
const dedupedConnectors = connectors.map((c) => {
|
|
351
|
-
var _a, _b
|
|
347
|
+
var _a, _b;
|
|
352
348
|
if ((_a = c.paraDetails) == null ? void 0 : _a.isWalletConnectModalConnector) {
|
|
353
349
|
return;
|
|
354
350
|
}
|
|
355
|
-
if (!isEIP6963Connector(c) &&
|
|
351
|
+
if (!isEIP6963Connector(c) && eip6963Names.includes(c.name)) {
|
|
356
352
|
return;
|
|
357
353
|
}
|
|
358
354
|
if (isEIP6963Connector(c)) {
|
|
359
355
|
const paraMetadata = nonEip6963ConnectorsByRdns[c.id];
|
|
360
356
|
return __spreadProps(__spreadValues({}, c), { paraDetails: paraMetadata });
|
|
361
357
|
}
|
|
362
|
-
if (((
|
|
358
|
+
if (((_b = c.paraDetails) == null ? void 0 : _b.id) === "WALLETCONNECT" && walletConnectModalConnector) {
|
|
363
359
|
return __spreadProps(__spreadValues({}, c), { walletConnectModalConnector });
|
|
364
360
|
}
|
|
365
361
|
return c;
|
|
366
362
|
}).filter((c) => !!c);
|
|
367
363
|
const wallets = dedupedConnectors.map((c) => {
|
|
368
|
-
var _a, _b, _c;
|
|
364
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
369
365
|
if (((_a = c.paraDetails) == null ? void 0 : _a.internalId) === "SAFE" && (typeof window === "undefined" || window.parent === window)) {
|
|
370
366
|
return void 0;
|
|
371
367
|
}
|
|
372
368
|
const connector = __spreadValues(__spreadValues({}, c), c.paraDetails);
|
|
373
369
|
const supportsWalletConnect = connector.type === "walletConnect" || ((_b = connector.paraDetails) == null ? void 0 : _b.internalId) === "WALLETCONNECT" || ((_c = connector.paraDetails) == null ? void 0 : _c.showQrModal);
|
|
370
|
+
const isInjected = !c.paraDetails && eip6963Names.includes(c.name);
|
|
371
|
+
if (isInjected && connectors.some((c2) => {
|
|
372
|
+
var _a2;
|
|
373
|
+
return ((_a2 = c2.paraDetails) == null ? void 0 : _a2.rdns) === c2.id;
|
|
374
|
+
})) {
|
|
375
|
+
return void 0;
|
|
376
|
+
}
|
|
374
377
|
return __spreadValues(__spreadProps(__spreadValues({}, connector), {
|
|
378
|
+
// Using name here since that's the only common id across the networks
|
|
379
|
+
id: connector.name,
|
|
380
|
+
internalId: (_d = connector.internalId) != null ? _d : connector.name,
|
|
381
|
+
isExtension: (_e = connector.isExtension) != null ? _e : isInjected,
|
|
382
|
+
installed: (_f = connector.installed) != null ? _f : isInjected,
|
|
383
|
+
iconUrl: (_g = connector.iconUrl) != null ? _g : connector.icon,
|
|
375
384
|
connect: () => connect(connector),
|
|
376
385
|
connectMobile: (manual) => connectMobile(connector, manual),
|
|
377
386
|
type: "EVM"
|
|
@@ -379,12 +388,11 @@ function EvmExternalWalletProvider({
|
|
|
379
388
|
}).filter(Boolean);
|
|
380
389
|
const getConnectorInfo = (connector) => {
|
|
381
390
|
const paraDetails = connector.paraDetails;
|
|
382
|
-
const
|
|
383
|
-
const withFullParaAuth = walletsWithFullAuth == null ? void 0 : walletsWithFullAuth.includes(providerId);
|
|
391
|
+
const withFullParaAuth = walletsWithFullAuth == null ? void 0 : walletsWithFullAuth.includes(paraDetails == null ? void 0 : paraDetails.internalId);
|
|
384
392
|
return {
|
|
385
393
|
type: "EVM",
|
|
386
|
-
providerId,
|
|
387
|
-
provider:
|
|
394
|
+
providerId: connector.name,
|
|
395
|
+
provider: connector.name,
|
|
388
396
|
withFullParaAuth
|
|
389
397
|
};
|
|
390
398
|
};
|
|
@@ -404,13 +412,13 @@ function EvmExternalWalletProvider({
|
|
|
404
412
|
}
|
|
405
413
|
);
|
|
406
414
|
if (!connection) {
|
|
407
|
-
return
|
|
415
|
+
return { isPresent: false };
|
|
408
416
|
}
|
|
409
417
|
const address = (_a = connection == null ? void 0 : connection.accounts) == null ? void 0 : _a[0];
|
|
410
|
-
return address ? { isConnected: true, address } : { isConnected: false };
|
|
418
|
+
return address ? { isPresent: true, isConnected: true, address } : { isPresent: true, isConnected: false };
|
|
411
419
|
}, [connections]);
|
|
412
420
|
const connectParaEmbedded = useCallback(() => __async(this, null, function* () {
|
|
413
|
-
const paraConnectorInstance = connectors.find((c) => c.id === "
|
|
421
|
+
const paraConnectorInstance = connectors.find((c) => c.id === "Para");
|
|
414
422
|
if (!paraConnectorInstance) {
|
|
415
423
|
return { error: "No para connector instance" };
|
|
416
424
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import "../chunk-MMUBH76A.js";
|
|
3
3
|
const isEIP6963Connector = (wallet) => {
|
|
4
4
|
var _a;
|
|
5
|
-
return !!(!wallet.isRainbowKitConnector && ((_a = wallet.icon) == null ? void 0 : _a.startsWith("data:image")) && wallet.uid && wallet.name);
|
|
5
|
+
return !!(!wallet.isRainbowKitConnector && ((_a = wallet.icon) == null ? void 0 : _a.trim().startsWith("data:image")) && wallet.uid && wallet.name);
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
8
8
|
isEIP6963Connector
|
|
@@ -13,7 +13,7 @@ const backpackWallet = ({ projectId, walletConnectParameters }) => {
|
|
|
13
13
|
id: "backpack",
|
|
14
14
|
internalId: "BACKPACK",
|
|
15
15
|
name: "Backpack",
|
|
16
|
-
rdns: "app.backpack
|
|
16
|
+
rdns: "app.backpack",
|
|
17
17
|
iconUrl: icon,
|
|
18
18
|
installed: isBackpackInjected,
|
|
19
19
|
isExtension: true,
|
|
@@ -13,7 +13,7 @@ const farcasterWallet = ({ para, createFarcasterConnector }) => {
|
|
|
13
13
|
iconUrl: icon,
|
|
14
14
|
installed: (para == null ? void 0 : para.isReady) && (para == null ? void 0 : para.isFarcasterMiniApp),
|
|
15
15
|
isExtension: true,
|
|
16
|
-
downloadUrl: "https://
|
|
16
|
+
downloadUrl: "https://farcaster.xyz/",
|
|
17
17
|
createConnector: (walletDetails) => createConnector((config) => __spreadValues(__spreadValues({}, createFarcasterConnector()(config)), walletDetails))
|
|
18
18
|
};
|
|
19
19
|
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/evm-wallet-connectors",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.34",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@coinbase/wallet-sdk": "4.3.0",
|
|
6
|
-
"@getpara/wagmi-v2-connector": "2.0.0-alpha.
|
|
7
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
6
|
+
"@getpara/wagmi-v2-connector": "2.0.0-alpha.34",
|
|
7
|
+
"@getpara/web-sdk": "2.0.0-alpha.34",
|
|
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-alpha.
|
|
12
|
+
"@getpara/react-common": "2.0.0-alpha.34",
|
|
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": "cff5cb1fa7284a850e688b20a6596d435315a475",
|
|
29
29
|
"main": "dist/index.js",
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@farcaster/miniapp-wagmi-connector": "^1.0.0",
|