@interchain-kit/react 0.2.202 → 0.2.204

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,6 +1,17 @@
1
+ import { useStore } from "zustand";
1
2
  import { useInterchainWalletContext } from "../provider";
2
- import { useStore } from 'zustand';
3
+ function bindMethodsToContext(context) {
4
+ for (const key of Object.getOwnPropertyNames(Object.getPrototypeOf(context))) {
5
+ const value = context[key];
6
+ if (typeof value === 'function') {
7
+ context[key] = value.bind(context);
8
+ }
9
+ }
10
+ }
3
11
  export const useWalletManager = () => {
4
- const store = useInterchainWalletContext();
5
- return useStore(store);
12
+ const object = useInterchainWalletContext();
13
+ // put useStore here to update the hook
14
+ const store = useStore(object.store);
15
+ bindMethodsToContext(object);
16
+ return object;
6
17
  };
package/esm/provider.js CHANGED
@@ -1,19 +1,16 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useRef } from "react";
2
+ import { useEffect } from "react";
3
3
  import { createContext, useContext } from "react";
4
4
  import { WalletManager, } from "@interchain-kit/core";
5
5
  import { WalletModalProvider } from "./modal";
6
- import { createInterchainStore } from "./store";
7
6
  const InterchainWalletContext = createContext(null);
8
7
  export const ChainProvider = ({ chains, assetLists, wallets, signerOptions, endpointOptions, children, }) => {
9
8
  // const [_, forceRender] = useState({});
10
9
  const walletManager = new WalletManager(chains, assetLists, wallets, signerOptions, endpointOptions);
11
- const store = useRef(createInterchainStore(walletManager));
12
10
  useEffect(() => {
13
- // walletManager.init();
14
- store.current.getState().init();
11
+ walletManager.init();
15
12
  }, []);
16
- return (_jsx(InterchainWalletContext.Provider, { value: store.current, children: _jsx(WalletModalProvider, { children: children }) }));
13
+ return (_jsx(InterchainWalletContext.Provider, { value: walletManager, children: _jsx(WalletModalProvider, { children: children }) }));
17
14
  };
18
15
  export const useInterchainWalletContext = () => {
19
16
  const context = useContext(InterchainWalletContext);
@@ -32,6 +32,7 @@ export const createInterchainStore = (walletManager) => {
32
32
  });
33
33
  });
34
34
  return createStore(persist(immer((set, get) => ({
35
+ store: walletManager.store,
35
36
  chainWalletState,
36
37
  currentWalletName: '',
37
38
  currentChainName: '',
@@ -1 +1 @@
1
- export declare const useWalletManager: () => import("..").InterchainStore;
1
+ export declare const useWalletManager: () => import("@interchain-kit/core").WalletManager;
@@ -1,10 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useWalletManager = void 0;
4
- const provider_1 = require("../provider");
5
4
  const zustand_1 = require("zustand");
5
+ const provider_1 = require("../provider");
6
+ function bindMethodsToContext(context) {
7
+ for (const key of Object.getOwnPropertyNames(Object.getPrototypeOf(context))) {
8
+ const value = context[key];
9
+ if (typeof value === 'function') {
10
+ context[key] = value.bind(context);
11
+ }
12
+ }
13
+ }
6
14
  const useWalletManager = () => {
7
- const store = (0, provider_1.useInterchainWalletContext)();
8
- return (0, zustand_1.useStore)(store);
15
+ const object = (0, provider_1.useInterchainWalletContext)();
16
+ // put useStore here to update the hook
17
+ const store = (0, zustand_1.useStore)(object.store);
18
+ bindMethodsToContext(object);
19
+ return object;
9
20
  };
10
21
  exports.useWalletManager = useWalletManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interchain-kit/react",
3
- "version": "0.2.202",
3
+ "version": "0.2.204",
4
4
  "author": "Hyperweb <developers@hyperweb.io>",
5
5
  "description": "interchain-kit wallet connector react package",
6
6
  "main": "index.js",
@@ -33,18 +33,18 @@
33
33
  "keywords": [],
34
34
  "dependencies": {
35
35
  "@chain-registry/v2-types": "^0.53.40",
36
- "@interchain-kit/core": "0.2.202",
36
+ "@interchain-kit/core": "0.2.204",
37
37
  "@interchain-ui/react": "1.26.1",
38
- "@interchainjs/cosmos": "1.9.3",
39
- "@interchainjs/cosmos-types": "1.9.3",
38
+ "@interchainjs/cosmos": "1.9.12",
39
+ "@interchainjs/cosmos-types": "1.9.12",
40
40
  "@react-icons/all-files": "^4.1.0",
41
41
  "@types/react": "^18.3.3",
42
42
  "@types/react-dom": "^18.3.0",
43
43
  "@walletconnect/types": "^2.17.3",
44
- "interchainjs": "1.9.3",
44
+ "interchainjs": "1.9.12",
45
45
  "react": "^18.3.1",
46
46
  "react-dom": "^18.3.1",
47
47
  "zustand": "^5.0.3"
48
48
  },
49
- "gitHead": "60f30aa20fa8d8e0167ebe67ce195dda02dcb3ff"
49
+ "gitHead": "256ae367a0ff176254eac9e8695f64099ba7b1a1"
50
50
  }
package/provider.d.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  import React from "react";
2
- import { BaseWallet, SignerOptions, EndpointOptions } from "@interchain-kit/core";
2
+ import { BaseWallet, SignerOptions, EndpointOptions, WalletManager } from "@interchain-kit/core";
3
3
  import { AssetList, Chain } from "@chain-registry/v2-types";
4
- import { InterchainStore } from "./store";
5
- import { StoreApi } from "zustand";
6
- type InterchainWalletContextType = StoreApi<InterchainStore>;
7
4
  type InterchainWalletProviderProps = {
8
5
  chains: Chain[];
9
6
  assetLists: AssetList[];
@@ -13,5 +10,5 @@ type InterchainWalletProviderProps = {
13
10
  children: React.ReactNode;
14
11
  };
15
12
  export declare const ChainProvider: ({ chains, assetLists, wallets, signerOptions, endpointOptions, children, }: InterchainWalletProviderProps) => import("react/jsx-runtime").JSX.Element;
16
- export declare const useInterchainWalletContext: () => InterchainWalletContextType;
13
+ export declare const useInterchainWalletContext: () => WalletManager;
17
14
  export {};
package/provider.js CHANGED
@@ -6,17 +6,14 @@ const react_1 = require("react");
6
6
  const react_2 = require("react");
7
7
  const core_1 = require("@interchain-kit/core");
8
8
  const modal_1 = require("./modal");
9
- const store_1 = require("./store");
10
9
  const InterchainWalletContext = (0, react_2.createContext)(null);
11
10
  const ChainProvider = ({ chains, assetLists, wallets, signerOptions, endpointOptions, children, }) => {
12
11
  // const [_, forceRender] = useState({});
13
12
  const walletManager = new core_1.WalletManager(chains, assetLists, wallets, signerOptions, endpointOptions);
14
- const store = (0, react_1.useRef)((0, store_1.createInterchainStore)(walletManager));
15
13
  (0, react_1.useEffect)(() => {
16
- // walletManager.init();
17
- store.current.getState().init();
14
+ walletManager.init();
18
15
  }, []);
19
- return ((0, jsx_runtime_1.jsx)(InterchainWalletContext.Provider, { value: store.current, children: (0, jsx_runtime_1.jsx)(modal_1.WalletModalProvider, { children: children }) }));
16
+ return ((0, jsx_runtime_1.jsx)(InterchainWalletContext.Provider, { value: walletManager, children: (0, jsx_runtime_1.jsx)(modal_1.WalletModalProvider, { children: children }) }));
20
17
  };
21
18
  exports.ChainProvider = ChainProvider;
22
19
  const useInterchainWalletContext = () => {
package/store/index.js CHANGED
@@ -35,6 +35,7 @@ const createInterchainStore = (walletManager) => {
35
35
  });
36
36
  });
37
37
  return (0, zustand_1.createStore)((0, middleware_1.persist)((0, immer_1.immer)((set, get) => ({
38
+ store: walletManager.store,
38
39
  chainWalletState,
39
40
  currentWalletName: '',
40
41
  currentChainName: '',