@getpara/evm-wallet-connectors 1.5.1 → 1.7.0
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 +187 -44
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/package.json +4 -0
- package/dist/providers/EvmExternalWalletContext.d.ts +12 -2
- package/dist/types/Wallet.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/utils/getInjectedConnector.d.ts +4 -0
- package/dist/wallets/connectors/index.d.ts +2 -1
- package/dist/wallets/connectors/safe/safe.d.ts +2 -0
- package/dist/wallets/connectors/safe/safeIcon.d.ts +1 -0
- package/package.json +4 -4
- package/dist/types/CommonTypes.d.ts +0 -27
package/dist/index.js
CHANGED
|
@@ -52,8 +52,18 @@ var __async = (__this, __arguments, generator) => {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
// src/providers/EvmExternalWalletContext.tsx
|
|
55
|
-
import { createContext, useEffect, useMemo } from "react";
|
|
56
|
-
import {
|
|
55
|
+
import { createContext, useEffect, useMemo, useRef } from "react";
|
|
56
|
+
import {
|
|
57
|
+
useAccount,
|
|
58
|
+
useSwitchChain,
|
|
59
|
+
useConnect,
|
|
60
|
+
useDisconnect,
|
|
61
|
+
useEnsName,
|
|
62
|
+
useEnsAvatar,
|
|
63
|
+
useSwitchAccount,
|
|
64
|
+
useConnections,
|
|
65
|
+
useSignMessage
|
|
66
|
+
} from "wagmi";
|
|
57
67
|
|
|
58
68
|
// src/utils/isEIP6963Connector.ts
|
|
59
69
|
var isEIP6963Connector = (wallet) => {
|
|
@@ -79,7 +89,12 @@ var getWalletConnectUri = (connector, uriConverter) => __async(void 0, null, fun
|
|
|
79
89
|
});
|
|
80
90
|
|
|
81
91
|
// src/providers/EvmExternalWalletContext.tsx
|
|
82
|
-
import {
|
|
92
|
+
import {
|
|
93
|
+
isMobile,
|
|
94
|
+
useExternalWalletProviderStore,
|
|
95
|
+
useWallet,
|
|
96
|
+
WalletType
|
|
97
|
+
} from "@getpara/react-sdk";
|
|
83
98
|
import { normalize } from "viem/ens";
|
|
84
99
|
|
|
85
100
|
// src/stores/useStore.ts
|
|
@@ -108,20 +123,28 @@ var defaultEvmExternalWallet = {
|
|
|
108
123
|
username: void 0,
|
|
109
124
|
avatar: void 0,
|
|
110
125
|
disconnect: () => Promise.resolve(),
|
|
111
|
-
switchChain: () => Promise.resolve({})
|
|
126
|
+
switchChain: () => Promise.resolve({}),
|
|
127
|
+
signMessage: () => Promise.resolve({}),
|
|
128
|
+
signVerificationMessage: () => Promise.resolve({})
|
|
112
129
|
};
|
|
113
130
|
var EvmExternalWalletContext = createContext(defaultEvmExternalWallet);
|
|
114
131
|
function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
115
132
|
const { connectAsync, connectors: untypedConnectors } = useConnect();
|
|
133
|
+
const connections = useConnections();
|
|
116
134
|
const { address: wagmiAddress, isConnecting, isReconnecting, chainId, connector: connectedConnector } = useAccount();
|
|
117
135
|
const { chains, switchChainAsync } = useSwitchChain();
|
|
118
136
|
const { disconnectAsync } = useDisconnect();
|
|
119
|
-
const {
|
|
120
|
-
const {
|
|
137
|
+
const { switchAccountAsync } = useSwitchAccount();
|
|
138
|
+
const { signMessageAsync } = useSignMessage();
|
|
139
|
+
const { data: ensName, refetch: refetchEnsName } = useEnsName({ address: wagmiAddress });
|
|
140
|
+
const { data: ensAvatar, refetch: refetchEnsAvatar } = useEnsAvatar({
|
|
121
141
|
name: normalize(ensName)
|
|
122
142
|
});
|
|
143
|
+
const fullAuthWallets = useExternalWalletProviderStore((state) => state.fullAuthWallets);
|
|
144
|
+
const { data: wallet } = useWallet();
|
|
123
145
|
const isLocalConnecting = useExternalWalletStore((state) => state.isConnecting);
|
|
124
146
|
const updateExternalWalletState = useExternalWalletStore((state) => state.updateState);
|
|
147
|
+
const verificationMessage = useRef();
|
|
125
148
|
const getStoredExternalWallets = () => {
|
|
126
149
|
const storedExternalWalletsString = localStorage.getItem("@CAPSULE/externalWallets");
|
|
127
150
|
let storedExternalWallets = {};
|
|
@@ -132,21 +155,56 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
132
155
|
};
|
|
133
156
|
useEffect(() => {
|
|
134
157
|
const storedExternalWallet = getStoredExternalWallets()[wagmiAddress != null ? wagmiAddress : ""];
|
|
135
|
-
if (!isConnecting && !isReconnecting && !isLocalConnecting && !!wagmiAddress && !storedExternalWallet &&
|
|
158
|
+
if (!isConnecting && !isReconnecting && !isLocalConnecting && !!wagmiAddress && !storedExternalWallet && (connectedConnector == null ? void 0 : connectedConnector.id) !== "para") {
|
|
136
159
|
reset();
|
|
137
160
|
}
|
|
138
161
|
}, [isConnecting, isReconnecting, isLocalConnecting, wagmiAddress, connectedConnector]);
|
|
139
162
|
useEffect(() => {
|
|
140
163
|
const storedExternalWallet = Object.values(para.externalWallets || {})[0];
|
|
141
|
-
if (!isLocalConnecting && !isConnecting && !isReconnecting && (storedExternalWallet == null ? void 0 : storedExternalWallet.type) === WalletType.EVM && (storedExternalWallet == null ? void 0 : storedExternalWallet.address) !== wagmiAddress) {
|
|
164
|
+
if (!isLocalConnecting && !isConnecting && !isReconnecting && (storedExternalWallet == null ? void 0 : storedExternalWallet.type) === WalletType.EVM && (storedExternalWallet == null ? void 0 : storedExternalWallet.address) !== wagmiAddress && (connectedConnector == null ? void 0 : connectedConnector.id) !== "para") {
|
|
142
165
|
switchWallet(wagmiAddress);
|
|
143
166
|
}
|
|
144
167
|
}, [isLocalConnecting, wagmiAddress, isReconnecting, isConnecting]);
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
if (wallet && connectedConnector && wallet.type === WalletType.EVM && (connectedConnector.id === "para" && wallet.isExternal || connectedConnector.id !== "para" && !wallet.isExternal)) {
|
|
170
|
+
switchAccount(wallet.isExternal ? wallet.name : "Para");
|
|
171
|
+
}
|
|
172
|
+
}, [wallet]);
|
|
145
173
|
const connectors = untypedConnectors;
|
|
146
174
|
const reset = () => __async(this, null, function* () {
|
|
147
175
|
yield disconnectAsync();
|
|
148
176
|
yield para.logout();
|
|
149
177
|
});
|
|
178
|
+
const signMessage = (message) => __async(this, null, function* () {
|
|
179
|
+
try {
|
|
180
|
+
const signature = yield signMessageAsync({
|
|
181
|
+
message,
|
|
182
|
+
account: wagmiAddress
|
|
183
|
+
});
|
|
184
|
+
return { address: wagmiAddress, signature };
|
|
185
|
+
} catch (e) {
|
|
186
|
+
switch (e.name) {
|
|
187
|
+
case "UserRejectedRequestError": {
|
|
188
|
+
return { error: "Signature request rejected" };
|
|
189
|
+
}
|
|
190
|
+
default: {
|
|
191
|
+
return { error: "An unknown error occurred" };
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
const signVerificationMessage = () => __async(this, null, function* () {
|
|
197
|
+
const signature = yield signMessage(verificationMessage.current);
|
|
198
|
+
return signature;
|
|
199
|
+
});
|
|
200
|
+
const switchAccount = (connectorName) => __async(this, null, function* () {
|
|
201
|
+
var _a;
|
|
202
|
+
const connector = (_a = connections.find((c) => c.connector.name === connectorName)) == null ? void 0 : _a.connector;
|
|
203
|
+
if (!connector) {
|
|
204
|
+
throw new Error(`connector not found: ${connectorName}`);
|
|
205
|
+
}
|
|
206
|
+
yield switchAccountAsync({ connector });
|
|
207
|
+
});
|
|
150
208
|
const switchChain = (chainId2) => __async(this, null, function* () {
|
|
151
209
|
var _a, _b, _c;
|
|
152
210
|
let error;
|
|
@@ -174,9 +232,21 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
174
232
|
}
|
|
175
233
|
return { error };
|
|
176
234
|
});
|
|
177
|
-
const login = (
|
|
235
|
+
const login = (_0) => __async(this, [_0], function* ({
|
|
236
|
+
address,
|
|
237
|
+
walletId,
|
|
238
|
+
connectorName
|
|
239
|
+
}) {
|
|
240
|
+
var _a;
|
|
178
241
|
try {
|
|
179
|
-
|
|
242
|
+
refetchEnsName();
|
|
243
|
+
refetchEnsAvatar();
|
|
244
|
+
return yield para.externalWalletLogin({
|
|
245
|
+
address,
|
|
246
|
+
type: WalletType.EVM,
|
|
247
|
+
provider: connectorName,
|
|
248
|
+
withFullParaAuth: fullAuthWallets == null ? void 0 : fullAuthWallets.includes((_a = walletId == null ? void 0 : walletId.toUpperCase()) != null ? _a : "")
|
|
249
|
+
});
|
|
180
250
|
} catch (err) {
|
|
181
251
|
yield disconnectAsync();
|
|
182
252
|
yield para.logout();
|
|
@@ -184,15 +254,24 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
184
254
|
}
|
|
185
255
|
});
|
|
186
256
|
const switchWallet = (address) => __async(this, null, function* () {
|
|
257
|
+
var _a;
|
|
187
258
|
updateExternalWalletState({ isConnecting: true });
|
|
188
259
|
let error;
|
|
189
260
|
if (!address) {
|
|
190
261
|
yield para.logout();
|
|
191
262
|
} else {
|
|
192
|
-
|
|
193
|
-
yield
|
|
194
|
-
}
|
|
195
|
-
|
|
263
|
+
if (para.isExternalWalletAuth) {
|
|
264
|
+
yield reset();
|
|
265
|
+
} else {
|
|
266
|
+
try {
|
|
267
|
+
yield login({
|
|
268
|
+
address,
|
|
269
|
+
connectorName: connectedConnector == null ? void 0 : connectedConnector.name,
|
|
270
|
+
walletId: (_a = getParaDetails(connectedConnector.id)) == null ? void 0 : _a.id
|
|
271
|
+
});
|
|
272
|
+
} catch (err) {
|
|
273
|
+
error = err;
|
|
274
|
+
}
|
|
196
275
|
}
|
|
197
276
|
}
|
|
198
277
|
onSwitchWallet({ address, error });
|
|
@@ -205,6 +284,8 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
205
284
|
const walletChainId = yield connector.getChainId();
|
|
206
285
|
let address;
|
|
207
286
|
let error;
|
|
287
|
+
let userExists = false;
|
|
288
|
+
let isVerified = false;
|
|
208
289
|
try {
|
|
209
290
|
const data = yield connectAsync({
|
|
210
291
|
// If the wallet is already on a supported chain, use that to avoid a chain switch prompt.
|
|
@@ -217,7 +298,10 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
217
298
|
address = (_d = data.accounts) == null ? void 0 : _d[0];
|
|
218
299
|
if (address) {
|
|
219
300
|
try {
|
|
220
|
-
yield login(address, connector.name);
|
|
301
|
+
const loginResp = yield login({ address, connectorName: connector.name, walletId: connector.paraDetails.id });
|
|
302
|
+
userExists = loginResp.userExists;
|
|
303
|
+
isVerified = loginResp.isVerified;
|
|
304
|
+
verificationMessage.current = loginResp.signatureVerificationMessage;
|
|
221
305
|
} catch (err) {
|
|
222
306
|
address = void 0;
|
|
223
307
|
error = err;
|
|
@@ -240,7 +324,7 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
240
324
|
}
|
|
241
325
|
}
|
|
242
326
|
updateExternalWalletState({ isConnecting: false });
|
|
243
|
-
return { address, error };
|
|
327
|
+
return { address, error, userExists, isVerified };
|
|
244
328
|
});
|
|
245
329
|
const connectMobile = (connector, isManualWalletConnect) => __async(this, null, function* () {
|
|
246
330
|
const _isMobile = isManualWalletConnect !== void 0 ? isManualWalletConnect : isMobile();
|
|
@@ -283,11 +367,15 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
283
367
|
const connector = __spreadValues(__spreadValues({}, c), c.paraDetails);
|
|
284
368
|
return __spreadProps(__spreadValues({}, connector), {
|
|
285
369
|
connect: () => connect2(connector),
|
|
286
|
-
connectMobile: (isManualWalletConnect) => connectMobile(connector, isManualWalletConnect),
|
|
370
|
+
connectMobile: ({ isManualWalletConnect }) => connectMobile(connector, isManualWalletConnect),
|
|
287
371
|
type: WalletType.EVM,
|
|
288
372
|
getQrUri: getQrUri(connector)
|
|
289
373
|
});
|
|
290
374
|
});
|
|
375
|
+
const getParaDetails = (id) => {
|
|
376
|
+
var _a;
|
|
377
|
+
return (_a = connectors.find((w) => w.id === id)) == null ? void 0 : _a.paraDetails;
|
|
378
|
+
};
|
|
291
379
|
const formattedChains = chains.map((c) => {
|
|
292
380
|
return {
|
|
293
381
|
id: c.id,
|
|
@@ -300,8 +388,28 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
300
388
|
EvmExternalWalletContext.Provider,
|
|
301
389
|
{
|
|
302
390
|
value: useMemo(
|
|
303
|
-
() => ({
|
|
304
|
-
|
|
391
|
+
() => ({
|
|
392
|
+
wallets,
|
|
393
|
+
chains: formattedChains,
|
|
394
|
+
chainId,
|
|
395
|
+
username,
|
|
396
|
+
avatar: ensAvatar,
|
|
397
|
+
disconnect,
|
|
398
|
+
switchChain,
|
|
399
|
+
signMessage,
|
|
400
|
+
signVerificationMessage
|
|
401
|
+
}),
|
|
402
|
+
[
|
|
403
|
+
wallets,
|
|
404
|
+
formattedChains,
|
|
405
|
+
chainId,
|
|
406
|
+
username,
|
|
407
|
+
ensAvatar,
|
|
408
|
+
disconnect,
|
|
409
|
+
switchChain,
|
|
410
|
+
signMessage,
|
|
411
|
+
signVerificationMessage
|
|
412
|
+
]
|
|
305
413
|
),
|
|
306
414
|
children
|
|
307
415
|
}
|
|
@@ -383,7 +491,7 @@ var connectorsForWallets = (walletList, { projectId, walletConnectParameters, ap
|
|
|
383
491
|
});
|
|
384
492
|
const walletListItems = uniqueBy([...wallets], "id");
|
|
385
493
|
for (const _a of walletListItems) {
|
|
386
|
-
const _b = _a, { createConnector:
|
|
494
|
+
const _b = _a, { createConnector: createConnector5 } = _b, walletMeta = __objRest(_b, ["createConnector"]);
|
|
387
495
|
const walletMetaData = (additionalParaParams) => {
|
|
388
496
|
return {
|
|
389
497
|
paraDetails: omitUndefinedValues(__spreadValues(__spreadProps(__spreadValues({}, walletMeta), {
|
|
@@ -394,7 +502,7 @@ var connectorsForWallets = (walletList, { projectId, walletConnectParameters, ap
|
|
|
394
502
|
const isWalletConnectConnector = walletMeta.id === "walletConnect";
|
|
395
503
|
if (isWalletConnectConnector) {
|
|
396
504
|
connectors.push(
|
|
397
|
-
|
|
505
|
+
createConnector5(
|
|
398
506
|
walletMetaData({
|
|
399
507
|
isWalletConnectModalConnector: true,
|
|
400
508
|
showQrModal: true
|
|
@@ -402,8 +510,8 @@ var connectorsForWallets = (walletList, { projectId, walletConnectParameters, ap
|
|
|
402
510
|
)
|
|
403
511
|
);
|
|
404
512
|
}
|
|
405
|
-
if (
|
|
406
|
-
connectors.push(
|
|
513
|
+
if (createConnector5) {
|
|
514
|
+
connectors.push(createConnector5(walletMetaData()));
|
|
407
515
|
}
|
|
408
516
|
}
|
|
409
517
|
return connectors;
|
|
@@ -411,7 +519,7 @@ var connectorsForWallets = (walletList, { projectId, walletConnectParameters, ap
|
|
|
411
519
|
|
|
412
520
|
// src/providers/ParaEvmContext.tsx
|
|
413
521
|
import { http } from "viem";
|
|
414
|
-
import { useClient, useExternalWalletProviderStore } from "@getpara/react-sdk";
|
|
522
|
+
import { useClient, useExternalWalletProviderStore as useExternalWalletProviderStore2 } from "@getpara/react-sdk";
|
|
415
523
|
import { connect } from "wagmi/actions";
|
|
416
524
|
import { paraConnector } from "@getpara/wagmi-v2-integration";
|
|
417
525
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
@@ -426,9 +534,9 @@ var createDefaultTransports = (chains) => {
|
|
|
426
534
|
function ParaEvmProvider(_a) {
|
|
427
535
|
var _b = _a, { children, config: _config } = _b, wagmiProviderProps = __objRest(_b, ["children", "config"]);
|
|
428
536
|
var _a2;
|
|
429
|
-
const updateExternalWalletProviderState =
|
|
430
|
-
const EvmProvider =
|
|
431
|
-
const evmContext =
|
|
537
|
+
const updateExternalWalletProviderState = useExternalWalletProviderStore2((state) => state.updateState);
|
|
538
|
+
const EvmProvider = useExternalWalletProviderStore2((state) => state.EvmProvider);
|
|
539
|
+
const evmContext = useExternalWalletProviderStore2((state) => state.evmContext);
|
|
432
540
|
const para = (_a2 = _config.para) != null ? _a2 : useClient();
|
|
433
541
|
const _b2 = _config, {
|
|
434
542
|
projectId,
|
|
@@ -454,17 +562,13 @@ function ParaEvmProvider(_a) {
|
|
|
454
562
|
"paraOptions"
|
|
455
563
|
]);
|
|
456
564
|
const wcMetadata = computeWalletConnectMetaData({ appName, appDescription, appUrl, appIcon });
|
|
457
|
-
const paraConnectorInstance =
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
options: paraOptions != null ? paraOptions : {}
|
|
465
|
-
});
|
|
466
|
-
return instance;
|
|
467
|
-
}, [para, chains, paraDisableModal, appName, paraOptions]);
|
|
565
|
+
const paraConnectorInstance = para ? paraConnector({
|
|
566
|
+
para,
|
|
567
|
+
chains: [...chains],
|
|
568
|
+
disableModal: paraDisableModal != null ? paraDisableModal : true,
|
|
569
|
+
appName,
|
|
570
|
+
options: paraOptions != null ? paraOptions : {}
|
|
571
|
+
}) : void 0;
|
|
468
572
|
const allConnectors = useMemo2(() => {
|
|
469
573
|
const baseConnectors = connectorsForWallets(wallets, {
|
|
470
574
|
projectId,
|
|
@@ -496,13 +600,19 @@ function ParaEvmProvider(_a) {
|
|
|
496
600
|
return { error };
|
|
497
601
|
}
|
|
498
602
|
}), [paraConnectorInstance, config, connect]);
|
|
603
|
+
useEffect2(() => {
|
|
604
|
+
if (!evmContext || !EvmProvider) {
|
|
605
|
+
updateExternalWalletProviderState({
|
|
606
|
+
EvmProvider: EvmExternalWalletProvider,
|
|
607
|
+
evmContext: EvmExternalWalletContext
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
}, []);
|
|
499
611
|
useEffect2(() => {
|
|
500
612
|
updateExternalWalletProviderState({
|
|
501
|
-
EvmProvider: evmContext && EvmProvider ? EvmProvider : EvmExternalWalletProvider,
|
|
502
|
-
evmContext: evmContext || EvmExternalWalletContext,
|
|
503
613
|
connectParaEvmWallet: paraConnectorInstance ? connectParaEvmWallet : void 0
|
|
504
614
|
});
|
|
505
|
-
}, [
|
|
615
|
+
}, [paraConnectorInstance]);
|
|
506
616
|
if (!evmContext || !EvmProvider) {
|
|
507
617
|
return null;
|
|
508
618
|
}
|
|
@@ -663,6 +773,7 @@ function isMetaMask(ethereum) {
|
|
|
663
773
|
if (ethereum.isPhantom) return false;
|
|
664
774
|
if (ethereum.isPortal) return false;
|
|
665
775
|
if (ethereum.isRabby) return false;
|
|
776
|
+
if (ethereum.isSafe) return false;
|
|
666
777
|
if (ethereum.isRainbow) return false;
|
|
667
778
|
if (ethereum.isStatus) return false;
|
|
668
779
|
if (ethereum.isTalisman) return false;
|
|
@@ -677,8 +788,14 @@ function isMetaMask(ethereum) {
|
|
|
677
788
|
return true;
|
|
678
789
|
}
|
|
679
790
|
var metaMaskWallet = ({ projectId, walletConnectParameters }) => {
|
|
680
|
-
var _a, _b, _c;
|
|
681
|
-
|
|
791
|
+
var _a, _b, _c, _d;
|
|
792
|
+
let metaMaskTarget = 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;
|
|
793
|
+
const metaMaskInjectedProvider = metaMaskTarget ? metaMaskTarget : getInjectedProvider({ flag: "isMetaMask" });
|
|
794
|
+
const isMetaMaskInjected = !!metaMaskInjectedProvider && metaMaskInjectedProvider.isMetaMask;
|
|
795
|
+
const providerMapTarget = (_d = metaMaskTarget == null ? void 0 : metaMaskTarget.providerMap) == null ? void 0 : _d.get("MetaMask");
|
|
796
|
+
if (providerMapTarget) {
|
|
797
|
+
metaMaskTarget = providerMapTarget;
|
|
798
|
+
}
|
|
682
799
|
const getUri = (uri) => {
|
|
683
800
|
return isAndroid() ? `metamask://wc?uri=${encodeURIComponent(uri)}` : isIOS() ? !isTelegram() ? (
|
|
684
801
|
// currently broken in MetaMask v6.5.0 https://github.com/MetaMask/metamask-mobile/issues/6457
|
|
@@ -696,7 +813,7 @@ var metaMaskWallet = ({ projectId, walletConnectParameters }) => {
|
|
|
696
813
|
downloadUrl: "https://metamask.io/download/",
|
|
697
814
|
getUri,
|
|
698
815
|
createConnector: isMetaMaskInjected ? getInjectedConnector({
|
|
699
|
-
target:
|
|
816
|
+
target: metaMaskTarget
|
|
700
817
|
}) : getWalletConnectConnector({
|
|
701
818
|
projectId,
|
|
702
819
|
walletConnectParameters
|
|
@@ -842,6 +959,31 @@ var rabbyWallet = ({ projectId, walletConnectParameters }) => {
|
|
|
842
959
|
})
|
|
843
960
|
};
|
|
844
961
|
};
|
|
962
|
+
|
|
963
|
+
// src/wallets/connectors/safe/safe.ts
|
|
964
|
+
import { createConnector as createConnector4 } from "wagmi";
|
|
965
|
+
import { safe } from "wagmi/connectors";
|
|
966
|
+
|
|
967
|
+
// src/wallets/connectors/safe/safeIcon.ts
|
|
968
|
+
var icon7 = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAyOCAyOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI4IiBoZWlnaHQ9IjI4IiBmaWxsPSIjMTJGRjgwIi8+CjxwYXRoIGQ9Ik0yMi41MTUxIDEzLjk5NzlIMjAuNDI0NEMxOS43OTgxIDEzLjk5NzkgMTkuMjk0NSAxNC41MDU4IDE5LjI5NDUgMTUuMTI4VjE4LjE2M0MxOS4yOTQ1IDE4Ljc4OTQgMTguNzg2NiAxOS4yOTMxIDE4LjE2NDUgMTkuMjkzMUg5LjgzOThDOS4yMTM0NCAxOS4yOTMxIDguNzA5ODEgMTkuODAxMSA4LjcwOTgxIDIwLjQyMzNWMjIuNTE4NUM4LjcwOTgxIDIzLjE0NSA5LjIxNzY3IDIzLjY0ODcgOS44Mzk4IDIzLjY0ODdIMTguNjQyN0MxOS4yNjkxIDIzLjY0ODcgMTkuNzY0MiAyMy4xNDA3IDE5Ljc2NDIgMjIuNTE4NVYyMC44NDIzQzE5Ljc2NDIgMjAuMjE1OSAyMC4yNzIxIDE5Ljc3NTc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yODkgMTUuNjQ4NyAxMS44Mjg5IDE0Ljk5NjhWMTIuOTg2MkMxMS44Mjg5IDEyLjMzMDIgMTIuMzYyMSAxMS44MDExIDEzLjAxMzkgMTEuODAxMVoiIGZpbGw9ImJsYWNrIi8+Cjwvc3ZnPgo=";
|
|
969
|
+
|
|
970
|
+
// src/wallets/connectors/safe/safe.ts
|
|
971
|
+
var safeWallet = () => ({
|
|
972
|
+
id: "safe",
|
|
973
|
+
name: "Safe",
|
|
974
|
+
rdns: "io.safe",
|
|
975
|
+
iconUrl: icon7,
|
|
976
|
+
installed: (
|
|
977
|
+
// Only allowed in iframe context
|
|
978
|
+
!(typeof window === "undefined") && (window == null ? void 0 : window.parent) !== window
|
|
979
|
+
),
|
|
980
|
+
isExtension: false,
|
|
981
|
+
isMobile: false,
|
|
982
|
+
downloadUrl: "https://safe.global",
|
|
983
|
+
createConnector: (walletDetails) => {
|
|
984
|
+
return createConnector4((config) => __spreadValues(__spreadValues({}, safe()(config)), walletDetails));
|
|
985
|
+
}
|
|
986
|
+
});
|
|
845
987
|
export {
|
|
846
988
|
EvmExternalWalletContext,
|
|
847
989
|
EvmExternalWalletProvider,
|
|
@@ -850,6 +992,7 @@ export {
|
|
|
850
992
|
metaMaskWallet,
|
|
851
993
|
rabbyWallet,
|
|
852
994
|
rainbowWallet,
|
|
995
|
+
safeWallet,
|
|
853
996
|
walletConnectWallet,
|
|
854
997
|
zerionWallet
|
|
855
998
|
};
|
package/dist/index.js.br
CHANGED
|
Binary file
|
package/dist/index.js.gz
CHANGED
|
Binary file
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { CommonChain, CommonWallet } from '
|
|
3
|
-
import ParaWeb from '@getpara/react-sdk';
|
|
2
|
+
import ParaWeb, { CommonChain, CommonWallet } from '@getpara/react-sdk';
|
|
4
3
|
export declare const defaultEvmExternalWallet: {
|
|
5
4
|
wallets: any[];
|
|
6
5
|
chains: any[];
|
|
@@ -9,6 +8,8 @@ export declare const defaultEvmExternalWallet: {
|
|
|
9
8
|
avatar: any;
|
|
10
9
|
disconnect: () => Promise<void>;
|
|
11
10
|
switchChain: () => Promise<{}>;
|
|
11
|
+
signMessage: () => Promise<{}>;
|
|
12
|
+
signVerificationMessage: () => Promise<{}>;
|
|
12
13
|
};
|
|
13
14
|
export declare const EvmExternalWalletContext: import("react").Context<{
|
|
14
15
|
wallets: CommonWallet[];
|
|
@@ -20,6 +21,15 @@ export declare const EvmExternalWalletContext: import("react").Context<{
|
|
|
20
21
|
switchChain: (chainId: number) => Promise<{
|
|
21
22
|
error?: string[];
|
|
22
23
|
}>;
|
|
24
|
+
signMessage: (message: string) => Promise<{
|
|
25
|
+
signature?: string;
|
|
26
|
+
error?: string;
|
|
27
|
+
}>;
|
|
28
|
+
signVerificationMessage: () => Promise<{
|
|
29
|
+
address?: string;
|
|
30
|
+
signature?: string;
|
|
31
|
+
error?: string;
|
|
32
|
+
}>;
|
|
23
33
|
}>;
|
|
24
34
|
interface EvmExternalWalletProviderProps {
|
|
25
35
|
children: ReactNode;
|
package/dist/types/Wallet.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Connector, CreateConnectorFn } from 'wagmi';
|
|
|
2
2
|
import { WalletConnectParameters } from 'wagmi/connectors';
|
|
3
3
|
import { CoinbaseWalletOptions } from '../wallets/connectors/coinbase/coinbase.js';
|
|
4
4
|
import { WalletConnectWalletOptions } from '../wallets/connectors/walletConnect/walletConnect.js';
|
|
5
|
-
import { WalletMetadata } from '
|
|
5
|
+
import { WalletMetadata } from '@getpara/react-sdk';
|
|
6
6
|
export type Wallet = {
|
|
7
7
|
createConnector?: (walletDetails: WalletDetailsParams) => CreateConnectorFn;
|
|
8
8
|
createMobileConnector?: (walletDetails: WalletDetailsParams) => CreateConnectorFn;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export type Mutable<type extends object> = {
|
|
|
9
9
|
};
|
|
10
10
|
/** Strict version of built-in Omit type */
|
|
11
11
|
export type Omit<type, keys extends keyof type> = Pick<type, Exclude<keyof type, keys>>;
|
|
12
|
-
export type WalletProviderFlags = 'isApexWallet' | 'isAvalanche' | 'isBackpack' | 'isBifrost' | 'isBitKeep' | 'isBitski' | 'isBlockWallet' | 'isBraveWallet' | 'isCoinbaseWallet' | 'isDawn' | 'isEnkrypt' | 'isExodus' | 'isFrame' | 'isFrontier' | 'isGamestop' | 'isHyperPay' | 'isImToken' | 'isKuCoinWallet' | 'isMathWallet' | 'isMetaMask' | 'isNestWallet' | 'isOkxWallet' | 'isOKExWallet' | 'isOneInchAndroidWallet' | 'isOneInchIOSWallet' | 'isOpera' | 'isPhantom' | 'isPortal' | 'isRabby' | 'isRainbow' | 'isStatus' | 'isTally' | 'isTokenPocket' | 'isTokenary' | 'isTrust' | 'isTrustWallet' | 'isXDEFI' | 'isZerion' | 'isTalisman' | 'isZeal' | 'isCoin98' | 'isMEWwallet' | 'isSafeheron' | 'isSafePal' | '__seif';
|
|
12
|
+
export type WalletProviderFlags = 'isApexWallet' | 'isAvalanche' | 'isBackpack' | 'isBifrost' | 'isBitKeep' | 'isBitski' | 'isBlockWallet' | 'isBraveWallet' | 'isCoinbaseWallet' | 'isDawn' | 'isEnkrypt' | 'isExodus' | 'isFrame' | 'isFrontier' | 'isGamestop' | 'isHyperPay' | 'isImToken' | 'isKuCoinWallet' | 'isMathWallet' | 'isMetaMask' | 'isNestWallet' | 'isOkxWallet' | 'isOKExWallet' | 'isOneInchAndroidWallet' | 'isOneInchIOSWallet' | 'isOpera' | 'isPhantom' | 'isPortal' | 'isRabby' | 'isRainbow' | 'isSafe' | 'isStatus' | 'isTally' | 'isTokenPocket' | 'isTokenary' | 'isTrust' | 'isTrustWallet' | 'isXDEFI' | 'isZerion' | 'isTalisman' | 'isZeal' | 'isCoin98' | 'isMEWwallet' | 'isSafeheron' | 'isSafePal' | '__seif';
|
|
13
13
|
export type WalletProvider = Evaluate<EIP1193Provider & {
|
|
14
14
|
[key in WalletProviderFlags]?: true | undefined;
|
|
15
15
|
} & {
|
|
@@ -4,6 +4,10 @@ export declare function hasInjectedProvider({ flag, namespace }: {
|
|
|
4
4
|
flag?: WalletProviderFlags;
|
|
5
5
|
namespace?: string;
|
|
6
6
|
}): boolean;
|
|
7
|
+
export declare function getInjectedProvider({ flag, namespace }: {
|
|
8
|
+
flag?: WalletProviderFlags;
|
|
9
|
+
namespace?: string;
|
|
10
|
+
}): any;
|
|
7
11
|
export declare function getInjectedConnector({ flag, namespace, target, }: {
|
|
8
12
|
flag?: WalletProviderFlags;
|
|
9
13
|
namespace?: string;
|
|
@@ -4,4 +4,5 @@ import { walletConnectWallet } from './walletConnect/walletConnect.js';
|
|
|
4
4
|
import { coinbaseWallet } from './coinbase/coinbase.js';
|
|
5
5
|
import { zerionWallet } from './zerion/zerion.js';
|
|
6
6
|
import { rabbyWallet } from './rabby/rabby.js';
|
|
7
|
-
|
|
7
|
+
import { safeWallet } from './safe/safe.js';
|
|
8
|
+
export { metaMaskWallet, rainbowWallet, walletConnectWallet, coinbaseWallet, zerionWallet, rabbyWallet, safeWallet };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const icon = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAyOCAyOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI4IiBoZWlnaHQ9IjI4IiBmaWxsPSIjMTJGRjgwIi8+CjxwYXRoIGQ9Ik0yMi41MTUxIDEzLjk5NzlIMjAuNDI0NEMxOS43OTgxIDEzLjk5NzkgMTkuMjk0NSAxNC41MDU4IDE5LjI5NDUgMTUuMTI4VjE4LjE2M0MxOS4yOTQ1IDE4Ljc4OTQgMTguNzg2NiAxOS4yOTMxIDE4LjE2NDUgMTkuMjkzMUg5LjgzOThDOS4yMTM0NCAxOS4yOTMx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EyN1oiIGZpbGw9ImJsYWNrIi8+CjxwYXRoIGQ9Ik0xMy4wMTM5IDExLjgwMTFIMTUuMDI0MkMxNS42ODAyIDExLjgwMTEgMTYuMjA5MiAxMi4zMzQ0IDE2LjIwOTIgMTIuOTg2MlYxNC45OTY4QzE2LjIwOTIgMTUuNjUyOSAxNS42NzU5IDE2LjE4MiAxNS4wMjQyIDE2LjE4MkgxMy4wMTM5QzEyLjM1NzkgMTYuMTgyIDExLjgyODkgMTUuNjQ4NyAxMS44Mjg5IDE0Ljk5NjhWMTIuOTg2MkMxMS44Mjg5IDEyLjMzMDIgMTIuMzYyMSAxMS44MDExIDEzLjAxMzkgMTEuODAxMVoiIGZpbGw9ImJsYWNrIi8+Cjwvc3ZnPgo=";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/evm-wallet-connectors",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
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.
|
|
14
|
-
"@getpara/wagmi-v2-integration": "1.
|
|
13
|
+
"@getpara/react-sdk": "1.7.0",
|
|
14
|
+
"@getpara/wagmi-v2-integration": "1.7.0",
|
|
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": "241b03ee3d3502af3b8d702dabd615b266da10ae"
|
|
41
41
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export type WalletMetadata = {
|
|
2
|
-
id: string;
|
|
3
|
-
name: string;
|
|
4
|
-
rdns?: string;
|
|
5
|
-
iconUrl: string;
|
|
6
|
-
installed?: boolean;
|
|
7
|
-
isExtension?: boolean;
|
|
8
|
-
isMobile?: boolean;
|
|
9
|
-
isWeb?: boolean;
|
|
10
|
-
downloadUrl?: string;
|
|
11
|
-
getQrUri?: () => Promise<string>;
|
|
12
|
-
};
|
|
13
|
-
export type CommonWallet = {
|
|
14
|
-
connect: () => Promise<{
|
|
15
|
-
address?: string;
|
|
16
|
-
error?: string;
|
|
17
|
-
}>;
|
|
18
|
-
connectMobile: (isManualWalletConnect?: boolean) => Promise<{
|
|
19
|
-
address?: string;
|
|
20
|
-
error?: string;
|
|
21
|
-
}>;
|
|
22
|
-
type: 'EVM' | 'SOLANA' | 'COSMOS';
|
|
23
|
-
} & WalletMetadata;
|
|
24
|
-
export type CommonChain = {
|
|
25
|
-
id: string | number;
|
|
26
|
-
name: string;
|
|
27
|
-
};
|