@xchainjs/xchain-thorchain 0.22.1 → 0.24.0-alpha.1

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/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ # v0.24.0 (2022-03-15)
2
+
3
+ ## Breaking Changes
4
+
5
+ - `buildDepositTx` now returns `proto.cosmos.tx.v1beta1.TxBody` from `@cosmos-client/core`
6
+
7
+ # v0.23.0 (2022-03-08)
8
+
9
+ ## Add
10
+
11
+ - Helpers `getChainId` + `getChainIds`
12
+
13
+ ## Breaking change
14
+
15
+ - `chainIds: ChainIds` is required to initialize `Client`
16
+
17
+ ## Fix
18
+
19
+ - Request fees from THORChain and use `defaultFees` in case of server errors only
20
+ - Fix `defaultFees` to be 0.02 RUNE
21
+
22
+ # v0.22.2 (2022-02-17)
23
+
24
+ ## Fix
25
+
26
+ - Request fees from THORChain and use `defaultFees` in case of server errors only
27
+ - Fix `defaultFees` to be 0.02 RUNE
28
+
1
29
  # v0.22.1 (2022-02-16)
2
30
 
3
31
  ## Fix
package/README.md CHANGED
@@ -11,10 +11,10 @@ yarn add @xchainjs/xchain-thorchain
11
11
  Following peer dependencies have to be installed into your project. These are not included in `@xchainjs/xchain-thorchain`.
12
12
 
13
13
  ```
14
- yarn add @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util @xchainjs/xchain-cosmos axios cosmos-client
14
+ yarn add @xchainjs/xchain-client @xchainjs/xchain-crypto @xchainjs/xchain-util @xchainjs/xchain-cosmos axios cosmos-client bech32-buffer
15
15
  ```
16
16
 
17
- Important note: Make sure to install same version of `cosmos-client` as `xchain-thorchain` is using (currently `cosmos-client@0.39.2` ). In other case things might break.
17
+ Important note: Make sure to install same version of `@cosmos-client/core` as `xchain-thorchain` is using (currently `@cosmos-client/core@0.45.1` ). In other case things might break.
18
18
 
19
19
  ## Thorchain Client Testing
20
20
 
@@ -48,17 +48,7 @@ const client = new Client({ network: Network.Testnet, phrase: 'my secret phrase'
48
48
 
49
49
  // get address
50
50
  const address = client.getAddress()
51
- console.log('address:', address) // address: tthor13gym97tmw3axj3hpewdggy2cr288d3qffr8skg
52
-
53
- // get private key
54
- const privKey = client.getPrivKey()
55
- console.log('privKey:', privKey.toBase64()) // privKey: {your-private-key} base64 encoded
56
- console.log('privKey:', privKey.toBuffer()) // privKey: {your-private-key} as `Buffer`
57
-
58
- // get public key
59
- const pubKey = client.getPubKey()
60
- console.log('pubKey:', pubKey.toBase64()) // pubKey: {your-public-key} base64 encoded
61
- console.log('pubKey:', pubKey.toBuffer()) // pubKey: {your-public-key} as `Buffer`
51
+ console.log('address:', client.getAddress()) // address: tthor13gym97tmw3axj3hpewdggy2cr288d3qffr8skg
62
52
 
63
53
  // get balances
64
54
  const balances = await client.getBalance(address)
@@ -74,3 +64,20 @@ console.log('tx asset:', tx.asset) // tx asset: { chain: 'THOR', symbol: 'RUNE',
74
64
  ```
75
65
 
76
66
  For more examples check out tests in `./__tests__/client.test.ts`
67
+
68
+ ## Creating protobuffer typescript bindings
69
+
70
+ In order for this library to de/serialize proto3 structures, you can use the following to create bindings
71
+
72
+ 1. `git clone https://gitlab.com/thorchain/thornode`
73
+ 2. run the following (adjust the paths acordingly) to generate a typecript file for MsgDeposit
74
+ ```bash
75
+ yarn run pbjs -w commonjs -t static-module <path to repo>/thornode/proto/thorchain/v1/x/thorchain/types/msg_deposit.proto <path to repo>/thornode/proto/thorchain/v1/common/common.proto <path to repo>/thornode/proto/thorchain/v1/x/thorchain/types/msg_send.proto <path to repo>/thornode/third_party/proto/cosmos/base/v1beta1/coin.proto -o src/types/proto/MsgCompiled.js
76
+ ```
77
+ 3. run the following to generate the .d.ts file
78
+ ```bash
79
+ yarn run pbts src/types/proto/MsgCompiled.js -o src/types/proto/MsgCompiled.d.ts
80
+ ```
81
+
82
+ Alternatively, you can run the convenience script: `genMsgs.sh`, which will overwrite the proto/js files in types/proto. This should only be done and checked in if changes were made to the upstream Msg in the THORNode repo.
83
+
package/lib/client.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { Address, Balance, Fees, Network, Tx, TxHash, TxHistoryParams, TxParams, TxsPage, XChainClient, XChainClientParams } from '@xchainjs/xchain-client';
1
+ import { cosmosclient, proto } from '@cosmos-client/core';
2
+ import { Address, Balance, BaseXChainClient, Fees, Network, Tx, TxHash, TxHistoryParams, TxParams, TxsPage, XChainClient, XChainClientParams } from '@xchainjs/xchain-client';
2
3
  import { CosmosSDKClient, RPCTxResult } from '@xchainjs/xchain-cosmos';
3
4
  import { Asset } from '@xchainjs/xchain-util';
4
- import { PrivKey, PubKey } from 'cosmos-client';
5
- import { StdTx } from 'cosmos-client/x/auth';
6
5
  import { ChainId, ClientUrl, DepositParam, ExplorerUrls, NodeUrl, ThorchainClientParams, TxOfflineParams } from './types';
7
6
  /**
8
7
  * Interface for custom Thorchain client
@@ -17,13 +16,10 @@ export interface ThorchainClient {
17
16
  /**
18
17
  * Custom Thorchain Client
19
18
  */
20
- declare class Client implements ThorchainClient, XChainClient {
21
- private network;
19
+ declare class Client extends BaseXChainClient implements ThorchainClient, XChainClient {
22
20
  private clientUrl;
23
21
  private explorerUrls;
24
22
  private chainIds;
25
- private phrase;
26
- private rootDerivationPaths;
27
23
  private cosmosClient;
28
24
  /**
29
25
  * Constructor
@@ -36,12 +32,6 @@ declare class Client implements ThorchainClient, XChainClient {
36
32
  * @throws {"Invalid phrase"} Thrown if the given phase is invalid.
37
33
  */
38
34
  constructor({ network, phrase, clientUrl, explorerUrls, rootDerivationPaths, chainIds, }: XChainClientParams & ThorchainClientParams);
39
- /**
40
- * Purge client.
41
- *
42
- * @returns {void}
43
- */
44
- purgeClient(): void;
45
35
  /**
46
36
  * Set/update the current network.
47
37
  *
@@ -52,12 +42,6 @@ declare class Client implements ThorchainClient, XChainClient {
52
42
  * Thrown if network has not been set before.
53
43
  */
54
44
  setNetwork(network: Network): void;
55
- /**
56
- * Get the current network.
57
- *
58
- * @returns {Network}
59
- */
60
- getNetwork(): Network;
61
45
  /**
62
46
  * Set/update the client URL.
63
47
  *
@@ -120,23 +104,6 @@ declare class Client implements ThorchainClient, XChainClient {
120
104
  * @returns {string} The explorer url for the given transaction id.
121
105
  */
122
106
  getExplorerTxUrl(txID: string): string;
123
- /**
124
- * Set/update a new phrase
125
- *
126
- * @param {string} phrase A new phrase.
127
- * @returns {Address} The address from the given phrase
128
- *
129
- * @throws {"Invalid phrase"}
130
- * Thrown if the given phase is invalid.
131
- */
132
- setPhrase(phrase: string, walletIndex?: number): Address;
133
- /**
134
- * Get getFullDerivationPath
135
- *
136
- * @param {number} index the HD wallet index
137
- * @returns {string} The bitcoin derivation path based on the network.
138
- */
139
- getFullDerivationPath(index: number): string;
140
107
  /**
141
108
  * Get private key
142
109
  *
@@ -146,7 +113,7 @@ declare class Client implements ThorchainClient, XChainClient {
146
113
  * @throws {"Phrase not set"}
147
114
  * Throws an error if phrase has not been set before
148
115
  * */
149
- getPrivKey(index?: number): PrivKey;
116
+ getPrivateKey(index?: number): proto.cosmos.crypto.secp256k1.PrivKey;
150
117
  /**
151
118
  * Get public key
152
119
  *
@@ -157,7 +124,7 @@ declare class Client implements ThorchainClient, XChainClient {
157
124
  * @throws {"Phrase not set"}
158
125
  * Throws an error if phrase has not been set before
159
126
  **/
160
- getPubKey(index?: number): PubKey;
127
+ getPubKey(index?: number): cosmosclient.PubKey;
161
128
  /**
162
129
  * Get the current address.
163
130
  *
@@ -228,11 +195,11 @@ declare class Client implements ThorchainClient, XChainClient {
228
195
  * Transfer without broadcast balances with MsgSend
229
196
  *
230
197
  * @param {TxOfflineParams} params The transfer offline options.
231
- * @returns {StdTx} The signed transaction.
198
+ * @returns {string} The signed transaction bytes.
232
199
  */
233
- transferOffline({ walletIndex, asset, amount, recipient, memo, from_rune_balance, from_asset_balance, from_account_number, from_sequence, }: TxOfflineParams): Promise<StdTx>;
200
+ transferOffline({ walletIndex, asset, amount, recipient, memo, from_rune_balance, from_asset_balance, from_account_number, from_sequence, }: TxOfflineParams): Promise<string>;
234
201
  /**
235
- * Get the fees.
202
+ * Gets fees from Node
236
203
  *
237
204
  * @returns {Fees}
238
205
  */