@xchainjs/xchain-thorchain 0.28.5 → 0.28.6
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/index.esm.js +7 -6
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +7 -6
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -10476,13 +10476,14 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10476
10476
|
* @returns {Tx} The transaction details of the given transaction id.
|
|
10477
10477
|
*/
|
|
10478
10478
|
getTransactionData(txId, address) {
|
|
10479
|
-
var _a, _b, _c, _d, _e, _f;
|
|
10479
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
10480
10480
|
return __awaiter(this, void 0, void 0, function* () {
|
|
10481
10481
|
const txResult = yield this.fetchTransaction(txId);
|
|
10482
10482
|
if (txResult && txResult.logs) {
|
|
10483
10483
|
// extract values from the response
|
|
10484
10484
|
const transferEvent = (_a = txResult.logs[0].events) === null || _a === void 0 ? void 0 : _a.find((event) => event.type === 'transfer');
|
|
10485
10485
|
const messageEvent = (_b = txResult.logs[0].events) === null || _b === void 0 ? void 0 : _b.find((event) => event.type === 'message');
|
|
10486
|
+
const coinReceivedEvent = (_c = txResult.logs[0].events) === null || _c === void 0 ? void 0 : _c.find((event) => event.type === 'coin_received');
|
|
10486
10487
|
if (!transferEvent || !messageEvent) {
|
|
10487
10488
|
throw new Error('Invalid transaction data');
|
|
10488
10489
|
}
|
|
@@ -10505,14 +10506,14 @@ class Client extends xchainClient.BaseXChainClient {
|
|
|
10505
10506
|
.split(/(?<=\d)(?=\D)/)
|
|
10506
10507
|
.filter(Boolean)[1]
|
|
10507
10508
|
.replace(/[a-z]/g, (letter) => letter.toUpperCase());
|
|
10508
|
-
const fromAddress = ((
|
|
10509
|
-
? (
|
|
10509
|
+
const fromAddress = ((_d = transferEvent.attributes.find((attr) => attr.key === 'sender')) === null || _d === void 0 ? void 0 : _d.value)
|
|
10510
|
+
? (_e = transferEvent.attributes.find((attr) => attr.key === 'sender')) === null || _e === void 0 ? void 0 : _e.value
|
|
10510
10511
|
: address;
|
|
10511
|
-
const memo = ((
|
|
10512
|
+
const memo = ((_f = txResult.tx) === null || _f === void 0 ? void 0 : _f.body) ? txResult.tx.body.memo.split(':') : '';
|
|
10512
10513
|
const toAddress = memo[2] ? memo[2] : '';
|
|
10513
|
-
const toAsset = memo[1] ? xchainUtil.assetFromStringEx(memo[1]) : AssetRuneNative;
|
|
10514
|
+
const toAsset = memo[1] && !coinReceivedEvent ? xchainUtil.assetFromStringEx(memo[1]) : AssetRuneNative;
|
|
10514
10515
|
const date = new Date(txResult.timestamp);
|
|
10515
|
-
const typeString = (
|
|
10516
|
+
const typeString = (_g = messageEvent.attributes.find((attr) => attr.key === 'action')) === null || _g === void 0 ? void 0 : _g.value;
|
|
10516
10517
|
const hash = txResult.txhash;
|
|
10517
10518
|
if (assetString && hash && fromAddress && typeString) {
|
|
10518
10519
|
const fromAsset = assetString === 'RUNE' ? AssetRuneNative : xchainUtil.assetFromStringEx(assetString);
|