UNPKG

@foreverrbum/ethsign

Version:

This package will allow you to electronically sign documents within your application

1,158 lines (975 loc) 42.1 kB
"use strict"; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _react = _interopRequireWildcard(require("react")); var _reactRouterDom = require("react-router-dom"); var _NewContract = _interopRequireDefault(require("./NewContract")); var _Documents = _interopRequireDefault(require("./Documents")); var _History = _interopRequireDefault(require("./History")); var _Sign = _interopRequireDefault(require("./Sign")); var _graphql = require("../helpers/graphql"); var _dashboard = require("../helpers/dashboard"); var _lodash = _interopRequireDefault(require("lodash")); var _UploadPDF = _interopRequireDefault(require("./UploadPDF")); var _reactIntl = require("react-intl"); var _sessionStorage = require("../helpers/sessionStorage"); var _pdf = require("../helpers/pdf"); var _NotFoundComponent = require("./NotFoundComponent"); var _emailNotification = require("./email-notification"); var _CreateAndSign = _interopRequireDefault(require("./CreateAndSign")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } var Dashboard = function Dashboard(props) { /* * Statuses: * -1: 'All Status' * 0: 'PDF Not Uploaded' * 1: 'More Signers Needed' * 2: 'Pending Signatures' * 3: 'All Signed' * 4: 'Waiting For Others' */ var language = props.language, fm = props.fm, torus = props.torus, networkId = props.networkId, web3Case = props.web3Case, web3 = props.web3, contract = props.contract, ethAccount = props.ethAccount, handleActivePage = props.handleActivePage, ensEnabled = props.ensEnabled, appLogout = props.appLogout, _changeNetwork = props.changeNetwork, networkChanged = props.networkChanged, handleNetworkChanged = props.handleNetworkChanged, ethAlias = props.ethAlias, ethAvatar = props.ethAvatar, open = props.open, handleOpen = props.handleOpen; var _useState = (0, _react.useState)('pending'), _useState2 = _slicedToArray(_useState, 2), filter = _useState2[0], handleFilter = _useState2[1]; var _useState3 = (0, _react.useState)(-1), _useState4 = _slicedToArray(_useState3, 2), status = _useState4[0], handleStatus = _useState4[1]; var _useState5 = (0, _react.useState)(""), _useState6 = _slicedToArray(_useState5, 2), search = _useState6[0], handleSearch = _useState6[1]; var _useState7 = (0, _react.useState)(''), _useState8 = _slicedToArray(_useState7, 2), name = _useState8[0], handleName = _useState8[1]; var _useState9 = (0, _react.useState)(null), _useState10 = _slicedToArray(_useState9, 2), controller = _useState10[0], handleController = _useState10[1]; var _useState11 = (0, _react.useState)(false), _useState12 = _slicedToArray(_useState11, 2), initializeTable = _useState12[0], handleInitializeTable = _useState12[1]; var _useState13 = (0, _react.useState)(null), _useState14 = _slicedToArray(_useState13, 2), fd = _useState14[0], handleFd = _useState14[1]; var _useState15 = (0, _react.useState)({}), _useState16 = _slicedToArray(_useState15, 2), dataObj = _useState16[0], handleDataObj = _useState16[1]; var _useState17 = (0, _react.useState)(null), _useState18 = _slicedToArray(_useState17, 2), dataKeys = _useState18[0], handleDataKeys = _useState18[1]; var _useState19 = (0, _react.useState)(null), _useState20 = _slicedToArray(_useState19, 2), archivedList = _useState20[0], handleArchivedList = _useState20[1]; var _useState21 = (0, _react.useState)(null), _useState22 = _slicedToArray(_useState21, 2), regularList = _useState22[0], handleRegularList = _useState22[1]; var _useState23 = (0, _react.useState)(false), _useState24 = _slicedToArray(_useState23, 2), loaded = _useState24[0], handleLoaded = _useState24[1]; var _useState25 = (0, _react.useState)(null), _useState26 = _slicedToArray(_useState25, 2), searchData = _useState26[0], handleSearchData = _useState26[1]; var _useIntl = (0, _reactIntl.useIntl)(), formatMessage = _useIntl.formatMessage; var _useState27 = (0, _react.useState)(false), _useState28 = _slicedToArray(_useState27, 2), error = _useState28[0], handleError = _useState28[1]; var _useState29 = (0, _react.useState)(false), _useState30 = _slicedToArray(_useState29, 2), dataAdded = _useState30[0], handleDataAdded = _useState30[1]; // Stored data for /create var _useStateWithSessionS = (0, _sessionStorage.useStateWithSessionStorage)('fileData', null), _useStateWithSessionS2 = _slicedToArray(_useStateWithSessionS, 2), storedData = _useStateWithSessionS2[0], handleStoredData = _useStateWithSessionS2[1]; var history = (0, _reactRouterDom.useHistory)(); (0, _react.useEffect)(function () { _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { return regeneratorRuntime.wrap(function _callee$(_context) { while (1) { switch (_context.prev = _context.next) { case 0: handleDataKeys(null); case 1: case "end": return _context.stop(); } } }, _callee); }))(); }, [networkId]); (0, _react.useEffect)(function () { var curController = new AbortController(); var isSubscribed = true; _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() { var data, currArchivedList, currRegularList, curDataKeys; return regeneratorRuntime.wrap(function _callee3$(_context3) { while (1) { switch (_context3.prev = _context3.next) { case 0: handleError(false); if (!(contract !== null && web3Case !== null)) { _context3.next = 39; break; } handleFd(null); handleDataKeys(null); handleDataObj({}); handleLoaded(false); handleDataKeys({ mine: [], shared: [], all: [], consensus: [], pending: [], voted: [], archived: [] }); _context3.prev = 7; if (!(contract !== null && ethAccount !== null && networkId !== null)) { _context3.next = 33; break; } handleLoaded(false); data = []; _context3.prev = 11; _context3.next = 14; return (0, _graphql.loadContracts)(networkId, ethAccount, curController.signal); case 14: data = _context3.sent; _context3.next = 22; break; case 17: _context3.prev = 17; _context3.t0 = _context3["catch"](11); data = []; handleError(true); return _context3.abrupt("return"); case 22: if (!(isSubscribed == false)) { _context3.next = 24; break; } return _context3.abrupt("return"); case 24: currArchivedList = data.filter(function (obj) { return obj.type == "Archived"; }); currRegularList = data.filter(function (obj) { return obj.type != "Archived"; }); handleArchivedList(currArchivedList); handleRegularList(currRegularList); curDataKeys = { mine: [], shared: [], all: [], consensus: [], pending: [], voted: [], archived: [] }; // get data keys per filter and fill skeleton data.map( /*#__PURE__*/function () { var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(id) { return regeneratorRuntime.wrap(function _callee2$(_context2) { while (1) { switch (_context2.prev = _context2.next) { case 0: curDataKeys = initializeSkeleton(id, id.ethAccount, curDataKeys); case 1: case "end": return _context2.stop(); } } }, _callee2); })); return function (_x) { return _ref3.apply(this, arguments); }; }()); handleController(curController); handleDataKeys(curDataKeys); //setting this to true triggers the fetching of contract details handleInitializeTable(true); case 33: _context3.next = 39; break; case 35: _context3.prev = 35; _context3.t1 = _context3["catch"](7); console.log(_context3.t1); handleError(true); case 39: case "end": return _context3.stop(); } } }, _callee3, null, [[7, 35], [11, 17]]); }))(); return function () { isSubscribed = false; curController === null || curController === void 0 ? void 0 : curController.abort(); handleInitializeTable(false); }; }, [contract, ethAccount, web3Case]); (0, _react.useEffect)(function () { _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() { return regeneratorRuntime.wrap(function _callee4$(_context4) { while (1) { switch (_context4.prev = _context4.next) { case 0: if (!(initializeTable == true && controller)) { _context4.next = 4; break; } if (!dataKeys) { _context4.next = 4; break; } _context4.next = 4; return initializeData(controller, regularList, archivedList); case 4: case "end": return _context4.stop(); } } }, _callee4); }))(); }, [initializeTable, controller]); (0, _react.useEffect)(function () { if (history.location.pathname !== '/create') { if (storedData !== null && storedData !== void 0 && storedData.documentKey && storedData !== null && storedData !== void 0 && storedData.originalFilename) { (0, _pdf.resetStoredData)(handleStoredData); } } }, [history.location.pathname]); (0, _react.useEffect)(function () { // This will ensure that we ignore network changes where they aren't needed or handled elsewhere. // Add page endpoints that need to be redirected or handled on a network switch. if (networkChanged && location) { if (history.location.pathname == '/history' || history.location.pathname == '/sign' || history.location.pathname == '/create') { history.push({ pathname: '/contracts' }); (0, _dashboard.storeNotif)(formatMessage({ id: "NETWORK_CHANGED" }), formatMessage({ id: "YOU_HAVE_BEEN_REDIRECTED_CONTACTS_LIST" }), "warning"); } handleNetworkChanged(false); } }, [networkChanged]); // TODO: optimize var addFilteredData = function addFilteredData(contract, type, filteredData) { if (!filteredData) { filteredData = { mine: [], shared: [], all: [], consensus: [], pending: [], voted: [], archived: [] }; } switch (type) { case 'CreatedByMe': if (contract.error) { filteredData.mine.push(contract.documentKey); filteredData.all.push(contract.documentKey); break; } filteredData.mine.push(contract.documentKey); filteredData.all.push(contract.documentKey); if (contract.status == 3) { filteredData.consensus.push(contract.documentKey); } else if (contract.status == 2) { filteredData.pending.push(contract.documentKey); } else if (contract.status == 4) { filteredData.voted.push(contract.documentKey); } break; case 'Archived': if (contract.error) { filteredData.archived.push(contract.documentKey); break; } filteredData.archived.push(contract.documentKey); break; case 'SharedWithMe': if (contract.error) { filteredData.shared.push(contract.documentKey); filteredData.all.push(contract.documentKey); break; } filteredData.shared.push(contract.documentKey); filteredData.all.push(contract.documentKey); if (contract.status == 3) { filteredData.consensus.push(contract.documentKey); } else if (contract.status == 2) { filteredData.pending.push(contract.documentKey); } else if (contract.status == 4) { filteredData.voted.push(contract.documentKey); } break; default: throw new Error('Invalid contract type.'); } return filteredData; }; var reloadContractDetails = /*#__PURE__*/function () { var _ref5 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(docKey, idx) { var da, obj; return regeneratorRuntime.wrap(function _callee5$(_context5) { while (1) { switch (_context5.prev = _context5.next) { case 0: da = dataAdded; try { if (dataKeys.mine.indexOf(docKey) !== -1) { updateData(docKey, idx, 1, controller.signal, null); } else if (dataKeys.shared.indexOf(docKey) !== -1) { updateData(docKey, idx, 2, controller.signal, null); } } catch (err) { obj = dataObj; obj[docKey].loading = false; obj[docKey].error = true; handleDataObj(obj); da = !da; handleDataAdded(da); console.log(err); } case 2: case "end": return _context5.stop(); } } }, _callee5); })); return function reloadContractDetails(_x2, _x3) { return _ref5.apply(this, arguments); }; }(); var initializeData = /*#__PURE__*/function () { var _ref6 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee9(controller, currRegularList, currArchivedList) { return regeneratorRuntime.wrap(function _callee9$(_context9) { while (1) { switch (_context9.prev = _context9.next) { case 0: _context9.next = 2; return Promise.all(currRegularList.map( /*#__PURE__*/function () { var _ref7 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(id) { return regeneratorRuntime.wrap(function _callee6$(_context6) { while (1) { switch (_context6.prev = _context6.next) { case 0: _context6.next = 2; return updateData(id.contract.id, -1, -1, controller.signal, true); case 2: return _context6.abrupt("return", _context6.sent); case 3: case "end": return _context6.stop(); } } }, _callee6); })); return function (_x7) { return _ref7.apply(this, arguments); }; }())).then( /*#__PURE__*/function () { var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee8(res) { return regeneratorRuntime.wrap(function _callee8$(_context8) { while (1) { switch (_context8.prev = _context8.next) { case 0: if (!true) { _context8.next = 3; break; } _context8.next = 3; return Promise.all(currArchivedList.map( /*#__PURE__*/function () { var _ref9 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(id) { return regeneratorRuntime.wrap(function _callee7$(_context7) { while (1) { switch (_context7.prev = _context7.next) { case 0: _context7.next = 2; return updateData(id.contract.id, -1, -1, controller.signal, true); case 2: return _context7.abrupt("return", _context7.sent); case 3: case "end": return _context7.stop(); } } }, _callee7); })); return function (_x9) { return _ref9.apply(this, arguments); }; }())).then(function (res2) { // const needToReload2 = res2.filter( obj => obj.status == "rejected").map((o)=>{ // return o.reason // }); // console.log(needToReload2) handleLoaded(true); }); case 3: case "end": return _context8.stop(); } } }, _callee8); })); return function (_x8) { return _ref8.apply(this, arguments); }; }()); case 2: case "end": return _context9.stop(); } } }, _callee9); })); return function initializeData(_x4, _x5, _x6) { return _ref6.apply(this, arguments); }; }(); // creates placeholder for skeleton but just contains documentKeys, status and type // need to optimize var initializeSkeleton = function initializeSkeleton(currData, expectedEthAccount, curDataKeys) { var filteredData = null; if (!currData) { return; } var da = dataAdded; var details = { documentKey: currData.contract.id, status: currData.signed && currData.contract.status == 2 ? 4 : currData.contract.status, type: currData.type, loading: true }; if (details.status != 5) { var obj = dataObj; obj[currData.contract.id] = details; handleDataObj(obj); filteredData = addFilteredData(details, currData.type, curDataKeys); // This forces a UI refresh when the filtered data updates. da = !da; handleDataAdded(da); } // let all = [] // all = all.concat(mine, shared) // getFilteredData(mine, shared, all, archived); if (error) { handleError(false); } return filteredData; }; var updateData = /*#__PURE__*/function () { var _ref10 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee10(documentKey, idx, type, signal, returnPromise, count) { var curCount, mine, shared, archived, consensus, pending, voted, all, obj, details, index, filtered; return regeneratorRuntime.wrap(function _callee10$(_context10) { while (1) { switch (_context10.prev = _context10.next) { case 0: curCount = count ? count + 1 : 1; mine = dataKeys && dataKeys.mine ? dataKeys.mine : []; shared = dataKeys && dataKeys.shared ? dataKeys.shared : []; archived = dataKeys && dataKeys.archived ? dataKeys.archived : []; consensus = dataKeys && dataKeys.consensus ? dataKeys.consensus : []; pending = dataKeys && dataKeys.pending ? dataKeys.pending : []; voted = dataKeys && dataKeys.voted ? dataKeys.voted : []; all = dataKeys && dataKeys.all ? dataKeys.all : []; obj = dataObj; if (obj[documentKey]) { obj[documentKey].loading = true; handleDataObj(obj); } else { if (idx === -1 && type === 0) { obj[documentKey] = { documentKey: documentKey, loading: true }; handleDataObj(obj); mine.unshift(documentKey); all.unshift(documentKey); } } handleDataAdded(!dataAdded); details = null; _context10.prev = 12; _context10.next = 15; return (0, _graphql.loadContractDetails)(networkId, documentKey, web3, ethAccount, signal); case 15: details = _context10.sent; _context10.next = 28; break; case 18: _context10.prev = 18; _context10.t0 = _context10["catch"](12); // TODO: catch abort error // details = { error: true, documentKey: documentKey }; if (!(_context10.t0.name == "AbortError" && returnPromise)) { _context10.next = 26; break; } handleDataKeys(null); return _context10.abrupt("return", Promise.reject(documentKey)); case 26: if (!(curCount < 5)) { _context10.next = 28; break; } return _context10.abrupt("return", setTimeout(updateData(documentKey, idx, type, signal, returnPromise, curCount), curCount * 1000)); case 28: if (!details || Object.keys(details).length === 0 && details.constructor === Object) { // This will prevent us from crashing when details is null for some reason. // The error should be printed to console if we come across an error, so // this is acceptable behavior. details = { error: true, documentKey: documentKey }; } obj[documentKey] = details; handleDataObj(obj); index = -1; //TODO: optimize-there are useless if else statements here _context10.t1 = type; _context10.next = _context10.t1 === 0 ? 35 : _context10.t1 === 1 ? 38 : _context10.t1 === 2 ? 48 : _context10.t1 === 3 ? 58 : _context10.t1 === 4 ? 69 : 80; break; case 35: //new document if (!(idx === -1 && type === 0)) { mine.unshift(documentKey); all.unshift(documentKey); } if (details.status == 3) { consensus.unshift(documentKey); } else if (details.status == 2) { pending.unshift(documentKey); } else if (details.status == 4) { voted.unshift(documentKey); } return _context10.abrupt("break", 81); case 38: //change document - mine if (idx >= 0) { mine[idx] = documentKey; } index = consensus.indexOf(documentKey); if (index > -1 && details.status != 3) { // Remove it because the status is no longer correct for this category consensus.splice(index, 1); } else if (details.status == 3 && index < 0) { // Add it because the status now fits this category and it's not here consensus.unshift(documentKey); } index = pending.indexOf(documentKey); if (index > -1 && details.status != 2) { // Remove it because the status is no longer correct for this category pending.splice(index, 1); } else if (details.status == 2 && index < 0) { // Add it because the status now fits this category and it's not here pending.unshift(documentKey); } index = voted.indexOf(documentKey); if (index > -1 && details.status != 4) { // Remove it because the status is no longer correct for this category voted.splice(index, 1); } else if (details.status == 4 && index < 0) { // Add it because the status now fits this category and it's not here voted.unshift(documentKey); } index = all.indexOf(documentKey); if (index > -1) { all.splice(index, 1); } return _context10.abrupt("break", 81); case 48: //change document - shared if (idx >= 0) { shared[idx] = documentKey; } index = consensus.indexOf(documentKey); if (index > -1 && details.status != 3) { // Remove it because the status is no longer correct for this category consensus.splice(index, 1); } else if (details.status == 3 && index < 0) { // Add it because the status now fits this category and it's not here consensus.unshift(documentKey); } index = pending.indexOf(documentKey); if (index > -1 && details.status != 2) { // Remove it because the status is no longer correct for this category pending.splice(index, 1); } else if (details.status == 2 && index < 0) { // Add it because the status now fits this category and it's not here pending.unshift(documentKey); } index = voted.indexOf(documentKey); if (index > -1 && details.status != 4) { // Remove it because the status is no longer correct for this category voted.splice(index, 1); } else if (details.status == 4 && index < 0) { // Add it because the status now fits this category and it's not here voted.unshift(documentKey); } index = all.indexOf(documentKey); if (index > -1) { all.splice(index, 1); } return _context10.abrupt("break", 81); case 58: //delete document - mine if (idx >= 0) { mine.splice(idx, 1); } index = consensus.indexOf(documentKey); if (index > -1) { consensus.splice(index, 1); } index = pending.indexOf(documentKey); if (index > -1) { pending.splice(index, 1); } index = voted.indexOf(documentKey); if (index > -1) { voted.splice(index, 1); } index = all.indexOf(documentKey); if (index > -1) { all.splice(index, 1); } archived.unshift(documentKey); return _context10.abrupt("break", 81); case 69: //delete document - shared if (index >= 0) { shared.splice(idx, 1); } index = consensus.indexOf(documentKey); if (index > -1) { consensus.splice(index, 1); } index = pending.indexOf(documentKey); if (index > -1) { pending.splice(index, 1); } index = voted.indexOf(documentKey); if (index > -1) { voted.splice(index, 1); } index = all.indexOf(documentKey); if (index > -1) { all.splice(index, 1); } archived.unshift(documentKey); return _context10.abrupt("break", 81); case 80: return _context10.abrupt("break", 81); case 81: // let all = []; // all = all.concat(mine, shared); // update data filters state since a doc might be transferred // from consensus to pending for example // getFilteredData(mine, shared, all, archived); filtered = { mine: mine, shared: shared, all: all, consensus: consensus, pending: pending, voted: voted, archived: archived }; handleDataKeys(filtered); if (!returnPromise) { _context10.next = 85; break; } return _context10.abrupt("return", Promise.resolve('success')); case 85: case "end": return _context10.stop(); } } }, _callee10, null, [[12, 18]]); })); return function updateData(_x10, _x11, _x12, _x13, _x14, _x15) { return _ref10.apply(this, arguments); }; }(); return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, { exact: true, path: "/home" }, web3Case == null ? /*#__PURE__*/_react.default.createElement(_reactRouterDom.Redirect, { to: "/signin" }) : /*#__PURE__*/ // <Home // ethAccount={ethAccount} // contract={contract} // web3={web3} // updateData={updateData} // data={data} // handleFilter={handleFilter} // handleActivePage={handleActivePage} // /> // TODO: temporary comment out because there is no home page yet _react.default.createElement(_reactRouterDom.Redirect, { to: "/contracts" })), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, { exact: true, path: "/contracts" }, web3Case == null ? /*#__PURE__*/_react.default.createElement(_reactRouterDom.Redirect, { to: "/signin" }) : /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Documents.default, { ethAccount: ethAccount, contract: contract, handleActivePage: handleActivePage, web3: web3, dataKeys: dataKeys, dataObj: dataObj, handleDataObj: handleDataObj, dataAdded: dataAdded, handleDataAdded: handleDataAdded, handleData: updateData, filter: filter, handleFilter: handleFilter, status: status, handleStatus: handleStatus, name: name, handleName: handleName, searchData: searchData, handleSearchData: handleSearchData, ensEnabled: ensEnabled, search: search, handleSearch: handleSearch, error: error, loaded: loaded, handleLoaded: handleLoaded, reloadContractDetails: reloadContractDetails }), /*#__PURE__*/_react.default.createElement(_emailNotification.EmailNotification, { web3: web3, open: open, handleOpen: handleOpen }))), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, { exact: true, path: "/history" }, web3Case == null ? /*#__PURE__*/_react.default.createElement(_reactRouterDom.Redirect, { to: "/signin" }) : /*#__PURE__*/_react.default.createElement(_History.default, { ethAccount: ethAccount, contract: contract, handleActivePage: handleActivePage, web3: web3, ensEnabled: ensEnabled })), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, { exact: true, path: "/create" }, web3Case != null ? /*#__PURE__*/_react.default.createElement(_NewContract.default, { ethAccount: ethAccount, ethAlias: ethAlias, ethAvatar: ethAvatar, handleActivePage: handleActivePage, provider: web3, fm: fm, torus: torus, contract: contract, appLogout: appLogout, ensEnabled: ensEnabled, changeNetwork: function changeNetwork(chain) { return _changeNetwork(chain); }, handleData: /*#__PURE__*/function () { var _ref11 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee11(documentKey) { return regeneratorRuntime.wrap(function _callee11$(_context11) { while (1) { switch (_context11.prev = _context11.next) { case 0: handleFilter('original'); _context11.next = 3; return updateData(documentKey, -1, 0, controller.signal, null); case 3: case "end": return _context11.stop(); } } }, _callee11); })); return function (_x16) { return _ref11.apply(this, arguments); }; }(), clearStoredSessionData: function clearStoredSessionData() { return (0, _pdf.resetStoredData)(handleStoredData); }, storedData: storedData, handleStoredData: handleStoredData, handleOpen: handleOpen }) : /*#__PURE__*/_react.default.createElement(_reactRouterDom.Redirect, { to: "/home" })), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, { exact: true, path: "/upload" }, web3Case != null ? /*#__PURE__*/_react.default.createElement(_UploadPDF.default, { ethAccount: ethAccount, ethAlias: ethAlias, ethAvatar: ethAvatar, handleActivePage: handleActivePage, web3: web3, fm: fm, torus: torus, contract: contract, appLogout: appLogout, ensEnabled: ensEnabled, changeNetwork: function changeNetwork(chain) { return _changeNetwork(chain); }, handleData: /*#__PURE__*/function () { var _ref12 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee12(documentKey, filter, idx) { return regeneratorRuntime.wrap(function _callee12$(_context12) { while (1) { switch (_context12.prev = _context12.next) { case 0: handleFilter(filter); _context12.next = 3; return updateData(documentKey, idx, 1); case 3: case "end": return _context12.stop(); } } }, _callee12); })); return function (_x17, _x18, _x19) { return _ref12.apply(this, arguments); }; }(), clearStoredSessionData: function clearStoredSessionData() { return (0, _pdf.resetStoredData)(handleStoredData); }, handleOpen: handleOpen }) : /*#__PURE__*/_react.default.createElement(_reactRouterDom.Redirect, { to: "/home" })), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, { exact: true, path: "/sign" }, web3Case != null ? /*#__PURE__*/_react.default.createElement(_Sign.default, { ethAccount: ethAccount, ethAlias: ethAlias, ethAvatar: ethAvatar, networkId: networkId, handleActivePage: handleActivePage, provider: web3, contract: contract, reloadContractDetails: reloadContractDetails, handleData: /*#__PURE__*/function () { var _ref13 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee13(documentKey, idx, type) { var index, mine_index; return regeneratorRuntime.wrap(function _callee13$(_context13) { while (1) { switch (_context13.prev = _context13.next) { case 0: index = idx; if (filter == "shared") { type = type + 1; } else if (filter != 'original') { mine_index = _lodash.default.indexOf(dataKeys.mine, documentKey); if (mine_index > -1) { index = mine_index; } else { index = _lodash.default.indexOf(dataKeys.shared, documentKey); type = type + 1; } } _context13.next = 4; return updateData(documentKey, index, type); case 4: case "end": return _context13.stop(); } } }, _callee13); })); return function (_x20, _x21, _x22) { return _ref13.apply(this, arguments); }; }() }) // <CreateAndSign // newDocument={{ // name: 'sometsdfsgjndfgljdnfglskdngldkfngdkjgbksdfgbkdfbgdkhing', // ext: '.pdf', // url: '/files/naos.pdf', // }} // bar={{ // button1: "Back", // button1Action: ()=>{ // }, // button2: "Sign" // }} // provider={web3} // allFieldsRequiredBeforeSave={false} // initialSigners={['0x2267Ee321C346A72F5371b81ffe4A585972AAF66']} // callback={()=>{ // console.log('callback fx') // }} // errorCallback={()=>{ // console.log('error callback fx') // }} // /> : /*#__PURE__*/_react.default.createElement(_reactRouterDom.Redirect, { to: "/home" })), /*#__PURE__*/_react.default.createElement(_reactRouterDom.Route, null, /*#__PURE__*/_react.default.createElement(_NotFoundComponent.NotFoundComponent, { handleActivePage: handleActivePage }))); }; var _default = (0, _reactRouterDom.withRouter)(Dashboard); exports.default = _default;