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.

depositPreauth.js 1.5KB

1234567891011121314151617181920212223242526272829303132
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.validateDepositPreauth = void 0;
  4. const errors_1 = require("../../errors");
  5. const common_1 = require("./common");
  6. function validateDepositPreauth(tx) {
  7. (0, common_1.validateBaseTransaction)(tx);
  8. if (tx.Authorize !== undefined && tx.Unauthorize !== undefined) {
  9. throw new errors_1.ValidationError("DepositPreauth: can't provide both Authorize and Unauthorize fields");
  10. }
  11. if (tx.Authorize === undefined && tx.Unauthorize === undefined) {
  12. throw new errors_1.ValidationError('DepositPreauth: must provide either Authorize or Unauthorize field');
  13. }
  14. if (tx.Authorize !== undefined) {
  15. if (typeof tx.Authorize !== 'string') {
  16. throw new errors_1.ValidationError('DepositPreauth: Authorize must be a string');
  17. }
  18. if (tx.Account === tx.Authorize) {
  19. throw new errors_1.ValidationError("DepositPreauth: Account can't preauthorize its own address");
  20. }
  21. }
  22. if (tx.Unauthorize !== undefined) {
  23. if (typeof tx.Unauthorize !== 'string') {
  24. throw new errors_1.ValidationError('DepositPreauth: Unauthorize must be a string');
  25. }
  26. if (tx.Account === tx.Unauthorize) {
  27. throw new errors_1.ValidationError("DepositPreauth: Account can't unauthorize its own address");
  28. }
  29. }
  30. }
  31. exports.validateDepositPreauth = validateDepositPreauth;
  32. //# sourceMappingURL=depositPreauth.js.map