|
|
@ -31,19 +31,19 @@ using namespace std; |
|
|
|
using namespace dev; |
|
|
|
using namespace dev::eth; |
|
|
|
|
|
|
|
OurWebThreeStubServer::OurWebThreeStubServer(jsonrpc::AbstractServerConnector& _conn, dev::WebThreeDirect& _web3, |
|
|
|
std::vector<dev::KeyPair> const& _accounts, Main* main): |
|
|
|
OurWebThreeStubServer::OurWebThreeStubServer(jsonrpc::AbstractServerConnector& _conn, WebThreeDirect& _web3, |
|
|
|
vector<KeyPair> const& _accounts, Main* main): |
|
|
|
WebThreeStubServer(_conn, _web3, _accounts), m_web3(&_web3), m_main(main) |
|
|
|
{} |
|
|
|
|
|
|
|
std::string OurWebThreeStubServer::shh_newIdentity() |
|
|
|
string OurWebThreeStubServer::shh_newIdentity() |
|
|
|
{ |
|
|
|
dev::KeyPair kp = dev::KeyPair::create(); |
|
|
|
KeyPair kp = dev::KeyPair::create(); |
|
|
|
emit onNewId(QString::fromStdString(toJS(kp.sec()))); |
|
|
|
return toJS(kp.pub()); |
|
|
|
} |
|
|
|
|
|
|
|
bool OurWebThreeStubServer::showAuthenticationPopup(std::string const& _title, std::string const& _text) const |
|
|
|
bool OurWebThreeStubServer::showAuthenticationPopup(string const& _title, string const& _text) const |
|
|
|
{ |
|
|
|
QMessageBox userInput; |
|
|
|
userInput.setText(QString::fromStdString(_title)); |
|
|
@ -55,16 +55,31 @@ bool OurWebThreeStubServer::showAuthenticationPopup(std::string const& _title, s |
|
|
|
return userInput.exec() == QMessageBox::Ok; |
|
|
|
} |
|
|
|
|
|
|
|
bool OurWebThreeStubServer::authenticate(dev::TransactionSkeleton const& _t) |
|
|
|
void OurWebThreeStubServer::showBasicValueTransferNotice(u256 _value) const |
|
|
|
{ |
|
|
|
QMessageBox notice; |
|
|
|
notice.setText("Basic Value Transfer Transaction"); |
|
|
|
notice.setInformativeText(QString::fromStdString("Value is " + toString(_value))); |
|
|
|
notice.setStandardButtons(QMessageBox::Ok); |
|
|
|
notice.exec(); |
|
|
|
} |
|
|
|
|
|
|
|
bool OurWebThreeStubServer::authenticate(TransactionSkeleton const& _t) |
|
|
|
{ |
|
|
|
h256 contractCodeHash = m_web3->ethereum()->postState().codeHash(_t.to); |
|
|
|
if (contractCodeHash == EmptySHA3) |
|
|
|
// recipient has no code - nothing special about this transaction.
|
|
|
|
// TODO: show basic message for value transfer.
|
|
|
|
// contract creation
|
|
|
|
return true; |
|
|
|
|
|
|
|
std::string userNotice = m_main->lookupNatSpecUserNotice(contractCodeHash, _t.data); |
|
|
|
|
|
|
|
if (false) //TODO: When is is just a value transfer?
|
|
|
|
{ |
|
|
|
// recipient has no code - nothing special about this transaction, show basic value transfer info
|
|
|
|
showBasicValueTransferNotice(_t.value); |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
string userNotice = m_main->lookupNatSpecUserNotice(contractCodeHash, _t.data); |
|
|
|
|
|
|
|
if (userNotice.empty()) |
|
|
|
return showAuthenticationPopup("Unverified Pending Transaction", |
|
|
|
"An undocumented transaction is about to be executed."); |
|
|
@ -83,17 +98,17 @@ QNatspecExpressionEvaluator::QNatspecExpressionEvaluator(OurWebThreeStubServer* |
|
|
|
QNatspecExpressionEvaluator::~QNatspecExpressionEvaluator() |
|
|
|
{} |
|
|
|
|
|
|
|
QString QNatspecExpressionEvaluator::evalExpression(QString const& _expression) |
|
|
|
QString QNatspecExpressionEvaluator::evalExpression(QString const& _expression) const |
|
|
|
{ |
|
|
|
|
|
|
|
// evaluate the natspec
|
|
|
|
// load natspec.js only when we need it for natspec evaluation
|
|
|
|
m_main->evalRaw(contentsOfQResource(":/js/natspec.js")); |
|
|
|
|
|
|
|
// _expression should be in the format like this
|
|
|
|
// auto toEval = QString::fromStdString("the result of calling multiply(4) is `multiply(4)`");
|
|
|
|
auto toEval = _expression; |
|
|
|
auto result = m_main->evalRaw("evaluateExpression('" + toEval + "')"); |
|
|
|
|
|
|
|
QVariant result = m_main->evalRaw("evaluateExpression('" + _expression + "')"); |
|
|
|
if (result.type() == QVariant::Invalid) |
|
|
|
{ |
|
|
|
cerr << "Could not evaluate natspec expression: \"" << _expression.toStdString() << "\"" << endl; |
|
|
|
// return the expression unevaluated
|
|
|
|
return _expression; |
|
|
|
} |
|
|
|
return result.toString(); |
|
|
|
} |
|
|
|
|
|
|
|