@getpara/cosmos-wallet-connectors 2.0.0-alpha.66 → 2.0.0-alpha.68

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/README.md ADDED
@@ -0,0 +1,13 @@
1
+ https://www.npmjs.com/package/@getpara/cosmos-wallet-connectors
2
+
3
+ `@getpara/cosmos-wallet-connectors` is a package that provides wallet connectors for Cosmos-based blockchains when using Para's React SDK Lite.
4
+ This package enables integration with Cosmos wallets like Keplr, Leap, and Cosmostation in Para applications. After installation, you can configure it in your ParaProvider to support external Cosmos wallet connections.
5
+ ###Prerequisites
6
+
7
+ To use Para, you need an API key. This key authenticates your requests to Para services and is essential for integration.
8
+
9
+ Don't have an API key yet? Request access to the [Developer Portal](https://developer.getpara.com/) to create API keys, manage billing, teams, and more.
10
+
11
+ ###Learn more
12
+
13
+ For more information on Para’s Cosmos wallet connection visit the [Para Docs](https://docs.getpara.com/v2/react/guides/external-wallets/cosmos-lite#cosmos-wallets-with-react-sdk-lite)
@@ -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(defaultCosmosExternalWallet);
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 isLinkingAccount = useRef(false);
69
+ const disconnectTypeRef = useRef();
68
70
  const verificationMessage = useRef();
69
71
  const reset = () => __async(this, null, function* () {
70
72
  yield disconnectAsync();
@@ -132,7 +134,9 @@ function CosmosExternalWalletProvider({
132
134
  withFullParaAuth,
133
135
  withVerification: includeWalletVerification,
134
136
  isConnectionOnly: connectionOnly
135
- }
137
+ },
138
+ uri: window == null ? void 0 : window.location.origin,
139
+ chainId: selectedChainId
136
140
  });
137
141
  } catch (err) {
138
142
  yield reset();
@@ -141,14 +145,14 @@ function CosmosExternalWalletProvider({
141
145
  });
142
146
  useEffect(() => {
143
147
  const storedExternalWallet = para.externalWallets[ethAddress != null ? ethAddress : ""];
144
- if (isConnected && !isConnecting && !isReconnecting && !isLocalConnecting && !!ethAddress && !storedExternalWallet && walletType !== GrazWalletType.PARA && !isLinkingAccount.current) {
148
+ if (isConnected && !isConnecting && !isReconnecting && !isLocalConnecting && !!ethAddress && !storedExternalWallet && walletType !== GrazWalletType.PARA && !disconnectTypeRef.current) {
145
149
  reset();
146
150
  }
147
151
  }, [isConnecting, isLocalConnecting, isReconnecting, isConnected]);
148
152
  useEffect(() => {
149
153
  const connect2 = () => __async(this, null, function* () {
150
154
  var _a2;
151
- if (!isLocalConnecting && !isConnecting && !isReconnecting && connectedWallet && connectedWallet.type === "COSMOS" && (connectedWallet.isExternal ? walletType !== ((_a2 = connectedWallet.name) == null ? void 0 : _a2.toLowerCase()) : walletType !== "para") && !isLinkingAccount.current && !isConnectError.current) {
155
+ 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
156
  const isLoggedIn = yield para.isFullyLoggedIn();
153
157
  if (!isLoggedIn) {
154
158
  return;
@@ -309,7 +313,6 @@ function CosmosExternalWalletProvider({
309
313
  return __spreadProps(__spreadValues({
310
314
  connect: () => connect(wallet.grazType),
311
315
  connectMobile: () => connect(wallet.grazType),
312
- getQrUri: () => "",
313
316
  type: "COSMOS"
314
317
  }, wallet), {
315
318
  // Using name here since that's the only common id across the networks
@@ -342,7 +345,7 @@ function CosmosExternalWalletProvider({
342
345
  if (!wallet) {
343
346
  throw new Error(`Wallet for provider ${providerId} not found`);
344
347
  }
345
- isLinkingAccount.current = true;
348
+ disconnectTypeRef.current = "ACCOUNT_LINKING";
346
349
  try {
347
350
  const externalWallet = yield connectBase(
348
351
  wallet.grazType,
@@ -354,14 +357,18 @@ function CosmosExternalWalletProvider({
354
357
  throw new Error((_a2 = e == null ? void 0 : e.message) != null ? _a2 : e);
355
358
  }
356
359
  });
357
- const disconnectBase = () => __async(this, null, function* () {
360
+ const disconnectBase = (_0, ..._1) => __async(this, [_0, ..._1], function* (_, { disconnectType } = {}) {
358
361
  var _a2;
359
- isLinkingAccount.current = true;
362
+ if (disconnectType) {
363
+ disconnectTypeRef.current = disconnectType;
364
+ }
360
365
  try {
361
366
  yield disconnectAsync();
362
367
  } catch (e) {
363
368
  console.error("Error linking account:", e);
364
369
  throw new Error((_a2 = e == null ? void 0 : e.message) != null ? _a2 : e);
370
+ } finally {
371
+ disconnectTypeRef.current = void 0;
365
372
  }
366
373
  });
367
374
  return /* @__PURE__ */ jsx(
@@ -373,6 +380,7 @@ function CosmosExternalWalletProvider({
373
380
  chains: formattedChains,
374
381
  chainId: selectedChainId,
375
382
  disconnect: disconnectAsync,
383
+ disconnectStatus,
376
384
  switchChain,
377
385
  connectParaEmbedded,
378
386
  signMessage,
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@getpara/cosmos-wallet-connectors",
3
- "version": "2.0.0-alpha.66",
3
+ "version": "2.0.0-alpha.68",
4
4
  "dependencies": {
5
- "@getpara/graz-connector": "2.0.0-alpha.66",
6
- "@getpara/react-common": "2.0.0-alpha.66",
7
- "@getpara/web-sdk": "2.0.0-alpha.66",
5
+ "@getpara/graz-connector": "2.0.0-alpha.68",
6
+ "@getpara/react-common": "2.0.0-alpha.68",
7
+ "@getpara/web-sdk": "2.0.0-alpha.68",
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": "07c8b7b68aa36dec6071e3b3b3a66de2870312c8",
26
+ "gitHead": "98955203281606201609bb4674f5984acb63d3bf",
27
27
  "main": "dist/index.js",
28
28
  "peerDependencies": {
29
29
  "graz": ">=0.4.1",