UNPKG

@helium/http

Version:

HTTP library for interacting with the Helium blockchain API

37 lines 1.56 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Account_1 = __importDefault(require("../models/Account")); const PendingTransaction_1 = __importDefault(require("../models/PendingTransaction")); const ResourceList_1 = __importDefault(require("../ResourceList")); class PendingTransactions { constructor(client, context) { this.client = client; this.context = context; } async get(hash) { const url = `/pending_transactions/${hash}`; const response = await this.client.get(url); const { data: { data: txns } } = response; const data = txns.map((d) => new PendingTransaction_1.default(d)); return new ResourceList_1.default(data); } async list() { if (this.context instanceof Account_1.default) { return this.listFromAccount(); } throw new Error('Must provide an account to list pending transactions from'); } async listFromAccount() { const account = this.context; const url = `/accounts/${account.address}/pending_transactions`; const response = await this.client.get(url); const { data: { data: txns } } = response; const data = txns.map((d) => new PendingTransaction_1.default(d)); return new ResourceList_1.default(data); } } exports.default = PendingTransactions; //# sourceMappingURL=PendingTransactions.js.map