From e48f5e0f6a21382cbf4adbb4a02b1c72f6ad22f9 Mon Sep 17 00:00:00 2001 From: Marek Kotewicz Date: Thu, 16 Oct 2014 17:38:13 +0200 Subject: [PATCH] doTransact and doCall --- libethrpc/eth.js | 4 ++-- libqethereum/QEthereum.cpp | 21 ++------------------- libqethereum/QEthereum.h | 15 ++++++--------- 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/libethrpc/eth.js b/libethrpc/eth.js index 4af7f9b44..39d0b2faa 100644 --- a/libethrpc/eth.js +++ b/libethrpc/eth.js @@ -173,8 +173,8 @@ window.eth = (function ethScope() { { name: "stateAt", async: "getStateAt", default: {block: 0} }, { name: "countAt", async: "getCountAt", default: {block: 0} }, { name: "codeAt", async: "getCodeAt", default: {block: 0} }, - { name: "transact", async: "makeTransact"}, - { name: "call", async: "makeCall" }, + { name: "transact", async: "doTransact"}, + { name: "call", async: "doCall" }, { name: "messages", async: "getMessages" }, { name: "block", async: "getBlock" }, { name: "transaction", async: "getTransaction" }, diff --git a/libqethereum/QEthereum.cpp b/libqethereum/QEthereum.cpp index 266c8e81d..3f30f5628 100644 --- a/libqethereum/QEthereum.cpp +++ b/libqethereum/QEthereum.cpp @@ -459,24 +459,7 @@ void QEthereum::_private_setMining(bool _l) } } -QString QEthereum::doCreate(QString _secret, QString _amount, QString _init, QString _gas, QString _gasPrice) -{ - if (!m_client) - return ""; - auto ret = toQJS(client()->transact(toSecret(_secret), toU256(_amount), toBytes(_init), toU256(_gas), toU256(_gasPrice))); - client()->flushTransactions(); - return ret; -} - -void QEthereum::doTransact(QString _secret, QString _amount, QString _dest, QString _data, QString _gas, QString _gasPrice) -{ - if (!m_client) - return; - client()->transact(toSecret(_secret), toU256(_amount), toAddress(_dest), toBytes(_data), toU256(_gas), toU256(_gasPrice)); - client()->flushTransactions(); -} - -QString QEthereum::doTransact(QString _json) +QString QEthereum::_private_doTransact(QString _json) { QString ret; if (!m_client) @@ -502,7 +485,7 @@ QString QEthereum::doTransact(QString _json) return ret; } -QString QEthereum::doCall(QString _json) +QString QEthereum::_private_doCall(QString _json) { if (!m_client) return QString(); diff --git a/libqethereum/QEthereum.h b/libqethereum/QEthereum.h index 5c2189d1e..bc26150ed 100644 --- a/libqethereum/QEthereum.h +++ b/libqethereum/QEthereum.h @@ -157,11 +157,8 @@ public: Q_INVOKABLE QString/*json*/ _private_getUncle(QString _json, int _index) const; Q_INVOKABLE QString/*json*/ _private_getMessages(QString _attribs/*json*/) const; - - Q_INVOKABLE QString doCreate(QString _secret, QString _amount, QString _init, QString _gas, QString _gasPrice); - Q_INVOKABLE void doTransact(QString _secret, QString _amount, QString _dest, QString _data, QString _gas, QString _gasPrice); - Q_INVOKABLE QString doTransact(QString _json); - Q_INVOKABLE QString doCall(QString _json); + Q_INVOKABLE QString _private_doTransact(QString _json); + Q_INVOKABLE QString _private_doCall(QString _json); Q_INVOKABLE unsigned newWatch(QString _json); Q_INVOKABLE QString watchMessages(unsigned _w); @@ -299,10 +296,10 @@ private: frame->evaluateJavaScript("eth.getStateAt = function() { var args = Array.prototype.slice.call(arguments, 0, -1); f = arguments[arguments.length - 1]; window.setTimeout(function () { if (f) { f(eth.stateAt.apply(null, args)); }},0);}"); \ frame->evaluateJavaScript("eth.getCountAt = function() { var args = Array.prototype.slice.call(arguments, 0, -1); f = arguments[arguments.length - 1]; window.setTimeout(function () { if (f) { f(eth.countAt.apply(null, args)); }},0);}"); \ frame->evaluateJavaScript("eth.getCodeAt = function() { var args = Array.prototype.slice.call(arguments, 0, -1); f = arguments[arguments.length - 1]; window.setTimeout(function () { if (f) { f(eth.codeAt.apply(null, args)); }},0);}"); \ - frame->evaluateJavaScript("eth.transact = function(a) { var ret = eth.doTransact(JSON.stringify(a)); return ret; }"); \ - frame->evaluateJavaScript("eth.makeTransact = function() { var args = Array.prototype.slice.call(arguments, 0, -1); f = arguments[arguments.length - 1]; window.setTimeout(function () { if (f) { f(eth.transact.apply(null, args)); }},0);}"); \ - frame->evaluateJavaScript("eth.call = function(a) { var ret = eth.doCallJson(JSON.stringify(a)); return ret; }"); \ - frame->evaluateJavaScript("eth.makeCall = function() { var args = Array.prototype.slice.call(arguments, 0, -1); f = arguments[arguments.length - 1]; window.setTimeout(function () { if (f) { f(eth.call.apply(null, args)); }},0);}"); \ + frame->evaluateJavaScript("eth.transact = function(a) { var ret = eth._private_doTransact(JSON.stringify(a)); return ret; }"); \ + frame->evaluateJavaScript("eth.doTransact = function() { var args = Array.prototype.slice.call(arguments, 0, -1); f = arguments[arguments.length - 1]; window.setTimeout(function () { if (f) { f(eth.transact.apply(null, args)); }},0);}"); \ + frame->evaluateJavaScript("eth.call = function(a) { var ret = eth._private_doCall(JSON.stringify(a)); return ret; }"); \ + frame->evaluateJavaScript("eth.doCall = function() { var args = Array.prototype.slice.call(arguments, 0, -1); f = arguments[arguments.length - 1]; window.setTimeout(function () { if (f) { f(eth.call.apply(null, args)); }},0);}"); \ frame->evaluateJavaScript("eth.block = function(a) { return JSON.parse(eth._private_getBlock(JSON.stringify(a))); }"); \ frame->evaluateJavaScript("eth.getBlock = function() { var args = Array.prototype.slice.call(arguments, 0, -1); f = arguments[arguments.length - 1]; window.setTimeout(function () { if (f) { f(eth.block.apply(null, args)); }},0);}"); \ frame->evaluateJavaScript("eth.transaction = function(a, i) { return JSON.parse(eth._private_getTransaction(JSON.stringify(a), i)); }"); \