UNPKG

@helium/transactions

Version:

Construct and serialize Helium blockchain transaction primatives

45 lines 1.72 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); /* eslint-disable class-methods-use-this */ const proto_1 = __importDefault(require("@helium/proto")); class Transaction { message() { throw new Error('unimplemented'); } static config(vars) { if (vars.txnFeeMultiplier) { Transaction.txnFeeMultiplier = vars.txnFeeMultiplier; } if (vars.dcPayloadSize) { Transaction.dcPayloadSize = vars.dcPayloadSize; } if (vars.stakingFeeTxnAssertLocationV1) { Transaction.stakingFeeTxnAssertLocationV1 = vars.stakingFeeTxnAssertLocationV1; } if (vars.stakingFeeTxnAddGatewayV1) { Transaction.stakingFeeTxnAddGatewayV1 = vars.stakingFeeTxnAddGatewayV1; } } toString() { return Buffer.from(this.serialize()).toString('base64'); } static stringType(serializedTxnString) { const buf = Buffer.from(serializedTxnString, 'base64'); const decoded = proto_1.default.helium.blockchain_txn.decode(buf); const obj = proto_1.default.helium.blockchain_txn.toObject(decoded); return Object.keys(obj)[0]; } static calculateFee(payload) { return (Math.ceil(payload.byteLength / Transaction.dcPayloadSize) * Transaction.txnFeeMultiplier); } } Transaction.txnFeeMultiplier = 0; Transaction.dcPayloadSize = 24; Transaction.stakingFeeTxnAssertLocationV1 = 1; Transaction.stakingFeeTxnAddGatewayV1 = 1; exports.default = Transaction; //# sourceMappingURL=Transaction.js.map