You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

payment-channel.js 1.6KB

12345678910111213141516171819202122232425262728293031323334
  1. "use strict";
  2. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  3. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  4. return new (P || (P = Promise))(function (resolve, reject) {
  5. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  6. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  7. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  8. step((generator = generator.apply(thisArg, _arguments || [])).next());
  9. });
  10. };
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. const payment_channel_1 = require("./parse/payment-channel");
  13. const common_1 = require("../common");
  14. const NotFoundError = common_1.errors.NotFoundError;
  15. function formatResponse(response) {
  16. if (response.node == null ||
  17. response.node.LedgerEntryType !== 'PayChannel') {
  18. throw new NotFoundError('Payment channel ledger entry not found');
  19. }
  20. return payment_channel_1.parsePaymentChannel(response.node);
  21. }
  22. function getPaymentChannel(id) {
  23. return __awaiter(this, void 0, void 0, function* () {
  24. common_1.validate.getPaymentChannel({ id });
  25. const response = yield this.request('ledger_entry', {
  26. index: id,
  27. binary: false,
  28. ledger_index: 'validated'
  29. });
  30. return formatResponse(response);
  31. });
  32. }
  33. exports.default = getPaymentChannel;
  34. //# sourceMappingURL=payment-channel.js.map