@xchainjs/xchain-thorchain 0.27.8 → 0.27.11
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 -0
- package/lib/const.d.ts +3 -1
- package/lib/index.esm.js +168 -37
- package/lib/index.js +169 -36
- package/lib/types/client-types.d.ts +21 -0
- package/lib/utils.d.ts +1 -1
- package/package.json +5 -7
- package/CHANGELOG.md +0 -598
package/lib/client.d.ts
CHANGED
|
@@ -167,6 +167,12 @@ declare class Client extends BaseXChainClient implements ThorchainClient, XChain
|
|
|
167
167
|
* @returns {Tx} The transaction details of the given transaction id.
|
|
168
168
|
*/
|
|
169
169
|
getTransactionData(txId: string, address: Address): Promise<Tx>;
|
|
170
|
+
/** This function is used when in bound or outbound tx is not of thorchain
|
|
171
|
+
*
|
|
172
|
+
* @param txId - transaction hash
|
|
173
|
+
* @returns - Tx object
|
|
174
|
+
*/
|
|
175
|
+
private getTransactionDataThornode;
|
|
170
176
|
/**
|
|
171
177
|
* Get the transaction details of a given transaction id. (from /thorchain/txs/hash)
|
|
172
178
|
*
|
|
@@ -199,6 +205,7 @@ declare class Client extends BaseXChainClient implements ThorchainClient, XChain
|
|
|
199
205
|
gasLimit?: BigNumber;
|
|
200
206
|
sequence?: number;
|
|
201
207
|
}): Promise<TxHash>;
|
|
208
|
+
broadcastTx(txHex: string): Promise<TxHash>;
|
|
202
209
|
/**
|
|
203
210
|
* Transfer without broadcast balances with MsgSend
|
|
204
211
|
*
|
package/lib/const.d.ts
CHANGED
|
@@ -4,7 +4,9 @@ export declare const DECIMAL = 8;
|
|
|
4
4
|
export declare const DEFAULT_GAS_ADJUSTMENT = 2;
|
|
5
5
|
export declare const DEFAULT_GAS_LIMIT_VALUE = "4000000";
|
|
6
6
|
export declare const DEPOSIT_GAS_LIMIT_VALUE = "600000000";
|
|
7
|
-
export declare const
|
|
7
|
+
export declare const MAX_TX_COUNT_PER_PAGE = 100;
|
|
8
|
+
export declare const MAX_TX_COUNT_PER_FUNCTION_CALL = 500;
|
|
9
|
+
export declare const MAX_PAGES_PER_FUNCTION_CALL = 15;
|
|
8
10
|
export declare const RUNE_SYMBOL = "\u16B1";
|
|
9
11
|
export declare const defaultExplorerUrls: ExplorerUrls;
|
|
10
12
|
/**
|
package/lib/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import cosmosclient from '@cosmos-client/core';
|
|
2
2
|
import { Network as Network$1, TxType, singleFee, FeeType, BaseXChainClient } from '@xchainjs/xchain-client';
|
|
3
3
|
import { GAIAChain, CosmosSDKClient } from '@xchainjs/xchain-cosmos';
|
|
4
|
-
import { assetToString, isSynthAsset, assetFromString, baseAmount, assetToBase, assetAmount } from '@xchainjs/xchain-util';
|
|
4
|
+
import { assetToString, isSynthAsset, assetFromString, baseAmount, assetToBase, assetAmount, delay, assetFromStringEx } from '@xchainjs/xchain-util';
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
import { Network } from '@xchainjs/xchain-client/lib';
|
|
7
7
|
import { decode } from 'bech32-buffer';
|
|
@@ -4269,7 +4269,9 @@ const DECIMAL = 8;
|
|
|
4269
4269
|
const DEFAULT_GAS_ADJUSTMENT = 2;
|
|
4270
4270
|
const DEFAULT_GAS_LIMIT_VALUE = '4000000';
|
|
4271
4271
|
const DEPOSIT_GAS_LIMIT_VALUE = '600000000';
|
|
4272
|
-
const
|
|
4272
|
+
const MAX_TX_COUNT_PER_PAGE = 100;
|
|
4273
|
+
const MAX_TX_COUNT_PER_FUNCTION_CALL = 500;
|
|
4274
|
+
const MAX_PAGES_PER_FUNCTION_CALL = 15;
|
|
4273
4275
|
const RUNE_SYMBOL = 'ᚱ';
|
|
4274
4276
|
const defaultExplorerUrls = {
|
|
4275
4277
|
root: {
|
|
@@ -9757,7 +9759,7 @@ const registerSendCodecs = () => {
|
|
|
9757
9759
|
* @param {Address} address - Address to get transaction data for
|
|
9758
9760
|
* @returns {TxData} Parsed transaction data
|
|
9759
9761
|
*/
|
|
9760
|
-
const getDepositTxDataFromLogs = (logs, address) => {
|
|
9762
|
+
const getDepositTxDataFromLogs = (logs, address, senderAsset, receiverAsset) => {
|
|
9761
9763
|
var _a;
|
|
9762
9764
|
const events = (_a = logs[0]) === null || _a === void 0 ? void 0 : _a.events;
|
|
9763
9765
|
if (!events) {
|
|
@@ -9784,7 +9786,7 @@ const getDepositTxDataFromLogs = (logs, address) => {
|
|
|
9784
9786
|
// filter out txs which are not based on given address
|
|
9785
9787
|
.filter(({ sender, recipient }) => sender === address || recipient === address)
|
|
9786
9788
|
// transform `TransferData` -> `TxData`
|
|
9787
|
-
.reduce((acc, { sender, recipient, amount }) => (Object.assign(Object.assign({}, acc), { from: [...acc.from, { amount, from: sender }], to: [...acc.to, { amount, to: recipient }] })), { from: [], to: [], type: TxType.Transfer });
|
|
9789
|
+
.reduce((acc, { sender, recipient, amount }) => (Object.assign(Object.assign({}, acc), { from: [...acc.from, { amount, from: sender, asset: senderAsset }], to: [...acc.to, { amount, to: recipient, asset: receiverAsset }] })), { from: [], to: [], type: TxType.Transfer });
|
|
9788
9790
|
return txData;
|
|
9789
9791
|
};
|
|
9790
9792
|
/**
|
|
@@ -10058,24 +10060,45 @@ class Client extends BaseXChainClient {
|
|
|
10058
10060
|
const address = (params === null || params === void 0 ? void 0 : params.address) || this.getAddress();
|
|
10059
10061
|
const txMinHeight = undefined;
|
|
10060
10062
|
const txMaxHeight = undefined;
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
const
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10063
|
+
if (limit + offset > MAX_PAGES_PER_FUNCTION_CALL * MAX_TX_COUNT_PER_PAGE) {
|
|
10064
|
+
throw Error(`limit plus offset can not be grater than ${MAX_PAGES_PER_FUNCTION_CALL * MAX_TX_COUNT_PER_PAGE}`);
|
|
10065
|
+
}
|
|
10066
|
+
if (limit > MAX_TX_COUNT_PER_FUNCTION_CALL) {
|
|
10067
|
+
throw Error(`Maximum number of transaction per call is ${MAX_TX_COUNT_PER_FUNCTION_CALL}`);
|
|
10068
|
+
}
|
|
10069
|
+
const pagesNumber = Math.ceil((limit + offset) / MAX_TX_COUNT_PER_PAGE);
|
|
10070
|
+
const promiseTotalTxIncomingHistory = [];
|
|
10071
|
+
const promiseTotalTxOutgoingHistory = [];
|
|
10072
|
+
for (let index = 1; index <= pagesNumber; index++) {
|
|
10073
|
+
promiseTotalTxIncomingHistory.push(this.cosmosClient.searchTxFromRPC({
|
|
10074
|
+
rpcEndpoint: this.getClientUrl().rpc,
|
|
10075
|
+
messageAction,
|
|
10076
|
+
transferRecipient: address,
|
|
10077
|
+
page: index,
|
|
10078
|
+
limit: MAX_TX_COUNT_PER_PAGE,
|
|
10079
|
+
txMinHeight,
|
|
10080
|
+
txMaxHeight,
|
|
10081
|
+
}));
|
|
10082
|
+
promiseTotalTxOutgoingHistory.push(this.cosmosClient.searchTxFromRPC({
|
|
10083
|
+
rpcEndpoint: this.getClientUrl().rpc,
|
|
10084
|
+
messageAction,
|
|
10085
|
+
transferSender: address,
|
|
10086
|
+
page: index,
|
|
10087
|
+
limit: MAX_TX_COUNT_PER_PAGE,
|
|
10088
|
+
txMinHeight,
|
|
10089
|
+
txMaxHeight,
|
|
10090
|
+
}));
|
|
10091
|
+
}
|
|
10092
|
+
const incomingSearchResult = yield Promise.all(promiseTotalTxIncomingHistory);
|
|
10093
|
+
const outgoingSearchResult = yield Promise.all(promiseTotalTxOutgoingHistory);
|
|
10094
|
+
const totalTxIncomingHistory = incomingSearchResult.reduce((allTxs, searchResult) => {
|
|
10095
|
+
return [...allTxs, ...searchResult.txs];
|
|
10096
|
+
}, []);
|
|
10097
|
+
const totalTxOutgoingHistory = outgoingSearchResult.reduce((allTxs, searchResult) => {
|
|
10098
|
+
return [...allTxs, ...searchResult.txs];
|
|
10099
|
+
}, []);
|
|
10100
|
+
let history = totalTxIncomingHistory
|
|
10101
|
+
.concat(totalTxOutgoingHistory)
|
|
10079
10102
|
.sort((a, b) => {
|
|
10080
10103
|
if (a.height !== b.height)
|
|
10081
10104
|
return parseInt(b.height) > parseInt(a.height) ? 1 : -1;
|
|
@@ -10084,12 +10107,16 @@ class Client extends BaseXChainClient {
|
|
|
10084
10107
|
return 0;
|
|
10085
10108
|
})
|
|
10086
10109
|
.reduce((acc, tx) => [...acc, ...(acc.length === 0 || acc[acc.length - 1].hash !== tx.hash ? [tx] : [])], [])
|
|
10087
|
-
.filter((params === null || params === void 0 ? void 0 : params.filterFn) ? params.filterFn : (tx) => tx)
|
|
10088
|
-
.filter((_, index) => index < MAX_TX_COUNT);
|
|
10089
|
-
// get `total` before filtering txs out for pagination
|
|
10090
|
-
const total = history.length;
|
|
10110
|
+
.filter((params === null || params === void 0 ? void 0 : params.filterFn) ? params.filterFn : (tx) => tx);
|
|
10091
10111
|
history = history.filter((_, index) => index >= offset && index < offset + limit);
|
|
10092
|
-
const
|
|
10112
|
+
const total = history.length;
|
|
10113
|
+
const txs = [];
|
|
10114
|
+
for (let i = 0; i < history.length; i += 10) {
|
|
10115
|
+
const batch = history.slice(i, i + 10);
|
|
10116
|
+
const result = yield Promise.all(batch.map(({ hash }) => this.getTransactionData(hash, address)));
|
|
10117
|
+
txs.push(...result);
|
|
10118
|
+
delay(2000); // Delay to avoid 503 from ninerealms server
|
|
10119
|
+
}
|
|
10093
10120
|
return {
|
|
10094
10121
|
total,
|
|
10095
10122
|
txs,
|
|
@@ -10274,20 +10301,119 @@ class Client extends BaseXChainClient {
|
|
|
10274
10301
|
* @returns {Tx} The transaction details of the given transaction id.
|
|
10275
10302
|
*/
|
|
10276
10303
|
getTransactionData(txId, address) {
|
|
10304
|
+
var _a, _b, _c;
|
|
10277
10305
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10278
|
-
|
|
10279
|
-
|
|
10280
|
-
|
|
10281
|
-
|
|
10282
|
-
|
|
10283
|
-
|
|
10306
|
+
try {
|
|
10307
|
+
const txResult = yield this.cosmosClient.txsHashGet(txId);
|
|
10308
|
+
const bond = txResult.logs && txResult.logs[0].events.filter((i) => i.type === 'bond');
|
|
10309
|
+
const transfer = txResult.logs && txResult.logs[0].events.filter((i) => i.type === 'transfer');
|
|
10310
|
+
if (!transfer)
|
|
10311
|
+
throw new Error(`Failed to get transaction logs (tx-hash: ${txId})`);
|
|
10312
|
+
const sender = (_a = transfer[0].attributes.find((attr) => attr.key === 'sender')) === null || _a === void 0 ? void 0 : _a.value;
|
|
10313
|
+
const senderAmount = transfer[0].attributes.filter((attr) => attr.key === 'amount')[1].value;
|
|
10314
|
+
const regex = /[a-zA-Z]+$/;
|
|
10315
|
+
const match = senderAmount.match(regex);
|
|
10316
|
+
const asset = match ? match[0] : null;
|
|
10317
|
+
const senderAsset = asset === 'rune' ? AssetRuneNative : assetFromStringEx(`${asset}`);
|
|
10318
|
+
const senderAddress = sender ? sender : address;
|
|
10319
|
+
const message = txResult.logs && txResult.logs[0].events.filter((i) => i.type === 'message');
|
|
10320
|
+
const coinSpent = txResult.logs && txResult.logs[0].events.filter((i) => i.type === 'coin_spent');
|
|
10321
|
+
if (!message || !coinSpent)
|
|
10322
|
+
throw new Error(`Failed to get transaction logs (tx-hash: ${txId})`);
|
|
10323
|
+
const action = (_b = message[0].attributes.find((attr) => attr.key === 'action')) === null || _b === void 0 ? void 0 : _b.value;
|
|
10324
|
+
if (!bond)
|
|
10325
|
+
throw new Error(`Failed to get transaction logs (tx-hash: ${txId})`);
|
|
10326
|
+
// Rune only transactions
|
|
10327
|
+
if (bond[0].type === 'bond' || action === 'send') {
|
|
10328
|
+
const assetTo = AssetRuneNative;
|
|
10329
|
+
const txData = txResult && txResult.logs
|
|
10330
|
+
? getDepositTxDataFromLogs(txResult.logs, senderAddress, senderAsset, assetTo)
|
|
10331
|
+
: null;
|
|
10332
|
+
//console.log(JSON.stringify(txData, null, 2))
|
|
10333
|
+
if (!txData)
|
|
10334
|
+
throw new Error(`Failed to get transaction data (tx-hash: ${txId})`);
|
|
10335
|
+
const { from, to, type } = txData;
|
|
10336
|
+
return {
|
|
10337
|
+
hash: txId,
|
|
10338
|
+
asset: senderAsset,
|
|
10339
|
+
from,
|
|
10340
|
+
to,
|
|
10341
|
+
date: new Date(txResult.timestamp),
|
|
10342
|
+
type,
|
|
10343
|
+
};
|
|
10344
|
+
}
|
|
10345
|
+
// synths and other tx types
|
|
10346
|
+
const messageBody = JSON.stringify((_c = txResult.tx) === null || _c === void 0 ? void 0 : _c.body.messages).split(':');
|
|
10347
|
+
const assetTo = assetFromStringEx(messageBody[7]);
|
|
10348
|
+
const txData = txResult && txResult.logs ? getDepositTxDataFromLogs(txResult.logs, senderAddress, senderAsset, assetTo) : null;
|
|
10349
|
+
if (!txData)
|
|
10350
|
+
throw new Error(`Failed to get transaction data (tx-hash: ${txId})`);
|
|
10351
|
+
const { from, to, type } = txData;
|
|
10352
|
+
return {
|
|
10353
|
+
hash: txId,
|
|
10354
|
+
asset: senderAsset,
|
|
10355
|
+
from,
|
|
10356
|
+
to,
|
|
10357
|
+
date: new Date(txResult.timestamp),
|
|
10358
|
+
type,
|
|
10359
|
+
};
|
|
10360
|
+
}
|
|
10361
|
+
catch (error) { }
|
|
10362
|
+
return yield this.getTransactionDataThornode(txId);
|
|
10363
|
+
});
|
|
10364
|
+
}
|
|
10365
|
+
/** This function is used when in bound or outbound tx is not of thorchain
|
|
10366
|
+
*
|
|
10367
|
+
* @param txId - transaction hash
|
|
10368
|
+
* @returns - Tx object
|
|
10369
|
+
*/
|
|
10370
|
+
getTransactionDataThornode(txId) {
|
|
10371
|
+
var _a, _b, _c;
|
|
10372
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10373
|
+
const txResult = JSON.stringify(yield this.thornodeAPIGet(`/tx/${txId}`));
|
|
10374
|
+
const getTx = JSON.parse(txResult);
|
|
10375
|
+
if (!getTx)
|
|
10376
|
+
throw Error(`Could not return tx data`);
|
|
10377
|
+
const senderAsset = assetFromStringEx(`${(_a = getTx.observed_tx) === null || _a === void 0 ? void 0 : _a.tx.coins[0].asset}`);
|
|
10378
|
+
const fromAddress = `${getTx.observed_tx.tx.from_address}`;
|
|
10379
|
+
const from = [
|
|
10380
|
+
{ from: fromAddress, amount: baseAmount((_b = getTx.observed_tx) === null || _b === void 0 ? void 0 : _b.tx.coins[0].amount), asset: senderAsset },
|
|
10381
|
+
];
|
|
10382
|
+
const splitMemo = (_c = getTx.observed_tx.tx.memo) === null || _c === void 0 ? void 0 : _c.split(':');
|
|
10383
|
+
if (!splitMemo)
|
|
10384
|
+
throw Error(`Could not parse memo`);
|
|
10385
|
+
let asset;
|
|
10386
|
+
let amount;
|
|
10387
|
+
if (splitMemo[0] === 'OUT') {
|
|
10388
|
+
asset = assetFromStringEx(getTx.observed_tx.tx.coins[0].asset);
|
|
10389
|
+
amount = getTx.observed_tx.tx.coins[0].amount;
|
|
10390
|
+
const addressTo = getTx.observed_tx.tx.to_address ? getTx.observed_tx.tx.to_address : 'undefined';
|
|
10391
|
+
const to = [{ to: addressTo, amount: baseAmount(amount, DECIMAL), asset: asset }];
|
|
10392
|
+
const txData = {
|
|
10393
|
+
hash: txId,
|
|
10394
|
+
asset: senderAsset,
|
|
10395
|
+
from,
|
|
10396
|
+
to,
|
|
10397
|
+
date: new Date(),
|
|
10398
|
+
type: TxType.Transfer,
|
|
10399
|
+
};
|
|
10400
|
+
return txData;
|
|
10401
|
+
}
|
|
10402
|
+
asset = assetFromStringEx(splitMemo[1]);
|
|
10403
|
+
const address = splitMemo[2];
|
|
10404
|
+
amount = splitMemo[3];
|
|
10405
|
+
const receiverAsset = asset;
|
|
10406
|
+
const recieverAmount = amount;
|
|
10407
|
+
const to = [{ to: address, amount: baseAmount(recieverAmount, DECIMAL), asset: receiverAsset }];
|
|
10408
|
+
const txData = {
|
|
10284
10409
|
hash: txId,
|
|
10285
|
-
asset:
|
|
10410
|
+
asset: senderAsset,
|
|
10286
10411
|
from,
|
|
10287
10412
|
to,
|
|
10288
|
-
date: new Date(
|
|
10289
|
-
type,
|
|
10413
|
+
date: new Date(),
|
|
10414
|
+
type: TxType.Transfer,
|
|
10290
10415
|
};
|
|
10416
|
+
return txData;
|
|
10291
10417
|
});
|
|
10292
10418
|
}
|
|
10293
10419
|
/**
|
|
@@ -10448,6 +10574,11 @@ class Client extends BaseXChainClient {
|
|
|
10448
10574
|
return txHash;
|
|
10449
10575
|
});
|
|
10450
10576
|
}
|
|
10577
|
+
broadcastTx(txHex) {
|
|
10578
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10579
|
+
return yield this.getCosmosClient().broadcast(txHex);
|
|
10580
|
+
});
|
|
10581
|
+
}
|
|
10451
10582
|
/**
|
|
10452
10583
|
* Transfer without broadcast balances with MsgSend
|
|
10453
10584
|
*
|
|
@@ -10529,4 +10660,4 @@ const msgNativeTxFromJson = (value) => {
|
|
|
10529
10660
|
return new MsgNativeTx(value.coins, value.memo, cosmosclient.AccAddress.fromString(value.signer));
|
|
10530
10661
|
};
|
|
10531
10662
|
|
|
10532
|
-
export { AssetRune67C, AssetRuneB1A, AssetRuneERC20, AssetRuneERC20Testnet, AssetRuneNative, Client, DECIMAL, DEFAULT_GAS_ADJUSTMENT, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE,
|
|
10663
|
+
export { AssetRune67C, AssetRuneB1A, AssetRuneERC20, AssetRuneERC20Testnet, AssetRuneNative, Client, DECIMAL, DEFAULT_GAS_ADJUSTMENT, DEFAULT_GAS_LIMIT_VALUE, DEPOSIT_GAS_LIMIT_VALUE, MAX_PAGES_PER_FUNCTION_CALL, MAX_TX_COUNT_PER_FUNCTION_CALL, MAX_TX_COUNT_PER_PAGE, MsgNativeTx, RUNE_SYMBOL, THORChain, assetFromDenom, buildDepositTx, buildTransferTx, buildUnsignedTx, defaultExplorerUrls, getAccount, getBalance, getChainId, getDefaultFees, getDenom, getDepositTxDataFromLogs, getEstimatedGas, getExplorerAddressUrl, getExplorerTxUrl, getExplorerUrl, getPrefix, getSequence, getTxType, isAssetRuneNative, isBroadcastSuccess, msgNativeTxFromJson, registerDepositCodecs, registerSendCodecs };
|
package/lib/index.js
CHANGED
|
@@ -4278,7 +4278,9 @@ const DECIMAL = 8;
|
|
|
4278
4278
|
const DEFAULT_GAS_ADJUSTMENT = 2;
|
|
4279
4279
|
const DEFAULT_GAS_LIMIT_VALUE = '4000000';
|
|
4280
4280
|
const DEPOSIT_GAS_LIMIT_VALUE = '600000000';
|
|
4281
|
-
const
|
|
4281
|
+
const MAX_TX_COUNT_PER_PAGE = 100;
|
|
4282
|
+
const MAX_TX_COUNT_PER_FUNCTION_CALL = 500;
|
|
4283
|
+
const MAX_PAGES_PER_FUNCTION_CALL = 15;
|
|
4282
4284
|
const RUNE_SYMBOL = 'ᚱ';
|
|
4283
4285
|
const defaultExplorerUrls = {
|
|
4284
4286
|
root: {
|
|
@@ -9766,7 +9768,7 @@ const registerSendCodecs = () => {
|
|
|
9766
9768
|
* @param {Address} address - Address to get transaction data for
|
|
9767
9769
|
* @returns {TxData} Parsed transaction data
|
|
9768
9770
|
*/
|
|
9769
|
-
const getDepositTxDataFromLogs = (logs, address) => {
|
|
9771
|
+
const getDepositTxDataFromLogs = (logs, address, senderAsset, receiverAsset) => {
|
|
9770
9772
|
var _a;
|
|
9771
9773
|
const events = (_a = logs[0]) === null || _a === void 0 ? void 0 : _a.events;
|
|
9772
9774
|
if (!events) {
|
|
@@ -9793,7 +9795,7 @@ const getDepositTxDataFromLogs = (logs, address) => {
|
|
|
9793
9795
|
// filter out txs which are not based on given address
|
|
9794
9796
|
.filter(({ sender, recipient }) => sender === address || recipient === address)
|
|
9795
9797
|
// transform `TransferData` -> `TxData`
|
|
9796
|
-
.reduce((acc, { sender, recipient, amount }) => (Object.assign(Object.assign({}, acc), { from: [...acc.from, { amount, from: sender }], to: [...acc.to, { amount, to: recipient }] })), { from: [], to: [], type: xchainClient.TxType.Transfer });
|
|
9798
|
+
.reduce((acc, { sender, recipient, amount }) => (Object.assign(Object.assign({}, acc), { from: [...acc.from, { amount, from: sender, asset: senderAsset }], to: [...acc.to, { amount, to: recipient, asset: receiverAsset }] })), { from: [], to: [], type: xchainClient.TxType.Transfer });
|
|
9797
9799
|
return txData;
|
|
9798
9800
|
};
|
|
9799
9801
|
/**
|
|
@@ -10067,24 +10069,45 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10067
10069
|
const address = (params === null || params === void 0 ? void 0 : params.address) || this.getAddress();
|
|
10068
10070
|
const txMinHeight = undefined;
|
|
10069
10071
|
const txMaxHeight = undefined;
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
const
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
|
|
10087
|
-
|
|
10072
|
+
if (limit + offset > MAX_PAGES_PER_FUNCTION_CALL * MAX_TX_COUNT_PER_PAGE) {
|
|
10073
|
+
throw Error(`limit plus offset can not be grater than ${MAX_PAGES_PER_FUNCTION_CALL * MAX_TX_COUNT_PER_PAGE}`);
|
|
10074
|
+
}
|
|
10075
|
+
if (limit > MAX_TX_COUNT_PER_FUNCTION_CALL) {
|
|
10076
|
+
throw Error(`Maximum number of transaction per call is ${MAX_TX_COUNT_PER_FUNCTION_CALL}`);
|
|
10077
|
+
}
|
|
10078
|
+
const pagesNumber = Math.ceil((limit + offset) / MAX_TX_COUNT_PER_PAGE);
|
|
10079
|
+
const promiseTotalTxIncomingHistory = [];
|
|
10080
|
+
const promiseTotalTxOutgoingHistory = [];
|
|
10081
|
+
for (let index = 1; index <= pagesNumber; index++) {
|
|
10082
|
+
promiseTotalTxIncomingHistory.push(this.cosmosClient.searchTxFromRPC({
|
|
10083
|
+
rpcEndpoint: this.getClientUrl().rpc,
|
|
10084
|
+
messageAction,
|
|
10085
|
+
transferRecipient: address,
|
|
10086
|
+
page: index,
|
|
10087
|
+
limit: MAX_TX_COUNT_PER_PAGE,
|
|
10088
|
+
txMinHeight,
|
|
10089
|
+
txMaxHeight,
|
|
10090
|
+
}));
|
|
10091
|
+
promiseTotalTxOutgoingHistory.push(this.cosmosClient.searchTxFromRPC({
|
|
10092
|
+
rpcEndpoint: this.getClientUrl().rpc,
|
|
10093
|
+
messageAction,
|
|
10094
|
+
transferSender: address,
|
|
10095
|
+
page: index,
|
|
10096
|
+
limit: MAX_TX_COUNT_PER_PAGE,
|
|
10097
|
+
txMinHeight,
|
|
10098
|
+
txMaxHeight,
|
|
10099
|
+
}));
|
|
10100
|
+
}
|
|
10101
|
+
const incomingSearchResult = yield Promise.all(promiseTotalTxIncomingHistory);
|
|
10102
|
+
const outgoingSearchResult = yield Promise.all(promiseTotalTxOutgoingHistory);
|
|
10103
|
+
const totalTxIncomingHistory = incomingSearchResult.reduce((allTxs, searchResult) => {
|
|
10104
|
+
return [...allTxs, ...searchResult.txs];
|
|
10105
|
+
}, []);
|
|
10106
|
+
const totalTxOutgoingHistory = outgoingSearchResult.reduce((allTxs, searchResult) => {
|
|
10107
|
+
return [...allTxs, ...searchResult.txs];
|
|
10108
|
+
}, []);
|
|
10109
|
+
let history = totalTxIncomingHistory
|
|
10110
|
+
.concat(totalTxOutgoingHistory)
|
|
10088
10111
|
.sort((a, b) => {
|
|
10089
10112
|
if (a.height !== b.height)
|
|
10090
10113
|
return parseInt(b.height) > parseInt(a.height) ? 1 : -1;
|
|
@@ -10093,12 +10116,16 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10093
10116
|
return 0;
|
|
10094
10117
|
})
|
|
10095
10118
|
.reduce((acc, tx) => [...acc, ...(acc.length === 0 || acc[acc.length - 1].hash !== tx.hash ? [tx] : [])], [])
|
|
10096
|
-
.filter((params === null || params === void 0 ? void 0 : params.filterFn) ? params.filterFn : (tx) => tx)
|
|
10097
|
-
.filter((_, index) => index < MAX_TX_COUNT);
|
|
10098
|
-
// get `total` before filtering txs out for pagination
|
|
10099
|
-
const total = history.length;
|
|
10119
|
+
.filter((params === null || params === void 0 ? void 0 : params.filterFn) ? params.filterFn : (tx) => tx);
|
|
10100
10120
|
history = history.filter((_, index) => index >= offset && index < offset + limit);
|
|
10101
|
-
const
|
|
10121
|
+
const total = history.length;
|
|
10122
|
+
const txs = [];
|
|
10123
|
+
for (let i = 0; i < history.length; i += 10) {
|
|
10124
|
+
const batch = history.slice(i, i + 10);
|
|
10125
|
+
const result = yield Promise.all(batch.map(({ hash }) => this.getTransactionData(hash, address)));
|
|
10126
|
+
txs.push(...result);
|
|
10127
|
+
xchainUtil.delay(2000); // Delay to avoid 503 from ninerealms server
|
|
10128
|
+
}
|
|
10102
10129
|
return {
|
|
10103
10130
|
total,
|
|
10104
10131
|
txs,
|
|
@@ -10283,20 +10310,119 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10283
10310
|
* @returns {Tx} The transaction details of the given transaction id.
|
|
10284
10311
|
*/
|
|
10285
10312
|
getTransactionData(txId, address) {
|
|
10313
|
+
var _a, _b, _c;
|
|
10286
10314
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10287
|
-
|
|
10288
|
-
|
|
10289
|
-
|
|
10290
|
-
|
|
10291
|
-
|
|
10292
|
-
|
|
10315
|
+
try {
|
|
10316
|
+
const txResult = yield this.cosmosClient.txsHashGet(txId);
|
|
10317
|
+
const bond = txResult.logs && txResult.logs[0].events.filter((i) => i.type === 'bond');
|
|
10318
|
+
const transfer = txResult.logs && txResult.logs[0].events.filter((i) => i.type === 'transfer');
|
|
10319
|
+
if (!transfer)
|
|
10320
|
+
throw new Error(`Failed to get transaction logs (tx-hash: ${txId})`);
|
|
10321
|
+
const sender = (_a = transfer[0].attributes.find((attr) => attr.key === 'sender')) === null || _a === void 0 ? void 0 : _a.value;
|
|
10322
|
+
const senderAmount = transfer[0].attributes.filter((attr) => attr.key === 'amount')[1].value;
|
|
10323
|
+
const regex = /[a-zA-Z]+$/;
|
|
10324
|
+
const match = senderAmount.match(regex);
|
|
10325
|
+
const asset = match ? match[0] : null;
|
|
10326
|
+
const senderAsset = asset === 'rune' ? AssetRuneNative : xchainUtil.assetFromStringEx(`${asset}`);
|
|
10327
|
+
const senderAddress = sender ? sender : address;
|
|
10328
|
+
const message = txResult.logs && txResult.logs[0].events.filter((i) => i.type === 'message');
|
|
10329
|
+
const coinSpent = txResult.logs && txResult.logs[0].events.filter((i) => i.type === 'coin_spent');
|
|
10330
|
+
if (!message || !coinSpent)
|
|
10331
|
+
throw new Error(`Failed to get transaction logs (tx-hash: ${txId})`);
|
|
10332
|
+
const action = (_b = message[0].attributes.find((attr) => attr.key === 'action')) === null || _b === void 0 ? void 0 : _b.value;
|
|
10333
|
+
if (!bond)
|
|
10334
|
+
throw new Error(`Failed to get transaction logs (tx-hash: ${txId})`);
|
|
10335
|
+
// Rune only transactions
|
|
10336
|
+
if (bond[0].type === 'bond' || action === 'send') {
|
|
10337
|
+
const assetTo = AssetRuneNative;
|
|
10338
|
+
const txData = txResult && txResult.logs
|
|
10339
|
+
? getDepositTxDataFromLogs(txResult.logs, senderAddress, senderAsset, assetTo)
|
|
10340
|
+
: null;
|
|
10341
|
+
//console.log(JSON.stringify(txData, null, 2))
|
|
10342
|
+
if (!txData)
|
|
10343
|
+
throw new Error(`Failed to get transaction data (tx-hash: ${txId})`);
|
|
10344
|
+
const { from, to, type } = txData;
|
|
10345
|
+
return {
|
|
10346
|
+
hash: txId,
|
|
10347
|
+
asset: senderAsset,
|
|
10348
|
+
from,
|
|
10349
|
+
to,
|
|
10350
|
+
date: new Date(txResult.timestamp),
|
|
10351
|
+
type,
|
|
10352
|
+
};
|
|
10353
|
+
}
|
|
10354
|
+
// synths and other tx types
|
|
10355
|
+
const messageBody = JSON.stringify((_c = txResult.tx) === null || _c === void 0 ? void 0 : _c.body.messages).split(':');
|
|
10356
|
+
const assetTo = xchainUtil.assetFromStringEx(messageBody[7]);
|
|
10357
|
+
const txData = txResult && txResult.logs ? getDepositTxDataFromLogs(txResult.logs, senderAddress, senderAsset, assetTo) : null;
|
|
10358
|
+
if (!txData)
|
|
10359
|
+
throw new Error(`Failed to get transaction data (tx-hash: ${txId})`);
|
|
10360
|
+
const { from, to, type } = txData;
|
|
10361
|
+
return {
|
|
10362
|
+
hash: txId,
|
|
10363
|
+
asset: senderAsset,
|
|
10364
|
+
from,
|
|
10365
|
+
to,
|
|
10366
|
+
date: new Date(txResult.timestamp),
|
|
10367
|
+
type,
|
|
10368
|
+
};
|
|
10369
|
+
}
|
|
10370
|
+
catch (error) { }
|
|
10371
|
+
return yield this.getTransactionDataThornode(txId);
|
|
10372
|
+
});
|
|
10373
|
+
}
|
|
10374
|
+
/** This function is used when in bound or outbound tx is not of thorchain
|
|
10375
|
+
*
|
|
10376
|
+
* @param txId - transaction hash
|
|
10377
|
+
* @returns - Tx object
|
|
10378
|
+
*/
|
|
10379
|
+
getTransactionDataThornode(txId) {
|
|
10380
|
+
var _a, _b, _c;
|
|
10381
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10382
|
+
const txResult = JSON.stringify(yield this.thornodeAPIGet(`/tx/${txId}`));
|
|
10383
|
+
const getTx = JSON.parse(txResult);
|
|
10384
|
+
if (!getTx)
|
|
10385
|
+
throw Error(`Could not return tx data`);
|
|
10386
|
+
const senderAsset = xchainUtil.assetFromStringEx(`${(_a = getTx.observed_tx) === null || _a === void 0 ? void 0 : _a.tx.coins[0].asset}`);
|
|
10387
|
+
const fromAddress = `${getTx.observed_tx.tx.from_address}`;
|
|
10388
|
+
const from = [
|
|
10389
|
+
{ from: fromAddress, amount: xchainUtil.baseAmount((_b = getTx.observed_tx) === null || _b === void 0 ? void 0 : _b.tx.coins[0].amount), asset: senderAsset },
|
|
10390
|
+
];
|
|
10391
|
+
const splitMemo = (_c = getTx.observed_tx.tx.memo) === null || _c === void 0 ? void 0 : _c.split(':');
|
|
10392
|
+
if (!splitMemo)
|
|
10393
|
+
throw Error(`Could not parse memo`);
|
|
10394
|
+
let asset;
|
|
10395
|
+
let amount;
|
|
10396
|
+
if (splitMemo[0] === 'OUT') {
|
|
10397
|
+
asset = xchainUtil.assetFromStringEx(getTx.observed_tx.tx.coins[0].asset);
|
|
10398
|
+
amount = getTx.observed_tx.tx.coins[0].amount;
|
|
10399
|
+
const addressTo = getTx.observed_tx.tx.to_address ? getTx.observed_tx.tx.to_address : 'undefined';
|
|
10400
|
+
const to = [{ to: addressTo, amount: xchainUtil.baseAmount(amount, DECIMAL), asset: asset }];
|
|
10401
|
+
const txData = {
|
|
10402
|
+
hash: txId,
|
|
10403
|
+
asset: senderAsset,
|
|
10404
|
+
from,
|
|
10405
|
+
to,
|
|
10406
|
+
date: new Date(),
|
|
10407
|
+
type: xchainClient.TxType.Transfer,
|
|
10408
|
+
};
|
|
10409
|
+
return txData;
|
|
10410
|
+
}
|
|
10411
|
+
asset = xchainUtil.assetFromStringEx(splitMemo[1]);
|
|
10412
|
+
const address = splitMemo[2];
|
|
10413
|
+
amount = splitMemo[3];
|
|
10414
|
+
const receiverAsset = asset;
|
|
10415
|
+
const recieverAmount = amount;
|
|
10416
|
+
const to = [{ to: address, amount: xchainUtil.baseAmount(recieverAmount, DECIMAL), asset: receiverAsset }];
|
|
10417
|
+
const txData = {
|
|
10293
10418
|
hash: txId,
|
|
10294
|
-
asset:
|
|
10419
|
+
asset: senderAsset,
|
|
10295
10420
|
from,
|
|
10296
10421
|
to,
|
|
10297
|
-
date: new Date(
|
|
10298
|
-
type,
|
|
10422
|
+
date: new Date(),
|
|
10423
|
+
type: xchainClient.TxType.Transfer,
|
|
10299
10424
|
};
|
|
10425
|
+
return txData;
|
|
10300
10426
|
});
|
|
10301
10427
|
}
|
|
10302
10428
|
/**
|
|
@@ -10457,6 +10583,11 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10457
10583
|
return txHash;
|
|
10458
10584
|
});
|
|
10459
10585
|
}
|
|
10586
|
+
broadcastTx(txHex) {
|
|
10587
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
10588
|
+
return yield this.getCosmosClient().broadcast(txHex);
|
|
10589
|
+
});
|
|
10590
|
+
}
|
|
10460
10591
|
/**
|
|
10461
10592
|
* Transfer without broadcast balances with MsgSend
|
|
10462
10593
|
*
|
|
@@ -10548,7 +10679,9 @@ exports.DECIMAL = DECIMAL;
|
|
|
10548
10679
|
exports.DEFAULT_GAS_ADJUSTMENT = DEFAULT_GAS_ADJUSTMENT;
|
|
10549
10680
|
exports.DEFAULT_GAS_LIMIT_VALUE = DEFAULT_GAS_LIMIT_VALUE;
|
|
10550
10681
|
exports.DEPOSIT_GAS_LIMIT_VALUE = DEPOSIT_GAS_LIMIT_VALUE;
|
|
10551
|
-
exports.
|
|
10682
|
+
exports.MAX_PAGES_PER_FUNCTION_CALL = MAX_PAGES_PER_FUNCTION_CALL;
|
|
10683
|
+
exports.MAX_TX_COUNT_PER_FUNCTION_CALL = MAX_TX_COUNT_PER_FUNCTION_CALL;
|
|
10684
|
+
exports.MAX_TX_COUNT_PER_PAGE = MAX_TX_COUNT_PER_PAGE;
|
|
10552
10685
|
exports.MsgNativeTx = MsgNativeTx;
|
|
10553
10686
|
exports.RUNE_SYMBOL = RUNE_SYMBOL;
|
|
10554
10687
|
exports.THORChain = THORChain;
|
|
@@ -69,3 +69,24 @@ export declare type SimulateResponse = {
|
|
|
69
69
|
gas_used: string;
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
+
export declare type MessageSend = {
|
|
73
|
+
'@type': string;
|
|
74
|
+
from_address: string;
|
|
75
|
+
to_address: string;
|
|
76
|
+
amount: Amount;
|
|
77
|
+
};
|
|
78
|
+
export declare type Amount = {
|
|
79
|
+
denom: string;
|
|
80
|
+
amount: string;
|
|
81
|
+
};
|
|
82
|
+
export declare type MessageDeposit = {
|
|
83
|
+
'@type': string;
|
|
84
|
+
coins: Coins[];
|
|
85
|
+
memo: string;
|
|
86
|
+
signer: string;
|
|
87
|
+
};
|
|
88
|
+
export declare type Coins = {
|
|
89
|
+
asset: string;
|
|
90
|
+
amount: number;
|
|
91
|
+
decimals: number;
|
|
92
|
+
};
|
package/lib/utils.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export declare const registerSendCodecs: () => void;
|
|
|
57
57
|
* @param {Address} address - Address to get transaction data for
|
|
58
58
|
* @returns {TxData} Parsed transaction data
|
|
59
59
|
*/
|
|
60
|
-
export declare const getDepositTxDataFromLogs: (logs: TxLog[], address: Address) => TxData;
|
|
60
|
+
export declare const getDepositTxDataFromLogs: (logs: TxLog[], address: Address, senderAsset?: Asset | undefined, receiverAsset?: Asset | undefined) => TxData;
|
|
61
61
|
/**
|
|
62
62
|
* Get the default fee.
|
|
63
63
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-thorchain",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.11",
|
|
4
4
|
"description": "Custom Thorchain client and utilities used by XChainJS clients",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"THORChain",
|
|
@@ -36,11 +36,9 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@cosmos-client/core": "0.46.1",
|
|
38
38
|
"@types/big.js": "^6.0.0",
|
|
39
|
-
"@xchainjs/xchain-
|
|
40
|
-
"@xchainjs/xchain-
|
|
41
|
-
"@xchainjs/xchain-cosmos": "^0.20.6",
|
|
39
|
+
"@xchainjs/xchain-client": "^0.13.7",
|
|
40
|
+
"@xchainjs/xchain-cosmos": "^0.20.9",
|
|
42
41
|
"@xchainjs/xchain-crypto": "^0.2.6",
|
|
43
|
-
"@xchainjs/xchain-ethereum": "^0.27.6",
|
|
44
42
|
"@xchainjs/xchain-util": "^0.12.0",
|
|
45
43
|
"axios": "^0.25.0",
|
|
46
44
|
"bech32-buffer": "^0.2.0",
|
|
@@ -51,8 +49,8 @@
|
|
|
51
49
|
},
|
|
52
50
|
"peerDependencies": {
|
|
53
51
|
"@cosmos-client/core": "0.46.1",
|
|
54
|
-
"@xchainjs/xchain-client": "^0.13.
|
|
55
|
-
"@xchainjs/xchain-cosmos": "^0.20.
|
|
52
|
+
"@xchainjs/xchain-client": "^0.13.7",
|
|
53
|
+
"@xchainjs/xchain-cosmos": "^0.20.9",
|
|
56
54
|
"@xchainjs/xchain-crypto": "^0.2.6",
|
|
57
55
|
"@xchainjs/xchain-util": "^0.12.0",
|
|
58
56
|
"axios": "^0.25.0",
|
package/CHANGELOG.md
DELETED
|
@@ -1,598 +0,0 @@
|
|
|
1
|
-
# v.0.27.8 (2023-01-19)
|
|
2
|
-
|
|
3
|
-
## Update
|
|
4
|
-
|
|
5
|
-
- Type safety `THORChain`
|
|
6
|
-
|
|
7
|
-
# v.0.27.7 (2022-12-27)
|
|
8
|
-
|
|
9
|
-
## Add
|
|
10
|
-
|
|
11
|
-
- Add `AssetRune67C`, `AssetRuneB1A`, `AssetRuneERC20`, `AssetRuneERC20Testnet`, `THORChain` and `AssetRuneNative` definitions
|
|
12
|
-
|
|
13
|
-
## Update
|
|
14
|
-
|
|
15
|
-
- Bump `xchain-client@13.5.0`
|
|
16
|
-
|
|
17
|
-
## Update
|
|
18
|
-
|
|
19
|
-
- Change `AssetETH`, `AssetBNB` and `GAIAChain` imports to its own `xchain-*` package
|
|
20
|
-
|
|
21
|
-
# v.0.27.6 (2022-12-13)
|
|
22
|
-
|
|
23
|
-
## Update
|
|
24
|
-
|
|
25
|
-
- removed `customRequestHeaders`
|
|
26
|
-
|
|
27
|
-
# v.0.27.5 (2022-12-12)
|
|
28
|
-
|
|
29
|
-
## Update
|
|
30
|
-
|
|
31
|
-
- Add optional `sequence` to `transfer` and `deposit` to override `sequence`
|
|
32
|
-
- Add helpers `getAccount` and `getSequence` to `utils`
|
|
33
|
-
|
|
34
|
-
# v.0.27.4 (2022-11-??)
|
|
35
|
-
|
|
36
|
-
# v.0.27.3 (2022-11-24)
|
|
37
|
-
|
|
38
|
-
## Update
|
|
39
|
-
|
|
40
|
-
- Added `customRequestHeaders` to `BroadcastTxParams`
|
|
41
|
-
- Bump `xchain-client`
|
|
42
|
-
|
|
43
|
-
# v.0.27.2 (2022-11-08)
|
|
44
|
-
|
|
45
|
-
## Update
|
|
46
|
-
|
|
47
|
-
- changed chain-id-stagenet to `thorchain-stagenet-v2`
|
|
48
|
-
|
|
49
|
-
# v.0.27.1 (2022-10-13)
|
|
50
|
-
|
|
51
|
-
- added default `chainIds` in constructor
|
|
52
|
-
- added default `explorerUrls` in constructor
|
|
53
|
-
- Set Default network to `Network.Mainnet`
|
|
54
|
-
|
|
55
|
-
## Update
|
|
56
|
-
|
|
57
|
-
- Bumped `xchain-utils` & `xchain-client`
|
|
58
|
-
|
|
59
|
-
# v0.27.0 (2022-10-07)
|
|
60
|
-
|
|
61
|
-
## Breaking Changes
|
|
62
|
-
|
|
63
|
-
- Removed `getDefaultClientUrl`
|
|
64
|
-
- Removed `getChainIds`
|
|
65
|
-
- Update `ThorchainClientParams` to make clientUrl required (not optional)
|
|
66
|
-
|
|
67
|
-
# v.0.26.2 (2022-10-06)
|
|
68
|
-
|
|
69
|
-
## Update
|
|
70
|
-
|
|
71
|
-
- Bumped `xchain-utils` & `xchain-client`
|
|
72
|
-
|
|
73
|
-
# v.0.26.1 (2022-09-29)
|
|
74
|
-
|
|
75
|
-
## Update
|
|
76
|
-
|
|
77
|
-
- bumped deps on xchain-utils & xchain-client
|
|
78
|
-
|
|
79
|
-
# v.0.26.0 (2022-07-20)
|
|
80
|
-
|
|
81
|
-
## Change
|
|
82
|
-
|
|
83
|
-
- updated packages xchain-client & xchain-util
|
|
84
|
-
|
|
85
|
-
# v0.25.3 (2022-07-01)
|
|
86
|
-
|
|
87
|
-
## Update
|
|
88
|
-
|
|
89
|
-
- Latest "xchain-cosmos@0.19.0"
|
|
90
|
-
|
|
91
|
-
# v0.25.2 (2022-06-22)
|
|
92
|
-
|
|
93
|
-
## Update
|
|
94
|
-
|
|
95
|
-
- Latest `@cosmos-client/core@0.45.10`
|
|
96
|
-
- Latest "xchain-cosmos@0.18.0"
|
|
97
|
-
|
|
98
|
-
## Fix
|
|
99
|
-
|
|
100
|
-
- Fix `setNetwork` to create new instance of SDK client
|
|
101
|
-
|
|
102
|
-
# v0.25.1 (2022-06-17)
|
|
103
|
-
|
|
104
|
-
## Fix
|
|
105
|
-
|
|
106
|
-
- Remove estimation of gas in `transfer` and `deposit` (introduced by #564) in favour of using `DEFAULT_GAS_LIMIT_VALUE` or `DEPOSIT_GAS_LIMIT_VALUE` (both can be overridden by users in `transfer` or `deposit`)
|
|
107
|
-
- Increase `DEPOSIT_GAS_LIMIT_VALUE` to `600000000` (before `500000000`)
|
|
108
|
-
|
|
109
|
-
# v0.25.0 (2022-06-16)
|
|
110
|
-
|
|
111
|
-
## Fix
|
|
112
|
-
|
|
113
|
-
- Before sending a transaction, gas limits are estimated
|
|
114
|
-
- Helper `getEstimatedGas`
|
|
115
|
-
|
|
116
|
-
## Breaking changes
|
|
117
|
-
|
|
118
|
-
- Client's `transferOffline` requires `fromAccountNumber` and `fromSequence`
|
|
119
|
-
- Rename parameters in `transferOffline` to keep names in camel case (not snake case)
|
|
120
|
-
- Rename `DEFAULT_GAS_VALUE` to `DEFAULT_GAS_LIMIT_VALUE`
|
|
121
|
-
- Rename `DEPOSIT_GAS_VALUE` to `DEPOSIT_GAS_LIMIT_VALUE`
|
|
122
|
-
|
|
123
|
-
# v0.24.1 (2022-04-23)
|
|
124
|
-
|
|
125
|
-
## Fix
|
|
126
|
-
|
|
127
|
-
- Increase `DEFAULT_GAS_VALUE` to `4000000` (before `3000000`)
|
|
128
|
-
|
|
129
|
-
# v0.24.0 (2022-03-23)
|
|
130
|
-
|
|
131
|
-
## Update
|
|
132
|
-
|
|
133
|
-
- upgraded to "@cosmos-client/core": "0.45.1"
|
|
134
|
-
- client now extend BaseXChainClient
|
|
135
|
-
|
|
136
|
-
## Breaking Changes
|
|
137
|
-
|
|
138
|
-
- `buildDepositTx` now returns `proto.cosmos.tx.v1beta1.TxBody` from `@cosmos-client/core`
|
|
139
|
-
|
|
140
|
-
# v0.23.0 (2022-03-08)
|
|
141
|
-
|
|
142
|
-
## Add
|
|
143
|
-
|
|
144
|
-
- Helpers `getChainId` + `getChainIds`
|
|
145
|
-
|
|
146
|
-
## Breaking change
|
|
147
|
-
|
|
148
|
-
- `chainIds: ChainIds` is required to initialize `Client`
|
|
149
|
-
|
|
150
|
-
## Fix
|
|
151
|
-
|
|
152
|
-
- Request fees from THORChain and use `defaultFees` in case of server errors only
|
|
153
|
-
- Fix `defaultFees` to be 0.02 RUNE
|
|
154
|
-
|
|
155
|
-
# v0.22.2 (2022-02-17)
|
|
156
|
-
|
|
157
|
-
## Fix
|
|
158
|
-
|
|
159
|
-
- Request fees from THORChain and use `defaultFees` in case of server errors only
|
|
160
|
-
- Fix `defaultFees` to be 0.02 RUNE
|
|
161
|
-
|
|
162
|
-
# v0.22.1 (2022-02-16)
|
|
163
|
-
|
|
164
|
-
## Fix
|
|
165
|
-
|
|
166
|
-
- Increase limit for `DEFAULT_GAS_VALUE` from 2000000 to 3000000 to accommodate recent increases in gas used that go above the old limit
|
|
167
|
-
|
|
168
|
-
# v0.22.0 (2022-02-06)
|
|
169
|
-
|
|
170
|
-
## Add
|
|
171
|
-
|
|
172
|
-
- Option to pass `ChainIds` into constructor
|
|
173
|
-
- getter / setter for `chainId` in `Client`
|
|
174
|
-
|
|
175
|
-
## Breaking change
|
|
176
|
-
|
|
177
|
-
- `buildDepositTx` needs `chainId` to be passed - all params are set as object
|
|
178
|
-
- Remove `enum ChainId` + `getChainId` + `isChainId` from `utils`
|
|
179
|
-
|
|
180
|
-
# v0.21.2 (2022-02-04)
|
|
181
|
-
|
|
182
|
-
## Fix
|
|
183
|
-
|
|
184
|
-
- Use latest axios@0.25.0
|
|
185
|
-
- xchain-client@0.11.1
|
|
186
|
-
- @xchainjs/xchain-util@0.5.1
|
|
187
|
-
- @xchainjs/xchain-cosmos@0.16.1
|
|
188
|
-
|
|
189
|
-
# v.0.21.1 (2022-02-04)
|
|
190
|
-
|
|
191
|
-
## Fix
|
|
192
|
-
|
|
193
|
-
- Fix chain id for `testnet` #477
|
|
194
|
-
|
|
195
|
-
## Add
|
|
196
|
-
|
|
197
|
-
- Helper `isChainId`
|
|
198
|
-
- `enum ChainId`
|
|
199
|
-
|
|
200
|
-
# v.0.21.0 (2022-02-02)
|
|
201
|
-
|
|
202
|
-
## Breaking change
|
|
203
|
-
|
|
204
|
-
- Remove `getDenomWithChain`
|
|
205
|
-
- Rename `getAsset` -> `assetFromDenom` (incl. fix to get synth asset properly)
|
|
206
|
-
|
|
207
|
-
## Update
|
|
208
|
-
|
|
209
|
-
- xchain-util@0.5.0
|
|
210
|
-
- xchain-cosmos@0.16.0
|
|
211
|
-
|
|
212
|
-
## Add
|
|
213
|
-
|
|
214
|
-
- `isAssetNativeRune` helper
|
|
215
|
-
- Add `TxOfflineParams` type
|
|
216
|
-
|
|
217
|
-
## Fix
|
|
218
|
-
|
|
219
|
-
- Fix synth notation in `transfer|transferOffline|deposit` #473
|
|
220
|
-
|
|
221
|
-
# v0.20.1 (2022-01-11)
|
|
222
|
-
|
|
223
|
-
## Fix
|
|
224
|
-
|
|
225
|
-
- Get chain ID from THORNode before posting to deposit handler.
|
|
226
|
-
|
|
227
|
-
# v.0.20.0 (2021-12-29)
|
|
228
|
-
|
|
229
|
-
## Breaking change
|
|
230
|
-
|
|
231
|
-
- Add stagenet environment handling for `Network` and `BaseXChainClient` to client
|
|
232
|
-
|
|
233
|
-
# v.0.19.5 (2021-11-22)
|
|
234
|
-
|
|
235
|
-
## Add
|
|
236
|
-
|
|
237
|
-
- Provide `transferOffline` method
|
|
238
|
-
|
|
239
|
-
# v.0.19.4 (2021-11-22)
|
|
240
|
-
|
|
241
|
-
## Add
|
|
242
|
-
|
|
243
|
-
- Provide `getPubKey` method to access public key
|
|
244
|
-
|
|
245
|
-
## Change
|
|
246
|
-
|
|
247
|
-
- Make `getPrivKey` method `public` to access private key
|
|
248
|
-
|
|
249
|
-
# v.0.19.3 (2021-10-31)
|
|
250
|
-
|
|
251
|
-
## Update
|
|
252
|
-
|
|
253
|
-
- Use latest `xchain-cosmos@0.13.8` to use `sync` mode for broadcasting txs
|
|
254
|
-
|
|
255
|
-
# v.0.19.2 (2021-09-27)
|
|
256
|
-
|
|
257
|
-
## Fix
|
|
258
|
-
|
|
259
|
-
- Increase `gas` to `500,000,000` (five hundred million)
|
|
260
|
-
|
|
261
|
-
# v.0.19.1 (2021-09-26)
|
|
262
|
-
|
|
263
|
-
## Fix
|
|
264
|
-
|
|
265
|
-
- Increase `gas` to `30,000,000` (thirty million)
|
|
266
|
-
|
|
267
|
-
# v.0.19.0 (2021-09-10)
|
|
268
|
-
|
|
269
|
-
## Breaking change
|
|
270
|
-
|
|
271
|
-
- Extract `buildDepositTx` from `Client` into `utils`
|
|
272
|
-
|
|
273
|
-
## Add
|
|
274
|
-
|
|
275
|
-
- Add `getBalance` to `utils`
|
|
276
|
-
|
|
277
|
-
# v.0.18.0 (2021-09-08)
|
|
278
|
-
|
|
279
|
-
## Add
|
|
280
|
-
|
|
281
|
-
- Make `buildDepositTx` public and overrides its fee
|
|
282
|
-
- Add `DEPOSIT_GAS_VALUE`
|
|
283
|
-
|
|
284
|
-
## Breaking change
|
|
285
|
-
|
|
286
|
-
- Remove `AssetRune` in favour of using `AssetRuneNative` of `xchain-util` only
|
|
287
|
-
- Extract `getChainId` into `util` module
|
|
288
|
-
|
|
289
|
-
# v.0.17.7 (2021-07-20)
|
|
290
|
-
|
|
291
|
-
## Fix
|
|
292
|
-
|
|
293
|
-
- cosmos 0.42.x has too many breaking changes that wren't caught in the last version, downgrade "cosmos-client": "0.39.2"
|
|
294
|
-
|
|
295
|
-
# v.0.17.6 (2021-07-19)
|
|
296
|
-
|
|
297
|
-
## Update
|
|
298
|
-
|
|
299
|
-
- bumping peer dependency "cosmos-client": "0.39.2" -> "cosmos-client": "^0.42.7"
|
|
300
|
-
|
|
301
|
-
# v.0.17.5 (2021-07-18)
|
|
302
|
-
|
|
303
|
-
## Update
|
|
304
|
-
|
|
305
|
-
- Updated rollupjs to include axios to enlable usage on node
|
|
306
|
-
|
|
307
|
-
# v.0.17.4 (2021-07-14)
|
|
308
|
-
|
|
309
|
-
### Fix
|
|
310
|
-
|
|
311
|
-
- Bump `fee.gas to `25000000` (twenty five million) to try to avoid failing withdraw txs
|
|
312
|
-
|
|
313
|
-
# v.0.17.3 (2021-07-07)
|
|
314
|
-
|
|
315
|
-
## Update
|
|
316
|
-
|
|
317
|
-
- Use latest `xchain-client@0.10.1` + `xchain-util@0.3.0`
|
|
318
|
-
|
|
319
|
-
# v.0.17.2 (2021-07-05)
|
|
320
|
-
|
|
321
|
-
## Fix
|
|
322
|
-
|
|
323
|
-
- refactored client methods to use regular method syntax (not fat arrow) in order for bcall to super.xxx() to work properly
|
|
324
|
-
|
|
325
|
-
# v.0.17.1 (2021-06-29)
|
|
326
|
-
|
|
327
|
-
### Fix
|
|
328
|
-
|
|
329
|
-
- Stick with `cosmos-client@0.39.2`
|
|
330
|
-
|
|
331
|
-
### Add
|
|
332
|
-
|
|
333
|
-
- Add examples to README
|
|
334
|
-
|
|
335
|
-
# v.0.17.0 (2021-06-21)
|
|
336
|
-
|
|
337
|
-
### Fix
|
|
338
|
-
|
|
339
|
-
- Fix `to` / `from` addresses by parsing tx data from event logs
|
|
340
|
-
|
|
341
|
-
### Breaking change
|
|
342
|
-
|
|
343
|
-
- Remove deprecated `getTxDataFromResponse` helper
|
|
344
|
-
|
|
345
|
-
# v.0.16.1 (2021-06-14)
|
|
346
|
-
|
|
347
|
-
### Fix
|
|
348
|
-
|
|
349
|
-
- Double `fee.gas to `20000000` (twenty million) to avoid failing withdraw transactions
|
|
350
|
-
|
|
351
|
-
# v.0.16.0 (2021-06-08)
|
|
352
|
-
|
|
353
|
-
### Breaking change
|
|
354
|
-
|
|
355
|
-
- Use `viewblock` as default explorer
|
|
356
|
-
- [types] Refactored structure of explorer urls (via `type ExplorerUrls`)
|
|
357
|
-
- [types] Refactored `ExplorerUrl`
|
|
358
|
-
- [client] Constructor accepts `ExplorerUrls`
|
|
359
|
-
- [client] Removed `getExplorerNodeUrl` (use `getExplorerAddressUrl` instead)
|
|
360
|
-
- [client] Extract `getDefaultClientUrl` into `utils`
|
|
361
|
-
- [utils] Renamed `getDefaultExplorerUrlByNetwork` -> `getDefaultExplorerUrl`
|
|
362
|
-
- [utils] Removed `getDefaultExplorerAddressUrl`, `getDefaultExplorerNodeUrl`, `getDefaultExplorerTxUrl`
|
|
363
|
-
- [utils] Added `getExplorerTxUrl`, `getExplorerAddressUrl`, `getExplorerUrl` helpers
|
|
364
|
-
|
|
365
|
-
# v.0.15.2 (2021-06-01)
|
|
366
|
-
|
|
367
|
-
### Update
|
|
368
|
-
|
|
369
|
-
- updated peer deps
|
|
370
|
-
|
|
371
|
-
# v.0.15.0 (2021-05-17)
|
|
372
|
-
|
|
373
|
-
### Breaking change
|
|
374
|
-
|
|
375
|
-
- added support for HD wallets
|
|
376
|
-
|
|
377
|
-
# v.0.14.0 (2021-05-05)
|
|
378
|
-
|
|
379
|
-
### Breaking change
|
|
380
|
-
|
|
381
|
-
- Latest @xchainjs/xchain-client@0.8.0
|
|
382
|
-
- Latest @xchainjs/xchain-util@0.2.7
|
|
383
|
-
|
|
384
|
-
# v.0.13.7 (2021-04-21)
|
|
385
|
-
|
|
386
|
-
### Update
|
|
387
|
-
|
|
388
|
-
- Export `MSG_SEND` `MSG_DEPOSIT` `MAX_COUNT`
|
|
389
|
-
- Added `getCosmosClient()`
|
|
390
|
-
- Extend `getTransactions` parameters with an optional `filterFn`
|
|
391
|
-
|
|
392
|
-
# v.0.13.6 (2021-04-16)
|
|
393
|
-
|
|
394
|
-
### Update
|
|
395
|
-
|
|
396
|
-
- Set `fee.gas` to `10000000` (ten million) in `deposit` due to failing withdraw transactions
|
|
397
|
-
|
|
398
|
-
# v.0.13.5 (2021-04-16)
|
|
399
|
-
|
|
400
|
-
### Update
|
|
401
|
-
|
|
402
|
-
- Set `fee.gas` to `1000000` (one million) in `deposit`
|
|
403
|
-
|
|
404
|
-
# v.0.13.4 (2021-04-16)
|
|
405
|
-
|
|
406
|
-
### Update
|
|
407
|
-
|
|
408
|
-
- Set `fee.gas` to `auto` in `deposit`
|
|
409
|
-
- Try sending `deposit` tx up to 3x
|
|
410
|
-
- Updates `DEFAULT_GAS_VALUE` to `2000000`
|
|
411
|
-
|
|
412
|
-
# v.0.13.3 (2021-04-12)
|
|
413
|
-
|
|
414
|
-
### Breaking changes
|
|
415
|
-
|
|
416
|
-
- Change `/addresses` to `/address` for explorer url.
|
|
417
|
-
|
|
418
|
-
### Update
|
|
419
|
-
|
|
420
|
-
- Add util helpers for explorer urls.
|
|
421
|
-
|
|
422
|
-
# v.0.13.2 (2021-04-01)
|
|
423
|
-
|
|
424
|
-
### Update
|
|
425
|
-
|
|
426
|
-
- Updates `getDefaultClientUrl` to use new mainnet endpoints
|
|
427
|
-
|
|
428
|
-
# v.0.13.1 (2021-03-18)
|
|
429
|
-
|
|
430
|
-
### Fix
|
|
431
|
-
|
|
432
|
-
- Changed `getDefaultExplorerUrl` to return valid urls
|
|
433
|
-
|
|
434
|
-
# v.0.13.0 (2021-03-02)
|
|
435
|
-
|
|
436
|
-
### Breaking change
|
|
437
|
-
|
|
438
|
-
- replace `find`, `findIndex`
|
|
439
|
-
- Update @xchainjs/xchain-client package to 0.7.0
|
|
440
|
-
- Update @xchainjs/xchain-cosmos package to 0.11.0
|
|
441
|
-
|
|
442
|
-
# v.0.12.0 (2021-02-24)
|
|
443
|
-
|
|
444
|
-
### Breaking change
|
|
445
|
-
|
|
446
|
-
- Update @xchainjs/xchain-client package to 0.6.0
|
|
447
|
-
- Update @xchainjs/xchain-cosmos package to 0.10.0
|
|
448
|
-
- Update `getBalance`
|
|
449
|
-
|
|
450
|
-
# v.0.11.1 (2021-02-24)
|
|
451
|
-
|
|
452
|
-
### Breaking change
|
|
453
|
-
|
|
454
|
-
- Update @xchainjs/xchain-cosmos package to 0.9.0
|
|
455
|
-
|
|
456
|
-
### Fix
|
|
457
|
-
|
|
458
|
-
- Fix `getTransactions` - sort transactions from latest
|
|
459
|
-
- Fix `DECIMAL`
|
|
460
|
-
|
|
461
|
-
# v.0.11.0 (2021-02-19)
|
|
462
|
-
|
|
463
|
-
### Breaking change
|
|
464
|
-
|
|
465
|
-
- Update @xchainjs/xchain-client package to 0.5.0
|
|
466
|
-
|
|
467
|
-
### Update
|
|
468
|
-
|
|
469
|
-
- Add `Service Providers` section in README.md
|
|
470
|
-
|
|
471
|
-
### Fix
|
|
472
|
-
|
|
473
|
-
- Fix `peerDependencies`
|
|
474
|
-
|
|
475
|
-
# v.0.10.1 (2021-02-05)
|
|
476
|
-
|
|
477
|
-
### Update
|
|
478
|
-
|
|
479
|
-
- Update `getTransactions` to support incoming transactions
|
|
480
|
-
|
|
481
|
-
### Breaking change
|
|
482
|
-
|
|
483
|
-
- Update @xchainjs/xchain-client package to 0.4.0
|
|
484
|
-
- Update @xchainjs/xchain-crypto package to 0.2.3
|
|
485
|
-
|
|
486
|
-
# v.0.10.0 (2021-02-03)
|
|
487
|
-
|
|
488
|
-
### Breaking changes
|
|
489
|
-
|
|
490
|
-
- Change `getTransactions` to use tendermint rpc. (transaction query from the latest ones.)
|
|
491
|
-
|
|
492
|
-
# v.0.9.3 (2021-02-02)
|
|
493
|
-
|
|
494
|
-
### Update
|
|
495
|
-
|
|
496
|
-
- Add `getExplorerNodeUrl`
|
|
497
|
-
|
|
498
|
-
# v.0.9.2 (2021-01-30)
|
|
499
|
-
|
|
500
|
-
- Clear lib folder on build
|
|
501
|
-
|
|
502
|
-
# v.0.9.1 (2021-01-26)
|
|
503
|
-
|
|
504
|
-
### Fix
|
|
505
|
-
|
|
506
|
-
- Fix `deposit`. Use `/thorchain/deposit` to build a deposit transaction.
|
|
507
|
-
|
|
508
|
-
# v.0.9.0 (2021-01-15)
|
|
509
|
-
|
|
510
|
-
### Breaking change
|
|
511
|
-
|
|
512
|
-
- Move `getPrefix` to util
|
|
513
|
-
|
|
514
|
-
# v.0.8.0 (2021-01-13)
|
|
515
|
-
|
|
516
|
-
### Breaking change
|
|
517
|
-
|
|
518
|
-
- change MsgNativeTx.fromJson
|
|
519
|
-
|
|
520
|
-
# v.0.7.1 (2021-01-06)
|
|
521
|
-
|
|
522
|
-
### Fix
|
|
523
|
-
|
|
524
|
-
- Fix getTransactions pagination issue #168
|
|
525
|
-
|
|
526
|
-
### Update
|
|
527
|
-
|
|
528
|
-
- Update comments for documentation
|
|
529
|
-
|
|
530
|
-
# v.0.7.0 (2020-12-28)
|
|
531
|
-
|
|
532
|
-
### Breaking change
|
|
533
|
-
|
|
534
|
-
- Extract `getDefaultFees` from `Client` to `utils` #157
|
|
535
|
-
|
|
536
|
-
# v.0.6.2 (2020-12-23)
|
|
537
|
-
|
|
538
|
-
### Update
|
|
539
|
-
|
|
540
|
-
- Use latest xchain-client@0.2.1
|
|
541
|
-
|
|
542
|
-
### Fix
|
|
543
|
-
|
|
544
|
-
- Fix invalid assets comparison #151
|
|
545
|
-
|
|
546
|
-
### Breaking change
|
|
547
|
-
|
|
548
|
-
- Remove `validateAddress` from `ThorchainClient` #149
|
|
549
|
-
|
|
550
|
-
# v.0.6.1 (2020-12-18)
|
|
551
|
-
|
|
552
|
-
### Update
|
|
553
|
-
|
|
554
|
-
- Add `setClientUrl`
|
|
555
|
-
- Add `getDefaultClientUrl`
|
|
556
|
-
- Add `getClientUrlByNetwork`
|
|
557
|
-
|
|
558
|
-
### Fix
|
|
559
|
-
|
|
560
|
-
- Fix client url for multichain testnet (`https://testnet.thornode.thorchain.info`)
|
|
561
|
-
|
|
562
|
-
# v.0.6.0 (2020-12-16)
|
|
563
|
-
|
|
564
|
-
### Update
|
|
565
|
-
|
|
566
|
-
- Set the latest multi-chain node
|
|
567
|
-
- Update `getTransactionData`, `getTransactions`
|
|
568
|
-
- Update `transfer` (for `MsgSend`)
|
|
569
|
-
- Update `deposit` (for `MsgNativeTx`)
|
|
570
|
-
|
|
571
|
-
# v.0.5.0 (2020-12-11)
|
|
572
|
-
|
|
573
|
-
### Update
|
|
574
|
-
|
|
575
|
-
- Update dependencies
|
|
576
|
-
- Add `getDefaultFees`
|
|
577
|
-
|
|
578
|
-
# v.0.4.2 (2020-11-23)
|
|
579
|
-
|
|
580
|
-
### Fix
|
|
581
|
-
|
|
582
|
-
- Fix import of `cosmos/codec`
|
|
583
|
-
|
|
584
|
-
### Update
|
|
585
|
-
|
|
586
|
-
- Use latest `@xchainjs/cosmos@0.4.2`
|
|
587
|
-
|
|
588
|
-
# v.0.4.1 (2020-11-23)
|
|
589
|
-
|
|
590
|
-
### Update
|
|
591
|
-
|
|
592
|
-
- Update to latest `@xchainjs/*` packages and other dependencies
|
|
593
|
-
|
|
594
|
-
# v.0.4.0 (2020-11-20)
|
|
595
|
-
|
|
596
|
-
### Breaking change
|
|
597
|
-
|
|
598
|
-
- Update @xchainjs/xchain-crypto package to 0.2.0, deprecating old keystores
|