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.

check-cash.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 ValidationError = utils.common.errors.ValidationError;
  24. const toRippledAmount = utils.common.toRippledAmount;
  25. const common_1 = require("../common");
  26. function createCheckCashTransaction(account, checkCash) {
  27. if (checkCash.amount && checkCash.deliverMin) {
  28. throw new ValidationError('"amount" and "deliverMin" properties on ' +
  29. 'CheckCash are mutually exclusive');
  30. }
  31. const txJSON = {
  32. Account: account,
  33. TransactionType: 'CheckCash',
  34. CheckID: checkCash.checkID
  35. };
  36. if (checkCash.amount != null) {
  37. txJSON.Amount = toRippledAmount(checkCash.amount);
  38. }
  39. if (checkCash.deliverMin != null) {
  40. txJSON.DeliverMin = toRippledAmount(checkCash.deliverMin);
  41. }
  42. return txJSON;
  43. }
  44. function prepareCheckCash(address, checkCash, instructions = {}) {
  45. try {
  46. common_1.validate.prepareCheckCash({ address, checkCash, instructions });
  47. const txJSON = createCheckCashTransaction(address, checkCash);
  48. return utils.prepareTransaction(txJSON, this, instructions);
  49. }
  50. catch (e) {
  51. return Promise.reject(e);
  52. }
  53. }
  54. exports.default = prepareCheckCash;
  55. //# sourceMappingURL=check-cash.js.map