@getpara/cosmos-wallet-connectors 2.0.0-alpha.65 → 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.
@@ -17,7 +17,7 @@ import {
17
17
  getChainInfo,
18
18
  getWallet as grazGetWallet,
19
19
  WALLET_TYPES
20
- } from "@getpara/graz";
20
+ } from "graz";
21
21
  import { useExternalWalletStore } from "../stores/useStore.js";
22
22
  import { rawSecp256k1PubkeyToRawAddress } from "@getpara/web-sdk";
23
23
  import {
@@ -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,
@@ -41,27 +43,30 @@ function CosmosExternalWalletProvider({
41
43
  includeWalletVerification,
42
44
  connectionOnly
43
45
  }) {
44
- var _a, _b, _c, _d;
46
+ var _a, _b, _c;
45
47
  const { suggestAndConnectAsync } = useSuggestChainAndConnect();
46
48
  const {
47
49
  data: account,
48
50
  isConnecting,
49
51
  isReconnecting,
50
52
  isConnected
51
- } = useAccount({
52
- chainId: multiChain ? chains.map((c) => c.chainId) : selectedChainId != null ? selectedChainId : "",
53
- multiChain
54
- });
53
+ } = useAccount(
54
+ multiChain ? {
55
+ chainId: chains.map((c) => c.chainId)
56
+ } : selectedChainId ? {
57
+ chainId: [selectedChainId]
58
+ } : void 0
59
+ );
55
60
  const { connectAsync } = useConnect();
56
- const { disconnectAsync } = useDisconnect();
61
+ const { disconnectAsync, status: disconnectStatus } = useDisconnect();
57
62
  const { walletType } = useActiveWalletType();
58
63
  const isLocalConnecting = useExternalWalletStore((state) => state.isConnecting);
59
64
  const updateExternalWalletState = useExternalWalletStore((state) => state.updateState);
60
65
  const isConnectError = useRef(false);
61
66
  const connectedWallet = connectedWalletProp ? para.findWallet(connectedWalletProp.id, connectedWalletProp.type) : null;
62
- const ethAddress = multiChain ? (_b = (_a = account == null ? void 0 : account[selectedChainId]) == null ? void 0 : _a.ethereumHexAddress) == null ? void 0 : _b.toLowerCase() : (_c = account == null ? void 0 : account.ethereumHexAddress) == null ? void 0 : _c.toLowerCase();
63
- const address = multiChain ? (_d = account == null ? void 0 : account[selectedChainId]) == null ? void 0 : _d.bech32Address : account == null ? void 0 : account.bech32Address;
64
- const isLinkingAccount = useRef(false);
67
+ const ethAddress = (_b = (_a = account == null ? void 0 : account[selectedChainId]) == null ? void 0 : _a.ethereumHexAddress) == null ? void 0 : _b.toLowerCase();
68
+ const address = (_c = account == null ? void 0 : account[selectedChainId]) == null ? void 0 : _c.bech32Address;
69
+ const disconnectTypeRef = useRef();
65
70
  const verificationMessage = useRef();
66
71
  const reset = () => __async(this, null, function* () {
67
72
  yield disconnectAsync();
@@ -138,14 +143,14 @@ function CosmosExternalWalletProvider({
138
143
  });
139
144
  useEffect(() => {
140
145
  const storedExternalWallet = para.externalWallets[ethAddress != null ? ethAddress : ""];
141
- if (isConnected && !isConnecting && !isReconnecting && !isLocalConnecting && !!ethAddress && !storedExternalWallet && walletType !== GrazWalletType.PARA && !isLinkingAccount.current) {
146
+ if (isConnected && !isConnecting && !isReconnecting && !isLocalConnecting && !!ethAddress && !storedExternalWallet && walletType !== GrazWalletType.PARA && !disconnectTypeRef.current) {
142
147
  reset();
143
148
  }
144
149
  }, [isConnecting, isLocalConnecting, isReconnecting, isConnected]);
145
150
  useEffect(() => {
146
151
  const connect2 = () => __async(this, null, function* () {
147
152
  var _a2;
148
- 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) {
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) {
149
154
  const isLoggedIn = yield para.isFullyLoggedIn();
150
155
  if (!isLoggedIn) {
151
156
  return;
@@ -339,7 +344,7 @@ function CosmosExternalWalletProvider({
339
344
  if (!wallet) {
340
345
  throw new Error(`Wallet for provider ${providerId} not found`);
341
346
  }
342
- isLinkingAccount.current = true;
347
+ disconnectTypeRef.current = "ACCOUNT_LINKING";
343
348
  try {
344
349
  const externalWallet = yield connectBase(
345
350
  wallet.grazType,
@@ -351,14 +356,18 @@ function CosmosExternalWalletProvider({
351
356
  throw new Error((_a2 = e == null ? void 0 : e.message) != null ? _a2 : e);
352
357
  }
353
358
  });
354
- const disconnectBase = () => __async(this, null, function* () {
359
+ const disconnectBase = (_0, ..._1) => __async(this, [_0, ..._1], function* (_, { disconnectType } = {}) {
355
360
  var _a2;
356
- isLinkingAccount.current = true;
361
+ if (disconnectType) {
362
+ disconnectTypeRef.current = disconnectType;
363
+ }
357
364
  try {
358
365
  yield disconnectAsync();
359
366
  } catch (e) {
360
367
  console.error("Error linking account:", e);
361
368
  throw new Error((_a2 = e == null ? void 0 : e.message) != null ? _a2 : e);
369
+ } finally {
370
+ disconnectTypeRef.current = void 0;
362
371
  }
363
372
  });
364
373
  return /* @__PURE__ */ jsx(
@@ -370,6 +379,7 @@ function CosmosExternalWalletProvider({
370
379
  chains: formattedChains,
371
380
  chainId: selectedChainId,
372
381
  disconnect: disconnectAsync,
382
+ disconnectStatus,
373
383
  switchChain,
374
384
  connectParaEmbedded,
375
385
  signMessage,
@@ -2,7 +2,7 @@ import { PropsWithChildren } from 'react';
2
2
  import { WalletList } from '../types/Wallet.js';
3
3
  import { CosmosExternalWalletProviderConfig } from './CosmosExternalWalletContext.js';
4
4
  import { ChainInfo } from '@keplr-wallet/types';
5
- import { ConfigureGrazArgs } from '@getpara/graz';
5
+ import { ConfigureGrazArgs } from 'graz';
6
6
  export type ParaCosmosProviderConfig = {
7
7
  wallets: WalletList;
8
8
  chains: ChainInfo[];
@@ -6,7 +6,8 @@ import {
6
6
  import { jsx } from "react/jsx-runtime";
7
7
  import { useMemo } from "react";
8
8
  import { CosmosExternalWalletProvider } from "./CosmosExternalWalletContext.js";
9
- import { GrazProvider } from "@getpara/graz";
9
+ import { ParaGrazConnector } from "@getpara/graz-connector";
10
+ import { GrazProvider } from "graz";
10
11
  function ParaCosmosProvider({
11
12
  children,
12
13
  config,
@@ -26,10 +27,26 @@ function ParaCosmosProvider({
26
27
  }),
27
28
  [walletsWithType, config, internalConfig]
28
29
  );
30
+ const paraConfig = useMemo(
31
+ () => ({
32
+ paraWeb: para
33
+ }),
34
+ [para]
35
+ );
29
36
  return (
30
37
  // Casting Para as any here to avoid ts errors due to the graz version being behind.
31
38
  // TODO: update graz para sdk to current version
32
- /* @__PURE__ */ jsx(GrazProvider, { grazOptions: __spreadValues({ chains, autoReconnect: true, para }, grazProviderProps), children: /* @__PURE__ */ jsx(CosmosExternalWalletProvider, __spreadProps(__spreadValues({}, cosmosExternalWalletProviderProps), { children })) })
39
+ /* @__PURE__ */ jsx(
40
+ GrazProvider,
41
+ {
42
+ grazOptions: __spreadValues({
43
+ chains,
44
+ autoReconnect: true,
45
+ paraConfig: __spreadProps(__spreadValues({}, paraConfig), { connectorClass: ParaGrazConnector })
46
+ }, grazProviderProps),
47
+ children: /* @__PURE__ */ jsx(CosmosExternalWalletProvider, __spreadProps(__spreadValues({}, cosmosExternalWalletProviderProps), { children }))
48
+ }
49
+ )
33
50
  );
34
51
  }
35
52
  export {
@@ -1,7 +1,6 @@
1
- import { useAccount } from '@getpara/graz';
2
- import { MultiChainHookArgs } from '../types/ExternalHooks.js';
1
+ import { useAccount } from 'graz';
3
2
  export type TExternalHooks = {
4
- useAccount: typeof useAccount<MultiChainHookArgs>;
3
+ useAccount: typeof useAccount;
5
4
  };
6
5
  export declare const externalHooks: {
7
6
  useAccount: typeof useAccount;
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import "../chunk-IV3L3JVM.js";
3
- import { useAccount } from "@getpara/graz";
3
+ import { useAccount } from "graz";
4
4
  const externalHooks = { useAccount };
5
5
  export {
6
6
  externalHooks
@@ -1,4 +1,4 @@
1
- import { UseAccountArgs } from '@getpara/graz';
1
+ import { UseAccountArgs } from 'graz';
2
2
  type ChainId$1 = string | string[];
3
3
  export interface MultiChainHookArgs {
4
4
  chainId?: ChainId$1;
@@ -1,4 +1,4 @@
1
- import { WalletType } from '@getpara/graz';
1
+ import { WalletType } from 'graz';
2
2
  import { type WalletMetadata } from '@getpara/react-common';
3
3
  export type WalletList = (() => WalletWithType)[];
4
4
  export type WalletWithType = {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import "../../../chunk-IV3L3JVM.js";
3
3
  import { icon } from "./cosmostationIcon.js";
4
- import { WalletType } from "@getpara/graz";
4
+ import { WalletType } from "graz";
5
5
  import { isMobile } from "@getpara/web-sdk";
6
6
  const cosmostationWallet = () => {
7
7
  return {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import "../../../chunk-IV3L3JVM.js";
3
3
  import { icon } from "./keplrIcon.js";
4
- import { WalletType } from "@getpara/graz";
4
+ import { WalletType } from "graz";
5
5
  import { isMobile } from "@getpara/web-sdk";
6
6
  const keplrWallet = () => {
7
7
  return {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import "../../../chunk-IV3L3JVM.js";
3
3
  import { icon } from "./leapIcon.js";
4
- import { WalletType } from "@getpara/graz";
4
+ import { WalletType } from "graz";
5
5
  import { isMobile } from "@getpara/web-sdk";
6
6
  const leapWallet = () => {
7
7
  return {
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@getpara/cosmos-wallet-connectors",
3
- "version": "2.0.0-alpha.65",
3
+ "version": "2.0.0-alpha.67",
4
4
  "dependencies": {
5
- "@getpara/react-common": "2.0.0-alpha.65",
6
- "@getpara/web-sdk": "2.0.0-alpha.65",
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",
7
8
  "@leapwallet/cosmos-social-login-capsule-provider": "^0.0.41",
8
- "starknet": "^6.11.0",
9
9
  "zustand": "^4.5.2",
10
10
  "zustand-sync-tabs": "^0.2.2"
11
11
  },
12
12
  "devDependencies": {
13
- "@getpara/graz": "2.0.0-alpha.5",
14
13
  "@types/react": "^18.0.31",
15
14
  "@types/react-dom": "^18.2.7",
15
+ "graz": "^0.4.1",
16
16
  "typescript": "^5.8.3"
17
17
  },
18
18
  "exports": {
@@ -23,10 +23,10 @@
23
23
  "dist",
24
24
  "package.json"
25
25
  ],
26
- "gitHead": "9945ab14944c22851eb81c5bbb831b23bf7eaf2a",
26
+ "gitHead": "0266cc49e978575fed0b12c9bb0c832651e140eb",
27
27
  "main": "dist/index.js",
28
28
  "peerDependencies": {
29
- "@getpara/graz": ">=2.0.0-alpha.5",
29
+ "graz": ">=0.4.1",
30
30
  "react": ">=18",
31
31
  "react-dom": ">=18"
32
32
  },