@interchain-kit/react 0.0.1-beta.2 → 0.0.1-beta.20

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 (58) hide show
  1. package/README.md +127 -12
  2. package/esm/hooks/index.js +1 -0
  3. package/esm/hooks/useAccount.js +10 -6
  4. package/esm/hooks/useActiveWallet.js +8 -0
  5. package/esm/hooks/useChain.js +25 -2
  6. package/esm/hooks/useConfig.js +10 -0
  7. package/esm/hooks/useInterchainClient.js +38 -39
  8. package/esm/hooks/useOfflineSigner.js +15 -0
  9. package/esm/hooks/useWalletManager.js +2 -2
  10. package/esm/modal/modal.js +42 -13
  11. package/esm/modal/provider.js +1 -2
  12. package/esm/modal/views/Astronaut.js +4 -0
  13. package/esm/modal/views/Connected.js +32 -0
  14. package/esm/modal/views/Connecting.js +33 -0
  15. package/esm/modal/views/QRCode.js +15 -0
  16. package/esm/modal/views/Reject.js +16 -0
  17. package/esm/modal/views/WalletList.js +32 -0
  18. package/esm/modal/views/index.js +5 -0
  19. package/esm/provider.js +9 -9
  20. package/esm/utils/index.js +8 -1
  21. package/esm/utils/wallet.js +1 -0
  22. package/hooks/index.d.ts +1 -0
  23. package/hooks/index.js +1 -0
  24. package/hooks/useAccount.js +10 -6
  25. package/hooks/useActiveWallet.js +8 -0
  26. package/hooks/useChain.d.ts +2 -2
  27. package/hooks/useChain.js +25 -2
  28. package/hooks/useConfig.d.ts +8 -0
  29. package/hooks/useConfig.js +14 -0
  30. package/hooks/useInterchainClient.d.ts +8 -7
  31. package/hooks/useInterchainClient.js +38 -39
  32. package/hooks/useOfflineSigner.d.ts +4 -0
  33. package/hooks/useOfflineSigner.js +19 -0
  34. package/hooks/useWalletManager.js +1 -1
  35. package/modal/modal.js +40 -11
  36. package/modal/provider.js +1 -2
  37. package/modal/views/Astronaut.d.ts +2 -0
  38. package/modal/views/Astronaut.js +8 -0
  39. package/modal/views/Connected.d.ts +4 -0
  40. package/modal/views/Connected.js +37 -0
  41. package/modal/views/Connecting.d.ts +4 -0
  42. package/modal/views/Connecting.js +38 -0
  43. package/modal/views/QRCode.d.ts +2 -0
  44. package/modal/views/QRCode.js +20 -0
  45. package/modal/views/Reject.d.ts +4 -0
  46. package/modal/views/Reject.js +21 -0
  47. package/modal/views/WalletList.d.ts +2 -0
  48. package/modal/views/WalletList.js +37 -0
  49. package/modal/views/index.d.ts +5 -0
  50. package/modal/views/index.js +21 -0
  51. package/package.json +7 -3
  52. package/provider.d.ts +6 -6
  53. package/provider.js +8 -8
  54. package/types/chain.d.ts +18 -9
  55. package/utils/index.d.ts +7 -0
  56. package/utils/index.js +11 -0
  57. package/utils/wallet.d.ts +1 -0
  58. package/utils/wallet.js +17 -0
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WalletListContent = exports.WalletListHeader = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("@interchain-ui/react");
6
+ const provider_1 = require("../provider");
7
+ const hooks_1 = require("../../hooks");
8
+ const WalletListHeader = () => {
9
+ const { close } = (0, provider_1.useWalletModal)();
10
+ return ((0, jsx_runtime_1.jsx)(react_1.ConnectModalHead, { title: "Select your wallet", hasBackButton: false, onClose: close, closeButtonProps: { onClick: close } }));
11
+ };
12
+ exports.WalletListHeader = WalletListHeader;
13
+ const WalletListContent = () => {
14
+ const walletManager = (0, hooks_1.useWalletManager)();
15
+ const { close } = (0, provider_1.useWalletModal)();
16
+ const wallets = walletManager.wallets.map((w) => {
17
+ return ({
18
+ name: w.option.name,
19
+ prettyName: w.option.prettyName,
20
+ logo: w.option.logo,
21
+ mobileDisabled: true,
22
+ shape: 'list',
23
+ originalWallet: w
24
+ });
25
+ });
26
+ const onWalletClick = async (wallet) => {
27
+ try {
28
+ await walletManager.connect(wallet.option.name);
29
+ close();
30
+ }
31
+ catch (error) {
32
+ console.log(error);
33
+ }
34
+ };
35
+ return (0, jsx_runtime_1.jsx)(react_1.ConnectModalWalletList, { wallets: wallets, onWalletItemClick: onWalletClick });
36
+ };
37
+ exports.WalletListContent = WalletListContent;
@@ -0,0 +1,5 @@
1
+ export * from './Connecting';
2
+ export * from './WalletList';
3
+ export * from './Connected';
4
+ export * from './Reject';
5
+ export * from './QRCode';
@@ -0,0 +1,21 @@
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("./Connecting"), exports);
18
+ __exportStar(require("./WalletList"), exports);
19
+ __exportStar(require("./Connected"), exports);
20
+ __exportStar(require("./Reject"), exports);
21
+ __exportStar(require("./QRCode"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interchain-kit/react",
3
- "version": "0.0.1-beta.2",
3
+ "version": "0.0.1-beta.20",
4
4
  "author": "cosmology-tech <developers@cosmology.zone>",
5
5
  "description": "interchain-kit wallet connector react package",
6
6
  "main": "index.js",
@@ -32,11 +32,15 @@
32
32
  "keywords": [],
33
33
  "dependencies": {
34
34
  "@chain-registry/v2-types": "^0.49.6",
35
- "@interchain-kit/core": "0.0.1-beta.2",
35
+ "@interchain-kit/core": "0.0.1-beta.20",
36
+ "@interchain-ui/react": "1.24.0",
37
+ "@interchainjs/cosmos-types": "0.0.1-beta.9",
38
+ "@interchainjs/injective": "0.0.1-beta.13",
36
39
  "@types/react": "^18.3.3",
37
40
  "@types/react-dom": "^18.3.0",
41
+ "interchainjs": "0.0.1-beta.14",
38
42
  "react": "^18.3.1",
39
43
  "react-dom": "^18.3.1"
40
44
  },
41
- "gitHead": "c501ca36b82d71763b563290dd71a3adec50c31f"
45
+ "gitHead": "dcaa8a6ee83cf747b3987746657ec50886766944"
42
46
  }
package/provider.d.ts CHANGED
@@ -1,10 +1,10 @@
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[];
@@ -12,6 +12,6 @@ type InterchianWalletProviderProps = {
12
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
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,14 @@ 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
+ return ((0, jsx_runtime_1.jsx)(InterchainWalletContext.Provider, { value: { walletManager }, children: (0, jsx_runtime_1.jsx)(modal_1.WalletModalProvider, { children: children }) }));
19
19
  };
20
20
  exports.ChainProvider = ChainProvider;
21
- const useInterChainWalletContext = () => {
22
- const context = (0, react_2.useContext)(InterChainWalletContext);
21
+ const useInterchainWalletContext = () => {
22
+ const context = (0, react_2.useContext)(InterchainWalletContext);
23
23
  if (!context) {
24
- throw new Error('useInterChainWalletContext must be used within a InterChainProvider');
24
+ throw new Error("useInterChainWalletContext must be used within a InterChainProvider");
25
25
  }
26
26
  return context;
27
27
  };
28
- exports.useInterChainWalletContext = useInterChainWalletContext;
28
+ exports.useInterchainWalletContext = useInterchainWalletContext;
package/types/chain.d.ts CHANGED
@@ -1,22 +1,31 @@
1
- import { CosmWasmSigningClient } from 'interchainjs/cosmwasm-stargate';
2
- import { StargateClient } from '@cosmjs/stargate';
1
+ import { HttpEndpoint } from '@interchainjs/types';
2
+ import { CosmWasmSigningClient } from 'interchainjs/cosmwasm';
3
3
  import { SigningClient } from 'interchainjs/signing-client';
4
4
  import { RpcQuery } from 'interchainjs/query/rpc';
5
- import { StargateSigningClient } from 'interchainjs/stargate';
6
- import { HttpEndpoint } from '@cosmjs/stargate';
5
+ import { CosmosSigningClient } from 'interchainjs/cosmos';
7
6
  import { Chain, AssetList } from '@chain-registry/v2-types';
8
- import { BaseWallet } from '@interChain-kit/core';
7
+ import { BaseWallet, WalletState } from '@interchain-kit/core';
8
+ export type CosmosKitUseChainReturnType = {
9
+ connect: () => void;
10
+ openView: () => void;
11
+ closeView: () => void;
12
+ getRpcEndpoint: () => Promise<string | HttpEndpoint>;
13
+ status: WalletState;
14
+ username: string;
15
+ message: string;
16
+ getSigningCosmWasmClient: () => Promise<CosmWasmSigningClient>;
17
+ getSigningCosmosClient: () => Promise<CosmosSigningClient>;
18
+ };
9
19
  export type UseChainReturnType = {
10
20
  chain: Chain;
11
21
  assetList: AssetList;
12
22
  address: string;
13
23
  wallet: BaseWallet;
14
24
  rpcEndpoint: string | HttpEndpoint;
15
- client: RpcQuery;
25
+ queryClient: RpcQuery;
16
26
  signingClient: SigningClient;
17
- stargateClient: StargateClient;
18
- stargateSigningClient: StargateSigningClient;
19
- cosmWasmSigningClient: CosmWasmSigningClient;
27
+ signingCosmosClient: CosmosSigningClient;
28
+ signingCosmWasmClient: CosmWasmSigningClient;
20
29
  isLoading: boolean;
21
30
  error: unknown;
22
31
  };
package/utils/index.d.ts CHANGED
@@ -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
+ };
package/utils/index.js CHANGED
@@ -1 +1,12 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWalletInfo = void 0;
4
+ const getWalletInfo = (wallet) => {
5
+ return {
6
+ name: wallet.option.name,
7
+ prettyName: wallet.option.prettyName,
8
+ logo: wallet.option.logo,
9
+ mobileDisabled: true,
10
+ };
11
+ };
12
+ exports.getWalletInfo = getWalletInfo;
@@ -0,0 +1 @@
1
+ export * from './wallet';
@@ -0,0 +1,17 @@
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);