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.

offerCreate.js 1.7KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.validateOfferCreate = exports.OfferCreateFlags = void 0;
  4. const errors_1 = require("../../errors");
  5. const common_1 = require("./common");
  6. var OfferCreateFlags;
  7. (function (OfferCreateFlags) {
  8. OfferCreateFlags[OfferCreateFlags["tfPassive"] = 65536] = "tfPassive";
  9. OfferCreateFlags[OfferCreateFlags["tfImmediateOrCancel"] = 131072] = "tfImmediateOrCancel";
  10. OfferCreateFlags[OfferCreateFlags["tfFillOrKill"] = 262144] = "tfFillOrKill";
  11. OfferCreateFlags[OfferCreateFlags["tfSell"] = 524288] = "tfSell";
  12. })(OfferCreateFlags = exports.OfferCreateFlags || (exports.OfferCreateFlags = {}));
  13. function validateOfferCreate(tx) {
  14. (0, common_1.validateBaseTransaction)(tx);
  15. if (tx.TakerGets === undefined) {
  16. throw new errors_1.ValidationError('OfferCreate: missing field TakerGets');
  17. }
  18. if (tx.TakerPays === undefined) {
  19. throw new errors_1.ValidationError('OfferCreate: missing field TakerPays');
  20. }
  21. if (typeof tx.TakerGets !== 'string' && !(0, common_1.isAmount)(tx.TakerGets)) {
  22. throw new errors_1.ValidationError('OfferCreate: invalid TakerGets');
  23. }
  24. if (typeof tx.TakerPays !== 'string' && !(0, common_1.isAmount)(tx.TakerPays)) {
  25. throw new errors_1.ValidationError('OfferCreate: invalid TakerPays');
  26. }
  27. if (tx.Expiration !== undefined && typeof tx.Expiration !== 'number') {
  28. throw new errors_1.ValidationError('OfferCreate: invalid Expiration');
  29. }
  30. if (tx.OfferSequence !== undefined && typeof tx.OfferSequence !== 'number') {
  31. throw new errors_1.ValidationError('OfferCreate: invalid OfferSequence');
  32. }
  33. }
  34. exports.validateOfferCreate = validateOfferCreate;
  35. //# sourceMappingURL=offerCreate.js.map