@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.
- package/README.md +165 -12
- package/esm/hooks/index.js +3 -1
- package/esm/hooks/useAccount.js +20 -19
- package/esm/hooks/useChain.js +59 -20
- package/esm/hooks/useChainWallet.js +33 -10
- package/esm/hooks/useCurrentChainWallet.js +11 -0
- package/esm/hooks/useCurrentWallet.js +18 -0
- package/esm/hooks/useInterchainClient.js +14 -50
- package/esm/hooks/useOfflineSigner.js +14 -2
- package/esm/hooks/useRpcEndpoint.js +26 -0
- package/esm/hooks/useWalletManager.js +4 -3
- package/esm/modal/modal.js +71 -12
- package/esm/modal/provider.js +1 -2
- package/esm/modal/views/Astronaut.js +4 -0
- package/esm/modal/views/Connected.js +33 -0
- package/esm/modal/views/Connecting.js +24 -0
- package/esm/modal/views/NotExist.js +44 -0
- package/esm/modal/views/QRCode.js +20 -0
- package/esm/modal/views/Reject.js +14 -0
- package/esm/modal/views/WalletList.js +40 -0
- package/esm/modal/views/index.js +6 -0
- package/esm/provider.js +12 -9
- package/esm/types/index.js +1 -0
- package/esm/types/sign-client.js +1 -0
- package/esm/utils/helpers.js +11 -0
- package/esm/utils/index.js +1 -1
- package/esm/utils/wallet.js +8 -0
- package/hooks/index.d.ts +3 -1
- package/hooks/index.js +3 -1
- package/hooks/useAccount.d.ts +6 -2
- package/hooks/useAccount.js +20 -19
- package/hooks/useChain.d.ts +2 -2
- package/hooks/useChain.js +59 -20
- package/hooks/useChainWallet.d.ts +2 -2
- package/hooks/useChainWallet.js +33 -10
- package/hooks/useConfig.d.ts +1 -1
- package/hooks/useCurrentChainWallet.d.ts +2 -0
- package/hooks/useCurrentChainWallet.js +15 -0
- package/hooks/useCurrentWallet.d.ts +2 -0
- package/hooks/useCurrentWallet.js +22 -0
- package/hooks/useInterchainClient.d.ts +3 -11
- package/hooks/useInterchainClient.js +14 -50
- package/hooks/useOfflineSigner.d.ts +3 -0
- package/hooks/useOfflineSigner.js +14 -2
- package/hooks/useRpcEndpoint.d.ts +6 -0
- package/hooks/useRpcEndpoint.js +30 -0
- package/hooks/useWalletManager.js +3 -2
- package/modal/modal.js +70 -11
- package/modal/provider.js +1 -2
- package/modal/views/Astronaut.d.ts +2 -0
- package/modal/views/Astronaut.js +8 -0
- package/modal/views/Connected.d.ts +4 -0
- package/modal/views/Connected.js +38 -0
- package/modal/views/Connecting.d.ts +8 -0
- package/modal/views/Connecting.js +29 -0
- package/modal/views/NotExist.d.ts +8 -0
- package/modal/views/NotExist.js +49 -0
- package/modal/views/QRCode.d.ts +4 -0
- package/modal/views/QRCode.js +25 -0
- package/modal/views/Reject.d.ts +8 -0
- package/modal/views/Reject.js +19 -0
- package/modal/views/WalletList.d.ts +5 -0
- package/modal/views/WalletList.js +45 -0
- package/modal/views/index.d.ts +6 -0
- package/modal/views/index.js +22 -0
- package/package.json +15 -5
- package/provider.d.ts +8 -8
- package/provider.js +12 -9
- package/types/chain.d.ts +16 -10
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/sign-client.d.ts +2 -0
- package/types/sign-client.js +2 -0
- package/types/wallet.d.ts +1 -1
- package/utils/helpers.d.ts +1 -0
- package/utils/helpers.js +15 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +16 -0
- package/utils/wallet.d.ts +7 -0
- package/utils/wallet.js +12 -0
- package/esm/hooks/useActiveWallet.js +0 -5
- package/hooks/useActiveWallet.d.ts +0 -1
- package/hooks/useActiveWallet.js +0 -9
package/provider.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { BaseWallet, SignerOptions, WalletManager, EndpointOptions } from
|
|
3
|
-
import { AssetList, Chain } from
|
|
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
|
|
7
|
+
type InterchainWalletProviderProps = {
|
|
8
8
|
chains: Chain[];
|
|
9
9
|
assetLists: AssetList[];
|
|
10
10
|
wallets: BaseWallet[];
|
|
11
|
-
signerOptions
|
|
12
|
-
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 }:
|
|
16
|
-
export declare const
|
|
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.
|
|
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("@
|
|
7
|
+
const core_1 = require("@interchain-kit/core");
|
|
8
8
|
const modal_1 = require("./modal");
|
|
9
|
-
const
|
|
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
|
-
|
|
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
|
|
22
|
-
const context = (0, react_2.useContext)(
|
|
24
|
+
const useInterchainWalletContext = () => {
|
|
25
|
+
const context = (0, react_2.useContext)(InterchainWalletContext);
|
|
23
26
|
if (!context) {
|
|
24
|
-
throw new Error(
|
|
27
|
+
throw new Error("useInterChainWalletContext must be used within a InterChainProvider");
|
|
25
28
|
}
|
|
26
29
|
return context;
|
|
27
30
|
};
|
|
28
|
-
exports.
|
|
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
|
-
|
|
28
|
-
|
|
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
package/types/index.js
CHANGED
package/types/wallet.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function bindAllMethodsToContext<T extends object>(context: T): T;
|
package/utils/helpers.js
ADDED
|
@@ -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);
|
package/utils/wallet.js
ADDED
|
@@ -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 +0,0 @@
|
|
|
1
|
-
export declare const useActiveWallet: () => import("@interChain-kit/core").BaseWallet;
|
package/hooks/useActiveWallet.js
DELETED
|
@@ -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;
|