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-fund.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. "use strict";
  2. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  3. if (k2 === undefined) k2 = k;
  4. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  5. }) : (function(o, m, k, k2) {
  6. if (k2 === undefined) k2 = k;
  7. o[k2] = m[k];
  8. }));
  9. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  10. Object.defineProperty(o, "default", { enumerable: true, value: v });
  11. }) : function(o, v) {
  12. o["default"] = v;
  13. });
  14. var __importStar = (this && this.__importStar) || function (mod) {
  15. if (mod && mod.__esModule) return mod;
  16. var result = {};
  17. if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  18. __setModuleDefault(result, mod);
  19. return result;
  20. };
  21. Object.defineProperty(exports, "__esModule", { value: true });
  22. const utils = __importStar(require("./utils"));
  23. const common_1 = require("../common");
  24. function createPaymentChannelFundTransaction(account, fund) {
  25. const txJSON = {
  26. Account: account,
  27. TransactionType: 'PaymentChannelFund',
  28. Channel: fund.channel,
  29. Amount: common_1.xrpToDrops(fund.amount)
  30. };
  31. if (fund.expiration != null) {
  32. txJSON.Expiration = common_1.iso8601ToRippleTime(fund.expiration);
  33. }
  34. return txJSON;
  35. }
  36. function preparePaymentChannelFund(address, paymentChannelFund, instructions = {}) {
  37. try {
  38. common_1.validate.preparePaymentChannelFund({
  39. address,
  40. paymentChannelFund,
  41. instructions
  42. });
  43. const txJSON = createPaymentChannelFundTransaction(address, paymentChannelFund);
  44. return utils.prepareTransaction(txJSON, this, instructions);
  45. }
  46. catch (e) {
  47. return Promise.reject(e);
  48. }
  49. }
  50. exports.default = preparePaymentChannelFund;
  51. //# sourceMappingURL=payment-channel-fund.js.map