@xchainjs/xchain-thorchain 0.19.1 → 0.19.4

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,4 +1,26 @@
1
- # v.0.19.1 (2021-09-25)
1
+ # v.0.19.4 (2021-11-22)
2
+
3
+ ## Add
4
+
5
+ - Provide `getPubKey` method to access public key
6
+
7
+ ## Change
8
+
9
+ - Make `getPrivKey` method `public` to access private key
10
+
11
+ # v.0.19.3 (2021-10-31)
12
+
13
+ ## Update
14
+
15
+ - Use latest `xchain-cosmos@0.13.8` to use `sync` mode for broadcasting txs
16
+
17
+ # v.0.19.2 (2021-09-27)
18
+
19
+ ## Fix
20
+
21
+ - Increase `gas` to `500,000,000` (five hundred million)
22
+
23
+ # v.0.19.1 (2021-09-26)
2
24
 
3
25
  ## Fix
4
26
 
package/README.md CHANGED
@@ -48,7 +48,17 @@ 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:', client.getAddress()) // address: tthor13gym97tmw3axj3hpewdggy2cr288d3qffr8skg
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`
52
62
 
53
63
  // get balances
54
64
  const balances = await client.getBalance(address)
package/lib/client.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Address, Balance, Fees, Network, Tx, TxHash, TxHistoryParams, TxParams, TxsPage, XChainClient, XChainClientParams } from '@xchainjs/xchain-client';
2
2
  import { CosmosSDKClient, RPCTxResult } from '@xchainjs/xchain-cosmos';
3
3
  import { Asset } from '@xchainjs/xchain-util';
4
+ import { PrivKey, PubKey } from 'cosmos-client';
4
5
  import { ClientUrl, DepositParam, ExplorerUrls, NodeUrl, ThorchainClientParams } from './types';
5
6
  /**
6
7
  * Interface for custom Thorchain client
@@ -118,15 +119,26 @@ declare class Client implements ThorchainClient, XChainClient {
118
119
  */
119
120
  getFullDerivationPath(index: number): string;
120
121
  /**
121
- * @private
122
- * Get private key.
122
+ * Get private key
123
123
  *
124
+ * @param {number} index the HD wallet index (optional)
124
125
  * @returns {PrivKey} The private key generated from the given phrase
125
126
  *
126
127
  * @throws {"Phrase not set"}
127
128
  * Throws an error if phrase has not been set before
128
129
  * */
129
- private getPrivateKey;
130
+ getPrivKey(index?: number): PrivKey;
131
+ /**
132
+ * Get public key
133
+ *
134
+ * @param {number} index the HD wallet index (optional)
135
+ *
136
+ * @returns {PubKey} The public key generated from the given phrase
137
+ *
138
+ * @throws {"Phrase not set"}
139
+ * Throws an error if phrase has not been set before
140
+ **/
141
+ getPubKey(index?: number): PubKey;
130
142
  /**
131
143
  * Get the current address.
132
144
  *
package/lib/index.esm.js CHANGED
@@ -116,7 +116,7 @@ var msgNativeTxFromJson = function (value) {
116
116
 
117
117
  var DECIMAL = 8;
118
118
  var DEFAULT_GAS_VALUE = '2000000';
119
- var DEPOSIT_GAS_VALUE = '30000000';
119
+ var DEPOSIT_GAS_VALUE = '500000000';
120
120
  var MAX_TX_COUNT = 100;
121
121
  /**
122
122
  * Get denomination from Asset
@@ -653,18 +653,32 @@ var Client = /** @class */ (function () {
653
653
  return this.rootDerivationPaths[this.network] + ("" + index);
654
654
  };
655
655
  /**
656
- * @private
657
- * Get private key.
656
+ * Get private key
658
657
  *
658
+ * @param {number} index the HD wallet index (optional)
659
659
  * @returns {PrivKey} The private key generated from the given phrase
660
660
  *
661
661
  * @throws {"Phrase not set"}
662
662
  * Throws an error if phrase has not been set before
663
663
  * */
664
- Client.prototype.getPrivateKey = function (index) {
664
+ Client.prototype.getPrivKey = function (index) {
665
665
  if (index === void 0) { index = 0; }
666
666
  return this.cosmosClient.getPrivKeyFromMnemonic(this.phrase, this.getFullDerivationPath(index));
667
667
  };
668
+ /**
669
+ * Get public key
670
+ *
671
+ * @param {number} index the HD wallet index (optional)
672
+ *
673
+ * @returns {PubKey} The public key generated from the given phrase
674
+ *
675
+ * @throws {"Phrase not set"}
676
+ * Throws an error if phrase has not been set before
677
+ **/
678
+ Client.prototype.getPubKey = function (index) {
679
+ if (index === void 0) { index = 0; }
680
+ return this.getPrivKey(index).getPubKey();
681
+ };
668
682
  /**
669
683
  * Get the current address.
670
684
  *
@@ -811,7 +825,7 @@ var Client = /** @class */ (function () {
811
825
  return [4 /*yield*/, buildDepositTx(msgNativeTx, this.getClientUrl().node)];
812
826
  case 2:
813
827
  unsignedStdTx = _f.sent();
814
- privateKey = this.getPrivateKey(walletIndex);
828
+ privateKey = this.getPrivKey(walletIndex);
815
829
  accAddress = AccAddress.fromBech32(signer);
816
830
  return [4 /*yield*/, this.cosmosClient.signAndBroadcast(unsignedStdTx, privateKey, accAddress)];
817
831
  case 3: return [2 /*return*/, (_c = (_b = (_f.sent())) === null || _b === void 0 ? void 0 : _b.txhash) !== null && _c !== void 0 ? _c : ''];
@@ -844,7 +858,7 @@ var Client = /** @class */ (function () {
844
858
  throw new Error('insufficient funds');
845
859
  }
846
860
  return [4 /*yield*/, this.cosmosClient.transfer({
847
- privkey: this.getPrivateKey(walletIndex),
861
+ privkey: this.getPrivKey(walletIndex),
848
862
  from: this.getAddress(walletIndex),
849
863
  to: recipient,
850
864
  amount: amount.amount().toString(),
package/lib/index.js CHANGED
@@ -124,7 +124,7 @@ var msgNativeTxFromJson = function (value) {
124
124
 
125
125
  var DECIMAL = 8;
126
126
  var DEFAULT_GAS_VALUE = '2000000';
127
- var DEPOSIT_GAS_VALUE = '30000000';
127
+ var DEPOSIT_GAS_VALUE = '500000000';
128
128
  var MAX_TX_COUNT = 100;
129
129
  /**
130
130
  * Get denomination from Asset
@@ -661,18 +661,32 @@ var Client = /** @class */ (function () {
661
661
  return this.rootDerivationPaths[this.network] + ("" + index);
662
662
  };
663
663
  /**
664
- * @private
665
- * Get private key.
664
+ * Get private key
666
665
  *
666
+ * @param {number} index the HD wallet index (optional)
667
667
  * @returns {PrivKey} The private key generated from the given phrase
668
668
  *
669
669
  * @throws {"Phrase not set"}
670
670
  * Throws an error if phrase has not been set before
671
671
  * */
672
- Client.prototype.getPrivateKey = function (index) {
672
+ Client.prototype.getPrivKey = function (index) {
673
673
  if (index === void 0) { index = 0; }
674
674
  return this.cosmosClient.getPrivKeyFromMnemonic(this.phrase, this.getFullDerivationPath(index));
675
675
  };
676
+ /**
677
+ * Get public key
678
+ *
679
+ * @param {number} index the HD wallet index (optional)
680
+ *
681
+ * @returns {PubKey} The public key generated from the given phrase
682
+ *
683
+ * @throws {"Phrase not set"}
684
+ * Throws an error if phrase has not been set before
685
+ **/
686
+ Client.prototype.getPubKey = function (index) {
687
+ if (index === void 0) { index = 0; }
688
+ return this.getPrivKey(index).getPubKey();
689
+ };
676
690
  /**
677
691
  * Get the current address.
678
692
  *
@@ -819,7 +833,7 @@ var Client = /** @class */ (function () {
819
833
  return [4 /*yield*/, buildDepositTx(msgNativeTx, this.getClientUrl().node)];
820
834
  case 2:
821
835
  unsignedStdTx = _f.sent();
822
- privateKey = this.getPrivateKey(walletIndex);
836
+ privateKey = this.getPrivKey(walletIndex);
823
837
  accAddress = cosmosClient.AccAddress.fromBech32(signer);
824
838
  return [4 /*yield*/, this.cosmosClient.signAndBroadcast(unsignedStdTx, privateKey, accAddress)];
825
839
  case 3: return [2 /*return*/, (_c = (_b = (_f.sent())) === null || _b === void 0 ? void 0 : _b.txhash) !== null && _c !== void 0 ? _c : ''];
@@ -852,7 +866,7 @@ var Client = /** @class */ (function () {
852
866
  throw new Error('insufficient funds');
853
867
  }
854
868
  return [4 /*yield*/, this.cosmosClient.transfer({
855
- privkey: this.getPrivateKey(walletIndex),
869
+ privkey: this.getPrivKey(walletIndex),
856
870
  from: this.getAddress(walletIndex),
857
871
  to: recipient,
858
872
  amount: amount.amount().toString(),
package/lib/util.d.ts CHANGED
@@ -8,7 +8,7 @@ import { ClientUrl, ExplorerUrls, TxData } from './types';
8
8
  import { MsgNativeTx } from './types/messages';
9
9
  export declare const DECIMAL = 8;
10
10
  export declare const DEFAULT_GAS_VALUE = "2000000";
11
- export declare const DEPOSIT_GAS_VALUE = "30000000";
11
+ export declare const DEPOSIT_GAS_VALUE = "500000000";
12
12
  export declare const MAX_TX_COUNT = 100;
13
13
  /**
14
14
  * Get denomination from Asset
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-thorchain",
3
- "version": "0.19.1",
3
+ "version": "0.19.4",
4
4
  "description": "Custom Thorchain client and utilities used by XChainJS clients",
5
5
  "keywords": [
6
6
  "THORChain",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@xchainjs/xchain-client": "^0.10.1",
49
- "@xchainjs/xchain-cosmos": "^0.13.7",
49
+ "@xchainjs/xchain-cosmos": "^0.13.8",
50
50
  "@xchainjs/xchain-crypto": "^0.2.4",
51
51
  "@xchainjs/xchain-util": "^0.3.0",
52
52
  "axios": "^0.21.0",