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.

escrowCreate.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.validateEscrowCreate = void 0;
  4. const errors_1 = require("../../errors");
  5. const common_1 = require("./common");
  6. function validateEscrowCreate(tx) {
  7. (0, common_1.validateBaseTransaction)(tx);
  8. if (tx.Amount === undefined) {
  9. throw new errors_1.ValidationError('EscrowCreate: missing field Amount');
  10. }
  11. if (typeof tx.Amount !== 'string') {
  12. throw new errors_1.ValidationError('EscrowCreate: Amount must be a string');
  13. }
  14. if (tx.Destination === undefined) {
  15. throw new errors_1.ValidationError('EscrowCreate: missing field Destination');
  16. }
  17. if (typeof tx.Destination !== 'string') {
  18. throw new errors_1.ValidationError('EscrowCreate: Destination must be a string');
  19. }
  20. if (tx.CancelAfter === undefined && tx.FinishAfter === undefined) {
  21. throw new errors_1.ValidationError('EscrowCreate: Either CancelAfter or FinishAfter must be specified');
  22. }
  23. if (tx.FinishAfter === undefined && tx.Condition === undefined) {
  24. throw new errors_1.ValidationError('EscrowCreate: Either Condition or FinishAfter must be specified');
  25. }
  26. if (tx.CancelAfter !== undefined && typeof tx.CancelAfter !== 'number') {
  27. throw new errors_1.ValidationError('EscrowCreate: CancelAfter must be a number');
  28. }
  29. if (tx.FinishAfter !== undefined && typeof tx.FinishAfter !== 'number') {
  30. throw new errors_1.ValidationError('EscrowCreate: FinishAfter must be a number');
  31. }
  32. if (tx.Condition !== undefined && typeof tx.Condition !== 'string') {
  33. throw new errors_1.ValidationError('EscrowCreate: Condition must be a string');
  34. }
  35. if (tx.DestinationTag !== undefined &&
  36. typeof tx.DestinationTag !== 'number') {
  37. throw new errors_1.ValidationError('EscrowCreate: DestinationTag must be a number');
  38. }
  39. }
  40. exports.validateEscrowCreate = validateEscrowCreate;
  41. //# sourceMappingURL=escrowCreate.js.map