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.

accountSet.js 4.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.validateAccountSet = exports.AccountSetTfFlags = exports.AccountSetAsfFlags = void 0;
  4. const ripple_address_codec_1 = require("ripple-address-codec");
  5. const errors_1 = require("../../errors");
  6. const common_1 = require("./common");
  7. var AccountSetAsfFlags;
  8. (function (AccountSetAsfFlags) {
  9. AccountSetAsfFlags[AccountSetAsfFlags["asfRequireDest"] = 1] = "asfRequireDest";
  10. AccountSetAsfFlags[AccountSetAsfFlags["asfRequireAuth"] = 2] = "asfRequireAuth";
  11. AccountSetAsfFlags[AccountSetAsfFlags["asfDisallowXRP"] = 3] = "asfDisallowXRP";
  12. AccountSetAsfFlags[AccountSetAsfFlags["asfDisableMaster"] = 4] = "asfDisableMaster";
  13. AccountSetAsfFlags[AccountSetAsfFlags["asfAccountTxnID"] = 5] = "asfAccountTxnID";
  14. AccountSetAsfFlags[AccountSetAsfFlags["asfNoFreeze"] = 6] = "asfNoFreeze";
  15. AccountSetAsfFlags[AccountSetAsfFlags["asfGlobalFreeze"] = 7] = "asfGlobalFreeze";
  16. AccountSetAsfFlags[AccountSetAsfFlags["asfDefaultRipple"] = 8] = "asfDefaultRipple";
  17. AccountSetAsfFlags[AccountSetAsfFlags["asfDepositAuth"] = 9] = "asfDepositAuth";
  18. AccountSetAsfFlags[AccountSetAsfFlags["asfAuthorizedNFTokenMinter"] = 10] = "asfAuthorizedNFTokenMinter";
  19. AccountSetAsfFlags[AccountSetAsfFlags["asfDisallowIncomingNFTokenOffer"] = 12] = "asfDisallowIncomingNFTokenOffer";
  20. AccountSetAsfFlags[AccountSetAsfFlags["asfDisallowIncomingCheck"] = 13] = "asfDisallowIncomingCheck";
  21. AccountSetAsfFlags[AccountSetAsfFlags["asfDisallowIncomingPayChan"] = 14] = "asfDisallowIncomingPayChan";
  22. AccountSetAsfFlags[AccountSetAsfFlags["asfDisallowIncomingTrustline"] = 15] = "asfDisallowIncomingTrustline";
  23. })(AccountSetAsfFlags = exports.AccountSetAsfFlags || (exports.AccountSetAsfFlags = {}));
  24. var AccountSetTfFlags;
  25. (function (AccountSetTfFlags) {
  26. AccountSetTfFlags[AccountSetTfFlags["tfRequireDestTag"] = 65536] = "tfRequireDestTag";
  27. AccountSetTfFlags[AccountSetTfFlags["tfOptionalDestTag"] = 131072] = "tfOptionalDestTag";
  28. AccountSetTfFlags[AccountSetTfFlags["tfRequireAuth"] = 262144] = "tfRequireAuth";
  29. AccountSetTfFlags[AccountSetTfFlags["tfOptionalAuth"] = 524288] = "tfOptionalAuth";
  30. AccountSetTfFlags[AccountSetTfFlags["tfDisallowXRP"] = 1048576] = "tfDisallowXRP";
  31. AccountSetTfFlags[AccountSetTfFlags["tfAllowXRP"] = 2097152] = "tfAllowXRP";
  32. })(AccountSetTfFlags = exports.AccountSetTfFlags || (exports.AccountSetTfFlags = {}));
  33. const MIN_TICK_SIZE = 3;
  34. const MAX_TICK_SIZE = 15;
  35. function validateAccountSet(tx) {
  36. (0, common_1.validateBaseTransaction)(tx);
  37. if (tx.NFTokenMinter !== undefined &&
  38. !(0, ripple_address_codec_1.isValidClassicAddress)(String(tx.NFTokenMinter))) {
  39. throw new errors_1.ValidationError('AccountSet: invalid NFTokenMinter');
  40. }
  41. if (tx.ClearFlag !== undefined) {
  42. if (typeof tx.ClearFlag !== 'number') {
  43. throw new errors_1.ValidationError('AccountSet: invalid ClearFlag');
  44. }
  45. if (!Object.values(AccountSetAsfFlags).includes(tx.ClearFlag)) {
  46. throw new errors_1.ValidationError('AccountSet: invalid ClearFlag');
  47. }
  48. }
  49. if (tx.Domain !== undefined && typeof tx.Domain !== 'string') {
  50. throw new errors_1.ValidationError('AccountSet: invalid Domain');
  51. }
  52. if (tx.EmailHash !== undefined && typeof tx.EmailHash !== 'string') {
  53. throw new errors_1.ValidationError('AccountSet: invalid EmailHash');
  54. }
  55. if (tx.MessageKey !== undefined && typeof tx.MessageKey !== 'string') {
  56. throw new errors_1.ValidationError('AccountSet: invalid MessageKey');
  57. }
  58. if (tx.SetFlag !== undefined) {
  59. if (typeof tx.SetFlag !== 'number') {
  60. throw new errors_1.ValidationError('AccountSet: invalid SetFlag');
  61. }
  62. if (!Object.values(AccountSetAsfFlags).includes(tx.SetFlag)) {
  63. throw new errors_1.ValidationError('AccountSet: invalid SetFlag');
  64. }
  65. }
  66. if (tx.TransferRate !== undefined && typeof tx.TransferRate !== 'number') {
  67. throw new errors_1.ValidationError('AccountSet: invalid TransferRate');
  68. }
  69. if (tx.TickSize !== undefined) {
  70. if (typeof tx.TickSize !== 'number') {
  71. throw new errors_1.ValidationError('AccountSet: invalid TickSize');
  72. }
  73. if (tx.TickSize !== 0 &&
  74. (tx.TickSize < MIN_TICK_SIZE || tx.TickSize > MAX_TICK_SIZE)) {
  75. throw new errors_1.ValidationError('AccountSet: invalid TickSize');
  76. }
  77. }
  78. }
  79. exports.validateAccountSet = validateAccountSet;
  80. //# sourceMappingURL=accountSet.js.map