@getpara/evm-wallet-connectors 1.5.0 → 1.5.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.
- package/dist/index.js +168 -116
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,55 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
var __async = (__this, __arguments, generator) => {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
var fulfilled = (value) => {
|
|
36
|
+
try {
|
|
37
|
+
step(generator.next(value));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
reject(e);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var rejected = (value) => {
|
|
43
|
+
try {
|
|
44
|
+
step(generator.throw(value));
|
|
45
|
+
} catch (e) {
|
|
46
|
+
reject(e);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
50
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
51
|
+
});
|
|
52
|
+
};
|
|
2
53
|
|
|
3
54
|
// src/providers/EvmExternalWalletContext.tsx
|
|
4
55
|
import { createContext, useEffect, useMemo } from "react";
|
|
@@ -6,12 +57,13 @@ import { useAccount, useSwitchChain, useConnect, useDisconnect, useEnsName, useE
|
|
|
6
57
|
|
|
7
58
|
// src/utils/isEIP6963Connector.ts
|
|
8
59
|
var isEIP6963Connector = (wallet) => {
|
|
9
|
-
|
|
60
|
+
var _a;
|
|
61
|
+
return !!(!wallet.isRainbowKitConnector && ((_a = wallet.icon) == null ? void 0 : _a.startsWith("data:image")) && wallet.uid && wallet.name);
|
|
10
62
|
};
|
|
11
63
|
|
|
12
64
|
// src/utils/getWalletConnectUri.ts
|
|
13
|
-
var getWalletConnectUri =
|
|
14
|
-
const provider =
|
|
65
|
+
var getWalletConnectUri = (connector, uriConverter) => __async(void 0, null, function* () {
|
|
66
|
+
const provider = yield connector.getProvider();
|
|
15
67
|
if (connector.type === "coinbaseWallet") {
|
|
16
68
|
return provider.qrUrl;
|
|
17
69
|
}
|
|
@@ -24,7 +76,7 @@ var getWalletConnectUri = async (connector, uriConverter) => {
|
|
|
24
76
|
})
|
|
25
77
|
)
|
|
26
78
|
);
|
|
27
|
-
};
|
|
79
|
+
});
|
|
28
80
|
|
|
29
81
|
// src/providers/EvmExternalWalletContext.tsx
|
|
30
82
|
import { isMobile, WalletType } from "@getpara/react-sdk";
|
|
@@ -38,7 +90,7 @@ var useExternalWalletStore = create(
|
|
|
38
90
|
(set) => ({
|
|
39
91
|
isConnecting: false,
|
|
40
92
|
updateState: (state) => {
|
|
41
|
-
set({
|
|
93
|
+
set(__spreadValues({}, state));
|
|
42
94
|
}
|
|
43
95
|
}),
|
|
44
96
|
{
|
|
@@ -79,32 +131,33 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
79
131
|
return storedExternalWallets;
|
|
80
132
|
};
|
|
81
133
|
useEffect(() => {
|
|
82
|
-
const storedExternalWallet = getStoredExternalWallets()[wagmiAddress
|
|
83
|
-
if (!isConnecting && !isReconnecting && !isLocalConnecting && !!wagmiAddress && !storedExternalWallet && !(connectedConnector
|
|
134
|
+
const storedExternalWallet = getStoredExternalWallets()[wagmiAddress != null ? wagmiAddress : ""];
|
|
135
|
+
if (!isConnecting && !isReconnecting && !isLocalConnecting && !!wagmiAddress && !storedExternalWallet && !((connectedConnector == null ? void 0 : connectedConnector.id) === "para")) {
|
|
84
136
|
reset();
|
|
85
137
|
}
|
|
86
138
|
}, [isConnecting, isReconnecting, isLocalConnecting, wagmiAddress, connectedConnector]);
|
|
87
139
|
useEffect(() => {
|
|
88
140
|
const storedExternalWallet = Object.values(para.externalWallets || {})[0];
|
|
89
|
-
if (!isLocalConnecting && !isConnecting && !isReconnecting && storedExternalWallet
|
|
141
|
+
if (!isLocalConnecting && !isConnecting && !isReconnecting && (storedExternalWallet == null ? void 0 : storedExternalWallet.type) === WalletType.EVM && (storedExternalWallet == null ? void 0 : storedExternalWallet.address) !== wagmiAddress) {
|
|
90
142
|
switchWallet(wagmiAddress);
|
|
91
143
|
}
|
|
92
144
|
}, [isLocalConnecting, wagmiAddress, isReconnecting, isConnecting]);
|
|
93
145
|
const connectors = untypedConnectors;
|
|
94
|
-
const reset =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
};
|
|
98
|
-
const switchChain =
|
|
146
|
+
const reset = () => __async(this, null, function* () {
|
|
147
|
+
yield disconnectAsync();
|
|
148
|
+
yield para.logout();
|
|
149
|
+
});
|
|
150
|
+
const switchChain = (chainId2) => __async(this, null, function* () {
|
|
151
|
+
var _a, _b, _c;
|
|
99
152
|
let error;
|
|
100
153
|
try {
|
|
101
|
-
|
|
154
|
+
yield switchChainAsync({ chainId: chainId2 });
|
|
102
155
|
} catch (e) {
|
|
103
156
|
if (e.details.includes("Missing or invalid.")) {
|
|
104
157
|
const chain = chains.find((c) => c.id === chainId2);
|
|
105
158
|
error = [
|
|
106
159
|
"Network not supported.",
|
|
107
|
-
`You may need to add ${chain
|
|
160
|
+
`You may need to add ${chain == null ? void 0 : chain.name} support to ${(_c = (_b = (_a = connectedConnector == null ? void 0 : connectedConnector.paraDetails) == null ? void 0 : _a.name) != null ? _b : connectedConnector == null ? void 0 : connectedConnector.name) != null ? _c : "the wallet"} manually.`
|
|
108
161
|
];
|
|
109
162
|
} else {
|
|
110
163
|
switch (e.name) {
|
|
@@ -120,48 +173,51 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
120
173
|
}
|
|
121
174
|
}
|
|
122
175
|
return { error };
|
|
123
|
-
};
|
|
124
|
-
const login =
|
|
176
|
+
});
|
|
177
|
+
const login = (address, connectorName) => __async(this, null, function* () {
|
|
125
178
|
try {
|
|
126
|
-
|
|
179
|
+
yield para.externalWalletLogin({ address, type: WalletType.EVM, provider: connectorName });
|
|
127
180
|
} catch (err) {
|
|
128
|
-
|
|
129
|
-
|
|
181
|
+
yield disconnectAsync();
|
|
182
|
+
yield para.logout();
|
|
130
183
|
throw "Error logging you in. Please try again.";
|
|
131
184
|
}
|
|
132
|
-
};
|
|
133
|
-
const switchWallet =
|
|
185
|
+
});
|
|
186
|
+
const switchWallet = (address) => __async(this, null, function* () {
|
|
134
187
|
updateExternalWalletState({ isConnecting: true });
|
|
135
188
|
let error;
|
|
136
189
|
if (!address) {
|
|
137
|
-
|
|
190
|
+
yield para.logout();
|
|
138
191
|
} else {
|
|
139
192
|
try {
|
|
140
|
-
|
|
193
|
+
yield login(address, connectedConnector == null ? void 0 : connectedConnector.name);
|
|
141
194
|
} catch (err) {
|
|
142
195
|
error = err;
|
|
143
196
|
}
|
|
144
197
|
}
|
|
145
198
|
onSwitchWallet({ address, error });
|
|
146
199
|
updateExternalWalletState({ isConnecting: false });
|
|
147
|
-
};
|
|
148
|
-
const connect2 =
|
|
200
|
+
});
|
|
201
|
+
const connect2 = (connector) => __async(this, null, function* () {
|
|
202
|
+
var _a, _b, _c, _d;
|
|
149
203
|
updateExternalWalletState({ isConnecting: true });
|
|
150
|
-
|
|
151
|
-
const walletChainId =
|
|
204
|
+
yield disconnectAsync();
|
|
205
|
+
const walletChainId = yield connector.getChainId();
|
|
152
206
|
let address;
|
|
153
207
|
let error;
|
|
154
208
|
try {
|
|
155
|
-
const data =
|
|
209
|
+
const data = yield connectAsync({
|
|
156
210
|
// If the wallet is already on a supported chain, use that to avoid a chain switch prompt.
|
|
157
|
-
chainId: chains.find(({ id }) => id === walletChainId)
|
|
158
|
-
|
|
211
|
+
chainId: (_c = (_a = chains.find(({ id }) => id === walletChainId)) == null ? void 0 : _a.id) != null ? _c : (
|
|
212
|
+
// Fall back to the first chain provided.
|
|
213
|
+
(_b = chains[0]) == null ? void 0 : _b.id
|
|
214
|
+
),
|
|
159
215
|
connector
|
|
160
216
|
});
|
|
161
|
-
address = data.accounts
|
|
217
|
+
address = (_d = data.accounts) == null ? void 0 : _d[0];
|
|
162
218
|
if (address) {
|
|
163
219
|
try {
|
|
164
|
-
|
|
220
|
+
yield login(address, connector.name);
|
|
165
221
|
} catch (err) {
|
|
166
222
|
address = void 0;
|
|
167
223
|
error = err;
|
|
@@ -185,14 +241,15 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
185
241
|
}
|
|
186
242
|
updateExternalWalletState({ isConnecting: false });
|
|
187
243
|
return { address, error };
|
|
188
|
-
};
|
|
189
|
-
const connectMobile =
|
|
244
|
+
});
|
|
245
|
+
const connectMobile = (connector, isManualWalletConnect) => __async(this, null, function* () {
|
|
190
246
|
const _isMobile = isManualWalletConnect !== void 0 ? isManualWalletConnect : isMobile();
|
|
191
247
|
const _connector = connector.walletConnectModalConnector && _isMobile ? connector.walletConnectModalConnector : connector;
|
|
192
|
-
return
|
|
193
|
-
};
|
|
248
|
+
return yield connect2(_connector);
|
|
249
|
+
});
|
|
194
250
|
const getQrUri = (connector) => () => {
|
|
195
|
-
|
|
251
|
+
var _a;
|
|
252
|
+
return getWalletConnectUri(connector, (_a = connector.paraDetails) == null ? void 0 : _a.getUri);
|
|
196
253
|
};
|
|
197
254
|
const nonEip6963ConnectorsByRdns = {};
|
|
198
255
|
let walletConnectModalConnector;
|
|
@@ -206,30 +263,30 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
206
263
|
});
|
|
207
264
|
const eip6963ids = connectors.filter((c) => isEIP6963Connector(c)).map((c) => c.id);
|
|
208
265
|
const dedupedConnectors = connectors.map((c) => {
|
|
209
|
-
|
|
266
|
+
var _a, _b, _c;
|
|
267
|
+
if ((_a = c.paraDetails) == null ? void 0 : _a.isWalletConnectModalConnector) {
|
|
210
268
|
return;
|
|
211
269
|
}
|
|
212
|
-
if (!isEIP6963Connector(c) && eip6963ids.includes(c.paraDetails
|
|
270
|
+
if (!isEIP6963Connector(c) && eip6963ids.includes((_b = c.paraDetails) == null ? void 0 : _b.rdns)) {
|
|
213
271
|
return;
|
|
214
272
|
}
|
|
215
273
|
if (isEIP6963Connector(c)) {
|
|
216
274
|
const paraMetadata = nonEip6963ConnectorsByRdns[c.id];
|
|
217
|
-
return {
|
|
275
|
+
return __spreadProps(__spreadValues({}, c), { paraDetails: paraMetadata });
|
|
218
276
|
}
|
|
219
|
-
if (c.paraDetails
|
|
220
|
-
return {
|
|
277
|
+
if (((_c = c.paraDetails) == null ? void 0 : _c.id) === "walletConnect" && walletConnectModalConnector) {
|
|
278
|
+
return __spreadProps(__spreadValues({}, c), { walletConnectModalConnector });
|
|
221
279
|
}
|
|
222
280
|
return c;
|
|
223
281
|
}).filter((c) => !!c);
|
|
224
282
|
const wallets = dedupedConnectors.map((c) => {
|
|
225
|
-
const connector = {
|
|
226
|
-
return {
|
|
227
|
-
...connector,
|
|
283
|
+
const connector = __spreadValues(__spreadValues({}, c), c.paraDetails);
|
|
284
|
+
return __spreadProps(__spreadValues({}, connector), {
|
|
228
285
|
connect: () => connect2(connector),
|
|
229
286
|
connectMobile: (isManualWalletConnect) => connectMobile(connector, isManualWalletConnect),
|
|
230
287
|
type: WalletType.EVM,
|
|
231
288
|
getQrUri: getQrUri(connector)
|
|
232
|
-
};
|
|
289
|
+
});
|
|
233
290
|
});
|
|
234
291
|
const formattedChains = chains.map((c) => {
|
|
235
292
|
return {
|
|
@@ -237,7 +294,7 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
237
294
|
name: c.name
|
|
238
295
|
};
|
|
239
296
|
});
|
|
240
|
-
const username = useMemo(() => ensName
|
|
297
|
+
const username = useMemo(() => ensName != null ? ensName : wagmiAddress, [ensName, wagmiAddress]);
|
|
241
298
|
const disconnect = disconnectAsync;
|
|
242
299
|
return /* @__PURE__ */ jsx(
|
|
243
300
|
EvmExternalWalletContext.Provider,
|
|
@@ -275,8 +332,8 @@ var computeWalletConnectMetaData = ({
|
|
|
275
332
|
}) => {
|
|
276
333
|
return {
|
|
277
334
|
name: appName,
|
|
278
|
-
description: appDescription
|
|
279
|
-
url: appUrl
|
|
335
|
+
description: appDescription != null ? appDescription : appName,
|
|
336
|
+
url: appUrl != null ? appUrl : typeof window !== "undefined" ? window.location.href : "",
|
|
280
337
|
icons: [...appIcon ? [appIcon] : []]
|
|
281
338
|
};
|
|
282
339
|
};
|
|
@@ -310,36 +367,28 @@ var connectorsForWallets = (walletList, { projectId, walletConnectParameters, ap
|
|
|
310
367
|
appName,
|
|
311
368
|
appIcon,
|
|
312
369
|
// `option` is being used only for `walletConnectWallet` wallet
|
|
313
|
-
options: {
|
|
314
|
-
metadata: walletConnectMetaData
|
|
315
|
-
|
|
316
|
-
},
|
|
370
|
+
options: __spreadValues({
|
|
371
|
+
metadata: walletConnectMetaData
|
|
372
|
+
}, walletConnectParameters),
|
|
317
373
|
// Every other wallet that supports walletConnect flow and is not
|
|
318
374
|
// `walletConnectWallet` wallet will have `walletConnectParameters` property
|
|
319
|
-
walletConnectParameters: {
|
|
320
|
-
metadata: walletConnectMetaData
|
|
321
|
-
|
|
322
|
-
}
|
|
375
|
+
walletConnectParameters: __spreadValues({
|
|
376
|
+
metadata: walletConnectMetaData
|
|
377
|
+
}, walletConnectParameters)
|
|
323
378
|
});
|
|
324
|
-
const walletListItem = {
|
|
325
|
-
...wallet,
|
|
379
|
+
const walletListItem = __spreadProps(__spreadValues({}, wallet), {
|
|
326
380
|
index
|
|
327
|
-
};
|
|
381
|
+
});
|
|
328
382
|
wallets.push(walletListItem);
|
|
329
383
|
});
|
|
330
384
|
const walletListItems = uniqueBy([...wallets], "id");
|
|
331
|
-
for (const
|
|
385
|
+
for (const _a of walletListItems) {
|
|
386
|
+
const _b = _a, { createConnector: createConnector4 } = _b, walletMeta = __objRest(_b, ["createConnector"]);
|
|
332
387
|
const walletMetaData = (additionalParaParams) => {
|
|
333
388
|
return {
|
|
334
|
-
paraDetails: omitUndefinedValues({
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
// These additional params will be used in Para react tree to
|
|
338
|
-
// merge `walletConnectWallet` and `walletConnect` connector from wagmi with
|
|
339
|
-
// showQrModal: true. This way we can let the user choose if they want to
|
|
340
|
-
// connect via QR code or open the official walletConnect modal instead
|
|
341
|
-
...additionalParaParams ? additionalParaParams : {}
|
|
342
|
-
})
|
|
389
|
+
paraDetails: omitUndefinedValues(__spreadValues(__spreadProps(__spreadValues({}, walletMeta), {
|
|
390
|
+
isParaConnector: true
|
|
391
|
+
}), additionalParaParams ? additionalParaParams : {}))
|
|
343
392
|
};
|
|
344
393
|
};
|
|
345
394
|
const isWalletConnectConnector = walletMeta.id === "walletConnect";
|
|
@@ -374,12 +423,14 @@ var createDefaultTransports = (chains) => {
|
|
|
374
423
|
}, {});
|
|
375
424
|
return transportsObject;
|
|
376
425
|
};
|
|
377
|
-
function ParaEvmProvider(
|
|
426
|
+
function ParaEvmProvider(_a) {
|
|
427
|
+
var _b = _a, { children, config: _config } = _b, wagmiProviderProps = __objRest(_b, ["children", "config"]);
|
|
428
|
+
var _a2;
|
|
378
429
|
const updateExternalWalletProviderState = useExternalWalletProviderStore((state) => state.updateState);
|
|
379
430
|
const EvmProvider = useExternalWalletProviderStore((state) => state.EvmProvider);
|
|
380
431
|
const evmContext = useExternalWalletProviderStore((state) => state.evmContext);
|
|
381
|
-
const para = _config.para
|
|
382
|
-
const {
|
|
432
|
+
const para = (_a2 = _config.para) != null ? _a2 : useClient();
|
|
433
|
+
const _b2 = _config, {
|
|
383
434
|
projectId,
|
|
384
435
|
appName,
|
|
385
436
|
appDescription,
|
|
@@ -389,18 +440,28 @@ function ParaEvmProvider({ children, config: _config, ...wagmiProviderProps }) {
|
|
|
389
440
|
chains,
|
|
390
441
|
transports,
|
|
391
442
|
paraDisableModal,
|
|
392
|
-
paraOptions
|
|
393
|
-
|
|
394
|
-
|
|
443
|
+
paraOptions
|
|
444
|
+
} = _b2, wagmiConfigParams = __objRest(_b2, [
|
|
445
|
+
"projectId",
|
|
446
|
+
"appName",
|
|
447
|
+
"appDescription",
|
|
448
|
+
"appIcon",
|
|
449
|
+
"appUrl",
|
|
450
|
+
"wallets",
|
|
451
|
+
"chains",
|
|
452
|
+
"transports",
|
|
453
|
+
"paraDisableModal",
|
|
454
|
+
"paraOptions"
|
|
455
|
+
]);
|
|
395
456
|
const wcMetadata = computeWalletConnectMetaData({ appName, appDescription, appUrl, appIcon });
|
|
396
457
|
const paraConnectorInstance = useMemo2(() => {
|
|
397
458
|
if (!para) return void 0;
|
|
398
459
|
const instance = paraConnector({
|
|
399
460
|
para,
|
|
400
461
|
chains: [...chains],
|
|
401
|
-
disableModal: paraDisableModal
|
|
462
|
+
disableModal: paraDisableModal != null ? paraDisableModal : true,
|
|
402
463
|
appName,
|
|
403
|
-
options: paraOptions
|
|
464
|
+
options: paraOptions != null ? paraOptions : {}
|
|
404
465
|
});
|
|
405
466
|
return instance;
|
|
406
467
|
}, [para, chains, paraDisableModal, appName, paraOptions]);
|
|
@@ -416,26 +477,25 @@ function ParaEvmProvider({ children, config: _config, ...wagmiProviderProps }) {
|
|
|
416
477
|
return paraConnectorInstance ? [...baseConnectors, paraConnectorInstance] : baseConnectors;
|
|
417
478
|
}, [wallets, projectId, appName, appDescription, appUrl, appIcon, wcMetadata, paraConnectorInstance]);
|
|
418
479
|
const config = useMemo2(
|
|
419
|
-
() => createConfig({
|
|
420
|
-
...wagmiConfigParams,
|
|
480
|
+
() => createConfig(__spreadProps(__spreadValues({}, wagmiConfigParams), {
|
|
421
481
|
chains,
|
|
422
482
|
transports: transports || createDefaultTransports(chains),
|
|
423
483
|
connectors: allConnectors
|
|
424
|
-
}),
|
|
484
|
+
})),
|
|
425
485
|
[wagmiConfigParams, chains, transports, allConnectors]
|
|
426
486
|
);
|
|
427
|
-
const connectParaEvmWallet = useCallback(
|
|
487
|
+
const connectParaEvmWallet = useCallback(() => __async(this, null, function* () {
|
|
428
488
|
if (!paraConnectorInstance) {
|
|
429
489
|
return { error: "No para connector instance" };
|
|
430
490
|
}
|
|
431
491
|
try {
|
|
432
|
-
const result =
|
|
492
|
+
const result = yield connect(config, { connector: paraConnectorInstance });
|
|
433
493
|
return { result };
|
|
434
494
|
} catch (err) {
|
|
435
495
|
const error = err instanceof Error ? err.message : "Unknown error";
|
|
436
496
|
return { error };
|
|
437
497
|
}
|
|
438
|
-
}, [paraConnectorInstance, config, connect]);
|
|
498
|
+
}), [paraConnectorInstance, config, connect]);
|
|
439
499
|
useEffect2(() => {
|
|
440
500
|
updateExternalWalletProviderState({
|
|
441
501
|
EvmProvider: evmContext && EvmProvider ? EvmProvider : EvmExternalWalletProvider,
|
|
@@ -446,7 +506,7 @@ function ParaEvmProvider({ children, config: _config, ...wagmiProviderProps }) {
|
|
|
446
506
|
if (!evmContext || !EvmProvider) {
|
|
447
507
|
return null;
|
|
448
508
|
}
|
|
449
|
-
return /* @__PURE__ */ jsx2(WagmiProvider, { config,
|
|
509
|
+
return /* @__PURE__ */ jsx2(WagmiProvider, __spreadProps(__spreadValues({ config }, wagmiProviderProps), { children }));
|
|
450
510
|
}
|
|
451
511
|
|
|
452
512
|
// src/wallets/connectors/metaMask/metaMask.ts
|
|
@@ -478,13 +538,14 @@ function hasInjectedProvider({ flag, namespace }) {
|
|
|
478
538
|
return false;
|
|
479
539
|
}
|
|
480
540
|
function getInjectedProvider({ flag, namespace }) {
|
|
541
|
+
var _a;
|
|
481
542
|
const _window = typeof window !== "undefined" ? window : void 0;
|
|
482
543
|
if (typeof _window === "undefined") return;
|
|
483
544
|
if (namespace) {
|
|
484
545
|
const windowProvider = getWindowProviderNamespace(namespace);
|
|
485
546
|
if (windowProvider) return windowProvider;
|
|
486
547
|
}
|
|
487
|
-
const providers = _window.ethereum
|
|
548
|
+
const providers = (_a = _window.ethereum) == null ? void 0 : _a.providers;
|
|
488
549
|
if (flag) {
|
|
489
550
|
const provider = getExplicitInjectedProvider(flag);
|
|
490
551
|
if (provider) return provider;
|
|
@@ -501,11 +562,7 @@ function createInjectedConnector(provider) {
|
|
|
501
562
|
provider
|
|
502
563
|
})
|
|
503
564
|
} : {};
|
|
504
|
-
return createConnector((config) => ({
|
|
505
|
-
// Spread the injectedConfig object, which may be empty or contain the target function
|
|
506
|
-
...injected(injectedConfig)(config),
|
|
507
|
-
...walletDetails
|
|
508
|
-
}));
|
|
565
|
+
return createConnector((config) => __spreadValues(__spreadValues({}, injected(injectedConfig)(config)), walletDetails));
|
|
509
566
|
};
|
|
510
567
|
}
|
|
511
568
|
function getInjectedConnector({
|
|
@@ -526,14 +583,13 @@ var getOrCreateWalletConnectInstance = ({
|
|
|
526
583
|
walletConnectParameters,
|
|
527
584
|
paraDetailsShowQrModal
|
|
528
585
|
}) => {
|
|
529
|
-
let config = {
|
|
530
|
-
...walletConnectParameters ? walletConnectParameters : {},
|
|
586
|
+
let config = __spreadProps(__spreadValues({}, walletConnectParameters ? walletConnectParameters : {}), {
|
|
531
587
|
projectId,
|
|
532
588
|
showQrModal: false
|
|
533
589
|
// Required. Otherwise WalletConnect modal (Web3Modal) will popup during time of connection for a wallet
|
|
534
|
-
};
|
|
590
|
+
});
|
|
535
591
|
if (paraDetailsShowQrModal) {
|
|
536
|
-
config = {
|
|
592
|
+
config = __spreadProps(__spreadValues({}, config), { showQrModal: true });
|
|
537
593
|
}
|
|
538
594
|
const serializedConfig = JSON.stringify(config);
|
|
539
595
|
const sharedWalletConnector = walletConnectInstances.get(serializedConfig);
|
|
@@ -549,15 +605,13 @@ function createWalletConnectConnector({
|
|
|
549
605
|
walletDetails,
|
|
550
606
|
walletConnectParameters
|
|
551
607
|
}) {
|
|
552
|
-
return createConnector2((config) => ({
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
})(config),
|
|
560
|
-
...walletDetails,
|
|
608
|
+
return createConnector2((config) => __spreadProps(__spreadValues(__spreadValues({}, getOrCreateWalletConnectInstance({
|
|
609
|
+
projectId,
|
|
610
|
+
walletConnectParameters,
|
|
611
|
+
// Used in `connectorsForWallets` to add another
|
|
612
|
+
// walletConnect wallet into Para with modal popup option
|
|
613
|
+
paraDetailsShowQrModal: walletDetails.paraDetails.showQrModal
|
|
614
|
+
})(config)), walletDetails), {
|
|
561
615
|
id: walletDetails.paraDetails.id
|
|
562
616
|
}));
|
|
563
617
|
}
|
|
@@ -582,7 +636,7 @@ var icon = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMj
|
|
|
582
636
|
|
|
583
637
|
// src/wallets/connectors/metaMask/metaMask.ts
|
|
584
638
|
function isMetaMask(ethereum) {
|
|
585
|
-
if (!ethereum
|
|
639
|
+
if (!(ethereum == null ? void 0 : ethereum.isMetaMask)) return false;
|
|
586
640
|
if (ethereum.isBraveWallet && !ethereum._events && !ethereum._state) return false;
|
|
587
641
|
if (ethereum.isApexWallet) return false;
|
|
588
642
|
if (ethereum.isAvalanche) return false;
|
|
@@ -623,6 +677,7 @@ function isMetaMask(ethereum) {
|
|
|
623
677
|
return true;
|
|
624
678
|
}
|
|
625
679
|
var metaMaskWallet = ({ projectId, walletConnectParameters }) => {
|
|
680
|
+
var _a, _b, _c;
|
|
626
681
|
const isMetaMaskInjected = hasInjectedProvider({ flag: "isMetaMask" });
|
|
627
682
|
const getUri = (uri) => {
|
|
628
683
|
return isAndroid() ? `metamask://wc?uri=${encodeURIComponent(uri)}` : isIOS() ? !isTelegram() ? (
|
|
@@ -641,7 +696,7 @@ var metaMaskWallet = ({ projectId, walletConnectParameters }) => {
|
|
|
641
696
|
downloadUrl: "https://metamask.io/download/",
|
|
642
697
|
getUri,
|
|
643
698
|
createConnector: isMetaMaskInjected ? getInjectedConnector({
|
|
644
|
-
target: typeof window !== "undefined" ? window.ethereum
|
|
699
|
+
target: typeof window !== "undefined" ? (_c = (_b = (_a = window.ethereum) == null ? void 0 : _a.providers) == null ? void 0 : _b.find(isMetaMask)) != null ? _c : window.ethereum : void 0
|
|
645
700
|
}) : getWalletConnectConnector({
|
|
646
701
|
projectId,
|
|
647
702
|
walletConnectParameters
|
|
@@ -722,15 +777,12 @@ var coinbaseWallet = ({ appName, appIcon }) => {
|
|
|
722
777
|
isMobile: true,
|
|
723
778
|
downloadUrl: "https://www.coinbase.com/wallet/downloads",
|
|
724
779
|
getUri,
|
|
725
|
-
createConnector: (walletDetails) => createConnector3((config) => ({
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
})(config),
|
|
732
|
-
...walletDetails
|
|
733
|
-
}))
|
|
780
|
+
createConnector: (walletDetails) => createConnector3((config) => __spreadValues(__spreadValues({}, coinbaseWagmiWallet({
|
|
781
|
+
version: "4",
|
|
782
|
+
appName,
|
|
783
|
+
appLogoUrl: appIcon,
|
|
784
|
+
preference: "eoaOnly"
|
|
785
|
+
})(config)), walletDetails))
|
|
734
786
|
};
|
|
735
787
|
};
|
|
736
788
|
|
package/dist/index.js.br
CHANGED
|
Binary file
|
package/dist/index.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/evm-wallet-connectors",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
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/react-sdk": "1.5.
|
|
14
|
-
"@getpara/wagmi-v2-integration": "1.5.
|
|
13
|
+
"@getpara/react-sdk": "1.5.1",
|
|
14
|
+
"@getpara/wagmi-v2-integration": "1.5.1",
|
|
15
15
|
"zustand": "^4.5.2",
|
|
16
16
|
"zustand-sync-tabs": "^0.2.2"
|
|
17
17
|
},
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"dist",
|
|
38
38
|
"package.json"
|
|
39
39
|
],
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "f77e0f5e162a1672219b01dbf7c06a3baadd2f35"
|
|
41
41
|
}
|