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.

submit.js 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  22. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  23. return new (P || (P = Promise))(function (resolve, reject) {
  24. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  25. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  26. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  27. step((generator = generator.apply(thisArg, _arguments || [])).next());
  28. });
  29. };
  30. Object.defineProperty(exports, "__esModule", { value: true });
  31. const utils = __importStar(require("./utils"));
  32. const common_1 = require("../common");
  33. function isImmediateRejection(engineResult) {
  34. return engineResult.startsWith('tem');
  35. }
  36. function formatSubmitResponse(response) {
  37. const data = {
  38. resultCode: response.engine_result,
  39. resultMessage: response.engine_result_message,
  40. engine_result: response.engine_result,
  41. engine_result_code: response.engine_result_code,
  42. engine_result_message: response.engine_result_message,
  43. tx_blob: response.tx_blob,
  44. tx_json: response.tx_json
  45. };
  46. if (isImmediateRejection(response.engine_result)) {
  47. throw new utils.common.errors.RippledError('Submit failed', data);
  48. }
  49. return data;
  50. }
  51. function submit(signedTransaction, failHard) {
  52. return __awaiter(this, void 0, void 0, function* () {
  53. common_1.validate.submit({ signedTransaction });
  54. const response = yield this.request('submit', Object.assign({ tx_blob: signedTransaction }, (failHard ? { fail_hard: failHard } : {})));
  55. return formatSubmitResponse(response);
  56. });
  57. }
  58. exports.default = submit;
  59. //# sourceMappingURL=submit.js.map