@pokt-network/pocket-js
Version:
Pocket-js core package with the main functionalities to interact with the Pocket Network.
77 lines • 2.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.QueryAccountTxsResponse = void 0;
var transaction_1 = require("../transaction");
/**
*
*
* @class QueryAccountTxsResponse
*/
var QueryAccountTxsResponse = /** @class */ (function () {
/**
* Query Account transaction list Response.
* @constructor
* @param {Transaction[]} transactions - List of transactions.
* @param {number} totalCount - Transaction count
*/
function QueryAccountTxsResponse(transactions, totalCount, pageCount) {
this.transactions = transactions;
this.totalCount = totalCount;
this.pageCount = pageCount;
if (!this.isValid()) {
throw new TypeError("Invalid QueryAccountTxsResponse properties.");
}
}
/**
*
* Creates a QueryAccountTxsResponse object using a JSON string
* @param {String} json - JSON string.
* @returns {QueryAccountTxsResponse} - QueryAccountTxsResponse object.
* @memberof QueryAccountTxsResponse
*/
QueryAccountTxsResponse.fromJSON = function (json) {
try {
var rawObjValue = JSON.parse(json);
var transactions_1 = [];
if (rawObjValue.txs) {
rawObjValue.txs.forEach(function (tx) {
var transaction = transaction_1.Transaction.fromJSON(JSON.stringify(tx));
transactions_1.push(transaction);
});
}
return new QueryAccountTxsResponse(transactions_1, rawObjValue.total_txs, rawObjValue.page_count);
}
catch (error) {
throw error;
}
};
/**
*
* Creates a JSON object with the QueryAccountTxsResponse properties
* @returns {JSON} - JSON Object.
* @memberof QueryAccountTxsResponse
*/
QueryAccountTxsResponse.prototype.toJSON = function () {
var transactions = [];
this.transactions.forEach(function (tx) {
transactions.push(tx.toJSON());
});
return {
txs: transactions,
total_count: this.totalCount,
page_count: this.pageCount
};
};
/**
*
* Check if the QueryAccountTxsResponse object is valid
* @returns {boolean} - True or false.
* @memberof QueryAccountTxsResponse
*/
QueryAccountTxsResponse.prototype.isValid = function () {
return true;
};
return QueryAccountTxsResponse;
}());
exports.QueryAccountTxsResponse = QueryAccountTxsResponse;
//# sourceMappingURL=query-account-txs-response.js.map