@foreverrbum/ethsign
Version:
This package will allow you to electronically sign documents within your application
106 lines (92 loc) • 4.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.handleNewTrustedParty = exports.default = void 0;
var _reactNotificationsComponent = require("react-notifications-component");
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); }); }; }
var handleNewTrustedParty = /*#__PURE__*/function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(contract, ethAccount, web3, data, handleSubmitButton, documentKey, close, handleData, formatMessage) {
var fromAscii, newAuthorizedPartyProposal, proposalComment;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
// Call smart contract to verify if document exists
fromAscii = web3.utils.fromAscii;
newAuthorizedPartyProposal = contract.methods.newAuthorizedPartyProposal;
proposalComment = fromAscii(data.comment); // Send transaction
_context.prev = 3;
_context.next = 6;
return newAuthorizedPartyProposal(documentKey, data.trustedParty, proposalComment).call({
from: ethAccount
});
case 6:
newAuthorizedPartyProposal(documentKey, data.trustedParty, proposalComment).send({
from: ethAccount
}).once('transactionHash', function (txHash) {
_reactNotificationsComponent.store.addNotification({
title: 'Transaction information',
message: "The network has accepted your new trusted party proposal transaction. TxHash ".concat(txHash),
type: 'info',
insert: 'top',
container: 'bottom-right',
animationIn: ['animated', 'fadeIn'],
animationOut: ['animated', 'fadeOut'],
dismiss: {
duration: 10000,
onScreen: true
}
});
handleData(documentKey);
}).once('confirmation', function (_, receipt) {// store.addNotification({
// title: 'Transaction success',
// message:
// 'Your new trusted party proposal transaction has been confirmed by the network!',
// type: 'success',
// insert: 'top',
// container: 'bottom-right',
// animationIn: ['animated', 'fadeIn'],
// animationOut: ['animated', 'fadeOut'],
// dismiss: {
// duration: 10000,
// onScreen: true,
// },
// });
});
close();
_context.next = 15;
break;
case 10:
_context.prev = 10;
_context.t0 = _context["catch"](3);
_reactNotificationsComponent.store.addNotification({
title: 'Smart contract error',
message: _context.t0.toString(),
type: 'danger',
insert: 'top',
container: 'bottom-right',
animationIn: ['animated', 'fadeIn'],
animationOut: ['animated', 'fadeOut']
});
handleSubmitButton(formatMessage({
id: "SUBMIT"
}));
return _context.abrupt("return");
case 15:
case "end":
return _context.stop();
}
}
}, _callee, null, [[3, 10]]);
}));
return function handleNewTrustedParty(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9) {
return _ref.apply(this, arguments);
};
}();
exports.handleNewTrustedParty = handleNewTrustedParty;
var _default = {
handleNewTrustedParty: handleNewTrustedParty
};
exports.default = _default;