@getpara/evm-wallet-connectors 1.6.0 → 1.7.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 +188 -44
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -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
|
+
useWalletState,
|
|
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 { selectedWallet } = useWalletState();
|
|
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,57 @@ 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
|
+
const wallet = para.findWallet(selectedWallet.id, selectedWallet.type);
|
|
170
|
+
if (wallet && connectedConnector && wallet.type === WalletType.EVM && (connectedConnector.id === "para" && wallet.isExternal || connectedConnector.id !== "para" && !wallet.isExternal)) {
|
|
171
|
+
switchAccount(wallet.isExternal ? wallet.name : "Para");
|
|
172
|
+
}
|
|
173
|
+
}, [selectedWallet]);
|
|
145
174
|
const connectors = untypedConnectors;
|
|
146
175
|
const reset = () => __async(this, null, function* () {
|
|
147
176
|
yield disconnectAsync();
|
|
148
177
|
yield para.logout();
|
|
149
178
|
});
|
|
179
|
+
const signMessage = (message) => __async(this, null, function* () {
|
|
180
|
+
try {
|
|
181
|
+
const signature = yield signMessageAsync({
|
|
182
|
+
message,
|
|
183
|
+
account: wagmiAddress
|
|
184
|
+
});
|
|
185
|
+
return { address: wagmiAddress, signature };
|
|
186
|
+
} catch (e) {
|
|
187
|
+
switch (e.name) {
|
|
188
|
+
case "UserRejectedRequestError": {
|
|
189
|
+
return { error: "Signature request rejected" };
|
|
190
|
+
}
|
|
191
|
+
default: {
|
|
192
|
+
return { error: "An unknown error occurred" };
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
const signVerificationMessage = () => __async(this, null, function* () {
|
|
198
|
+
const signature = yield signMessage(verificationMessage.current);
|
|
199
|
+
return signature;
|
|
200
|
+
});
|
|
201
|
+
const switchAccount = (connectorName) => __async(this, null, function* () {
|
|
202
|
+
var _a;
|
|
203
|
+
const connector = (_a = connections.find((c) => c.connector.name === connectorName)) == null ? void 0 : _a.connector;
|
|
204
|
+
if (!connector) {
|
|
205
|
+
throw new Error(`connector not found: ${connectorName}`);
|
|
206
|
+
}
|
|
207
|
+
yield switchAccountAsync({ connector });
|
|
208
|
+
});
|
|
150
209
|
const switchChain = (chainId2) => __async(this, null, function* () {
|
|
151
210
|
var _a, _b, _c;
|
|
152
211
|
let error;
|
|
@@ -174,9 +233,21 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
174
233
|
}
|
|
175
234
|
return { error };
|
|
176
235
|
});
|
|
177
|
-
const login = (
|
|
236
|
+
const login = (_0) => __async(this, [_0], function* ({
|
|
237
|
+
address,
|
|
238
|
+
walletId,
|
|
239
|
+
connectorName
|
|
240
|
+
}) {
|
|
241
|
+
var _a;
|
|
178
242
|
try {
|
|
179
|
-
|
|
243
|
+
refetchEnsName();
|
|
244
|
+
refetchEnsAvatar();
|
|
245
|
+
return yield para.externalWalletLogin({
|
|
246
|
+
address,
|
|
247
|
+
type: WalletType.EVM,
|
|
248
|
+
provider: connectorName,
|
|
249
|
+
withFullParaAuth: fullAuthWallets == null ? void 0 : fullAuthWallets.includes((_a = walletId == null ? void 0 : walletId.toUpperCase()) != null ? _a : "")
|
|
250
|
+
});
|
|
180
251
|
} catch (err) {
|
|
181
252
|
yield disconnectAsync();
|
|
182
253
|
yield para.logout();
|
|
@@ -184,15 +255,24 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
184
255
|
}
|
|
185
256
|
});
|
|
186
257
|
const switchWallet = (address) => __async(this, null, function* () {
|
|
258
|
+
var _a;
|
|
187
259
|
updateExternalWalletState({ isConnecting: true });
|
|
188
260
|
let error;
|
|
189
261
|
if (!address) {
|
|
190
262
|
yield para.logout();
|
|
191
263
|
} else {
|
|
192
|
-
|
|
193
|
-
yield
|
|
194
|
-
}
|
|
195
|
-
|
|
264
|
+
if (para.isExternalWalletAuth) {
|
|
265
|
+
yield reset();
|
|
266
|
+
} else {
|
|
267
|
+
try {
|
|
268
|
+
yield login({
|
|
269
|
+
address,
|
|
270
|
+
connectorName: connectedConnector == null ? void 0 : connectedConnector.name,
|
|
271
|
+
walletId: (_a = getParaDetails(connectedConnector.id)) == null ? void 0 : _a.id
|
|
272
|
+
});
|
|
273
|
+
} catch (err) {
|
|
274
|
+
error = err;
|
|
275
|
+
}
|
|
196
276
|
}
|
|
197
277
|
}
|
|
198
278
|
onSwitchWallet({ address, error });
|
|
@@ -205,6 +285,8 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
205
285
|
const walletChainId = yield connector.getChainId();
|
|
206
286
|
let address;
|
|
207
287
|
let error;
|
|
288
|
+
let userExists = false;
|
|
289
|
+
let isVerified = false;
|
|
208
290
|
try {
|
|
209
291
|
const data = yield connectAsync({
|
|
210
292
|
// If the wallet is already on a supported chain, use that to avoid a chain switch prompt.
|
|
@@ -217,7 +299,10 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
217
299
|
address = (_d = data.accounts) == null ? void 0 : _d[0];
|
|
218
300
|
if (address) {
|
|
219
301
|
try {
|
|
220
|
-
yield login(address, connector.name);
|
|
302
|
+
const loginResp = yield login({ address, connectorName: connector.name, walletId: connector.paraDetails.id });
|
|
303
|
+
userExists = loginResp.userExists;
|
|
304
|
+
isVerified = loginResp.isVerified;
|
|
305
|
+
verificationMessage.current = loginResp.signatureVerificationMessage;
|
|
221
306
|
} catch (err) {
|
|
222
307
|
address = void 0;
|
|
223
308
|
error = err;
|
|
@@ -240,7 +325,7 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
240
325
|
}
|
|
241
326
|
}
|
|
242
327
|
updateExternalWalletState({ isConnecting: false });
|
|
243
|
-
return { address, error };
|
|
328
|
+
return { address, error, userExists, isVerified };
|
|
244
329
|
});
|
|
245
330
|
const connectMobile = (connector, isManualWalletConnect) => __async(this, null, function* () {
|
|
246
331
|
const _isMobile = isManualWalletConnect !== void 0 ? isManualWalletConnect : isMobile();
|
|
@@ -283,11 +368,15 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
283
368
|
const connector = __spreadValues(__spreadValues({}, c), c.paraDetails);
|
|
284
369
|
return __spreadProps(__spreadValues({}, connector), {
|
|
285
370
|
connect: () => connect2(connector),
|
|
286
|
-
connectMobile: (isManualWalletConnect) => connectMobile(connector, isManualWalletConnect),
|
|
371
|
+
connectMobile: ({ isManualWalletConnect }) => connectMobile(connector, isManualWalletConnect),
|
|
287
372
|
type: WalletType.EVM,
|
|
288
373
|
getQrUri: getQrUri(connector)
|
|
289
374
|
});
|
|
290
375
|
});
|
|
376
|
+
const getParaDetails = (id) => {
|
|
377
|
+
var _a;
|
|
378
|
+
return (_a = connectors.find((w) => w.id === id)) == null ? void 0 : _a.paraDetails;
|
|
379
|
+
};
|
|
291
380
|
const formattedChains = chains.map((c) => {
|
|
292
381
|
return {
|
|
293
382
|
id: c.id,
|
|
@@ -300,8 +389,28 @@ function EvmExternalWalletProvider({ children, para, onSwitchWallet }) {
|
|
|
300
389
|
EvmExternalWalletContext.Provider,
|
|
301
390
|
{
|
|
302
391
|
value: useMemo(
|
|
303
|
-
() => ({
|
|
304
|
-
|
|
392
|
+
() => ({
|
|
393
|
+
wallets,
|
|
394
|
+
chains: formattedChains,
|
|
395
|
+
chainId,
|
|
396
|
+
username,
|
|
397
|
+
avatar: ensAvatar,
|
|
398
|
+
disconnect,
|
|
399
|
+
switchChain,
|
|
400
|
+
signMessage,
|
|
401
|
+
signVerificationMessage
|
|
402
|
+
}),
|
|
403
|
+
[
|
|
404
|
+
wallets,
|
|
405
|
+
formattedChains,
|
|
406
|
+
chainId,
|
|
407
|
+
username,
|
|
408
|
+
ensAvatar,
|
|
409
|
+
disconnect,
|
|
410
|
+
switchChain,
|
|
411
|
+
signMessage,
|
|
412
|
+
signVerificationMessage
|
|
413
|
+
]
|
|
305
414
|
),
|
|
306
415
|
children
|
|
307
416
|
}
|
|
@@ -383,7 +492,7 @@ var connectorsForWallets = (walletList, { projectId, walletConnectParameters, ap
|
|
|
383
492
|
});
|
|
384
493
|
const walletListItems = uniqueBy([...wallets], "id");
|
|
385
494
|
for (const _a of walletListItems) {
|
|
386
|
-
const _b = _a, { createConnector:
|
|
495
|
+
const _b = _a, { createConnector: createConnector5 } = _b, walletMeta = __objRest(_b, ["createConnector"]);
|
|
387
496
|
const walletMetaData = (additionalParaParams) => {
|
|
388
497
|
return {
|
|
389
498
|
paraDetails: omitUndefinedValues(__spreadValues(__spreadProps(__spreadValues({}, walletMeta), {
|
|
@@ -394,7 +503,7 @@ var connectorsForWallets = (walletList, { projectId, walletConnectParameters, ap
|
|
|
394
503
|
const isWalletConnectConnector = walletMeta.id === "walletConnect";
|
|
395
504
|
if (isWalletConnectConnector) {
|
|
396
505
|
connectors.push(
|
|
397
|
-
|
|
506
|
+
createConnector5(
|
|
398
507
|
walletMetaData({
|
|
399
508
|
isWalletConnectModalConnector: true,
|
|
400
509
|
showQrModal: true
|
|
@@ -402,8 +511,8 @@ var connectorsForWallets = (walletList, { projectId, walletConnectParameters, ap
|
|
|
402
511
|
)
|
|
403
512
|
);
|
|
404
513
|
}
|
|
405
|
-
if (
|
|
406
|
-
connectors.push(
|
|
514
|
+
if (createConnector5) {
|
|
515
|
+
connectors.push(createConnector5(walletMetaData()));
|
|
407
516
|
}
|
|
408
517
|
}
|
|
409
518
|
return connectors;
|
|
@@ -411,7 +520,7 @@ var connectorsForWallets = (walletList, { projectId, walletConnectParameters, ap
|
|
|
411
520
|
|
|
412
521
|
// src/providers/ParaEvmContext.tsx
|
|
413
522
|
import { http } from "viem";
|
|
414
|
-
import { useClient, useExternalWalletProviderStore } from "@getpara/react-sdk";
|
|
523
|
+
import { useClient, useExternalWalletProviderStore as useExternalWalletProviderStore2 } from "@getpara/react-sdk";
|
|
415
524
|
import { connect } from "wagmi/actions";
|
|
416
525
|
import { paraConnector } from "@getpara/wagmi-v2-integration";
|
|
417
526
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
@@ -426,9 +535,9 @@ var createDefaultTransports = (chains) => {
|
|
|
426
535
|
function ParaEvmProvider(_a) {
|
|
427
536
|
var _b = _a, { children, config: _config } = _b, wagmiProviderProps = __objRest(_b, ["children", "config"]);
|
|
428
537
|
var _a2;
|
|
429
|
-
const updateExternalWalletProviderState =
|
|
430
|
-
const EvmProvider =
|
|
431
|
-
const evmContext =
|
|
538
|
+
const updateExternalWalletProviderState = useExternalWalletProviderStore2((state) => state.updateState);
|
|
539
|
+
const EvmProvider = useExternalWalletProviderStore2((state) => state.EvmProvider);
|
|
540
|
+
const evmContext = useExternalWalletProviderStore2((state) => state.evmContext);
|
|
432
541
|
const para = (_a2 = _config.para) != null ? _a2 : useClient();
|
|
433
542
|
const _b2 = _config, {
|
|
434
543
|
projectId,
|
|
@@ -454,17 +563,13 @@ function ParaEvmProvider(_a) {
|
|
|
454
563
|
"paraOptions"
|
|
455
564
|
]);
|
|
456
565
|
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]);
|
|
566
|
+
const paraConnectorInstance = para ? paraConnector({
|
|
567
|
+
para,
|
|
568
|
+
chains: [...chains],
|
|
569
|
+
disableModal: paraDisableModal != null ? paraDisableModal : true,
|
|
570
|
+
appName,
|
|
571
|
+
options: paraOptions != null ? paraOptions : {}
|
|
572
|
+
}) : void 0;
|
|
468
573
|
const allConnectors = useMemo2(() => {
|
|
469
574
|
const baseConnectors = connectorsForWallets(wallets, {
|
|
470
575
|
projectId,
|
|
@@ -496,13 +601,19 @@ function ParaEvmProvider(_a) {
|
|
|
496
601
|
return { error };
|
|
497
602
|
}
|
|
498
603
|
}), [paraConnectorInstance, config, connect]);
|
|
604
|
+
useEffect2(() => {
|
|
605
|
+
if (!evmContext || !EvmProvider) {
|
|
606
|
+
updateExternalWalletProviderState({
|
|
607
|
+
EvmProvider: EvmExternalWalletProvider,
|
|
608
|
+
evmContext: EvmExternalWalletContext
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
}, []);
|
|
499
612
|
useEffect2(() => {
|
|
500
613
|
updateExternalWalletProviderState({
|
|
501
|
-
EvmProvider: evmContext && EvmProvider ? EvmProvider : EvmExternalWalletProvider,
|
|
502
|
-
evmContext: evmContext || EvmExternalWalletContext,
|
|
503
614
|
connectParaEvmWallet: paraConnectorInstance ? connectParaEvmWallet : void 0
|
|
504
615
|
});
|
|
505
|
-
}, [
|
|
616
|
+
}, [paraConnectorInstance]);
|
|
506
617
|
if (!evmContext || !EvmProvider) {
|
|
507
618
|
return null;
|
|
508
619
|
}
|
|
@@ -663,6 +774,7 @@ function isMetaMask(ethereum) {
|
|
|
663
774
|
if (ethereum.isPhantom) return false;
|
|
664
775
|
if (ethereum.isPortal) return false;
|
|
665
776
|
if (ethereum.isRabby) return false;
|
|
777
|
+
if (ethereum.isSafe) return false;
|
|
666
778
|
if (ethereum.isRainbow) return false;
|
|
667
779
|
if (ethereum.isStatus) return false;
|
|
668
780
|
if (ethereum.isTalisman) return false;
|
|
@@ -677,8 +789,14 @@ function isMetaMask(ethereum) {
|
|
|
677
789
|
return true;
|
|
678
790
|
}
|
|
679
791
|
var metaMaskWallet = ({ projectId, walletConnectParameters }) => {
|
|
680
|
-
var _a, _b, _c;
|
|
681
|
-
|
|
792
|
+
var _a, _b, _c, _d;
|
|
793
|
+
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;
|
|
794
|
+
const metaMaskInjectedProvider = metaMaskTarget ? metaMaskTarget : getInjectedProvider({ flag: "isMetaMask" });
|
|
795
|
+
const isMetaMaskInjected = !!metaMaskInjectedProvider && metaMaskInjectedProvider.isMetaMask;
|
|
796
|
+
const providerMapTarget = (_d = metaMaskTarget == null ? void 0 : metaMaskTarget.providerMap) == null ? void 0 : _d.get("MetaMask");
|
|
797
|
+
if (providerMapTarget) {
|
|
798
|
+
metaMaskTarget = providerMapTarget;
|
|
799
|
+
}
|
|
682
800
|
const getUri = (uri) => {
|
|
683
801
|
return isAndroid() ? `metamask://wc?uri=${encodeURIComponent(uri)}` : isIOS() ? !isTelegram() ? (
|
|
684
802
|
// currently broken in MetaMask v6.5.0 https://github.com/MetaMask/metamask-mobile/issues/6457
|
|
@@ -696,7 +814,7 @@ var metaMaskWallet = ({ projectId, walletConnectParameters }) => {
|
|
|
696
814
|
downloadUrl: "https://metamask.io/download/",
|
|
697
815
|
getUri,
|
|
698
816
|
createConnector: isMetaMaskInjected ? getInjectedConnector({
|
|
699
|
-
target:
|
|
817
|
+
target: metaMaskTarget
|
|
700
818
|
}) : getWalletConnectConnector({
|
|
701
819
|
projectId,
|
|
702
820
|
walletConnectParameters
|
|
@@ -842,6 +960,31 @@ var rabbyWallet = ({ projectId, walletConnectParameters }) => {
|
|
|
842
960
|
})
|
|
843
961
|
};
|
|
844
962
|
};
|
|
963
|
+
|
|
964
|
+
// src/wallets/connectors/safe/safe.ts
|
|
965
|
+
import { createConnector as createConnector4 } from "wagmi";
|
|
966
|
+
import { safe } from "wagmi/connectors";
|
|
967
|
+
|
|
968
|
+
// src/wallets/connectors/safe/safeIcon.ts
|
|
969
|
+
var icon7 = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjgiIGhlaWdodD0iMjgiIHZpZXdCb3g9IjAgMCAyOCAyOCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjI4IiBoZWlnaHQ9IjI4IiBmaWxsPSIjMTJGRjgwIi8+CjxwYXRoIGQ9Ik0yMi41MTUxIDEzLjk5NzlIMjAuNDI0NEMxOS43OTgxIDEzLjk5NzkgMTkuMjk0NSAxNC41MDU4IDE5LjI5NDUgMTUuMTI4VjE4LjE2M0MxOS4yOTQ1IDE4Ljc4OTQgMTguNzg2NiAxOS4yOTMxIDE4LjE2NDUgMTkuMjkzMUg5LjgzOThDOS4yMTM0NCAxOS4yOTMxIDguNzA5ODEgMTkuODAxMSA4LjcwOTgxIDIwLjQyMzNWMjIuNTE4NUM4LjcwOTgxIDIzLjE0NSA5LjIxNzY3IDIzLjY0ODcgOS44Mzk4IDIzLjY0ODdIMTguNjQyN0MxOS4yNjkxIDIzLjY0ODcgMTkuNzY0MiAyMy4xNDA3IDE5Ljc2NDIgMjIuNTE4NVYyMC44NDIzQzE5Ljc2NDIg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4wMTM5QzEyLjM1NzkgMTYuMTgyIDExLjgyODkgMTUuNjQ4NyAxMS44Mjg5IDE0Ljk5NjhWMTIuOTg2MkMxMS44Mjg5IDEyLjMzMDIgMTIuMzYyMSAxMS44MDExIDEzLjAxMzkgMTEuODAxMVoiIGZpbGw9ImJsYWNrIi8+Cjwvc3ZnPgo=";
|
|
970
|
+
|
|
971
|
+
// src/wallets/connectors/safe/safe.ts
|
|
972
|
+
var safeWallet = () => ({
|
|
973
|
+
id: "safe",
|
|
974
|
+
name: "Safe",
|
|
975
|
+
rdns: "io.safe",
|
|
976
|
+
iconUrl: icon7,
|
|
977
|
+
installed: (
|
|
978
|
+
// Only allowed in iframe context
|
|
979
|
+
!(typeof window === "undefined") && (window == null ? void 0 : window.parent) !== window
|
|
980
|
+
),
|
|
981
|
+
isExtension: false,
|
|
982
|
+
isMobile: false,
|
|
983
|
+
downloadUrl: "https://safe.global",
|
|
984
|
+
createConnector: (walletDetails) => {
|
|
985
|
+
return createConnector4((config) => __spreadValues(__spreadValues({}, safe()(config)), walletDetails));
|
|
986
|
+
}
|
|
987
|
+
});
|
|
845
988
|
export {
|
|
846
989
|
EvmExternalWalletContext,
|
|
847
990
|
EvmExternalWalletProvider,
|
|
@@ -850,6 +993,7 @@ export {
|
|
|
850
993
|
metaMaskWallet,
|
|
851
994
|
rabbyWallet,
|
|
852
995
|
rainbowWallet,
|
|
996
|
+
safeWallet,
|
|
853
997
|
walletConnectWallet,
|
|
854
998
|
zerionWallet
|
|
855
999
|
};
|
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+CjxwYXRoIGQ9Ik0yMi41MTUxIDEzLjk5NzlIMjAuNDI0NEMxOS43OTgxIDEzLjk5NzkgMTkuMjk0NSAxNC41MDU4IDE5LjI5NDUgMTUuMTI4VjE4LjE2M0MxOS4yOTQ1IDE4Ljc4OTQgMTguNzg2NiAxOS4yOTMxIDE4LjE2NDUgMTkuMjk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guNzE0MDMgMTIuODY3N0w4LjcwOTggOS44NDEyN1oiIGZpbGw9ImJsYWNrIi8+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.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.
|
|
14
|
-
"@getpara/wagmi-v2-integration": "1.
|
|
13
|
+
"@getpara/react-sdk": "1.7.1",
|
|
14
|
+
"@getpara/wagmi-v2-integration": "1.7.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": "767395af96d4a724946a092de760e9137a73369a"
|
|
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
|
-
};
|