@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 +8 -8
- package/lib/clientKeystore.d.ts +3 -4
- package/lib/clientLedger.d.ts +1 -2
- package/lib/index.esm.js +238 -12
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +237 -10
- package/lib/index.js.map +1 -1
- package/lib/types/client-types.d.ts +7 -3
- package/lib/utils.d.ts +16 -5
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -124885,6 +124885,7 @@ $root.common = (function() {
|
|
|
124885
124885
|
* @property {string|null} [symbol] Asset symbol
|
|
124886
124886
|
* @property {string|null} [ticker] Asset ticker
|
|
124887
124887
|
* @property {boolean|null} [synth] Asset synth
|
|
124888
|
+
* @property {boolean|null} [trade] Asset trade
|
|
124888
124889
|
*/
|
|
124889
124890
|
|
|
124890
124891
|
/**
|
|
@@ -124934,6 +124935,14 @@ $root.common = (function() {
|
|
|
124934
124935
|
*/
|
|
124935
124936
|
Asset.prototype.synth = false;
|
|
124936
124937
|
|
|
124938
|
+
/**
|
|
124939
|
+
* Asset trade.
|
|
124940
|
+
* @member {boolean} trade
|
|
124941
|
+
* @memberof common.Asset
|
|
124942
|
+
* @instance
|
|
124943
|
+
*/
|
|
124944
|
+
Asset.prototype.trade = false;
|
|
124945
|
+
|
|
124937
124946
|
/**
|
|
124938
124947
|
* Creates a new Asset instance using the specified properties.
|
|
124939
124948
|
* @function create
|
|
@@ -124966,6 +124975,8 @@ $root.common = (function() {
|
|
|
124966
124975
|
writer.uint32(/* id 3, wireType 2 =*/26).string(message.ticker);
|
|
124967
124976
|
if (message.synth != null && Object.hasOwnProperty.call(message, "synth"))
|
|
124968
124977
|
writer.uint32(/* id 4, wireType 0 =*/32).bool(message.synth);
|
|
124978
|
+
if (message.trade != null && Object.hasOwnProperty.call(message, "trade"))
|
|
124979
|
+
writer.uint32(/* id 5, wireType 0 =*/40).bool(message.trade);
|
|
124969
124980
|
return writer;
|
|
124970
124981
|
};
|
|
124971
124982
|
|
|
@@ -125012,6 +125023,9 @@ $root.common = (function() {
|
|
|
125012
125023
|
case 4:
|
|
125013
125024
|
message.synth = reader.bool();
|
|
125014
125025
|
break;
|
|
125026
|
+
case 5:
|
|
125027
|
+
message.trade = reader.bool();
|
|
125028
|
+
break;
|
|
125015
125029
|
default:
|
|
125016
125030
|
reader.skipType(tag & 7);
|
|
125017
125031
|
break;
|
|
@@ -125059,6 +125073,9 @@ $root.common = (function() {
|
|
|
125059
125073
|
if (message.synth != null && message.hasOwnProperty("synth"))
|
|
125060
125074
|
if (typeof message.synth !== "boolean")
|
|
125061
125075
|
return "synth: boolean expected";
|
|
125076
|
+
if (message.trade != null && message.hasOwnProperty("trade"))
|
|
125077
|
+
if (typeof message.trade !== "boolean")
|
|
125078
|
+
return "trade: boolean expected";
|
|
125062
125079
|
return null;
|
|
125063
125080
|
};
|
|
125064
125081
|
|
|
@@ -125082,6 +125099,8 @@ $root.common = (function() {
|
|
|
125082
125099
|
message.ticker = String(object.ticker);
|
|
125083
125100
|
if (object.synth != null)
|
|
125084
125101
|
message.synth = Boolean(object.synth);
|
|
125102
|
+
if (object.trade != null)
|
|
125103
|
+
message.trade = Boolean(object.trade);
|
|
125085
125104
|
return message;
|
|
125086
125105
|
};
|
|
125087
125106
|
|
|
@@ -125103,6 +125122,7 @@ $root.common = (function() {
|
|
|
125103
125122
|
object.symbol = "";
|
|
125104
125123
|
object.ticker = "";
|
|
125105
125124
|
object.synth = false;
|
|
125125
|
+
object.trade = false;
|
|
125106
125126
|
}
|
|
125107
125127
|
if (message.chain != null && message.hasOwnProperty("chain"))
|
|
125108
125128
|
object.chain = message.chain;
|
|
@@ -125112,6 +125132,8 @@ $root.common = (function() {
|
|
|
125112
125132
|
object.ticker = message.ticker;
|
|
125113
125133
|
if (message.synth != null && message.hasOwnProperty("synth"))
|
|
125114
125134
|
object.synth = message.synth;
|
|
125135
|
+
if (message.trade != null && message.hasOwnProperty("trade"))
|
|
125136
|
+
object.trade = message.trade;
|
|
125115
125137
|
return object;
|
|
125116
125138
|
};
|
|
125117
125139
|
|
|
@@ -126185,6 +126207,193 @@ $root.common = (function() {
|
|
|
126185
126207
|
return Fee;
|
|
126186
126208
|
})();
|
|
126187
126209
|
|
|
126210
|
+
common.ProtoUint = (function() {
|
|
126211
|
+
|
|
126212
|
+
/**
|
|
126213
|
+
* Properties of a ProtoUint.
|
|
126214
|
+
* @memberof common
|
|
126215
|
+
* @interface IProtoUint
|
|
126216
|
+
* @property {string|null} [value] ProtoUint value
|
|
126217
|
+
*/
|
|
126218
|
+
|
|
126219
|
+
/**
|
|
126220
|
+
* Constructs a new ProtoUint.
|
|
126221
|
+
* @memberof common
|
|
126222
|
+
* @classdesc Represents a ProtoUint.
|
|
126223
|
+
* @implements IProtoUint
|
|
126224
|
+
* @constructor
|
|
126225
|
+
* @param {common.IProtoUint=} [properties] Properties to set
|
|
126226
|
+
*/
|
|
126227
|
+
function ProtoUint(properties) {
|
|
126228
|
+
if (properties)
|
|
126229
|
+
for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i)
|
|
126230
|
+
if (properties[keys[i]] != null)
|
|
126231
|
+
this[keys[i]] = properties[keys[i]];
|
|
126232
|
+
}
|
|
126233
|
+
|
|
126234
|
+
/**
|
|
126235
|
+
* ProtoUint value.
|
|
126236
|
+
* @member {string} value
|
|
126237
|
+
* @memberof common.ProtoUint
|
|
126238
|
+
* @instance
|
|
126239
|
+
*/
|
|
126240
|
+
ProtoUint.prototype.value = "";
|
|
126241
|
+
|
|
126242
|
+
/**
|
|
126243
|
+
* Creates a new ProtoUint instance using the specified properties.
|
|
126244
|
+
* @function create
|
|
126245
|
+
* @memberof common.ProtoUint
|
|
126246
|
+
* @static
|
|
126247
|
+
* @param {common.IProtoUint=} [properties] Properties to set
|
|
126248
|
+
* @returns {common.ProtoUint} ProtoUint instance
|
|
126249
|
+
*/
|
|
126250
|
+
ProtoUint.create = function create(properties) {
|
|
126251
|
+
return new ProtoUint(properties);
|
|
126252
|
+
};
|
|
126253
|
+
|
|
126254
|
+
/**
|
|
126255
|
+
* Encodes the specified ProtoUint message. Does not implicitly {@link common.ProtoUint.verify|verify} messages.
|
|
126256
|
+
* @function encode
|
|
126257
|
+
* @memberof common.ProtoUint
|
|
126258
|
+
* @static
|
|
126259
|
+
* @param {common.IProtoUint} message ProtoUint message or plain object to encode
|
|
126260
|
+
* @param {$protobuf.Writer} [writer] Writer to encode to
|
|
126261
|
+
* @returns {$protobuf.Writer} Writer
|
|
126262
|
+
*/
|
|
126263
|
+
ProtoUint.encode = function encode(message, writer) {
|
|
126264
|
+
if (!writer)
|
|
126265
|
+
writer = $Writer.create();
|
|
126266
|
+
if (message.value != null && Object.hasOwnProperty.call(message, "value"))
|
|
126267
|
+
writer.uint32(/* id 1, wireType 2 =*/10).string(message.value);
|
|
126268
|
+
return writer;
|
|
126269
|
+
};
|
|
126270
|
+
|
|
126271
|
+
/**
|
|
126272
|
+
* Encodes the specified ProtoUint message, length delimited. Does not implicitly {@link common.ProtoUint.verify|verify} messages.
|
|
126273
|
+
* @function encodeDelimited
|
|
126274
|
+
* @memberof common.ProtoUint
|
|
126275
|
+
* @static
|
|
126276
|
+
* @param {common.IProtoUint} message ProtoUint message or plain object to encode
|
|
126277
|
+
* @param {$protobuf.Writer} [writer] Writer to encode to
|
|
126278
|
+
* @returns {$protobuf.Writer} Writer
|
|
126279
|
+
*/
|
|
126280
|
+
ProtoUint.encodeDelimited = function encodeDelimited(message, writer) {
|
|
126281
|
+
return this.encode(message, writer).ldelim();
|
|
126282
|
+
};
|
|
126283
|
+
|
|
126284
|
+
/**
|
|
126285
|
+
* Decodes a ProtoUint message from the specified reader or buffer.
|
|
126286
|
+
* @function decode
|
|
126287
|
+
* @memberof common.ProtoUint
|
|
126288
|
+
* @static
|
|
126289
|
+
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
|
126290
|
+
* @param {number} [length] Message length if known beforehand
|
|
126291
|
+
* @returns {common.ProtoUint} ProtoUint
|
|
126292
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
126293
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
126294
|
+
*/
|
|
126295
|
+
ProtoUint.decode = function decode(reader, length) {
|
|
126296
|
+
if (!(reader instanceof $Reader))
|
|
126297
|
+
reader = $Reader.create(reader);
|
|
126298
|
+
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.common.ProtoUint();
|
|
126299
|
+
while (reader.pos < end) {
|
|
126300
|
+
var tag = reader.uint32();
|
|
126301
|
+
switch (tag >>> 3) {
|
|
126302
|
+
case 1:
|
|
126303
|
+
message.value = reader.string();
|
|
126304
|
+
break;
|
|
126305
|
+
default:
|
|
126306
|
+
reader.skipType(tag & 7);
|
|
126307
|
+
break;
|
|
126308
|
+
}
|
|
126309
|
+
}
|
|
126310
|
+
return message;
|
|
126311
|
+
};
|
|
126312
|
+
|
|
126313
|
+
/**
|
|
126314
|
+
* Decodes a ProtoUint message from the specified reader or buffer, length delimited.
|
|
126315
|
+
* @function decodeDelimited
|
|
126316
|
+
* @memberof common.ProtoUint
|
|
126317
|
+
* @static
|
|
126318
|
+
* @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
|
|
126319
|
+
* @returns {common.ProtoUint} ProtoUint
|
|
126320
|
+
* @throws {Error} If the payload is not a reader or valid buffer
|
|
126321
|
+
* @throws {$protobuf.util.ProtocolError} If required fields are missing
|
|
126322
|
+
*/
|
|
126323
|
+
ProtoUint.decodeDelimited = function decodeDelimited(reader) {
|
|
126324
|
+
if (!(reader instanceof $Reader))
|
|
126325
|
+
reader = new $Reader(reader);
|
|
126326
|
+
return this.decode(reader, reader.uint32());
|
|
126327
|
+
};
|
|
126328
|
+
|
|
126329
|
+
/**
|
|
126330
|
+
* Verifies a ProtoUint message.
|
|
126331
|
+
* @function verify
|
|
126332
|
+
* @memberof common.ProtoUint
|
|
126333
|
+
* @static
|
|
126334
|
+
* @param {Object.<string,*>} message Plain object to verify
|
|
126335
|
+
* @returns {string|null} `null` if valid, otherwise the reason why it is not
|
|
126336
|
+
*/
|
|
126337
|
+
ProtoUint.verify = function verify(message) {
|
|
126338
|
+
if (typeof message !== "object" || message === null)
|
|
126339
|
+
return "object expected";
|
|
126340
|
+
if (message.value != null && message.hasOwnProperty("value"))
|
|
126341
|
+
if (!$util.isString(message.value))
|
|
126342
|
+
return "value: string expected";
|
|
126343
|
+
return null;
|
|
126344
|
+
};
|
|
126345
|
+
|
|
126346
|
+
/**
|
|
126347
|
+
* Creates a ProtoUint message from a plain object. Also converts values to their respective internal types.
|
|
126348
|
+
* @function fromObject
|
|
126349
|
+
* @memberof common.ProtoUint
|
|
126350
|
+
* @static
|
|
126351
|
+
* @param {Object.<string,*>} object Plain object
|
|
126352
|
+
* @returns {common.ProtoUint} ProtoUint
|
|
126353
|
+
*/
|
|
126354
|
+
ProtoUint.fromObject = function fromObject(object) {
|
|
126355
|
+
if (object instanceof $root.common.ProtoUint)
|
|
126356
|
+
return object;
|
|
126357
|
+
var message = new $root.common.ProtoUint();
|
|
126358
|
+
if (object.value != null)
|
|
126359
|
+
message.value = String(object.value);
|
|
126360
|
+
return message;
|
|
126361
|
+
};
|
|
126362
|
+
|
|
126363
|
+
/**
|
|
126364
|
+
* Creates a plain object from a ProtoUint message. Also converts values to other types if specified.
|
|
126365
|
+
* @function toObject
|
|
126366
|
+
* @memberof common.ProtoUint
|
|
126367
|
+
* @static
|
|
126368
|
+
* @param {common.ProtoUint} message ProtoUint
|
|
126369
|
+
* @param {$protobuf.IConversionOptions} [options] Conversion options
|
|
126370
|
+
* @returns {Object.<string,*>} Plain object
|
|
126371
|
+
*/
|
|
126372
|
+
ProtoUint.toObject = function toObject(message, options) {
|
|
126373
|
+
if (!options)
|
|
126374
|
+
options = {};
|
|
126375
|
+
var object = {};
|
|
126376
|
+
if (options.defaults)
|
|
126377
|
+
object.value = "";
|
|
126378
|
+
if (message.value != null && message.hasOwnProperty("value"))
|
|
126379
|
+
object.value = message.value;
|
|
126380
|
+
return object;
|
|
126381
|
+
};
|
|
126382
|
+
|
|
126383
|
+
/**
|
|
126384
|
+
* Converts this ProtoUint to JSON.
|
|
126385
|
+
* @function toJSON
|
|
126386
|
+
* @memberof common.ProtoUint
|
|
126387
|
+
* @instance
|
|
126388
|
+
* @returns {Object.<string,*>} JSON object
|
|
126389
|
+
*/
|
|
126390
|
+
ProtoUint.prototype.toJSON = function toJSON() {
|
|
126391
|
+
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
126392
|
+
};
|
|
126393
|
+
|
|
126394
|
+
return ProtoUint;
|
|
126395
|
+
})();
|
|
126396
|
+
|
|
126188
126397
|
return common;
|
|
126189
126398
|
})();
|
|
126190
126399
|
|
|
@@ -127614,14 +127823,14 @@ const getExplorerTxUrl = (tx) => ({
|
|
|
127614
127823
|
/**
|
|
127615
127824
|
* Checks whether an asset is the native RUNE asset
|
|
127616
127825
|
*
|
|
127617
|
-
* @param {
|
|
127826
|
+
* @param {CompatibleAsset} asset
|
|
127618
127827
|
* @returns {boolean} `true` or `false`
|
|
127619
127828
|
*/
|
|
127620
127829
|
const isAssetRuneNative = (asset) => xchainUtil.assetToString(asset) === xchainUtil.assetToString(AssetRuneNative);
|
|
127621
127830
|
/**
|
|
127622
127831
|
* Get denomination from Asset
|
|
127623
127832
|
*
|
|
127624
|
-
* @param {
|
|
127833
|
+
* @param {CompatibleAsset} asset
|
|
127625
127834
|
* @returns {string} The denomination of the given asset
|
|
127626
127835
|
*/
|
|
127627
127836
|
const getDenom = (asset) => {
|
|
@@ -127712,6 +127921,18 @@ function sortedObject(obj) {
|
|
|
127712
127921
|
function sortAndStringifyJson(obj) {
|
|
127713
127922
|
return JSON.stringify(sortedObject(obj));
|
|
127714
127923
|
}
|
|
127924
|
+
/**
|
|
127925
|
+
* Parse XChainJS asset to Thornode asset
|
|
127926
|
+
*/
|
|
127927
|
+
const parseAssetToTHORNodeAsset = (asset) => {
|
|
127928
|
+
return {
|
|
127929
|
+
chain: asset.chain,
|
|
127930
|
+
symbol: asset.symbol,
|
|
127931
|
+
ticker: asset.ticker,
|
|
127932
|
+
synth: asset.type === xchainUtil.AssetType.SYNTH,
|
|
127933
|
+
trade: asset.type === xchainUtil.AssetType.TRADE,
|
|
127934
|
+
};
|
|
127935
|
+
};
|
|
127715
127936
|
|
|
127716
127937
|
/**
|
|
127717
127938
|
* Import necessary modules and types for the Thorchain client configuration.
|
|
@@ -127751,7 +127972,12 @@ const THORChain = 'THOR';
|
|
|
127751
127972
|
/**
|
|
127752
127973
|
* Native asset representation for RUNE in Thorchain
|
|
127753
127974
|
*/
|
|
127754
|
-
const AssetRuneNative = {
|
|
127975
|
+
const AssetRuneNative = {
|
|
127976
|
+
chain: THORChain,
|
|
127977
|
+
symbol: RUNE_TICKER,
|
|
127978
|
+
ticker: RUNE_TICKER,
|
|
127979
|
+
type: xchainUtil.AssetType.NATIVE,
|
|
127980
|
+
};
|
|
127755
127981
|
/**
|
|
127756
127982
|
* Message type URL used to make send transactions
|
|
127757
127983
|
*/
|
|
@@ -127814,7 +128040,7 @@ class Client extends xchainCosmosSdk.Client {
|
|
|
127814
128040
|
/**
|
|
127815
128041
|
* Returns the number of the decimals of known assets
|
|
127816
128042
|
*
|
|
127817
|
-
* @param {
|
|
128043
|
+
* @param {CompatibleAsset} asset - Asset of which return the number of decimals
|
|
127818
128044
|
* @returns {number} the number of decimals of the assets
|
|
127819
128045
|
*/
|
|
127820
128046
|
getAssetDecimals(asset) {
|
|
@@ -127852,7 +128078,7 @@ class Client extends xchainCosmosSdk.Client {
|
|
|
127852
128078
|
* Get Asset from denomination
|
|
127853
128079
|
*
|
|
127854
128080
|
* @param {string} denom The denomination for which to get the asset.
|
|
127855
|
-
* @returns {
|
|
128081
|
+
* @returns {CompatibleAsset|null} The asset of the given denomination.
|
|
127856
128082
|
*/
|
|
127857
128083
|
assetFromDenom(denom) {
|
|
127858
128084
|
if (denom === RUNE_DENOM)
|
|
@@ -127862,7 +128088,7 @@ class Client extends xchainCosmosSdk.Client {
|
|
|
127862
128088
|
/**
|
|
127863
128089
|
* Get denomination from Asset
|
|
127864
128090
|
*
|
|
127865
|
-
* @param {
|
|
128091
|
+
* @param {CompatibleAsset} asset The asset for which to get the denomination.
|
|
127866
128092
|
* @returns {string} The denomination of the given asset.
|
|
127867
128093
|
*/
|
|
127868
128094
|
getDenom(asset) {
|
|
@@ -128033,7 +128259,7 @@ class ClientKeystore extends Client {
|
|
|
128033
128259
|
*
|
|
128034
128260
|
* @param {number} param.walletIndex Optional - The index to use to generate the address from the transaction will be done.
|
|
128035
128261
|
* If it is not set, address associated with index 0 will be used
|
|
128036
|
-
* @param {
|
|
128262
|
+
* @param {CompatibleAsset} param.asset Optional - The asset that will be deposit. If it is not set, Thorchain native asset will be
|
|
128037
128263
|
* used
|
|
128038
128264
|
* @param {BaseAmount} param.amount The amount that will be deposit
|
|
128039
128265
|
* @param {string} param.memo Optional - The memo associated with the deposit
|
|
@@ -128159,7 +128385,7 @@ class ClientKeystore extends Client {
|
|
|
128159
128385
|
* @param {BigNumber} gasLimit Gas limit for the transaction
|
|
128160
128386
|
* @param {BaseAmount} amount Amount to deposit
|
|
128161
128387
|
* @param {string} memo Deposit memo
|
|
128162
|
-
* @param {
|
|
128388
|
+
* @param {CompatibleAsset} asset Asset to deposit
|
|
128163
128389
|
* @returns {DeliverTxResponse} The transaction broadcasted
|
|
128164
128390
|
*/
|
|
128165
128391
|
roundRobinSignAndBroadcastDeposit(sender, signer, gasLimit, amount, memo, asset) {
|
|
@@ -128179,7 +128405,7 @@ class ClientKeystore extends Client {
|
|
|
128179
128405
|
coins: [
|
|
128180
128406
|
{
|
|
128181
128407
|
amount: amount.amount().toString(),
|
|
128182
|
-
asset,
|
|
128408
|
+
asset: parseAssetToTHORNodeAsset(asset),
|
|
128183
128409
|
},
|
|
128184
128410
|
],
|
|
128185
128411
|
},
|
|
@@ -128408,7 +128634,7 @@ class ClientLedger extends Client {
|
|
|
128408
128634
|
signer: xchainCosmosSdk.bech32ToBase64(params.signer),
|
|
128409
128635
|
memo: params.memo,
|
|
128410
128636
|
coins: params.coins.map((coin) => {
|
|
128411
|
-
return Object.assign(Object.assign({}, coin), { asset: xchainUtil.assetFromStringEx(coin.asset) });
|
|
128637
|
+
return Object.assign(Object.assign({}, coin), { asset: parseAssetToTHORNodeAsset(xchainUtil.assetFromStringEx(coin.asset)) });
|
|
128412
128638
|
}),
|
|
128413
128639
|
}),
|
|
128414
128640
|
},
|
|
@@ -128440,6 +128666,7 @@ exports.getExplorerAddressUrl = getExplorerAddressUrl;
|
|
|
128440
128666
|
exports.getExplorerTxUrl = getExplorerTxUrl;
|
|
128441
128667
|
exports.getPrefix = getPrefix;
|
|
128442
128668
|
exports.isAssetRuneNative = isAssetRuneNative;
|
|
128669
|
+
exports.parseAssetToTHORNodeAsset = parseAssetToTHORNodeAsset;
|
|
128443
128670
|
exports.parseDerivationPath = parseDerivationPath;
|
|
128444
128671
|
exports.sortAndStringifyJson = sortAndStringifyJson;
|
|
128445
128672
|
exports.sortedObject = sortedObject;
|