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.

NFTokenAcceptOffer.js 1.3KB

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.validateNFTokenAcceptOffer = void 0;
  4. const errors_1 = require("../../errors");
  5. const common_1 = require("./common");
  6. function validateNFTokenBrokerFee(tx) {
  7. const value = (0, common_1.parseAmountValue)(tx.NFTokenBrokerFee);
  8. if (Number.isNaN(value)) {
  9. throw new errors_1.ValidationError('NFTokenAcceptOffer: invalid NFTokenBrokerFee');
  10. }
  11. if (value <= 0) {
  12. throw new errors_1.ValidationError('NFTokenAcceptOffer: NFTokenBrokerFee must be greater than 0; omit if there is no fee');
  13. }
  14. if (tx.NFTokenSellOffer == null || tx.NFTokenBuyOffer == null) {
  15. throw new errors_1.ValidationError('NFTokenAcceptOffer: both NFTokenSellOffer and NFTokenBuyOffer must be set if using brokered mode');
  16. }
  17. }
  18. function validateNFTokenAcceptOffer(tx) {
  19. (0, common_1.validateBaseTransaction)(tx);
  20. if (tx.NFTokenBrokerFee != null) {
  21. validateNFTokenBrokerFee(tx);
  22. }
  23. if (tx.NFTokenSellOffer == null && tx.NFTokenBuyOffer == null) {
  24. throw new errors_1.ValidationError('NFTokenAcceptOffer: must set either NFTokenSellOffer or NFTokenBuyOffer');
  25. }
  26. }
  27. exports.validateNFTokenAcceptOffer = validateNFTokenAcceptOffer;
  28. //# sourceMappingURL=NFTokenAcceptOffer.js.map