@getpara/cosmos-wallet-connectors 0.1.0 → 0.2.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.
@@ -11,7 +11,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { createContext, useEffect, useMemo, useState } from 'react';
12
12
  import { useParaCosmos } from './ParaCosmosContext.js';
13
13
  import { WalletType } from '@getpara/react-sdk';
14
- import { checkWallet, WalletType as GrazWalletType, useAccount, useActiveChainIds, useActiveWalletType, useConnect, useDisconnect, useSuggestChainAndConnect, getChainInfo, } from '@usecapsule/graz';
14
+ import { checkWallet, WalletType as GrazWalletType, useAccount, useActiveChainIds, useActiveWalletType, useConnect, useDisconnect, useSuggestChainAndConnect, getChainInfo, } from '@getpara/graz';
15
15
  export const defaultCosmosExternalWallet = {
16
16
  wallets: [],
17
17
  chains: [],
@@ -80,7 +80,7 @@ export function CosmosExternalWalletProvider({ children, para, onSwitchWallet })
80
80
  address &&
81
81
  storedExternalWallet &&
82
82
  storedExternalWallet.address !== address &&
83
- walletType !== GrazWalletType.CAPSULE_EMBEDDED) {
83
+ walletType !== GrazWalletType.PARA) {
84
84
  para.setExternalWallet({
85
85
  address: bufferAddress,
86
86
  type: WalletType.COSMOS,
@@ -96,7 +96,7 @@ export function CosmosExternalWalletProvider({ children, para, onSwitchWallet })
96
96
  !isLocalConnecting &&
97
97
  !!bufferAddress &&
98
98
  !storedExternalWallet &&
99
- walletType !== GrazWalletType.CAPSULE_EMBEDDED) {
99
+ walletType !== GrazWalletType.PARA) {
100
100
  reset();
101
101
  }
102
102
  }, [isConnecting, isReconnecting]);
@@ -1,7 +1,7 @@
1
1
  import { ReactNode } from 'react';
2
2
  import { WalletList, WalletWithType } from '../types/Wallet.js';
3
3
  import { ChainInfo } from '@keplr-wallet/types';
4
- import { ConfigureGrazArgs } from '@usecapsule/graz';
4
+ import { ConfigureGrazArgs } from '@getpara/graz';
5
5
  export declare const ParaCosmosContext: import("react").Context<{
6
6
  selectedChainId?: string;
7
7
  wallets: WalletWithType[];
@@ -20,38 +20,44 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  };
21
21
  import { jsx as _jsx } from "react/jsx-runtime";
22
22
  import { createContext, useCallback, useContext, useEffect, useMemo } from 'react';
23
- import { useExternalWalletProviderStore } from '@getpara/react-sdk';
23
+ import { useClient, useExternalWalletProviderStore } from '@getpara/react-sdk';
24
24
  import { CosmosExternalWalletContext, CosmosExternalWalletProvider } from './CosmosExternalWalletContext.js';
25
- import { GrazProvider, WalletType, connect } from '@usecapsule/graz';
25
+ import { GrazProvider, WalletType, connect } from '@getpara/graz';
26
26
  export const ParaCosmosContext = createContext({ wallets: [], chains: [], onSwitchChain: () => { } });
27
27
  export function ParaCosmosProvider(_a) {
28
+ var _b;
28
29
  var { children, wallets, chains, selectedChainId, multiChain, shouldUseSuggestChainAndConnect, onSwitchChain } = _a, grazOpts = __rest(_a, ["children", "wallets", "chains", "selectedChainId", "multiChain", "shouldUseSuggestChainAndConnect", "onSwitchChain"]);
29
30
  const updateExternalWalletProviderState = useExternalWalletProviderStore(state => state.updateState);
30
31
  const CosmosProvider = useExternalWalletProviderStore(state => state.CosmosProvider);
31
32
  const cosmosContext = useExternalWalletProviderStore(state => state.cosmosContext);
33
+ const para = (_b = useClient()) !== null && _b !== void 0 ? _b : grazOpts.para;
32
34
  const connectParaCosmosWallet = useCallback(() => __awaiter(this, void 0, void 0, function* () {
33
- if (!grazOpts.capsule) {
34
- return { error: 'No capsule instance passed to Graz' };
35
+ if (!para) {
36
+ return { error: 'No para instance available' };
35
37
  }
36
38
  try {
37
39
  const chainId = multiChain ? chains.map(c => c.chainId) : selectedChainId;
38
- const result = yield connect({ walletType: WalletType.CAPSULE_EMBEDDED, chainId });
40
+ const result = yield connect({ walletType: WalletType.PARA, chainId });
39
41
  return { result };
40
42
  }
41
43
  catch (err) {
42
44
  const error = err instanceof Error ? err.message : 'Unknown error';
43
45
  return { error };
44
46
  }
45
- }), [connect]);
47
+ }), [para, connect]);
46
48
  useEffect(() => {
47
49
  if (!cosmosContext || !CosmosProvider) {
48
50
  updateExternalWalletProviderState({
49
51
  CosmosProvider: CosmosExternalWalletProvider,
50
52
  cosmosContext: CosmosExternalWalletContext,
51
- connectParaCosmosWallet,
52
53
  });
53
54
  }
54
55
  }, []);
56
+ useEffect(() => {
57
+ updateExternalWalletProviderState({
58
+ connectParaCosmosWallet,
59
+ });
60
+ }, [para]);
55
61
  const walletsWithType = [];
56
62
  wallets.forEach(w => {
57
63
  const wallet = w();
@@ -68,6 +74,6 @@ export function ParaCosmosProvider(_a) {
68
74
  if (!cosmosContext || !CosmosProvider) {
69
75
  return null;
70
76
  }
71
- return (_jsx(GrazProvider, { grazOptions: Object.assign({ chains, autoReconnect: true }, grazOpts), children: _jsx(ParaCosmosContext.Provider, { value: value, children: children }) }));
77
+ return (_jsx(GrazProvider, { grazOptions: Object.assign(Object.assign({ chains, autoReconnect: true }, grazOpts), { para }), children: _jsx(ParaCosmosContext.Provider, { value: value, children: children }) }));
72
78
  }
73
79
  export const useParaCosmos = () => useContext(ParaCosmosContext);
@@ -1,4 +1,4 @@
1
- import { WalletType } from '@usecapsule/graz';
1
+ import { WalletType } from '@getpara/graz';
2
2
  import { WalletMetadata } from './CommonTypes.js';
3
3
  export type WalletList = (() => WalletWithType)[];
4
4
  export type WalletWithType = {
@@ -1,5 +1,5 @@
1
1
  import { icon } from './keplrIcon.js';
2
- import { WalletType } from '@usecapsule/graz';
2
+ import { WalletType } from '@getpara/graz';
3
3
  import { isMobile } from '@getpara/react-sdk';
4
4
  export const keplrWallet = () => {
5
5
  return {
@@ -1,5 +1,5 @@
1
1
  import { icon } from './leapIcon.js';
2
- import { WalletType } from '@usecapsule/graz';
2
+ import { WalletType } from '@getpara/graz';
3
3
  import { isMobile } from '@getpara/react-sdk';
4
4
  export const leapWallet = () => {
5
5
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/cosmos-wallet-connectors",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,17 +9,17 @@
9
9
  "./connectors": "./dist/wallets/connectors/index.js"
10
10
  },
11
11
  "dependencies": {
12
- "@getpara/react-sdk": "0.1.0"
12
+ "@getpara/react-sdk": "0.2.0"
13
13
  },
14
14
  "scripts": {
15
15
  "build": "rm -rf dist && tsc",
16
16
  "test": "vitest run --coverage"
17
17
  },
18
18
  "devDependencies": {
19
+ "@getpara/graz": "^0.1.0",
19
20
  "@leapwallet/cosmos-social-login-capsule-provider": "^0.0.41",
20
21
  "@types/react": "^18.0.31",
21
22
  "@types/react-dom": "^18.2.7",
22
- "@usecapsule/graz": "^0.3.0",
23
23
  "typescript": "^5.4.3"
24
24
  },
25
25
  "peerDependencies": {
@@ -28,7 +28,7 @@
28
28
  "@cosmjs/proto-signing": "<=0.31.3",
29
29
  "@cosmjs/stargate": "<=0.31.3",
30
30
  "@cosmjs/tendermint-rpc": "<=0.31.3",
31
- "@usecapsule/graz": "^0.3.0",
31
+ "@getpara/graz": "^0.1.0",
32
32
  "react": ">=18",
33
33
  "react-dom": ">=18"
34
34
  },
@@ -36,5 +36,5 @@
36
36
  "dist",
37
37
  "package.json"
38
38
  ],
39
- "gitHead": "625aaa94001a5461dcde8d6775c3b73f3862c76c"
39
+ "gitHead": "9e28f35ede16f3627aeb5baebdf26dae03fa4dcf"
40
40
  }