infoblock
Version:
A typed wrapper of the blockchain.info API
25 lines (24 loc) • 1.06 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Block = void 0;
var Transaction_1 = __importDefault(require("./Transaction"));
var Block = /** @class */ (function () {
function Block(hash, timestamp, height, prevBlock, mrklTree, transactions) {
this.hash = hash;
this.time = new Date(timestamp * 1000);
this.height = height;
this.previousBlockHash = prevBlock;
this.merkleTreeRoot = mrklTree;
this.transactions = transactions;
}
Block.constructFromObj = function (_a) {
var hash = _a.hash, time = _a.time, height = _a.height, prev_block = _a.prev_block, mrkl_root = _a.mrkl_root, tx = _a.tx;
var transactions = tx ? tx.map(Transaction_1.default.constructFromObj) : [];
return new Block(hash, time, height, prev_block, mrkl_root, transactions);
};
return Block;
}());
exports.Block = Block;