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-create.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 toRippledAmount = utils.common.toRippledAmount;
  24. const common_1 = require("../common");
  25. function createCheckCreateTransaction(account, check) {
  26. const txJSON = {
  27. Account: account,
  28. TransactionType: 'CheckCreate',
  29. Destination: check.destination,
  30. SendMax: toRippledAmount(check.sendMax)
  31. };
  32. if (check.destinationTag != null) {
  33. txJSON.DestinationTag = check.destinationTag;
  34. }
  35. if (check.expiration != null) {
  36. txJSON.Expiration = common_1.iso8601ToRippleTime(check.expiration);
  37. }
  38. if (check.invoiceID != null) {
  39. txJSON.InvoiceID = check.invoiceID;
  40. }
  41. return txJSON;
  42. }
  43. function prepareCheckCreate(address, checkCreate, instructions = {}) {
  44. try {
  45. common_1.validate.prepareCheckCreate({ address, checkCreate, instructions });
  46. const txJSON = createCheckCreateTransaction(address, checkCreate);
  47. return utils.prepareTransaction(txJSON, this, instructions);
  48. }
  49. catch (e) {
  50. return Promise.reject(e);
  51. }
  52. }
  53. exports.default = prepareCheckCreate;
  54. //# sourceMappingURL=check-create.js.map