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.

validate.js 6.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. exports.tx_json = exports.instructions = exports.apiOptions = exports.verifyPaymentChannelClaim = exports.signPaymentChannelClaim = exports.generateAddress = exports.computeLedgerHash = exports.submit = exports.combine = exports.sign = exports.prepareTicketCreate = exports.prepareCheckCancel = exports.prepareCheckCash = exports.prepareCheckCreate = exports.preparePaymentChannelClaim = exports.preparePaymentChannelFund = exports.preparePaymentChannelCreate = exports.prepareEscrowExecution = exports.prepareEscrowCancellation = exports.prepareEscrowCreation = exports.prepareSettings = exports.prepareTrustline = exports.prepareOrderCancellation = exports.prepareOrder = exports.preparePayment = exports.getLedger = exports.getPaymentChannel = exports.getTransaction = exports.getOrderbook = exports.getOrders = exports.getBalanceSheet = exports.getBalances = exports.getTrustlines = exports.getAccountInfo = exports.getSettings = exports.getTransactions = exports.getPaths = void 0;
  23. const _ = __importStar(require("lodash"));
  24. const errors_1 = require("./errors");
  25. const schema_validator_1 = require("./schema-validator");
  26. function error(text) {
  27. return new errors_1.ValidationError(text);
  28. }
  29. function validateLedgerRange(options) {
  30. if (options != null &&
  31. options.minLedgerVersion != null &&
  32. options.maxLedgerVersion != null) {
  33. if (Number(options.minLedgerVersion) > Number(options.maxLedgerVersion)) {
  34. throw error('minLedgerVersion must not be greater than maxLedgerVersion');
  35. }
  36. }
  37. }
  38. function validateOptions(schema, instance) {
  39. schema_validator_1.schemaValidate(schema, instance);
  40. validateLedgerRange(instance.options);
  41. }
  42. exports.getPaths = _.partial(schema_validator_1.schemaValidate, 'getPathsParameters');
  43. exports.getTransactions = _.partial(validateOptions, 'getTransactionsParameters');
  44. exports.getSettings = _.partial(validateOptions, 'getSettingsParameters');
  45. exports.getAccountInfo = _.partial(validateOptions, 'getAccountInfoParameters');
  46. exports.getTrustlines = _.partial(validateOptions, 'getTrustlinesParameters');
  47. exports.getBalances = _.partial(validateOptions, 'getBalancesParameters');
  48. exports.getBalanceSheet = _.partial(validateOptions, 'getBalanceSheetParameters');
  49. exports.getOrders = _.partial(validateOptions, 'getOrdersParameters');
  50. exports.getOrderbook = _.partial(validateOptions, 'getOrderbookParameters');
  51. exports.getTransaction = _.partial(validateOptions, 'getTransactionParameters');
  52. exports.getPaymentChannel = _.partial(validateOptions, 'getPaymentChannelParameters');
  53. exports.getLedger = _.partial(validateOptions, 'getLedgerParameters');
  54. exports.preparePayment = _.partial(schema_validator_1.schemaValidate, 'preparePaymentParameters');
  55. exports.prepareOrder = _.partial(schema_validator_1.schemaValidate, 'prepareOrderParameters');
  56. exports.prepareOrderCancellation = _.partial(schema_validator_1.schemaValidate, 'prepareOrderCancellationParameters');
  57. exports.prepareTrustline = _.partial(schema_validator_1.schemaValidate, 'prepareTrustlineParameters');
  58. exports.prepareSettings = _.partial(schema_validator_1.schemaValidate, 'prepareSettingsParameters');
  59. exports.prepareEscrowCreation = _.partial(schema_validator_1.schemaValidate, 'prepareEscrowCreationParameters');
  60. exports.prepareEscrowCancellation = _.partial(schema_validator_1.schemaValidate, 'prepareEscrowCancellationParameters');
  61. exports.prepareEscrowExecution = _.partial(schema_validator_1.schemaValidate, 'prepareEscrowExecutionParameters');
  62. exports.preparePaymentChannelCreate = _.partial(schema_validator_1.schemaValidate, 'preparePaymentChannelCreateParameters');
  63. exports.preparePaymentChannelFund = _.partial(schema_validator_1.schemaValidate, 'preparePaymentChannelFundParameters');
  64. exports.preparePaymentChannelClaim = _.partial(schema_validator_1.schemaValidate, 'preparePaymentChannelClaimParameters');
  65. exports.prepareCheckCreate = _.partial(schema_validator_1.schemaValidate, 'prepareCheckCreateParameters');
  66. exports.prepareCheckCash = _.partial(schema_validator_1.schemaValidate, 'prepareCheckCashParameters');
  67. exports.prepareCheckCancel = _.partial(schema_validator_1.schemaValidate, 'prepareCheckCancelParameters');
  68. exports.prepareTicketCreate = _.partial(schema_validator_1.schemaValidate, 'prepareTicketParameters');
  69. exports.sign = _.partial(schema_validator_1.schemaValidate, 'signParameters');
  70. exports.combine = _.partial(schema_validator_1.schemaValidate, 'combineParameters');
  71. exports.submit = _.partial(schema_validator_1.schemaValidate, 'submitParameters');
  72. exports.computeLedgerHash = _.partial(schema_validator_1.schemaValidate, 'computeLedgerHashParameters');
  73. exports.generateAddress = _.partial(schema_validator_1.schemaValidate, 'generateAddressParameters');
  74. exports.signPaymentChannelClaim = _.partial(schema_validator_1.schemaValidate, 'signPaymentChannelClaimParameters');
  75. exports.verifyPaymentChannelClaim = _.partial(schema_validator_1.schemaValidate, 'verifyPaymentChannelClaimParameters');
  76. exports.apiOptions = _.partial(schema_validator_1.schemaValidate, 'api-options');
  77. exports.instructions = _.partial(schema_validator_1.schemaValidate, 'instructions');
  78. exports.tx_json = _.partial(schema_validator_1.schemaValidate, 'tx-json');
  79. //# sourceMappingURL=validate.js.map