xrpl-txdata
Advanced tools
Comparing version 1.2.1 to 1.2.3
@@ -139,2 +139,3 @@ "use strict"; | ||
var e_1, _a; | ||
var _b, _c; | ||
let Timer; | ||
@@ -203,3 +204,6 @@ let WaitMode = false; | ||
const onTx = (r) => { | ||
if (!meta.resolved && r.txHash === TxHash) { | ||
var _a, _b; | ||
if (!meta.resolved && r.txHash === TxHash && | ||
typeof (r === null || r === void 0 ? void 0 : r.result) === 'object' && | ||
((((_a = this.FormatResult(r.result)) === null || _a === void 0 ? void 0 : _a.meta) || ((_b = this.FormatResult(r.result)) === null || _b === void 0 ? void 0 : _b.error)))) { | ||
this.EventBus.off('result', onTx); | ||
@@ -211,4 +215,4 @@ ResolveFormatted(r.result, 'emitter', r.host); | ||
try { | ||
for (var _b = __asyncValues(this.ConnectAndQuery(TxHash)), _c; _c = yield _b.next(), !_c.done;) { | ||
const val = _c.value; | ||
for (var _d = __asyncValues(this.ConnectAndQuery(TxHash)), _e; _e = yield _d.next(), !_e.done;) { | ||
const val = _e.value; | ||
if (meta.resolved) { | ||
@@ -220,3 +224,6 @@ break; | ||
if (typeof val.socket !== 'boolean') { | ||
if (!meta.resolved && val.socket.readyState === val.socket.OPEN && typeof val.result !== 'boolean') { | ||
if (!meta.resolved && | ||
val.socket.readyState === val.socket.OPEN && | ||
typeof (val === null || val === void 0 ? void 0 : val.result) === 'object' && | ||
((((_b = this.FormatResult(val.result)) === null || _b === void 0 ? void 0 : _b.meta) || ((_c = this.FormatResult(val.result)) === null || _c === void 0 ? void 0 : _c.error)))) { | ||
ResolveFormatted(val.result, 'generator', val.socket.url); | ||
@@ -241,3 +248,3 @@ break; | ||
try { | ||
if (_c && !_c.done && (_a = _b.return)) yield _a.call(_b); | ||
if (_e && !_e.done && (_a = _d.return)) yield _a.call(_d); | ||
} | ||
@@ -329,9 +336,14 @@ finally { if (e_1) throw e_1.error; } | ||
socket.onmessage = (m) => __awaiter(this, void 0, void 0, function* () { | ||
var _a, _b, _c, _d, _e, _f, _g; | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; | ||
try { | ||
const response = JSON.parse(m.data.toString()); | ||
if (socketMeta.ready) { | ||
this.EventBus.emit('xrpljson', response); | ||
const txHash = (_b = (_a = response) === null || _a === void 0 ? void 0 : _a.transaction) === null || _b === void 0 ? void 0 : _b.hash; | ||
if (((_c = response) === null || _c === void 0 ? void 0 : _c.validated) && txHash) { | ||
if (typeof ((_b = (_a = response) === null || _a === void 0 ? void 0 : _a.transaction) === null || _b === void 0 ? void 0 : _b.validated) === 'undefined' || ((_d = (_c = response) === null || _c === void 0 ? void 0 : _c.transaction) === null || _d === void 0 ? void 0 : _d.validated)) { | ||
this.EventBus.emit('xrpljson', response); | ||
} | ||
else { | ||
log('Ignore xrpljson, validated present but false'); | ||
} | ||
const txHash = (_f = (_e = response) === null || _e === void 0 ? void 0 : _e.transaction) === null || _f === void 0 ? void 0 : _f.hash; | ||
if (((_g = response) === null || _g === void 0 ? void 0 : _g.validated) && txHash) { | ||
// log('Seen TX', txHash, 'emitted', 'tx.#') | ||
@@ -342,5 +354,5 @@ this.EventBus.emit('tx.' + txHash, { response, url: socket.url }); | ||
else { | ||
if (typeof ((_e = (_d = response === null || response === void 0 ? void 0 : response.result) === null || _d === void 0 ? void 0 : _d.info) === null || _e === void 0 ? void 0 : _e.complete_ledgers) !== 'undefined') { | ||
if (typeof ((_j = (_h = response === null || response === void 0 ? void 0 : response.result) === null || _h === void 0 ? void 0 : _h.info) === null || _j === void 0 ? void 0 : _j.complete_ledgers) !== 'undefined') { | ||
socketMeta.ready = true; | ||
const ledgerString = String(((_g = (_f = response === null || response === void 0 ? void 0 : response.result) === null || _f === void 0 ? void 0 : _f.info) === null || _g === void 0 ? void 0 : _g.complete_ledgers) || ''); | ||
const ledgerString = String(((_l = (_k = response === null || response === void 0 ? void 0 : response.result) === null || _k === void 0 ? void 0 : _k.info) === null || _l === void 0 ? void 0 : _l.complete_ledgers) || ''); | ||
const isFullHistory = ledgerString.split(',').length < 2 && ledgerString.split('-')[0] === '32570'; | ||
@@ -347,0 +359,0 @@ if (!isFullHistory && !this.AllowNoFullHistory) { |
{ | ||
"name": "xrpl-txdata", | ||
"version": "1.2.1", | ||
"version": "1.2.3", | ||
"description": "Fetch XRPL transaction by hash (+ meta & balances), awaits if required", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -66,2 +66,4 @@ # XRPL Transaction Data fetcher [![npm version](https://badge.fury.io/js/xrpl-txdata.svg)](https://www.npmjs.com/xrpl-txdata) [![GitHub Actions NodeJS status](https://github.com/XRPL-Labs/XrplTxData/workflows/NodeJS/badge.svg?branch=main)](https://github.com/XRPL-Labs/XrplTxData/actions) [![CDNJS Browserified](https://img.shields.io/badge/cdnjs-browserified-blue)](https://cdn.jsdelivr.net/gh/XRPL-Labs/XrplTxData@main/dist/browser.js) [![CDNJS Browserified Minified](https://img.shields.io/badge/cdnjs-minified-orange)](https://cdn.jsdelivr.net/gh/XRPL-Labs/XrplTxData@main/dist/browser.min.js) | ||
More info: https://xumm.readme.io/docs/secure-payment-verification#example-flow--code-using-the-xrpl-txdata-package-jsts | ||
#### Advanced options | ||
@@ -145,5 +147,5 @@ | ||
}, | ||
"resolvedBy": "generator", | ||
"resolvedBy": "generator", // or `"asynchash"` if resolved by waiting & monitoring the live ledger transaction stream | ||
"host": "wss://s2.ripple.com/", | ||
"balanceChanges": {, or `"asynchash"` if resolved by waiting & monitoring the live ledger transaction stream | ||
"balanceChanges": { ... } | ||
} | ||
@@ -209,5 +211,5 @@ ``` | ||
}, | ||
"resolvedBy": "generator", | ||
"resolvedBy": "generator", // or `"asynchash"` if resolved by waiting & monitoring the live ledger transaction stream | ||
"host": "wss://s2.ripple.com/", | ||
"balanceChanges": , or `"asynchash"` if resolved by waiting & monitoring the live ledger transaction stream | ||
"balanceChanges": | ||
"rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq": [ | ||
@@ -214,0 +216,0 @@ { |
45830
727
239