@xchainjs/xchain-thorchain 0.28.1 → 0.28.3
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 +7 -1
- package/lib/const.d.ts +18 -1
- package/lib/index.esm.js +89 -24
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +89 -23
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -4285,7 +4285,7 @@ const addressUrl = `${DEFAULT_EXPLORER_URL}/address`;
|
|
|
4285
4285
|
const RUNE_TICKER = 'RUNE';
|
|
4286
4286
|
const RUNE_DECIMAL = 8;
|
|
4287
4287
|
const DEFAULT_GAS_ADJUSTMENT = 2;
|
|
4288
|
-
const DEFAULT_GAS_LIMIT_VALUE = '
|
|
4288
|
+
const DEFAULT_GAS_LIMIT_VALUE = '6000000';
|
|
4289
4289
|
const DEPOSIT_GAS_LIMIT_VALUE = '600000000';
|
|
4290
4290
|
const MAX_TX_COUNT_PER_PAGE = 100;
|
|
4291
4291
|
const MAX_TX_COUNT_PER_FUNCTION_CALL = 500;
|
|
@@ -4358,6 +4358,25 @@ const AssetRuneERC20Testnet = {
|
|
|
4358
4358
|
ticker: RUNE_TICKER,
|
|
4359
4359
|
synth: false,
|
|
4360
4360
|
};
|
|
4361
|
+
/**
|
|
4362
|
+
* Fall back node's and rpc's
|
|
4363
|
+
*/
|
|
4364
|
+
const FallBackUrls = [
|
|
4365
|
+
{
|
|
4366
|
+
[lib.Network.Testnet]: {
|
|
4367
|
+
node: ['deprecated'],
|
|
4368
|
+
rpc: ['deprecated'],
|
|
4369
|
+
},
|
|
4370
|
+
[lib.Network.Stagenet]: {
|
|
4371
|
+
node: ['https://stagenet-thornode.ninerealms.com'],
|
|
4372
|
+
rpc: ['https://stagenet-rpc.ninerealms.com'],
|
|
4373
|
+
},
|
|
4374
|
+
[lib.Network.Mainnet]: {
|
|
4375
|
+
node: ['https://thornode-v1.ninerealms.com', 'https://thornode.thorswap.net/'],
|
|
4376
|
+
rpc: ['https://rpc-v1.ninerealms.com', 'https://rpc.thorswap.net'],
|
|
4377
|
+
},
|
|
4378
|
+
},
|
|
4379
|
+
];
|
|
4361
4380
|
|
|
4362
4381
|
var indexMinimal = {};
|
|
4363
4382
|
|
|
@@ -5000,21 +5019,29 @@ function requireFloat () {
|
|
|
5000
5019
|
return float;
|
|
5001
5020
|
}
|
|
5002
5021
|
|
|
5003
|
-
var inquire_1
|
|
5022
|
+
var inquire_1;
|
|
5023
|
+
var hasRequiredInquire;
|
|
5024
|
+
|
|
5025
|
+
function requireInquire () {
|
|
5026
|
+
if (hasRequiredInquire) return inquire_1;
|
|
5027
|
+
hasRequiredInquire = 1;
|
|
5028
|
+
inquire_1 = inquire;
|
|
5004
5029
|
|
|
5005
|
-
/**
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
function inquire(moduleName) {
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5030
|
+
/**
|
|
5031
|
+
* Requires a module only if available.
|
|
5032
|
+
* @memberof util
|
|
5033
|
+
* @param {string} moduleName Module to require
|
|
5034
|
+
* @returns {?Object} Required module if available and not empty, otherwise `null`
|
|
5035
|
+
*/
|
|
5036
|
+
function inquire(moduleName) {
|
|
5037
|
+
try {
|
|
5038
|
+
var mod = eval("quire".replace(/^/,"re"))(moduleName); // eslint-disable-line no-eval
|
|
5039
|
+
if (mod && (mod.length || Object.keys(mod).length))
|
|
5040
|
+
return mod;
|
|
5041
|
+
} catch (e) {} // eslint-disable-line no-empty
|
|
5042
|
+
return null;
|
|
5043
|
+
}
|
|
5044
|
+
return inquire_1;
|
|
5018
5045
|
}
|
|
5019
5046
|
|
|
5020
5047
|
var utf8$2 = {};
|
|
@@ -5418,7 +5445,7 @@ function requireMinimal () {
|
|
|
5418
5445
|
util.float = requireFloat();
|
|
5419
5446
|
|
|
5420
5447
|
// requires modules optionally and hides the call from bundlers
|
|
5421
|
-
util.inquire =
|
|
5448
|
+
util.inquire = requireInquire();
|
|
5422
5449
|
|
|
5423
5450
|
// converts to / from utf8 encoded strings
|
|
5424
5451
|
util.utf8 = requireUtf8();
|
|
@@ -10401,6 +10428,40 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10401
10428
|
};
|
|
10402
10429
|
return assetInfo;
|
|
10403
10430
|
}
|
|
10431
|
+
/**
|
|
10432
|
+
*
|
|
10433
|
+
* @param txId - tx hash
|
|
10434
|
+
* @returns txResponse
|
|
10435
|
+
*/
|
|
10436
|
+
fetchTransaction(txId) {
|
|
10437
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10438
|
+
try {
|
|
10439
|
+
const transaction = yield this.cosmosClient.txsHashGet(txId);
|
|
10440
|
+
return transaction;
|
|
10441
|
+
}
|
|
10442
|
+
catch (error) {
|
|
10443
|
+
for (const fallback of FallBackUrls) {
|
|
10444
|
+
for (const network of Object.keys(fallback)) {
|
|
10445
|
+
try {
|
|
10446
|
+
const networkObj = fallback[network];
|
|
10447
|
+
const clientUrl = networkObj.node;
|
|
10448
|
+
const cosmosClient = new xchainCosmos.CosmosSDKClient({
|
|
10449
|
+
server: Array.isArray(clientUrl) ? clientUrl[0] : clientUrl,
|
|
10450
|
+
chainId: this.getChainId(network),
|
|
10451
|
+
prefix: getPrefix(network),
|
|
10452
|
+
});
|
|
10453
|
+
const tx = yield cosmosClient.txsHashGet(txId);
|
|
10454
|
+
return tx;
|
|
10455
|
+
}
|
|
10456
|
+
catch (error) {
|
|
10457
|
+
// Handle specific error if needed
|
|
10458
|
+
}
|
|
10459
|
+
}
|
|
10460
|
+
}
|
|
10461
|
+
return null;
|
|
10462
|
+
}
|
|
10463
|
+
});
|
|
10464
|
+
}
|
|
10404
10465
|
/**
|
|
10405
10466
|
* Get the transaction details of a given transaction id.
|
|
10406
10467
|
*
|
|
@@ -10410,8 +10471,9 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10410
10471
|
getTransactionData(txId, address) {
|
|
10411
10472
|
var _a, _b, _c;
|
|
10412
10473
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10413
|
-
|
|
10414
|
-
|
|
10474
|
+
const response = yield this.fetchTransaction(txId);
|
|
10475
|
+
if (response) {
|
|
10476
|
+
const txResult = response;
|
|
10415
10477
|
const bond = txResult.logs && txResult.logs[0].events.filter((i) => i.type === 'bond');
|
|
10416
10478
|
const transfer = txResult.logs && txResult.logs[0].events.filter((i) => i.type === 'transfer');
|
|
10417
10479
|
if (!transfer)
|
|
@@ -10431,10 +10493,10 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10431
10493
|
if (!bond)
|
|
10432
10494
|
throw new Error(`Failed to get transaction logs (tx-hash: ${txId})`);
|
|
10433
10495
|
// Rune only transactions
|
|
10434
|
-
if (
|
|
10496
|
+
if (action === 'send' || bond[0].type === 'bond') {
|
|
10435
10497
|
const assetTo = AssetRuneNative;
|
|
10436
10498
|
const txData = txResult && txResult.logs
|
|
10437
|
-
? getDepositTxDataFromLogs(txResult.logs, senderAddress
|
|
10499
|
+
? getDepositTxDataFromLogs(txResult.logs, `${senderAddress}`, senderAsset, assetTo)
|
|
10438
10500
|
: null;
|
|
10439
10501
|
//console.log(JSON.stringify(txData, null, 2))
|
|
10440
10502
|
if (!txData)
|
|
@@ -10452,7 +10514,9 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10452
10514
|
// synths and other tx types
|
|
10453
10515
|
const messageBody = JSON.stringify((_c = txResult.tx) === null || _c === void 0 ? void 0 : _c.body.messages).split(':');
|
|
10454
10516
|
const assetTo = xchainUtil.assetFromStringEx(messageBody[7]);
|
|
10455
|
-
const txData = txResult && txResult.logs
|
|
10517
|
+
const txData = txResult && txResult.logs
|
|
10518
|
+
? getDepositTxDataFromLogs(txResult.logs, `${senderAddress}`, senderAsset, assetTo)
|
|
10519
|
+
: null;
|
|
10456
10520
|
if (!txData)
|
|
10457
10521
|
throw new Error(`Failed to get transaction data (tx-hash: ${txId})`);
|
|
10458
10522
|
const { from, to, type } = txData;
|
|
@@ -10465,8 +10529,9 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10465
10529
|
type,
|
|
10466
10530
|
};
|
|
10467
10531
|
}
|
|
10468
|
-
|
|
10469
|
-
|
|
10532
|
+
else {
|
|
10533
|
+
return yield this.getTransactionDataThornode(txId);
|
|
10534
|
+
}
|
|
10470
10535
|
});
|
|
10471
10536
|
}
|
|
10472
10537
|
/** This function is used when in bound or outbound tx is not of thorchain
|
|
@@ -10776,6 +10841,7 @@ exports.Client = Client;
|
|
|
10776
10841
|
exports.DEFAULT_GAS_ADJUSTMENT = DEFAULT_GAS_ADJUSTMENT;
|
|
10777
10842
|
exports.DEFAULT_GAS_LIMIT_VALUE = DEFAULT_GAS_LIMIT_VALUE;
|
|
10778
10843
|
exports.DEPOSIT_GAS_LIMIT_VALUE = DEPOSIT_GAS_LIMIT_VALUE;
|
|
10844
|
+
exports.FallBackUrls = FallBackUrls;
|
|
10779
10845
|
exports.MAX_PAGES_PER_FUNCTION_CALL = MAX_PAGES_PER_FUNCTION_CALL;
|
|
10780
10846
|
exports.MAX_TX_COUNT_PER_FUNCTION_CALL = MAX_TX_COUNT_PER_FUNCTION_CALL;
|
|
10781
10847
|
exports.MAX_TX_COUNT_PER_PAGE = MAX_TX_COUNT_PER_PAGE;
|