@interchain-kit/react 0.3.9 → 0.3.11

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.
@@ -1,8 +1,8 @@
1
1
  import { useWalletModal } from "../modal";
2
2
  import { useWalletManager } from './useWalletManager';
3
3
  import { ChainNameNotExist } from '@interchain-kit/core';
4
- import { ChainWallet } from '../store/chain-wallet';
5
4
  import { useSigningClient } from './useSigningClient';
5
+ import { decorateWallet } from '../utils/decorateWallet';
6
6
  export const useChain = (chainName) => {
7
7
  const { assetLists, currentWalletName, disconnect, setCurrentChainName, getChainByName, getWalletByName, getChainWalletState, getChainLogoUrl, connect, getSigningClient, getRpcEndpoint, getAccount } = useWalletManager();
8
8
  const chain = getChainByName(chainName);
@@ -35,7 +35,11 @@ export const useChain = (chainName) => {
35
35
  chain,
36
36
  assetList,
37
37
  address: chainWalletStateToShow?.account?.address,
38
- wallet: new ChainWallet(wallet, () => connect(currentWalletName, chainName), () => disconnect(currentWalletName, chainName), () => getAccount(currentWalletName, chainName)),
38
+ wallet: decorateWallet(wallet, {
39
+ connect: () => connect(currentWalletName, chainName),
40
+ disconnect: () => disconnect(currentWalletName, chainName),
41
+ getAccount: () => getAccount(currentWalletName, chainName),
42
+ }),
39
43
  getSigningClient: () => getSigningClient(currentWalletName, chainName),
40
44
  signingClient,
41
45
  isSigningClientLoading,
@@ -0,0 +1,14 @@
1
+ export const decorateWallet = (wallet, decorateMethods) => {
2
+ return new Proxy(wallet, {
3
+ get(target, prop, receiver) {
4
+ if (prop in decorateMethods) {
5
+ const method = decorateMethods[prop];
6
+ if (typeof method === "function") {
7
+ return method.bind(target);
8
+ }
9
+ return method;
10
+ }
11
+ return Reflect.get(target, prop, receiver);
12
+ },
13
+ });
14
+ };
package/hooks/useChain.js CHANGED
@@ -4,8 +4,8 @@ exports.useChain = void 0;
4
4
  const modal_1 = require("../modal");
5
5
  const useWalletManager_1 = require("./useWalletManager");
6
6
  const core_1 = require("@interchain-kit/core");
7
- const chain_wallet_1 = require("../store/chain-wallet");
8
7
  const useSigningClient_1 = require("./useSigningClient");
8
+ const decorateWallet_1 = require("../utils/decorateWallet");
9
9
  const useChain = (chainName) => {
10
10
  const { assetLists, currentWalletName, disconnect, setCurrentChainName, getChainByName, getWalletByName, getChainWalletState, getChainLogoUrl, connect, getSigningClient, getRpcEndpoint, getAccount } = (0, useWalletManager_1.useWalletManager)();
11
11
  const chain = getChainByName(chainName);
@@ -38,7 +38,11 @@ const useChain = (chainName) => {
38
38
  chain,
39
39
  assetList,
40
40
  address: chainWalletStateToShow?.account?.address,
41
- wallet: new chain_wallet_1.ChainWallet(wallet, () => connect(currentWalletName, chainName), () => disconnect(currentWalletName, chainName), () => getAccount(currentWalletName, chainName)),
41
+ wallet: (0, decorateWallet_1.decorateWallet)(wallet, {
42
+ connect: () => connect(currentWalletName, chainName),
43
+ disconnect: () => disconnect(currentWalletName, chainName),
44
+ getAccount: () => getAccount(currentWalletName, chainName),
45
+ }),
42
46
  getSigningClient: () => getSigningClient(currentWalletName, chainName),
43
47
  signingClient,
44
48
  isSigningClientLoading,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interchain-kit/react",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "author": "Hyperweb <developers@hyperweb.io>",
5
5
  "description": "interchain-kit wallet connector react package",
6
6
  "main": "index.js",
@@ -34,13 +34,13 @@
34
34
  "keywords": [],
35
35
  "dependencies": {
36
36
  "@chain-registry/v2-types": "^0.53.40",
37
- "@interchain-kit/core": "0.3.9",
37
+ "@interchain-kit/core": "0.3.11",
38
38
  "@interchain-ui/react": "1.26.1",
39
- "@interchainjs/cosmos": "1.11.2",
40
- "@interchainjs/cosmos-types": "1.11.2",
39
+ "@interchainjs/cosmos": "1.11.5",
40
+ "@interchainjs/cosmos-types": "1.11.5",
41
41
  "@react-icons/all-files": "^4.1.0",
42
42
  "@walletconnect/types": "^2.17.3",
43
- "interchainjs": "1.11.2",
43
+ "interchainjs": "1.11.5",
44
44
  "zustand": "^5.0.3"
45
45
  },
46
46
  "devDependencies": {
@@ -63,5 +63,5 @@
63
63
  "react": "^19.0.0",
64
64
  "react-dom": "^19.0.0"
65
65
  },
66
- "gitHead": "cdd951713335e926876368175d0ed3acd7aeaf31"
66
+ "gitHead": "bab07a8b12e409fd5d61f272d0a688b00330f49a"
67
67
  }
package/types/chain.d.ts CHANGED
@@ -2,7 +2,6 @@ import { HttpEndpoint } from '@interchainjs/types';
2
2
  import { Chain, AssetList } from '@chain-registry/v2-types';
3
3
  import { BaseWallet, WalletState } from '@interchain-kit/core';
4
4
  import { SigningClient } from './sign-client';
5
- import { ChainWallet } from '../store/chain-wallet';
6
5
  export type CosmosKitUseChainReturnType = {
7
6
  connect: () => void;
8
7
  disconnect: () => void;
@@ -18,7 +17,7 @@ export type UseChainReturnType = {
18
17
  chain: Chain;
19
18
  assetList: AssetList;
20
19
  address: string;
21
- wallet: ChainWallet<BaseWallet>;
20
+ wallet: BaseWallet;
22
21
  rpcEndpoint: string | HttpEndpoint | unknown;
23
22
  getSigningClient: () => Promise<SigningClient>;
24
23
  signingClient: SigningClient | null;
@@ -0,0 +1,2 @@
1
+ import { BaseWallet } from "@interchain-kit/core";
2
+ export declare const decorateWallet: <T extends BaseWallet>(wallet: T, decorateMethods: Partial<T>) => T;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decorateWallet = void 0;
4
+ const decorateWallet = (wallet, decorateMethods) => {
5
+ return new Proxy(wallet, {
6
+ get(target, prop, receiver) {
7
+ if (prop in decorateMethods) {
8
+ const method = decorateMethods[prop];
9
+ if (typeof method === "function") {
10
+ return method.bind(target);
11
+ }
12
+ return method;
13
+ }
14
+ return Reflect.get(target, prop, receiver);
15
+ },
16
+ });
17
+ };
18
+ exports.decorateWallet = decorateWallet;