@xchainjs/xchain-thorchain 1.1.0 → 2.0.0

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/lib/client.d.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  import { StdFee } from '@cosmjs/amino';
5
5
  import { AssetInfo, Network, PreparedTx, TxHash, TxParams } from '@xchainjs/xchain-client';
6
6
  import { Client as CosmosSDKClient, CosmosSdkClientParams, MsgTypes } from '@xchainjs/xchain-cosmos-sdk';
7
- import { Address, Asset } from '@xchainjs/xchain-util';
8
- import { DepositParam, DepositTx, TxOfflineParams } from './types';
7
+ import { Address } from '@xchainjs/xchain-util';
8
+ import { CompatibleAsset, DepositParam, DepositTx, TxOfflineParams } from './types';
9
9
  /**
10
10
  * Interface for custom Thorchain client
11
11
  */
@@ -43,10 +43,10 @@ export declare abstract class Client extends CosmosSDKClient implements Thorchai
43
43
  /**
44
44
  * Returns the number of the decimals of known assets
45
45
  *
46
- * @param {Asset} asset - Asset of which return the number of decimals
46
+ * @param {CompatibleAsset} asset - Asset of which return the number of decimals
47
47
  * @returns {number} the number of decimals of the assets
48
48
  */
49
- getAssetDecimals(asset: Asset): number;
49
+ getAssetDecimals(asset: CompatibleAsset): number;
50
50
  /**
51
51
  * Get the explorer url.
52
52
  *
@@ -71,16 +71,16 @@ export declare abstract class Client extends CosmosSDKClient implements Thorchai
71
71
  * Get Asset from denomination
72
72
  *
73
73
  * @param {string} denom The denomination for which to get the asset.
74
- * @returns {Asset|null} The asset of the given denomination.
74
+ * @returns {CompatibleAsset|null} The asset of the given denomination.
75
75
  */
76
- assetFromDenom(denom: string): Asset | null;
76
+ assetFromDenom(denom: string): CompatibleAsset | null;
77
77
  /**
78
78
  * Get denomination from Asset
79
79
  *
80
- * @param {Asset} asset The asset for which to get the denomination.
80
+ * @param {CompatibleAsset} asset The asset for which to get the denomination.
81
81
  * @returns {string} The denomination of the given asset.
82
82
  */
83
- getDenom(asset: Asset): string | null;
83
+ getDenom(asset: CompatibleAsset): string | null;
84
84
  /**
85
85
  * Prepare transfer transaction.
86
86
  *
@@ -1,7 +1,6 @@
1
- import { TxParams } from '@xchainjs/xchain-client';
2
1
  import { BigNumber } from 'bignumber.js';
3
2
  import { Client } from './client';
4
- import { DepositParam, TxOfflineParams } from './types';
3
+ import { DepositParam, TxOfflineParams, TxParams } from './types';
5
4
  /**
6
5
  * Thorchain Keystore client
7
6
  */
@@ -40,7 +39,7 @@ export declare class ClientKeystore extends Client {
40
39
  *
41
40
  * @param {number} param.walletIndex Optional - The index to use to generate the address from the transaction will be done.
42
41
  * If it is not set, address associated with index 0 will be used
43
- * @param {Asset} param.asset Optional - The asset that will be deposit. If it is not set, Thorchain native asset will be
42
+ * @param {CompatibleAsset} param.asset Optional - The asset that will be deposit. If it is not set, Thorchain native asset will be
44
43
  * used
45
44
  * @param {BaseAmount} param.amount The amount that will be deposit
46
45
  * @param {string} param.memo Optional - The memo associated with the deposit
@@ -90,7 +89,7 @@ export declare class ClientKeystore extends Client {
90
89
  * @param {BigNumber} gasLimit Gas limit for the transaction
91
90
  * @param {BaseAmount} amount Amount to deposit
92
91
  * @param {string} memo Deposit memo
93
- * @param {Asset} asset Asset to deposit
92
+ * @param {CompatibleAsset} asset Asset to deposit
94
93
  * @returns {DeliverTxResponse} The transaction broadcasted
95
94
  */
96
95
  private roundRobinSignAndBroadcastDeposit;
@@ -1,7 +1,6 @@
1
1
  import Transport from '@ledgerhq/hw-transport';
2
- import { TxParams } from '@xchainjs/xchain-client';
3
2
  import { Client, ThorchainClientParams } from './client';
4
- import { DepositParam } from './types';
3
+ import { DepositParam, TxParams } from './types';
5
4
  /**
6
5
  * Thorchain Ledger client
7
6
  */
package/lib/index.esm.js CHANGED
@@ -15,7 +15,7 @@ import { BigNumber } from 'bignumber.js';
15
15
  import { toWords as toWords$1, encode as encode$2 } from 'bech32';
16
16
  import { fromSeed } from 'bip32';
17
17
  import { publicKeyCreate } from 'secp256k1';
18
- import { assetToString, isSynthAsset, assetToBase, assetAmount, eqAsset, assetFromString, assetFromStringEx } from '@xchainjs/xchain-util';
18
+ import { assetToString, isSynthAsset, AssetType, assetToBase, assetAmount, eqAsset, assetFromString, assetFromStringEx } from '@xchainjs/xchain-util';
19
19
  import { Network } from '@xchainjs/xchain-client';
20
20
  import THORChainApp, { extractSignatureFromTLV } from '@xchainjs/ledger-thorchain';
21
21
 
@@ -124856,6 +124856,7 @@ $root.common = (function() {
124856
124856
  * @property {string|null} [symbol] Asset symbol
124857
124857
  * @property {string|null} [ticker] Asset ticker
124858
124858
  * @property {boolean|null} [synth] Asset synth
124859
+ * @property {boolean|null} [trade] Asset trade
124859
124860
  */
124860
124861
 
124861
124862
  /**
@@ -124905,6 +124906,14 @@ $root.common = (function() {
124905
124906
  */
124906
124907
  Asset.prototype.synth = false;
124907
124908
 
124909
+ /**
124910
+ * Asset trade.
124911
+ * @member {boolean} trade
124912
+ * @memberof common.Asset
124913
+ * @instance
124914
+ */
124915
+ Asset.prototype.trade = false;
124916
+
124908
124917
  /**
124909
124918
  * Creates a new Asset instance using the specified properties.
124910
124919
  * @function create
@@ -124937,6 +124946,8 @@ $root.common = (function() {
124937
124946
  writer.uint32(/* id 3, wireType 2 =*/26).string(message.ticker);
124938
124947
  if (message.synth != null && Object.hasOwnProperty.call(message, "synth"))
124939
124948
  writer.uint32(/* id 4, wireType 0 =*/32).bool(message.synth);
124949
+ if (message.trade != null && Object.hasOwnProperty.call(message, "trade"))
124950
+ writer.uint32(/* id 5, wireType 0 =*/40).bool(message.trade);
124940
124951
  return writer;
124941
124952
  };
124942
124953
 
@@ -124983,6 +124994,9 @@ $root.common = (function() {
124983
124994
  case 4:
124984
124995
  message.synth = reader.bool();
124985
124996
  break;
124997
+ case 5:
124998
+ message.trade = reader.bool();
124999
+ break;
124986
125000
  default:
124987
125001
  reader.skipType(tag & 7);
124988
125002
  break;
@@ -125030,6 +125044,9 @@ $root.common = (function() {
125030
125044
  if (message.synth != null && message.hasOwnProperty("synth"))
125031
125045
  if (typeof message.synth !== "boolean")
125032
125046
  return "synth: boolean expected";
125047
+ if (message.trade != null && message.hasOwnProperty("trade"))
125048
+ if (typeof message.trade !== "boolean")
125049
+ return "trade: boolean expected";
125033
125050
  return null;
125034
125051
  };
125035
125052
 
@@ -125053,6 +125070,8 @@ $root.common = (function() {
125053
125070
  message.ticker = String(object.ticker);
125054
125071
  if (object.synth != null)
125055
125072
  message.synth = Boolean(object.synth);
125073
+ if (object.trade != null)
125074
+ message.trade = Boolean(object.trade);
125056
125075
  return message;
125057
125076
  };
125058
125077
 
@@ -125074,6 +125093,7 @@ $root.common = (function() {
125074
125093
  object.symbol = "";
125075
125094
  object.ticker = "";
125076
125095
  object.synth = false;
125096
+ object.trade = false;
125077
125097
  }
125078
125098
  if (message.chain != null && message.hasOwnProperty("chain"))
125079
125099
  object.chain = message.chain;
@@ -125083,6 +125103,8 @@ $root.common = (function() {
125083
125103
  object.ticker = message.ticker;
125084
125104
  if (message.synth != null && message.hasOwnProperty("synth"))
125085
125105
  object.synth = message.synth;
125106
+ if (message.trade != null && message.hasOwnProperty("trade"))
125107
+ object.trade = message.trade;
125086
125108
  return object;
125087
125109
  };
125088
125110
 
@@ -126156,6 +126178,193 @@ $root.common = (function() {
126156
126178
  return Fee;
126157
126179
  })();
126158
126180
 
126181
+ common.ProtoUint = (function() {
126182
+
126183
+ /**
126184
+ * Properties of a ProtoUint.
126185
+ * @memberof common
126186
+ * @interface IProtoUint
126187
+ * @property {string|null} [value] ProtoUint value
126188
+ */
126189
+
126190
+ /**
126191
+ * Constructs a new ProtoUint.
126192
+ * @memberof common
126193
+ * @classdesc Represents a ProtoUint.
126194
+ * @implements IProtoUint
126195
+ * @constructor
126196
+ * @param {common.IProtoUint=} [properties] Properties to set
126197
+ */
126198
+ function ProtoUint(properties) {
126199
+ if (properties)
126200
+ for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
126201
+ if (properties[keys[i]] != null)
126202
+ this[keys[i]] = properties[keys[i]];
126203
+ }
126204
+
126205
+ /**
126206
+ * ProtoUint value.
126207
+ * @member {string} value
126208
+ * @memberof common.ProtoUint
126209
+ * @instance
126210
+ */
126211
+ ProtoUint.prototype.value = "";
126212
+
126213
+ /**
126214
+ * Creates a new ProtoUint instance using the specified properties.
126215
+ * @function create
126216
+ * @memberof common.ProtoUint
126217
+ * @static
126218
+ * @param {common.IProtoUint=} [properties] Properties to set
126219
+ * @returns {common.ProtoUint} ProtoUint instance
126220
+ */
126221
+ ProtoUint.create = function create(properties) {
126222
+ return new ProtoUint(properties);
126223
+ };
126224
+
126225
+ /**
126226
+ * Encodes the specified ProtoUint message. Does not implicitly {@link common.ProtoUint.verify|verify} messages.
126227
+ * @function encode
126228
+ * @memberof common.ProtoUint
126229
+ * @static
126230
+ * @param {common.IProtoUint} message ProtoUint message or plain object to encode
126231
+ * @param {$protobuf.Writer} [writer] Writer to encode to
126232
+ * @returns {$protobuf.Writer} Writer
126233
+ */
126234
+ ProtoUint.encode = function encode(message, writer) {
126235
+ if (!writer)
126236
+ writer = $Writer.create();
126237
+ if (message.value != null && Object.hasOwnProperty.call(message, "value"))
126238
+ writer.uint32(/* id 1, wireType 2 =*/10).string(message.value);
126239
+ return writer;
126240
+ };
126241
+
126242
+ /**
126243
+ * Encodes the specified ProtoUint message, length delimited. Does not implicitly {@link common.ProtoUint.verify|verify} messages.
126244
+ * @function encodeDelimited
126245
+ * @memberof common.ProtoUint
126246
+ * @static
126247
+ * @param {common.IProtoUint} message ProtoUint message or plain object to encode
126248
+ * @param {$protobuf.Writer} [writer] Writer to encode to
126249
+ * @returns {$protobuf.Writer} Writer
126250
+ */
126251
+ ProtoUint.encodeDelimited = function encodeDelimited(message, writer) {
126252
+ return this.encode(message, writer).ldelim();
126253
+ };
126254
+
126255
+ /**
126256
+ * Decodes a ProtoUint message from the specified reader or buffer.
126257
+ * @function decode
126258
+ * @memberof common.ProtoUint
126259
+ * @static
126260
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
126261
+ * @param {number} [length] Message length if known beforehand
126262
+ * @returns {common.ProtoUint} ProtoUint
126263
+ * @throws {Error} If the payload is not a reader or valid buffer
126264
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
126265
+ */
126266
+ ProtoUint.decode = function decode(reader, length) {
126267
+ if (!(reader instanceof $Reader))
126268
+ reader = $Reader.create(reader);
126269
+ var end = length === undefined ? reader.len : reader.pos + length, message = new $root.common.ProtoUint();
126270
+ while (reader.pos < end) {
126271
+ var tag = reader.uint32();
126272
+ switch (tag >>> 3) {
126273
+ case 1:
126274
+ message.value = reader.string();
126275
+ break;
126276
+ default:
126277
+ reader.skipType(tag & 7);
126278
+ break;
126279
+ }
126280
+ }
126281
+ return message;
126282
+ };
126283
+
126284
+ /**
126285
+ * Decodes a ProtoUint message from the specified reader or buffer, length delimited.
126286
+ * @function decodeDelimited
126287
+ * @memberof common.ProtoUint
126288
+ * @static
126289
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
126290
+ * @returns {common.ProtoUint} ProtoUint
126291
+ * @throws {Error} If the payload is not a reader or valid buffer
126292
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
126293
+ */
126294
+ ProtoUint.decodeDelimited = function decodeDelimited(reader) {
126295
+ if (!(reader instanceof $Reader))
126296
+ reader = new $Reader(reader);
126297
+ return this.decode(reader, reader.uint32());
126298
+ };
126299
+
126300
+ /**
126301
+ * Verifies a ProtoUint message.
126302
+ * @function verify
126303
+ * @memberof common.ProtoUint
126304
+ * @static
126305
+ * @param {Object.<string,*>} message Plain object to verify
126306
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
126307
+ */
126308
+ ProtoUint.verify = function verify(message) {
126309
+ if (typeof message !== "object" || message === null)
126310
+ return "object expected";
126311
+ if (message.value != null && message.hasOwnProperty("value"))
126312
+ if (!$util.isString(message.value))
126313
+ return "value: string expected";
126314
+ return null;
126315
+ };
126316
+
126317
+ /**
126318
+ * Creates a ProtoUint message from a plain object. Also converts values to their respective internal types.
126319
+ * @function fromObject
126320
+ * @memberof common.ProtoUint
126321
+ * @static
126322
+ * @param {Object.<string,*>} object Plain object
126323
+ * @returns {common.ProtoUint} ProtoUint
126324
+ */
126325
+ ProtoUint.fromObject = function fromObject(object) {
126326
+ if (object instanceof $root.common.ProtoUint)
126327
+ return object;
126328
+ var message = new $root.common.ProtoUint();
126329
+ if (object.value != null)
126330
+ message.value = String(object.value);
126331
+ return message;
126332
+ };
126333
+
126334
+ /**
126335
+ * Creates a plain object from a ProtoUint message. Also converts values to other types if specified.
126336
+ * @function toObject
126337
+ * @memberof common.ProtoUint
126338
+ * @static
126339
+ * @param {common.ProtoUint} message ProtoUint
126340
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
126341
+ * @returns {Object.<string,*>} Plain object
126342
+ */
126343
+ ProtoUint.toObject = function toObject(message, options) {
126344
+ if (!options)
126345
+ options = {};
126346
+ var object = {};
126347
+ if (options.defaults)
126348
+ object.value = "";
126349
+ if (message.value != null && message.hasOwnProperty("value"))
126350
+ object.value = message.value;
126351
+ return object;
126352
+ };
126353
+
126354
+ /**
126355
+ * Converts this ProtoUint to JSON.
126356
+ * @function toJSON
126357
+ * @memberof common.ProtoUint
126358
+ * @instance
126359
+ * @returns {Object.<string,*>} JSON object
126360
+ */
126361
+ ProtoUint.prototype.toJSON = function toJSON() {
126362
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
126363
+ };
126364
+
126365
+ return ProtoUint;
126366
+ })();
126367
+
126159
126368
  return common;
126160
126369
  })();
126161
126370
 
@@ -127585,14 +127794,14 @@ const getExplorerTxUrl = (tx) => ({
127585
127794
  /**
127586
127795
  * Checks whether an asset is the native RUNE asset
127587
127796
  *
127588
- * @param {Asset} asset
127797
+ * @param {CompatibleAsset} asset
127589
127798
  * @returns {boolean} `true` or `false`
127590
127799
  */
127591
127800
  const isAssetRuneNative = (asset) => assetToString(asset) === assetToString(AssetRuneNative);
127592
127801
  /**
127593
127802
  * Get denomination from Asset
127594
127803
  *
127595
- * @param {Asset} asset
127804
+ * @param {CompatibleAsset} asset
127596
127805
  * @returns {string} The denomination of the given asset
127597
127806
  */
127598
127807
  const getDenom = (asset) => {
@@ -127683,6 +127892,18 @@ function sortedObject(obj) {
127683
127892
  function sortAndStringifyJson(obj) {
127684
127893
  return JSON.stringify(sortedObject(obj));
127685
127894
  }
127895
+ /**
127896
+ * Parse XChainJS asset to Thornode asset
127897
+ */
127898
+ const parseAssetToTHORNodeAsset = (asset) => {
127899
+ return {
127900
+ chain: asset.chain,
127901
+ symbol: asset.symbol,
127902
+ ticker: asset.ticker,
127903
+ synth: asset.type === AssetType.SYNTH,
127904
+ trade: asset.type === AssetType.TRADE,
127905
+ };
127906
+ };
127686
127907
 
127687
127908
  /**
127688
127909
  * Import necessary modules and types for the Thorchain client configuration.
@@ -127722,7 +127943,12 @@ const THORChain = 'THOR';
127722
127943
  /**
127723
127944
  * Native asset representation for RUNE in Thorchain
127724
127945
  */
127725
- const AssetRuneNative = { chain: THORChain, symbol: RUNE_TICKER, ticker: RUNE_TICKER, synth: false };
127946
+ const AssetRuneNative = {
127947
+ chain: THORChain,
127948
+ symbol: RUNE_TICKER,
127949
+ ticker: RUNE_TICKER,
127950
+ type: AssetType.NATIVE,
127951
+ };
127726
127952
  /**
127727
127953
  * Message type URL used to make send transactions
127728
127954
  */
@@ -127785,7 +128011,7 @@ class Client extends Client$1 {
127785
128011
  /**
127786
128012
  * Returns the number of the decimals of known assets
127787
128013
  *
127788
- * @param {Asset} asset - Asset of which return the number of decimals
128014
+ * @param {CompatibleAsset} asset - Asset of which return the number of decimals
127789
128015
  * @returns {number} the number of decimals of the assets
127790
128016
  */
127791
128017
  getAssetDecimals(asset) {
@@ -127823,7 +128049,7 @@ class Client extends Client$1 {
127823
128049
  * Get Asset from denomination
127824
128050
  *
127825
128051
  * @param {string} denom The denomination for which to get the asset.
127826
- * @returns {Asset|null} The asset of the given denomination.
128052
+ * @returns {CompatibleAsset|null} The asset of the given denomination.
127827
128053
  */
127828
128054
  assetFromDenom(denom) {
127829
128055
  if (denom === RUNE_DENOM)
@@ -127833,7 +128059,7 @@ class Client extends Client$1 {
127833
128059
  /**
127834
128060
  * Get denomination from Asset
127835
128061
  *
127836
- * @param {Asset} asset The asset for which to get the denomination.
128062
+ * @param {CompatibleAsset} asset The asset for which to get the denomination.
127837
128063
  * @returns {string} The denomination of the given asset.
127838
128064
  */
127839
128065
  getDenom(asset) {
@@ -128004,7 +128230,7 @@ class ClientKeystore extends Client {
128004
128230
  *
128005
128231
  * @param {number} param.walletIndex Optional - The index to use to generate the address from the transaction will be done.
128006
128232
  * If it is not set, address associated with index 0 will be used
128007
- * @param {Asset} param.asset Optional - The asset that will be deposit. If it is not set, Thorchain native asset will be
128233
+ * @param {CompatibleAsset} param.asset Optional - The asset that will be deposit. If it is not set, Thorchain native asset will be
128008
128234
  * used
128009
128235
  * @param {BaseAmount} param.amount The amount that will be deposit
128010
128236
  * @param {string} param.memo Optional - The memo associated with the deposit
@@ -128130,7 +128356,7 @@ class ClientKeystore extends Client {
128130
128356
  * @param {BigNumber} gasLimit Gas limit for the transaction
128131
128357
  * @param {BaseAmount} amount Amount to deposit
128132
128358
  * @param {string} memo Deposit memo
128133
- * @param {Asset} asset Asset to deposit
128359
+ * @param {CompatibleAsset} asset Asset to deposit
128134
128360
  * @returns {DeliverTxResponse} The transaction broadcasted
128135
128361
  */
128136
128362
  roundRobinSignAndBroadcastDeposit(sender, signer, gasLimit, amount, memo, asset) {
@@ -128150,7 +128376,7 @@ class ClientKeystore extends Client {
128150
128376
  coins: [
128151
128377
  {
128152
128378
  amount: amount.amount().toString(),
128153
- asset,
128379
+ asset: parseAssetToTHORNodeAsset(asset),
128154
128380
  },
128155
128381
  ],
128156
128382
  },
@@ -128379,7 +128605,7 @@ class ClientLedger extends Client {
128379
128605
  signer: bech32ToBase64(params.signer),
128380
128606
  memo: params.memo,
128381
128607
  coins: params.coins.map((coin) => {
128382
- return Object.assign(Object.assign({}, coin), { asset: assetFromStringEx(coin.asset) });
128608
+ return Object.assign(Object.assign({}, coin), { asset: parseAssetToTHORNodeAsset(assetFromStringEx(coin.asset)) });
128383
128609
  }),
128384
128610
  }),
128385
128611
  },
@@ -128387,5 +128613,5 @@ class ClientLedger extends Client {
128387
128613
  }
128388
128614
  }
128389
128615
 
128390
- export { AssetRuneNative, ClientKeystore as Client, ClientKeystore, ClientLedger, DEFAULT_EXPLORER_URL, DEFAULT_FEE, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MSG_DEPOSIT_TYPE_URL, MSG_SEND_TYPE_URL, RUNE_DECIMAL, RUNE_DENOM, RUNE_TICKER, THORChain, defaultClientConfig, getChainId, getDefaultClientUrls, getDefaultExplorers, getDefaultRootDerivationPaths, getDenom, getExplorerAddressUrl, getExplorerTxUrl, getPrefix, isAssetRuneNative, parseDerivationPath, sortAndStringifyJson, sortedObject };
128616
+ export { AssetRuneNative, ClientKeystore as Client, ClientKeystore, ClientLedger, DEFAULT_EXPLORER_URL, DEFAULT_FEE, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MSG_DEPOSIT_TYPE_URL, MSG_SEND_TYPE_URL, RUNE_DECIMAL, RUNE_DENOM, RUNE_TICKER, THORChain, defaultClientConfig, getChainId, getDefaultClientUrls, getDefaultExplorers, getDefaultRootDerivationPaths, getDenom, getExplorerAddressUrl, getExplorerTxUrl, getPrefix, isAssetRuneNative, parseAssetToTHORNodeAsset, parseDerivationPath, sortAndStringifyJson, sortedObject };
128391
128617
  //# sourceMappingURL=index.esm.js.map