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