UNPKG

@walletpack/core

Version:

> TODO: description

93 lines (81 loc) 2.55 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.post = exports.get = void 0; var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); /*** * THIS HTTP SERVICE IS ONLY USED FOR HARDWARE WALLET CONNECTIONS * */ var get = /*#__PURE__*/ function () { var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/ _regenerator["default"].mark(function _callee(route) { return _regenerator["default"].wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: return _context.abrupt("return", Promise.race([fetch(route).then(function (res) { return res.json(); })["catch"](function () { return null; }), new Promise(function (resolve) { return setTimeout(function () { return resolve(null); }, 60000); })])); case 1: case "end": return _context.stop(); } } }, _callee); })); return function get(_x) { return _ref.apply(this, arguments); }; }(); exports.get = get; var post = /*#__PURE__*/ function () { var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/ _regenerator["default"].mark(function _callee2(route, data) { return _regenerator["default"].wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: return _context2.abrupt("return", Promise.race([fetch(route, { method: "POST", headers: { 'Accept': 'application/json, text/plain, */*', 'Content-Type': 'application/json' }, body: JSON.stringify(data) }).then(function (res) { return res.json(); })["catch"](function () { return null; }), new Promise(function (resolve) { return setTimeout(function () { return resolve(null); }, 120000); })])); case 1: case "end": return _context2.stop(); } } }, _callee2); })); return function post(_x2, _x3) { return _ref2.apply(this, arguments); }; }(); exports.post = post;