@interchain-kit/react 0.0.1-beta.5 → 0.0.1-beta.50

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.
Files changed (83) hide show
  1. package/README.md +165 -12
  2. package/esm/hooks/index.js +3 -1
  3. package/esm/hooks/useAccount.js +20 -19
  4. package/esm/hooks/useChain.js +59 -20
  5. package/esm/hooks/useChainWallet.js +33 -10
  6. package/esm/hooks/useCurrentChainWallet.js +11 -0
  7. package/esm/hooks/useCurrentWallet.js +18 -0
  8. package/esm/hooks/useInterchainClient.js +14 -50
  9. package/esm/hooks/useOfflineSigner.js +14 -2
  10. package/esm/hooks/useRpcEndpoint.js +26 -0
  11. package/esm/hooks/useWalletManager.js +4 -3
  12. package/esm/modal/modal.js +71 -12
  13. package/esm/modal/provider.js +1 -2
  14. package/esm/modal/views/Astronaut.js +4 -0
  15. package/esm/modal/views/Connected.js +33 -0
  16. package/esm/modal/views/Connecting.js +24 -0
  17. package/esm/modal/views/NotExist.js +44 -0
  18. package/esm/modal/views/QRCode.js +20 -0
  19. package/esm/modal/views/Reject.js +14 -0
  20. package/esm/modal/views/WalletList.js +40 -0
  21. package/esm/modal/views/index.js +6 -0
  22. package/esm/provider.js +12 -9
  23. package/esm/types/index.js +1 -0
  24. package/esm/types/sign-client.js +1 -0
  25. package/esm/utils/helpers.js +11 -0
  26. package/esm/utils/index.js +1 -1
  27. package/esm/utils/wallet.js +8 -0
  28. package/hooks/index.d.ts +3 -1
  29. package/hooks/index.js +3 -1
  30. package/hooks/useAccount.d.ts +6 -2
  31. package/hooks/useAccount.js +20 -19
  32. package/hooks/useChain.d.ts +2 -2
  33. package/hooks/useChain.js +59 -20
  34. package/hooks/useChainWallet.d.ts +2 -2
  35. package/hooks/useChainWallet.js +33 -10
  36. package/hooks/useConfig.d.ts +1 -1
  37. package/hooks/useCurrentChainWallet.d.ts +2 -0
  38. package/hooks/useCurrentChainWallet.js +15 -0
  39. package/hooks/useCurrentWallet.d.ts +2 -0
  40. package/hooks/useCurrentWallet.js +22 -0
  41. package/hooks/useInterchainClient.d.ts +3 -11
  42. package/hooks/useInterchainClient.js +14 -50
  43. package/hooks/useOfflineSigner.d.ts +3 -0
  44. package/hooks/useOfflineSigner.js +14 -2
  45. package/hooks/useRpcEndpoint.d.ts +6 -0
  46. package/hooks/useRpcEndpoint.js +30 -0
  47. package/hooks/useWalletManager.js +3 -2
  48. package/modal/modal.js +70 -11
  49. package/modal/provider.js +1 -2
  50. package/modal/views/Astronaut.d.ts +2 -0
  51. package/modal/views/Astronaut.js +8 -0
  52. package/modal/views/Connected.d.ts +4 -0
  53. package/modal/views/Connected.js +38 -0
  54. package/modal/views/Connecting.d.ts +8 -0
  55. package/modal/views/Connecting.js +29 -0
  56. package/modal/views/NotExist.d.ts +8 -0
  57. package/modal/views/NotExist.js +49 -0
  58. package/modal/views/QRCode.d.ts +4 -0
  59. package/modal/views/QRCode.js +25 -0
  60. package/modal/views/Reject.d.ts +8 -0
  61. package/modal/views/Reject.js +19 -0
  62. package/modal/views/WalletList.d.ts +5 -0
  63. package/modal/views/WalletList.js +45 -0
  64. package/modal/views/index.d.ts +6 -0
  65. package/modal/views/index.js +22 -0
  66. package/package.json +15 -5
  67. package/provider.d.ts +8 -8
  68. package/provider.js +12 -9
  69. package/types/chain.d.ts +16 -10
  70. package/types/index.d.ts +1 -0
  71. package/types/index.js +1 -0
  72. package/types/sign-client.d.ts +2 -0
  73. package/types/sign-client.js +2 -0
  74. package/types/wallet.d.ts +1 -1
  75. package/utils/helpers.d.ts +1 -0
  76. package/utils/helpers.js +15 -0
  77. package/utils/index.d.ts +1 -0
  78. package/utils/index.js +16 -0
  79. package/utils/wallet.d.ts +7 -0
  80. package/utils/wallet.js +12 -0
  81. package/esm/hooks/useActiveWallet.js +0 -5
  82. package/hooks/useActiveWallet.d.ts +0 -1
  83. package/hooks/useActiveWallet.js +0 -9
package/provider.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- import React from 'react';
2
- import { BaseWallet, SignerOptions, WalletManager, EndpointOptions } from '@interChain-kit/core';
3
- import { AssetList, Chain } from '@chain-registry/v2-types';
1
+ import React from "react";
2
+ import { BaseWallet, SignerOptions, WalletManager, EndpointOptions } from "@interchain-kit/core";
3
+ import { AssetList, Chain } from "@chain-registry/v2-types";
4
4
  type InterchainWalletContextType = {
5
5
  walletManager: WalletManager;
6
6
  };
7
- type InterchianWalletProviderProps = {
7
+ type InterchainWalletProviderProps = {
8
8
  chains: Chain[];
9
9
  assetLists: AssetList[];
10
10
  wallets: BaseWallet[];
11
- signerOptions: SignerOptions;
12
- endpointOptions: EndpointOptions;
11
+ signerOptions?: SignerOptions;
12
+ endpointOptions?: EndpointOptions;
13
13
  children: React.ReactNode;
14
14
  };
15
- export declare const ChainProvider: ({ chains, assetLists, wallets, signerOptions, endpointOptions, children }: InterchianWalletProviderProps) => import("react/jsx-runtime").JSX.Element;
16
- export declare const useInterChainWalletContext: () => InterchainWalletContextType;
15
+ export declare const ChainProvider: ({ chains, assetLists, wallets, signerOptions, endpointOptions, children, }: InterchainWalletProviderProps) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const useInterchainWalletContext: () => InterchainWalletContextType;
17
17
  export {};
package/provider.js CHANGED
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useInterChainWalletContext = exports.ChainProvider = void 0;
3
+ exports.useInterchainWalletContext = exports.ChainProvider = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
6
  const react_2 = require("react");
7
- const core_1 = require("@interChain-kit/core");
7
+ const core_1 = require("@interchain-kit/core");
8
8
  const modal_1 = require("./modal");
9
- const InterChainWalletContext = (0, react_2.createContext)(null);
10
- const ChainProvider = ({ chains, assetLists, wallets, signerOptions, endpointOptions, children }) => {
9
+ const InterchainWalletContext = (0, react_2.createContext)(null);
10
+ const ChainProvider = ({ chains, assetLists, wallets, signerOptions, endpointOptions, children, }) => {
11
11
  const [_, forceRender] = (0, react_1.useState)({});
12
12
  const walletManager = (0, react_1.useMemo)(() => {
13
13
  return new core_1.WalletManager(chains, assetLists, wallets, signerOptions, endpointOptions, () => forceRender({}));
@@ -15,14 +15,17 @@ const ChainProvider = ({ chains, assetLists, wallets, signerOptions, endpointOpt
15
15
  (0, react_1.useEffect)(() => {
16
16
  walletManager.init();
17
17
  }, []);
18
- return ((0, jsx_runtime_1.jsx)(InterChainWalletContext.Provider, { value: { walletManager }, children: (0, jsx_runtime_1.jsx)(modal_1.WalletModalProvider, { children: children }) }));
18
+ if (walletManager.state === core_1.WalletManagerState.Initializing) {
19
+ return (0, jsx_runtime_1.jsx)("div", { children: "Interchain Kit Initializing..." });
20
+ }
21
+ return ((0, jsx_runtime_1.jsx)(InterchainWalletContext.Provider, { value: { walletManager }, children: (0, jsx_runtime_1.jsx)(modal_1.WalletModalProvider, { children: children }) }));
19
22
  };
20
23
  exports.ChainProvider = ChainProvider;
21
- const useInterChainWalletContext = () => {
22
- const context = (0, react_2.useContext)(InterChainWalletContext);
24
+ const useInterchainWalletContext = () => {
25
+ const context = (0, react_2.useContext)(InterchainWalletContext);
23
26
  if (!context) {
24
- throw new Error('useInterChainWalletContext must be used within a InterChainProvider');
27
+ throw new Error("useInterChainWalletContext must be used within a InterChainProvider");
25
28
  }
26
29
  return context;
27
30
  };
28
- exports.useInterChainWalletContext = useInterChainWalletContext;
31
+ exports.useInterchainWalletContext = useInterchainWalletContext;
package/types/chain.d.ts CHANGED
@@ -1,31 +1,37 @@
1
1
  import { HttpEndpoint } from '@interchainjs/types';
2
- import { CosmWasmSigningClient } from 'interchainjs/cosmwasm-stargate';
3
- import { SigningClient } from 'interchainjs/signing-client';
4
- import { RpcQuery } from 'interchainjs/query/rpc';
5
- import { StargateSigningClient } from 'interchainjs/stargate';
6
2
  import { Chain, AssetList } from '@chain-registry/v2-types';
7
3
  import { BaseWallet, WalletState } from '@interchain-kit/core';
4
+ import { SigningClient } from './sign-client';
8
5
  export type CosmosKitUseChainReturnType = {
9
6
  connect: () => void;
7
+ disconnect: () => void;
10
8
  openView: () => void;
11
9
  closeView: () => void;
12
10
  getRpcEndpoint: () => Promise<string | HttpEndpoint>;
13
11
  status: WalletState;
14
12
  username: string;
15
13
  message: string;
16
- getSigningCosmWasmClient: () => Promise<CosmWasmSigningClient>;
17
- getSigningStargateClient: () => Promise<StargateSigningClient>;
18
14
  };
19
15
  export type UseChainReturnType = {
16
+ logoUrl: string | undefined;
20
17
  chain: Chain;
21
18
  assetList: AssetList;
22
19
  address: string;
23
20
  wallet: BaseWallet;
24
21
  rpcEndpoint: string | HttpEndpoint;
25
- queryClient: RpcQuery;
26
22
  signingClient: SigningClient;
27
- signingStargateClient: StargateSigningClient;
28
- signingCosmWasmClient: CosmWasmSigningClient;
23
+ getSigningClient: () => Promise<SigningClient>;
24
+ isRpcEndpointLoading: boolean;
25
+ isAccountLoading: boolean;
26
+ isSigningClientLoading: boolean;
27
+ isLoading: boolean;
28
+ getRpcEndpointError: Error | null;
29
+ getSigningClientError: Error | null;
30
+ getAccountError: Error | null;
31
+ } & CosmosKitUseChainReturnType;
32
+ export type UseChainWalletReturnType = Omit<UseChainReturnType, 'openView' | 'closeView'>;
33
+ export type UseInterchainClientReturnType = {
34
+ signingClient: SigningClient | null;
35
+ error: string | unknown | null;
29
36
  isLoading: boolean;
30
- error: unknown;
31
37
  };
package/types/index.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './wallet';
2
+ export * from './sign-client';
package/types/index.js CHANGED
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./wallet"), exports);
18
+ __exportStar(require("./sign-client"), exports);
@@ -0,0 +1,2 @@
1
+ import { WalletManager } from "@interchain-kit/core";
2
+ export type SigningClient = Awaited<ReturnType<WalletManager['getSigningClient']>>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/types/wallet.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseWallet } from "@interChain-kit/core";
1
+ import { BaseWallet } from "@interchain-kit/core";
2
2
  import { ConnectState } from "../enum";
3
3
  export type UseWalletReturnType = {
4
4
  wallet: BaseWallet;
@@ -0,0 +1 @@
1
+ export declare function bindAllMethodsToContext<T extends object>(context: T): T;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bindAllMethodsToContext = void 0;
4
+ function bindAllMethodsToContext(context) {
5
+ return new Proxy(context, {
6
+ get(target, prop, receiver) {
7
+ const value = Reflect.get(target, prop, receiver);
8
+ if (typeof value === 'function') {
9
+ return value.bind(context);
10
+ }
11
+ return value;
12
+ }
13
+ });
14
+ }
15
+ exports.bindAllMethodsToContext = bindAllMethodsToContext;
package/utils/index.d.ts CHANGED
@@ -0,0 +1 @@
1
+ export * from './wallet';
package/utils/index.js CHANGED
@@ -1 +1,17 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./wallet"), exports);
@@ -0,0 +1,7 @@
1
+ import { BaseWallet } from "@interchain-kit/core";
2
+ export declare const getWalletInfo: (wallet: BaseWallet) => {
3
+ name: string;
4
+ prettyName: string;
5
+ logo: string;
6
+ mobileDisabled: boolean;
7
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWalletInfo = void 0;
4
+ const getWalletInfo = (wallet) => {
5
+ return {
6
+ name: wallet.info.name,
7
+ prettyName: wallet.info.prettyName,
8
+ logo: wallet.info.logo,
9
+ mobileDisabled: true,
10
+ };
11
+ };
12
+ exports.getWalletInfo = getWalletInfo;
@@ -1,5 +0,0 @@
1
- import { useWalletManager } from "./useWalletManager";
2
- export const useActiveWallet = () => {
3
- const walletManager = useWalletManager();
4
- return walletManager.getActiveWallet();
5
- };
@@ -1 +0,0 @@
1
- export declare const useActiveWallet: () => import("@interChain-kit/core").BaseWallet;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useActiveWallet = void 0;
4
- const useWalletManager_1 = require("./useWalletManager");
5
- const useActiveWallet = () => {
6
- const walletManager = (0, useWalletManager_1.useWalletManager)();
7
- return walletManager.getActiveWallet();
8
- };
9
- exports.useActiveWallet = useActiveWallet;