@getpara/cosmos-wallet-connectors 2.0.0-alpha.66 → 2.0.0-alpha.67
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.
|
@@ -25,7 +25,9 @@ import {
|
|
|
25
25
|
} from "@getpara/react-common";
|
|
26
26
|
import { formatEthHexAddress } from "../utils/formatEthHexAddress.js";
|
|
27
27
|
import { externalHooks } from "./externalHooks.js";
|
|
28
|
-
const CosmosExternalWalletContext = createContext(
|
|
28
|
+
const CosmosExternalWalletContext = createContext(
|
|
29
|
+
defaultCosmosExternalWallet
|
|
30
|
+
);
|
|
29
31
|
function CosmosExternalWalletProvider({
|
|
30
32
|
children,
|
|
31
33
|
onSwitchWallet,
|
|
@@ -56,7 +58,7 @@ function CosmosExternalWalletProvider({
|
|
|
56
58
|
} : void 0
|
|
57
59
|
);
|
|
58
60
|
const { connectAsync } = useConnect();
|
|
59
|
-
const { disconnectAsync } = useDisconnect();
|
|
61
|
+
const { disconnectAsync, status: disconnectStatus } = useDisconnect();
|
|
60
62
|
const { walletType } = useActiveWalletType();
|
|
61
63
|
const isLocalConnecting = useExternalWalletStore((state) => state.isConnecting);
|
|
62
64
|
const updateExternalWalletState = useExternalWalletStore((state) => state.updateState);
|
|
@@ -64,7 +66,7 @@ function CosmosExternalWalletProvider({
|
|
|
64
66
|
const connectedWallet = connectedWalletProp ? para.findWallet(connectedWalletProp.id, connectedWalletProp.type) : null;
|
|
65
67
|
const ethAddress = (_b = (_a = account == null ? void 0 : account[selectedChainId]) == null ? void 0 : _a.ethereumHexAddress) == null ? void 0 : _b.toLowerCase();
|
|
66
68
|
const address = (_c = account == null ? void 0 : account[selectedChainId]) == null ? void 0 : _c.bech32Address;
|
|
67
|
-
const
|
|
69
|
+
const disconnectTypeRef = useRef();
|
|
68
70
|
const verificationMessage = useRef();
|
|
69
71
|
const reset = () => __async(this, null, function* () {
|
|
70
72
|
yield disconnectAsync();
|
|
@@ -141,14 +143,14 @@ function CosmosExternalWalletProvider({
|
|
|
141
143
|
});
|
|
142
144
|
useEffect(() => {
|
|
143
145
|
const storedExternalWallet = para.externalWallets[ethAddress != null ? ethAddress : ""];
|
|
144
|
-
if (isConnected && !isConnecting && !isReconnecting && !isLocalConnecting && !!ethAddress && !storedExternalWallet && walletType !== GrazWalletType.PARA && !
|
|
146
|
+
if (isConnected && !isConnecting && !isReconnecting && !isLocalConnecting && !!ethAddress && !storedExternalWallet && walletType !== GrazWalletType.PARA && !disconnectTypeRef.current) {
|
|
145
147
|
reset();
|
|
146
148
|
}
|
|
147
149
|
}, [isConnecting, isLocalConnecting, isReconnecting, isConnected]);
|
|
148
150
|
useEffect(() => {
|
|
149
151
|
const connect2 = () => __async(this, null, function* () {
|
|
150
152
|
var _a2;
|
|
151
|
-
if (!isLocalConnecting && !isConnecting && !isReconnecting && connectedWallet && connectedWallet.type === "COSMOS" && (connectedWallet.isExternal ? walletType !== ((_a2 = connectedWallet.name) == null ? void 0 : _a2.toLowerCase()) : walletType !== "para") && !
|
|
153
|
+
if (!isLocalConnecting && !isConnecting && !isReconnecting && connectedWallet && connectedWallet.type === "COSMOS" && (connectedWallet.isExternal ? walletType !== ((_a2 = connectedWallet.name) == null ? void 0 : _a2.toLowerCase()) : walletType !== "para") && !disconnectTypeRef.current && !isConnectError.current) {
|
|
152
154
|
const isLoggedIn = yield para.isFullyLoggedIn();
|
|
153
155
|
if (!isLoggedIn) {
|
|
154
156
|
return;
|
|
@@ -342,7 +344,7 @@ function CosmosExternalWalletProvider({
|
|
|
342
344
|
if (!wallet) {
|
|
343
345
|
throw new Error(`Wallet for provider ${providerId} not found`);
|
|
344
346
|
}
|
|
345
|
-
|
|
347
|
+
disconnectTypeRef.current = "ACCOUNT_LINKING";
|
|
346
348
|
try {
|
|
347
349
|
const externalWallet = yield connectBase(
|
|
348
350
|
wallet.grazType,
|
|
@@ -354,14 +356,18 @@ function CosmosExternalWalletProvider({
|
|
|
354
356
|
throw new Error((_a2 = e == null ? void 0 : e.message) != null ? _a2 : e);
|
|
355
357
|
}
|
|
356
358
|
});
|
|
357
|
-
const disconnectBase = () => __async(this,
|
|
359
|
+
const disconnectBase = (_0, ..._1) => __async(this, [_0, ..._1], function* (_, { disconnectType } = {}) {
|
|
358
360
|
var _a2;
|
|
359
|
-
|
|
361
|
+
if (disconnectType) {
|
|
362
|
+
disconnectTypeRef.current = disconnectType;
|
|
363
|
+
}
|
|
360
364
|
try {
|
|
361
365
|
yield disconnectAsync();
|
|
362
366
|
} catch (e) {
|
|
363
367
|
console.error("Error linking account:", e);
|
|
364
368
|
throw new Error((_a2 = e == null ? void 0 : e.message) != null ? _a2 : e);
|
|
369
|
+
} finally {
|
|
370
|
+
disconnectTypeRef.current = void 0;
|
|
365
371
|
}
|
|
366
372
|
});
|
|
367
373
|
return /* @__PURE__ */ jsx(
|
|
@@ -373,6 +379,7 @@ function CosmosExternalWalletProvider({
|
|
|
373
379
|
chains: formattedChains,
|
|
374
380
|
chainId: selectedChainId,
|
|
375
381
|
disconnect: disconnectAsync,
|
|
382
|
+
disconnectStatus,
|
|
376
383
|
switchChain,
|
|
377
384
|
connectParaEmbedded,
|
|
378
385
|
signMessage,
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/cosmos-wallet-connectors",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.67",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@getpara/graz-connector": "2.0.0-alpha.
|
|
6
|
-
"@getpara/react-common": "2.0.0-alpha.
|
|
7
|
-
"@getpara/web-sdk": "2.0.0-alpha.
|
|
5
|
+
"@getpara/graz-connector": "2.0.0-alpha.67",
|
|
6
|
+
"@getpara/react-common": "2.0.0-alpha.67",
|
|
7
|
+
"@getpara/web-sdk": "2.0.0-alpha.67",
|
|
8
8
|
"@leapwallet/cosmos-social-login-capsule-provider": "^0.0.41",
|
|
9
9
|
"zustand": "^4.5.2",
|
|
10
10
|
"zustand-sync-tabs": "^0.2.2"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dist",
|
|
24
24
|
"package.json"
|
|
25
25
|
],
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "0266cc49e978575fed0b12c9bb0c832651e140eb",
|
|
27
27
|
"main": "dist/index.js",
|
|
28
28
|
"peerDependencies": {
|
|
29
29
|
"graz": ">=0.4.1",
|