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.

trustline.js 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. "use strict";
  2. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
  3. if (k2 === undefined) k2 = k;
  4. Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
  5. }) : (function(o, m, k, k2) {
  6. if (k2 === undefined) k2 = k;
  7. o[k2] = m[k];
  8. }));
  9. var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
  10. Object.defineProperty(o, "default", { enumerable: true, value: v });
  11. }) : function(o, v) {
  12. o["default"] = v;
  13. });
  14. var __importStar = (this && this.__importStar) || function (mod) {
  15. if (mod && mod.__esModule) return mod;
  16. var result = {};
  17. if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  18. __setModuleDefault(result, mod);
  19. return result;
  20. };
  21. Object.defineProperty(exports, "__esModule", { value: true });
  22. const assert = __importStar(require("assert"));
  23. const utils_1 = require("./utils");
  24. const common_1 = require("../../common");
  25. const flags = common_1.txFlags.TrustSet;
  26. function parseFlag(flagsValue, trueValue, falseValue) {
  27. if (flagsValue & trueValue) {
  28. return true;
  29. }
  30. if (flagsValue & falseValue) {
  31. return false;
  32. }
  33. return undefined;
  34. }
  35. function parseTrustline(tx) {
  36. assert.ok(tx.TransactionType === 'TrustSet');
  37. return common_1.removeUndefined({
  38. limit: tx.LimitAmount.value,
  39. currency: tx.LimitAmount.currency,
  40. counterparty: tx.LimitAmount.issuer,
  41. memos: utils_1.parseMemos(tx),
  42. qualityIn: utils_1.parseQuality(tx.QualityIn),
  43. qualityOut: utils_1.parseQuality(tx.QualityOut),
  44. ripplingDisabled: parseFlag(tx.Flags, flags.SetNoRipple, flags.ClearNoRipple),
  45. frozen: parseFlag(tx.Flags, flags.SetFreeze, flags.ClearFreeze),
  46. authorized: parseFlag(tx.Flags, flags.SetAuth, 0)
  47. });
  48. }
  49. exports.default = parseTrustline;
  50. //# sourceMappingURL=trustline.js.map