@interchain-kit/react 0.0.1-beta.62 → 0.0.1-beta.64

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2024 Cosmology Developers <developers@cosmology.zone>
3
+ Copyright (c) 2024 Cosmology Developers <developers@hyperweb.io>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,6 +1,22 @@
1
- <p align="center">
2
- <img src="https://user-images.githubusercontent.com/545047/188804067-28e67e5e-0214-4449-ab04-2e0c564a6885.svg" width="80"><br />
3
- @interchain-kit/react
1
+ # @interchain-kit/react
2
+
3
+ <p align="center" width="100%">
4
+ <img height="90" src="https://user-images.githubusercontent.com/545047/190171432-5526db8f-9952-45ce-a745-bea4302f912b.svg" />
5
+ </p>
6
+
7
+ <p align="center" width="100%">
8
+ <a href="https://github.com/hyperweb-io/cosmos-kit/actions/workflows/run-tests.yml">
9
+ <img height="20" src="https://github.com/hyperweb-io/cosmos-kit/actions/workflows/run-tests.yml/badge.svg" />
10
+ </a>
11
+ <a href="https://github.com/hyperweb-io/lib-count">
12
+ <img height="20" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fhyperweb-io%2Flib-count%2Fmain%2Foutput%2Fbadges%2Fproducts%2Fcosmos-kit%2Ftotal.json"/>
13
+ </a>
14
+ <a href="https://github.com/hyperweb-io/lib-count">
15
+ <img height="20" src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fhyperweb-io%2Flib-count%2Fmain%2Foutput%2Fbadges%2Fproducts%2Fcosmos-kit%2Fmonthly.json"/>
16
+ </a>
17
+ <br />
18
+ <a href="https://github.com/hyperweb-io/cosmos-kit/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-BSD%203--Clause%20Clear-blue.svg"></a>
19
+ <a href="https://www.npmjs.com/package/cosmos-kit"><img height="20" src="https://img.shields.io/github/package-json/v/hyperweb-io/cosmos-kit?filename=packages%2Fcosmos-kit%2Fpackage.json"></a>
4
20
  </p>
5
21
 
6
22
  ## Install
@@ -89,21 +105,13 @@ export default App;
89
105
  ```js
90
106
 
91
107
  const chainName = 'cosmoshub'
92
- const { chain, assetList, address, wallet, queryClient, signingClient } = useChain(chainName)
108
+ const { chain, assetList, address, wallet } = useChain(chainName)
93
109
 
94
110
  console.log(wallet) //keprl extension wallet info
95
111
  console.log(chain) // chain info for cosmoshub
96
112
  console.log(assetList) // assets info for cosmoshub
97
113
  console.log(address) // address for cosmoshub in keplr-extension wallet
98
114
 
99
- //query
100
- const { balance } = await queryClient.balance({
101
- address,
102
- denom: 'uosmo'
103
- })
104
- console.log(balance)
105
- // { amount: 23423, denom: 'uosmos' }
106
-
107
115
  ```
108
116
 
109
117
  ### useChainWallet
@@ -141,36 +149,21 @@ function App() {
141
149
  export default App;
142
150
  ```
143
151
 
144
- ### useCurrentWallet
145
- ```js
146
- const wallet = useCurrentWallet()
147
-
148
- console.log(wallet) // current connected wallet
149
-
150
- ```
152
+ ### useChains
151
153
 
152
- ### useAccount
153
154
  ```js
154
- const account = useAccount('cosmoshub', 'keplr-extension')
155
-
156
- console.log(account.address) // cosmoshub address in keplr-extension wallet
157
-
155
+ WIP
158
156
  ```
159
-
160
- ### useOfflineSigner
157
+ ### use wallet methods
161
158
  ```js
162
- const offlineSigner = useOfflineSigner('cosmoshub', 'keplr-extension')
163
-
164
- console.log(offlineSigner) // cosmoshub offlineSigner in keplr-extension wallet
165
- ```
159
+ const { wallet } = useChain('osmosis')
166
160
 
167
- ### useChains
161
+ //use method from wallet that you select
162
+ await wallet.signAmino(chainId, signAddress, stdDoc)
163
+ await wallet.verifyArbitrary(chainId, signAddress, stdDoc)
168
164
 
169
- ```js
170
- WIP
171
165
  ```
172
166
 
173
-
174
167
  ## Developing
175
168
 
176
169
  When first cloning the repo:
@@ -186,25 +179,28 @@ Or if you want to make your dev process smoother, you can run:
186
179
  ```sh
187
180
  yarn
188
181
  # build the dev packages with .map files, this enables navigation from references to their source code between packages.
189
- yarn build:dev
182
+ yarn watch:dev
190
183
  ```
191
184
 
192
- ## Related
185
+ ## Interchain JavaScript Stack
193
186
 
194
- Checkout these related projects:
187
+ A unified toolkit for building applications and smart contracts in the Interchain ecosystem ⚛️
195
188
 
196
- * [@cosmology/telescope](https://github.com/cosmology-tech/telescope) Your Frontend Companion for Building with TypeScript with Cosmos SDK Modules.
197
- * [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) Convert your CosmWasm smart contracts into dev-friendly TypeScript classes.
198
- * [chain-registry](https://github.com/cosmology-tech/chain-registry) Everything from token symbols, logos, and IBC denominations for all assets you want to support in your application.
199
- * [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) Experience the convenience of connecting with a variety of web3 wallets through a single, streamlined interface.
200
- * [create-cosmos-app](https://github.com/cosmology-tech/create-cosmos-app) Set up a modern Cosmos app by running one command.
201
- * [interchain-ui](https://github.com/cosmology-tech/interchain-ui) The Interchain Design System, empowering developers with a flexible, easy-to-use UI kit.
202
- * [starship](https://github.com/cosmology-tech/starship) Unified Testing and Development for the Interchain.
189
+ | Category | Tools | Description |
190
+ |----------------------|------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
191
+ | **Chain Information** | [**Chain Registry**](https://github.com/hyperweb-io/chain-registry), [**Utils**](https://www.npmjs.com/package/@chain-registry/utils), [**Client**](https://www.npmjs.com/package/@chain-registry/client) | Everything from token symbols, logos, and IBC denominations for all assets you want to support in your application. |
192
+ | **Wallet Connectors**| [**Interchain Kit**](https://github.com/hyperweb-io/interchain-kit)<sup>beta</sup>, [**Cosmos Kit**](https://github.com/hyperweb-io/cosmos-kit) | Experience the convenience of connecting with a variety of web3 wallets through a single, streamlined interface. |
193
+ | **Signing Clients** | [**InterchainJS**](https://github.com/hyperweb-io/interchainjs)<sup>beta</sup>, [**CosmJS**](https://github.com/cosmos/cosmjs) | A single, universal signing interface for any network |
194
+ | **SDK Clients** | [**Telescope**](https://github.com/hyperweb-io/telescope) | Your Frontend Companion for Building with TypeScript with Cosmos SDK Modules. |
195
+ | **Starter Kits** | [**Create Interchain App**](https://github.com/hyperweb-io/create-interchain-app)<sup>beta</sup>, [**Create Cosmos App**](https://github.com/hyperweb-io/create-cosmos-app) | Set up a modern Interchain app by running one command. |
196
+ | **UI Kits** | [**Interchain UI**](https://github.com/hyperweb-io/interchain-ui) | The Interchain Design System, empowering developers with a flexible, easy-to-use UI kit. |
197
+ | **Testing Frameworks** | [**Starship**](https://github.com/hyperweb-io/starship) | Unified Testing and Development for the Interchain. |
198
+ | **TypeScript Smart Contracts** | [**Create Hyperweb App**](https://github.com/hyperweb-io/create-hyperweb-app) | Build and deploy full-stack blockchain applications with TypeScript |
199
+ | **CosmWasm Contracts** | [**CosmWasm TS Codegen**](https://github.com/CosmWasm/ts-codegen) | Convert your CosmWasm smart contracts into dev-friendly TypeScript classes. |
203
200
 
204
201
  ## Credits
205
202
 
206
- 🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.zone/validator)
207
-
203
+ 🛠 Built by Hyperweb (formerly Cosmology) — if you like our tools, please checkout and contribute to [our github ⚛️](https://github.com/hyperweb-io)
208
204
 
209
205
  ## Disclaimer
210
206
 
@@ -12,7 +12,6 @@ export const useChain = (chainName) => {
12
12
  const wallet = getWalletByName(currentWalletName);
13
13
  const chainWalletStateToShow = getChainWalletState(currentWalletName, chainName);
14
14
  const { open, close } = useWalletModal();
15
- console.log({ chainName, chain });
16
15
  return {
17
16
  //for migration cosmos kit
18
17
  connect: () => {
@@ -3,15 +3,21 @@ import { ConnectedContent, ConnectedHeader, ConnectingContent, ConnectingHeader,
3
3
  import { useWalletModal } from "./provider";
4
4
  import { useChainWallet, useWalletManager } from "../hooks";
5
5
  import { useEffect, useMemo, useState } from "react";
6
- import { WalletState } from "@interchain-kit/core";
6
+ import { WalletState, WCWallet } from "@interchain-kit/core";
7
7
  import { ConnectModal } from "@interchain-ui/react";
8
8
  export const WalletModal = () => {
9
+ const [qrCode, setQRCode] = useState(null);
9
10
  const { currentWalletName, currentChainName, wallets, connect, getAccount, setCurrentWalletName, } = useWalletManager();
10
11
  const { modalIsOpen, open, close } = useWalletModal();
11
12
  const [modalType, setModalType] = useState("wallet-list");
12
13
  const [selectedWallet, setSelectedWallet] = useState(null);
13
14
  const { chain, status, wallet } = useChainWallet(currentChainName, currentWalletName);
14
15
  const handleConnect = async () => {
16
+ if (wallet.originalWallet instanceof WCWallet) {
17
+ wallet.originalWallet.setOnPairingUriCreatedCallback((uri) => {
18
+ setQRCode(uri);
19
+ });
20
+ }
15
21
  await connect(selectedWallet?.info?.name, chain.chainName);
16
22
  await getAccount(selectedWallet?.info?.name, chain.chainName);
17
23
  setSelectedWallet(null);
@@ -42,6 +48,9 @@ export const WalletModal = () => {
42
48
  if (status === WalletState.Disconnected) {
43
49
  setModalType("wallet-list");
44
50
  }
51
+ if (qrCode) {
52
+ setModalType("qr-code");
53
+ }
45
54
  }
46
55
  }, [
47
56
  currentWalletName,
@@ -49,6 +58,7 @@ export const WalletModal = () => {
49
58
  status,
50
59
  modalIsOpen,
51
60
  selectedWallet,
61
+ qrCode
52
62
  ]);
53
63
  const goBackList = () => setModalType("wallet-list");
54
64
  const { header, content } = useMemo(() => {
package/hooks/useChain.js CHANGED
@@ -15,7 +15,6 @@ const useChain = (chainName) => {
15
15
  const wallet = getWalletByName(currentWalletName);
16
16
  const chainWalletStateToShow = getChainWalletState(currentWalletName, chainName);
17
17
  const { open, close } = (0, modal_1.useWalletModal)();
18
- console.log({ chainName, chain });
19
18
  return {
20
19
  //for migration cosmos kit
21
20
  connect: () => {
package/modal/modal.js CHANGED
@@ -9,12 +9,18 @@ const react_1 = require("react");
9
9
  const core_1 = require("@interchain-kit/core");
10
10
  const react_2 = require("@interchain-ui/react");
11
11
  const WalletModal = () => {
12
+ const [qrCode, setQRCode] = (0, react_1.useState)(null);
12
13
  const { currentWalletName, currentChainName, wallets, connect, getAccount, setCurrentWalletName, } = (0, hooks_1.useWalletManager)();
13
14
  const { modalIsOpen, open, close } = (0, provider_1.useWalletModal)();
14
15
  const [modalType, setModalType] = (0, react_1.useState)("wallet-list");
15
16
  const [selectedWallet, setSelectedWallet] = (0, react_1.useState)(null);
16
17
  const { chain, status, wallet } = (0, hooks_1.useChainWallet)(currentChainName, currentWalletName);
17
18
  const handleConnect = async () => {
19
+ if (wallet.originalWallet instanceof core_1.WCWallet) {
20
+ wallet.originalWallet.setOnPairingUriCreatedCallback((uri) => {
21
+ setQRCode(uri);
22
+ });
23
+ }
18
24
  await connect(selectedWallet?.info?.name, chain.chainName);
19
25
  await getAccount(selectedWallet?.info?.name, chain.chainName);
20
26
  setSelectedWallet(null);
@@ -45,6 +51,9 @@ const WalletModal = () => {
45
51
  if (status === core_1.WalletState.Disconnected) {
46
52
  setModalType("wallet-list");
47
53
  }
54
+ if (qrCode) {
55
+ setModalType("qr-code");
56
+ }
48
57
  }
49
58
  }, [
50
59
  currentWalletName,
@@ -52,6 +61,7 @@ const WalletModal = () => {
52
61
  status,
53
62
  modalIsOpen,
54
63
  selectedWallet,
64
+ qrCode
55
65
  ]);
56
66
  const goBackList = () => setModalType("wallet-list");
57
67
  const { header, content } = (0, react_1.useMemo)(() => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@interchain-kit/react",
3
- "version": "0.0.1-beta.62",
4
- "author": "cosmology-tech <developers@cosmology.zone>",
3
+ "version": "0.0.1-beta.64",
4
+ "author": "Hyperweb <developers@hyperweb.io>",
5
5
  "description": "interchain-kit wallet connector react package",
6
6
  "main": "index.js",
7
7
  "module": "esm/index.js",
@@ -33,7 +33,7 @@
33
33
  "keywords": [],
34
34
  "dependencies": {
35
35
  "@chain-registry/v2-types": "^0.53.40",
36
- "@interchain-kit/core": "0.0.1-beta.62",
36
+ "@interchain-kit/core": "^0.0.1-beta.64",
37
37
  "@interchain-ui/react": "1.26.1",
38
38
  "@interchainjs/cosmos": "1.6.3",
39
39
  "@interchainjs/cosmos-types": "1.6.3",
@@ -46,5 +46,5 @@
46
46
  "react-dom": "^18.3.1",
47
47
  "zustand": "^5.0.3"
48
48
  },
49
- "gitHead": "b63ee16e1bbb876bfa9d683e32eb687b0bf10838"
49
+ "gitHead": "5d5934c835bbe83fc3cfd2aa9bb6cfa617722019"
50
50
  }
package/types/chain.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import { HttpEndpoint } from '@interchainjs/types';
2
2
  import { Chain, AssetList } from '@chain-registry/v2-types';
3
- import { BaseWallet, WalletState } from '@interchain-kit/core';
3
+ import { WalletState } from '@interchain-kit/core';
4
4
  import { SigningClient } from './sign-client';
5
+ import { ChainWallet } from '../store/chain-wallet';
5
6
  export type CosmosKitUseChainReturnType = {
6
7
  connect: () => void;
7
8
  disconnect: () => void;
@@ -17,7 +18,7 @@ export type UseChainReturnType = {
17
18
  chain: Chain;
18
19
  assetList: AssetList;
19
20
  address: string;
20
- wallet: BaseWallet;
21
+ wallet: ChainWallet;
21
22
  rpcEndpoint: string | HttpEndpoint;
22
23
  getSigningClient: () => Promise<SigningClient>;
23
24
  } & CosmosKitUseChainReturnType;