diff --git a/alethzero/DappLoader.cpp b/alethzero/DappLoader.cpp index 69555521d..6ac1afbcb 100644 --- a/alethzero/DappLoader.cpp +++ b/alethzero/DappLoader.cpp @@ -39,13 +39,10 @@ using namespace dev; using namespace dev::eth; using namespace dev::crypto; -Address c_registrar = Address("0000000000000000000000000000000000000a28"); -Address c_urlHint = Address("0000000000000000000000000000000000000a29"); - QString contentsOfQResource(std::string const& res); -DappLoader::DappLoader(QObject* _parent, WebThreeDirect* _web3): - QObject(_parent), m_web3(_web3) +DappLoader::DappLoader(QObject* _parent, WebThreeDirect* _web3, Address _nameReg): + QObject(_parent), m_web3(_web3), m_nameReg(_nameReg) { connect(&m_net, &QNetworkAccessManager::finished, this, &DappLoader::downloadComplete); } @@ -61,31 +58,35 @@ DappLocation DappLoader::resolveAppUri(QString const& _uri) std::reverse(parts.begin(), parts.end()); parts.append(url.path().split('/', QString::SkipEmptyParts)); - Address address = c_registrar; + Address address = m_nameReg; Address lastAddress; int partIndex = 0; h256 contentHash; - while (address && partIndex < parts.length()) { lastAddress = address; string32 name = ZeroString32; QByteArray utf8 = parts[partIndex].toUtf8(); std::copy(utf8.data(), utf8.data() + utf8.size(), name.data()); - address = abiOut
(web3()->ethereum()->call(address, abiIn("addr(string32)", name)).output); + address = abiOut
(web3()->ethereum()->call(address, abiIn("subRegistrar(bytes32)", name)).output); domainParts.append(parts[partIndex]); if (!address) { //we have the address of the last part, try to get content hash - contentHash = abiOut(web3()->ethereum()->call(lastAddress, abiIn("content(string32)", name)).output); + contentHash = abiOut(web3()->ethereum()->call(lastAddress, abiIn("content(bytes32)", name)).output); if (!contentHash) throw dev::Exception() << errinfo_comment("Can't resolve address"); } ++partIndex; } - string32 contentUrl = abiOut(web3()->ethereum()->call(c_urlHint, abiIn("url(hash256)", contentHash)).output); + string32 urlHintName = ZeroString32; + QByteArray utf8 = QString("UrlHint").toUtf8(); + std::copy(utf8.data(), utf8.data() + utf8.size(), urlHintName.data()); + + Address urlHint = abiOut
(web3()->ethereum()->call(m_nameReg, abiIn("addr(bytes32)", urlHintName)).output); + string32 contentUrl = abiOut(web3()->ethereum()->call(urlHint, abiIn("url(bytes32)", contentHash)).output); QString domain = domainParts.join('/'); parts.erase(parts.begin(), parts.begin() + partIndex); QString path = parts.join('/'); @@ -237,6 +238,7 @@ void DappLoader::loadDapp(QString const& _uri) DappLocation location = resolveAppUri(_uri); contentUri = location.contentUri; hash = location.contentHash; + uri = contentUri; } QNetworkRequest request(contentUri); m_uriHashes[uri] = hash; diff --git a/alethzero/DappLoader.h b/alethzero/DappLoader.h index deba62c68..f2d3ee5e5 100644 --- a/alethzero/DappLoader.h +++ b/alethzero/DappLoader.h @@ -29,6 +29,7 @@ #include #include #include +#include namespace dev { @@ -69,7 +70,7 @@ class DappLoader: public QObject { Q_OBJECT public: - DappLoader(QObject* _parent, dev::WebThreeDirect* _web3); + DappLoader(QObject* _parent, dev::WebThreeDirect* _web3, dev::Address _nameReg); ///Load a new DApp. Resolves a name with a name reg contract. Asynchronous. dappReady is emitted once everything is read, dappError othervise ///@param _uri Eth name path void loadDapp(QString const& _uri); @@ -97,5 +98,6 @@ private: std::map m_uriHashes; std::set m_pageUrls; QByteArray m_web3Js; + dev::Address m_nameReg; }; diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp index 023351361..4963d2742 100644 --- a/alethzero/MainWin.cpp +++ b/alethzero/MainWin.cpp @@ -174,7 +174,7 @@ Main::Main(QWidget *parent) : ui->blockCount->setText(QString("PV%1.%2 D%3 %4-%5 v%6").arg(eth::c_protocolVersion).arg(eth::c_minorProtocolVersion).arg(c_databaseVersion).arg(QString::fromStdString(ProofOfWork::name())).arg(ProofOfWork::revision()).arg(dev::Version)); connect(ui->ourAccounts->model(), SIGNAL(rowsMoved(const QModelIndex &, int, int, const QModelIndex &, int)), SLOT(ourAccountsRowsMoved())); - + QSettings s("ethereum", "alethzero"); m_networkConfig = s.value("peers").toByteArray(); bytesConstRef network((byte*)m_networkConfig.data(), m_networkConfig.size()); @@ -197,7 +197,7 @@ Main::Main(QWidget *parent) : }); m_dappHost.reset(new DappHost(8081)); - m_dappLoader = new DappLoader(this, web3()); + m_dappLoader = new DappLoader(this, web3(), getNameReg()); connect(m_dappLoader, &DappLoader::dappReady, this, &Main::dappLoaded); connect(m_dappLoader, &DappLoader::pageReady, this, &Main::pageLoaded); // ui->webView->page()->settings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, true); diff --git a/mix/ClientModel.cpp b/mix/ClientModel.cpp index 7863eb31d..61a3dee1f 100644 --- a/mix/ClientModel.cpp +++ b/mix/ClientModel.cpp @@ -151,6 +151,39 @@ QString ClientModel::encodeAbiString(QString _string) return QString::fromStdString(toHex(encoder.encodeBytes(_string))); } +QString ClientModel::encodeStringParam(QString const& _param) +{ + ContractCallDataEncoder encoder; + return QString::fromStdString(toHex(encoder.encodeStringParam(_param, 32))); +} + +QStringList ClientModel::encodeParams(QVariant const& _param, QString const& _contract, QString const& _function) +{ + QStringList ret; + CompiledContract const& compilerRes = m_codeModel->contract(_contract); + QList paramsList; + shared_ptr contractDef = compilerRes.sharedContract(); + if (_contract == _function) + paramsList = contractDef->constructor()->parametersList(); + else + for (QFunctionDefinition* tf: contractDef->functionsList()) + if (tf->name() == _function) + { + paramsList = tf->parametersList(); + break; + } + if (paramsList.length() > 0) + for (QVariableDeclaration* var: paramsList) + { + ContractCallDataEncoder encoder; + QSolidityType const* type = var->type(); + QVariant value = _param.toMap().value(var->name()); + encoder.encode(value, type->type()); + ret.push_back(QString::fromStdString(toHex(encoder.encodedData()))); + } + return ret; +} + QVariantMap ClientModel::contractAddresses() const { QVariantMap res; diff --git a/mix/ClientModel.h b/mix/ClientModel.h index 714b81431..9b0529ae6 100644 --- a/mix/ClientModel.h +++ b/mix/ClientModel.h @@ -26,8 +26,10 @@ #include #include #include +#include #include #include +#include #include "MachineStates.h" namespace dev @@ -156,6 +158,10 @@ public: Q_INVOKABLE void mine(); /// Get/set code model. Should be set from qml Q_PROPERTY(CodeModel* codeModel MEMBER m_codeModel) + /// Encode parameters + Q_INVOKABLE QStringList encodeParams(QVariant const& _param, QString const& _contract, QString const& _function); + /// Encode parameter + Q_INVOKABLE QString encodeStringParam(QString const& _param); public slots: /// Setup state, run transaction sequence, show debugger for the last transaction diff --git a/mix/CodeModel.h b/mix/CodeModel.h index 199e1dee2..0572483c0 100644 --- a/mix/CodeModel.h +++ b/mix/CodeModel.h @@ -145,7 +145,7 @@ public: CompiledContract const& contract(QString const& _name) const; /// Get contract by name /// @returns nullptr if not found - CompiledContract const* tryGetContract(QString const& _name) const; + Q_INVOKABLE CompiledContract const* tryGetContract(QString const& _name) const; /// Find a contract by document id /// @returns CompiledContract object or null if not found Q_INVOKABLE CompiledContract* contractByDocumentId(QString const& _documentId) const; diff --git a/mix/ContractCallDataEncoder.cpp b/mix/ContractCallDataEncoder.cpp index 854623a6a..6b29d8b98 100644 --- a/mix/ContractCallDataEncoder.cpp +++ b/mix/ContractCallDataEncoder.cpp @@ -121,9 +121,7 @@ unsigned ContractCallDataEncoder::encodeSingleItem(QString const& _data, Solidit catch (std::exception const&) { // manage input as a string. - QByteArray bytesAr = src.toLocal8Bit(); - result = bytes(bytesAr.begin(), bytesAr.end()); - result = paddedRight(result, alignSize); + result = encodeStringParam(src, alignSize); } } @@ -167,6 +165,14 @@ QString ContractCallDataEncoder::toString(bool _b) return _b ? "true" : "false"; } +dev::bytes ContractCallDataEncoder::encodeStringParam(QString const& _str, unsigned alignSize) +{ + bytes result; + QByteArray bytesAr = _str.toLocal8Bit(); + result = bytes(bytesAr.begin(), bytesAr.end()); + return paddedRight(result, alignSize); +} + dev::bytes ContractCallDataEncoder::encodeBytes(QString const& _str) { QByteArray bytesAr = _str.toLocal8Bit(); diff --git a/mix/ContractCallDataEncoder.h b/mix/ContractCallDataEncoder.h index 805f26691..cab00dd93 100644 --- a/mix/ContractCallDataEncoder.h +++ b/mix/ContractCallDataEncoder.h @@ -52,6 +52,8 @@ public: QVariant decode(SolidityType const& _type, bytes const& _value); /// Get all encoded data encoded by encode function. bytes encodedData(); + /// Encode a string to bytes (in order to be used as funtion param) + dev::bytes encodeStringParam(QString const& _str, unsigned _alignSize); /// Encode a string to ABI bytes dev::bytes encodeBytes(QString const& _str); /// Decode bytes from ABI diff --git a/mix/qml/DeploymentDialog.qml b/mix/qml/DeploymentDialog.qml index 9235bfaab..f8eeb7a88 100644 --- a/mix/qml/DeploymentDialog.qml +++ b/mix/qml/DeploymentDialog.qml @@ -19,13 +19,13 @@ Dialog { visible: false property alias applicationUrlEth: applicationUrlEth.text property alias applicationUrlHttp: applicationUrlHttp.text - property alias urlHintContract: urlHintAddr.text property alias localPackageUrl: localPackageUrl.text property string packageHash property string packageBase64 property string eth: registrarAddr.text property string currentAccount - property alias gasToUse: gasToUseInput.text + property string gasToUse: "0x188132" //gasToUseInput.text + property variant paramsModel: [] function close() { @@ -43,6 +43,7 @@ Dialog { id: 0 }]; + console.log(packageHash); TransactionHelper.rpcCall(requests, function(arg1, arg2) { modelAccounts.clear(); @@ -54,8 +55,8 @@ Dialog { requests.push({ //accounts jsonrpc: "2.0", - method: "eth_balanceAt", - params: [ids[k]], + method: "eth_getBalance", + params: [ids[k], 'latest'], id: k }); } @@ -135,6 +136,7 @@ Dialog { TransactionHelper.rpcCall(requests, function (httpRequest, response){ response = response.replace(/,0+/, ''); // ==> result:27,00000000 var count = JSON.parse(response)[0].result + console.log("count " + count); if (k < parseInt(count) && k > 0) { stop(); @@ -247,15 +249,37 @@ Dialog { columns: 2 width: parent.width + DefaultLabel + { + text: qsTr("State:") + } + + Rectangle + { + width: 300 + color: "transparent" + height: 25 + id: paramsRect + ComboBox + { + id: statesList + textRole: "title" + model: projectModel.stateListModel + } + } + DefaultLabel { text: qsTr("Root Registrar address:") + visible: false //still use it for now in dev env. } DefaultTextField { Layout.preferredWidth: 350 id: registrarAddr + text: "c6d9d2cd449a754c494264e1809c50e34d64562b" + visible: false } DefaultLabel @@ -320,7 +344,7 @@ Dialog { width: 200 id: applicationUrlEth onTextChanged: { - appUrlFormatted.text = ProjectModelCode.formatAppUrl(text).join('/'); + appUrlFormatted.text = NetworkDeploymentCode.formatAppUrl(text).join('/'); } } @@ -364,6 +388,7 @@ Dialog { } if (!stopForInputError(inError)) { + projectModel.deployedState = statesList.currentText; if (contractRedeploy.checked) deployWarningDialog.open(); else @@ -427,20 +452,6 @@ Dialog { Layout.preferredWidth: 350 id: localPackageUrl readOnly: true - - } - - DefaultLabel - { - Layout.preferredWidth: 355 - text: qsTr("URL Hint contract address:") - } - - DefaultTextField - { - Layout.preferredWidth: 350 - id: urlHintAddr - enabled: rowRegister.isOkToRegister() } DefaultLabel @@ -494,7 +505,7 @@ Dialog { if (applicationUrlHttp.text.length > 32) inError.push(qsTr(applicationUrlHttp.text)); if (!stopForInputError(inError)) - ProjectModelCode.registerToUrlHint(); + NetworkDeploymentCode.registerToUrlHint(); } } } diff --git a/mix/qml/ProjectModel.qml b/mix/qml/ProjectModel.qml index b15c996fb..0bf7c0fb2 100644 --- a/mix/qml/ProjectModel.qml +++ b/mix/qml/ProjectModel.qml @@ -48,6 +48,7 @@ Item { property CodeEditorView codeEditor: null property var unsavedFiles: [] property alias newProjectDialog: newProjectDialog + property string deployedState //interface function saveAll() { ProjectModelCode.saveAll(); } diff --git a/mix/qml/StateListModel.qml b/mix/qml/StateListModel.qml index 51df3b1a8..889a2d940 100644 --- a/mix/qml/StateListModel.qml +++ b/mix/qml/StateListModel.qml @@ -257,7 +257,7 @@ Item { function addNewContracts() { //add new contracts for all states var changed = false; - for(var c in codeModel.contracts) { + for (var c in codeModel.contracts) { for (var s = 0; s < stateListModel.count; s++) { var state = stateList[s]; for (var t = 0; t < state.transactions.length; t++) { diff --git a/mix/qml/js/NetworkDeployment.js b/mix/qml/js/NetworkDeployment.js index 627277f20..fa85ddc54 100644 --- a/mix/qml/js/NetworkDeployment.js +++ b/mix/qml/js/NetworkDeployment.js @@ -20,6 +20,8 @@ * @date 2015 * Ethereum IDE client. */ +.import org.ethereum.qml.QSolidityType 1.0 as QSolidityType + Qt.include("TransactionHelper.js") @@ -43,40 +45,116 @@ function startDeployProject(erasePrevious) console.log("Deploying " + deploymentId + " to " + jsonRpcUrl); deploymentStarted(); - var ctrNames = Object.keys(codeModel.contracts); var ctrAddresses = {}; - deployContracts(0, ctrAddresses, ctrNames, function (){ + var state = retrieveState(projectModel.deployedState); + if (!state) + { + var txt = qsTr("Unable to find state " + projectModel.deployedState); + deploymentError(txt); + console.log(txt); + return; + } + executeTr(0, state, ctrAddresses, function (){ finalizeDeployment(deploymentId, ctrAddresses); }); } -function deployContracts(ctrIndex, ctrAddresses, ctrNames, callBack) +function retrieveState(state) { - var code = codeModel.contracts[ctrNames[ctrIndex]].codeHex; - var requests = [{ - jsonrpc: "2.0", - method: "eth_sendTransaction", - params: [ { "from": deploymentDialog.currentAccount, "gas": deploymentDialog.gasToUse, "code": code } ], - id: 0 - }]; - rpcCall(requests, function (httpCall, response){ - var txt = qsTr("Please wait while " + ctrNames[ctrIndex] + " is published ...") - deploymentStepChanged(txt); - console.log(txt); - ctrAddresses[ctrNames[ctrIndex]] = JSON.parse(response)[0].result - deploymentDialog.waitForTrCountToIncrement(function(status) { - if (status === -1) + for (var k = 0; k < projectModel.stateListModel.count; k++) + { + if (projectModel.stateListModel.get(k).title === state) + return projectModel.stateListModel.get(k); + } + return null; +} + +function replaceParamToken(paramsDef, params, ctrAddresses) +{ + var retParams = {}; + for (var k in paramsDef) + { + var value = ""; + if (params[paramsDef[k].name] !== undefined) + { + value = params[paramsDef[k].name]; + if (paramsDef[k].type.category === 4 && value.indexOf("<") === 0) { - trCountIncrementTimeOut(); - return; + value = value.replace("<", "").replace(">", ""); + value = ctrAddresses[value]; } - ctrIndex++; - if (ctrIndex < ctrNames.length) - deployContracts(ctrIndex, ctrAddresses, ctrNames, callBack); - else - callBack(); + } + retParams[paramsDef[k].name] = value; + } + return retParams; +} + +function getFunction(ctrName, functionId) +{ + if (codeModel.contracts[ctrName] === undefined) + return null; + if (ctrName === functionId) + return codeModel.contracts[ctrName].contract.constructor; + else + { + for (var j in codeModel.contracts[ctrName].contract.functions) + { + if (codeModel.contracts[ctrName].contract.functions[j].name === functionId) + return codeModel.contracts[ctrName].contract.functions[j]; + } + } +} + +function executeTr(trIndex, state, ctrAddresses, callBack) +{ + var tr = state.transactions.get(trIndex); + var func = getFunction(tr.contractId, tr.functionId); + if (!func) + executeTrNextStep(trIndex, state, ctrAddresses, callBack); + else + { + var rpcParams = { "from": deploymentDialog.currentAccount, "gas": deploymentDialog.gasToUse }; + var params = replaceParamToken(func.parameters, tr.parameters, ctrAddresses); + var encodedParams = clientModel.encodeParams(params, tr.contractId, tr.functionId); + + if (state.contractId === state.functionId) + rpcParams.code = codeModel.contracts[tr.contractId].codeHex + encodedParams.join(""); + else + rpcParams.data = func.hash + encodedParams.join(""); + + var requests = [{ + jsonrpc: "2.0", + method: "eth_sendTransaction", + params: [ rpcParams ], + id: jsonRpcRequestId + }]; + + rpcCall(requests, function (httpCall, response){ + var txt = qsTr(tr.contractId + "." + tr.functionId + "() ...") + deploymentStepChanged(txt); + console.log(txt); + if (tr.contractId === tr.functionId) + { + ctrAddresses[tr.contractId] = JSON.parse(response)[0].result + ctrAddresses[tr.contractId + " - " + trIndex] = JSON.parse(response)[0].result //get right ctr address if deploy more than one contract of same type. + } + deploymentDialog.waitForTrCountToIncrement(function(status) { + if (status === -1) + trCountIncrementTimeOut(); + else + executeTrNextStep(trIndex, state, ctrAddresses, callBack) + }); }); - }); + } +} + +function executeTrNextStep(trIndex, state, ctrAddresses, callBack) +{ + trIndex++; + if (trIndex < state.transactions.count) + executeTr(trIndex, state, ctrAddresses, callBack); + else + callBack(); } function finalizeDeployment(deploymentId, addresses) { @@ -144,14 +222,14 @@ function checkEthPath(dappUrl, callBack) registerContentHash(deploymentDialog.eth, callBack); // we directly create a dapp under the root registrar. else { - // the first owned reigstrar must have been created to follow the path. - var str = createString(dappUrl[0]); + // the first owned registrar must have been created to follow the path. + var str = clientModel.encodeStringParam(dappUrl[0]); var requests = []; requests.push({ - //register() + //subRegistrar() jsonrpc: "2.0", method: "eth_call", - params: [ { "gas": 150000, "from": deploymentDialog.currentAccount, "to": '0x' + deploymentDialog.eth, "data": "0x6be16bed" + str.encodeValueAsString() } ], + params: [ { "gas": "0xffff", "from": deploymentDialog.currentAccount, "to": '0x' + deploymentDialog.eth, "data": "0x5a3a05bd" + str }, "pending" ], id: jsonRpcRequestId++ }); rpcCall(requests, function (httpRequest, response) { @@ -183,12 +261,12 @@ function checkRegistration(dappUrl, addr, callBack) console.log(txt); var requests = []; var registrar = {} - var str = createString(dappUrl[0]); + var str = clientModel.encodeStringParam(dappUrl[0]); requests.push({ //getOwner() jsonrpc: "2.0", method: "eth_call", - params: [ { "gas" : 2000, "from": deploymentDialog.currentAccount, "to": '0x' + addr, "data": "0x893d20e8" } ], + params: [ { "gas" : 2000, "from": deploymentDialog.currentAccount, "to": '0x' + addr, "data": "0x02571be3" }, "pending" ], id: jsonRpcRequestId++ }); @@ -196,7 +274,7 @@ function checkRegistration(dappUrl, addr, callBack) //register() jsonrpc: "2.0", method: "eth_call", - params: [ { "from": deploymentDialog.currentAccount, "to": '0x' + addr, "data": "0x6be16bed" + str.encodeValueAsString() } ], + params: [ { "from": deploymentDialog.currentAccount, "to": '0x' + addr, "data": "0x5a3a05bd" + str }, "pending" ], id: jsonRpcRequestId++ }); @@ -232,7 +310,7 @@ function checkRegistration(dappUrl, addr, callBack) requests.push({ jsonrpc: "2.0", method: "eth_sendTransaction", - params: [ { "from": deploymentDialog.currentAccount, "gas": 20000, "code": "0x60056013565b61059e8061001d6000396000f35b33600081905550560060003560e060020a90048063019848921461009a578063449c2090146100af5780635d574e32146100cd5780635fd4b08a146100e1578063618242da146100f65780636be16bed1461010b5780636c4489b414610129578063893d20e8146101585780639607730714610173578063c284bc2a14610187578063e50f599a14610198578063e5811b35146101af578063ec7b9200146101cd57005b6100a560043561031b565b8060005260206000f35b6100ba6004356103a0565b80600160a060020a031660005260206000f35b6100db600435602435610537565b60006000f35b6100ec600435610529565b8060005260206000f35b6101016004356103dd565b8060005260206000f35b6101166004356103bd565b80600160a060020a031660005260206000f35b61013460043561034b565b82600160a060020a031660005281600160a060020a03166020528060405260606000f35b610160610341565b80600160a060020a031660005260206000f35b6101816004356024356102b4565b60006000f35b6101926004356103fd565b60006000f35b6101a96004356024356044356101f2565b60006000f35b6101ba6004356101eb565b80600160a060020a031660005260206000f35b6101d8600435610530565b80600160a060020a031660005260206000f35b6000919050565b600054600160a060020a031633600160a060020a031614610212576102af565b8160026000858152602001908152602001600020819055508061023457610287565b81600160a060020a0316837f680ad70765443c2967675ab0fb91a46350c01c6df59bf9a41ff8a8dd097464ec60006000a3826001600084600160a060020a03168152602001908152602001600020819055505b827f18d67da0cd86808336a3aa8912f6ea70c5250f1a98b586d1017ef56fe199d4fc60006000a25b505050565b600054600160a060020a031633600160a060020a0316146102d457610317565b806002600084815260200190815260200160002060010181905550817f18d67da0cd86808336a3aa8912f6ea70c5250f1a98b586d1017ef56fe199d4fc60006000a25b5050565b60006001600083600160a060020a03168152602001908152602001600020549050919050565b6000600054905090565b6000600060006002600085815260200190815260200160002054925060026000858152602001908152602001600020600101549150600260008581526020019081526020016000206002015490509193909250565b600060026000838152602001908152602001600020549050919050565b600060026000838152602001908152602001600020600101549050919050565b600060026000838152602001908152602001600020600201549050919050565b600054600160a060020a031633600160a060020a03161461041d57610526565b80600160006002600085815260200190815260200160002054600160a060020a031681526020019081526020016000205414610458576104d2565b6002600082815260200190815260200160002054600160a060020a0316817f680ad70765443c2967675ab0fb91a46350c01c6df59bf9a41ff8a8dd097464ec60006000a36000600160006002600085815260200190815260200160002054600160a060020a03168152602001908152602001600020819055505b6002600082815260200190815260200160002060008101600090556001810160009055600281016000905550807f18d67da0cd86808336a3aa8912f6ea70c5250f1a98b586d1017ef56fe199d4fc60006000a25b50565b6000919050565b6000919050565b600054600160a060020a031633600160a060020a0316146105575761059a565b806002600084815260200190815260200160002060020181905550817f18d67da0cd86808336a3aa8912f6ea70c5250f1a98b586d1017ef56fe199d4fc60006000a25b505056" } ], + params: [ { "from": deploymentDialog.currentAccount, "gas": 20000, "code": "0x600080547fffffffffffffffffffffffff0000000000000000000000000000000000000000163317815561058990819061003990396000f3007c010000000000000000000000000000000000000000000000000000000060003504630198489281146100a757806302571be3146100d957806321f8a721146100e35780632dff6941146100ed5780633b3b57de1461010d5780635a3a05bd1461013d5780635fd4b08a1461017057806389a69c0e1461017c578063b5c645bd146101b0578063be99a9801461022c578063c3d014d614610264578063d93e75731461029857005b73ffffffffffffffffffffffffffffffffffffffff600435166000908152600160205260409020548060005260206000f35b6000808052602081f35b6000808052602081f35b600435600090815260026020819052604090912001548060005260206000f35b600435600090815260026020908152604082205473ffffffffffffffffffffffffffffffffffffffff1680835291f35b600435600090815260026020908152604082206001015473ffffffffffffffffffffffffffffffffffffffff1680835291f35b60008060005260206000f35b6000546102c89060043590602435903373ffffffffffffffffffffffffffffffffffffffff908116911614610451576104b1565b600435600090815260026020819052604090912080546001820154919092015473ffffffffffffffffffffffffffffffffffffffff9283169291909116908273ffffffffffffffffffffffffffffffffffffffff166000528173ffffffffffffffffffffffffffffffffffffffff166020528060405260606000f35b6000546102ce906004359060243590604435903373ffffffffffffffffffffffffffffffffffffffff9081169116146104b557610584565b6000546102d49060043590602435903373ffffffffffffffffffffffffffffffffffffffff9081169116146102e05761031d565b6000546102da90600435903373ffffffffffffffffffffffffffffffffffffffff9081169116146103215761044e565b60006000f35b60006000f35b60006000f35b60006000f35b600082815260026020819052604080832090910183905583917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b5050565b60008181526002602090815260408083205473ffffffffffffffffffffffffffffffffffffffff1683526001909152902054811461035e576103de565b6000818152600260205260408082205473ffffffffffffffffffffffffffffffffffffffff169183917ff63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a85459190a360008181526002602090815260408083205473ffffffffffffffffffffffffffffffffffffffff16835260019091528120555b600081815260026020819052604080832080547fffffffffffffffffffffffff00000000000000000000000000000000000000009081168255600182018054909116905590910182905582917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b50565b60008281526002602052604080822060010180547fffffffffffffffffffffffff0000000000000000000000000000000000000000168417905583917fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc91a25b5050565b600083815260026020526040902080547fffffffffffffffffffffffff000000000000000000000000000000000000000016831790558061051c57827fa6697e974e6a320f454390be03f74955e8978f1a6971ea6730542e37b66179bc60006040a2610583565b73ffffffffffffffffffffffffffffffffffffffff8216837ff63780e752c6a54a94fc52715dbc5518a3b4c3c2833d301a204226548a2a854560006040a373ffffffffffffffffffffffffffffffffffffffff821660009081526001602052604090208390555b5b50505056" } ], id: jsonRpcRequestId++ }); @@ -248,12 +326,12 @@ function checkRegistration(dappUrl, addr, callBack) trCountIncrementTimeOut(); return; } - var crLevel = createString(dappUrl[0]).encodeValueAsString(); + var crLevel = clientModel.encodeStringParam(dappUrl[0]); requests.push({ //setRegister() jsonrpc: "2.0", method: "eth_sendTransaction", - params: [ { "from": deploymentDialog.currentAccount, "gas": 30000, "to": '0x' + addr, "data": "0x96077307" + crLevel + deploymentDialog.pad(newCtrAddress) } ], + params: [ { "from": deploymentDialog.currentAccount, "gas": 30000, "to": '0x' + addr, "data": "0x89a69c0e" + crLevel + deploymentDialog.pad(newCtrAddress) } ], id: jsonRpcRequestId++ }); @@ -281,12 +359,13 @@ function registerContentHash(registrar, callBack) deploymentStepChanged(txt); console.log(txt); var requests = []; - var paramTitle = clientModel.encodeAbiString(projectModel.projectTitle); + var paramTitle = clientModel.encodeStringParam(projectModel.projectTitle); + requests.push({ //setContent() jsonrpc: "2.0", method: "eth_sendTransaction", - params: [ { "from": deploymentDialog.currentAccount, "gas": 30000, "gasPrice": "10", "to": '0x' + registrar, "data": "0x5d574e32" + paramTitle + deploymentDialog.packageHash } ], + params: [ { "from": deploymentDialog.currentAccount, "gas": "0xfffff", "to": '0x' + registrar, "data": "0xc3d014d6" + paramTitle + deploymentDialog.packageHash } ], id: jsonRpcRequestId++ }); rpcCall(requests, function (httpRequest, response) { @@ -297,18 +376,40 @@ function registerContentHash(registrar, callBack) function registerToUrlHint() { deploymentStepChanged(qsTr("Registering application Resources (" + deploymentDialog.applicationUrlHttp) + ") ..."); + + urlHintAddress(function(urlHint){ + var requests = []; + var paramUrlHttp = clientModel.encodeStringParam(deploymentDialog.applicationUrlHttp); + + requests.push({ + //urlHint => suggestUrl + jsonrpc: "2.0", + method: "eth_sendTransaction", + params: [ { "to": '0x' + urlHint, "from": deploymentDialog.currentAccount, "gas": "0xfffff", "data": "0x584e86ad" + deploymentDialog.packageHash + paramUrlHttp } ], + id: jsonRpcRequestId++ + }); + + rpcCall(requests, function (httpRequest, response) { + deploymentComplete(); + }); + }); +} + +function urlHintAddress(callBack) +{ var requests = []; - var paramUrlHttp = createString(deploymentDialog.applicationUrlHttp); + var urlHint = clientModel.encodeStringParam("UrlHint"); requests.push({ - //urlHint => suggestUrl + //registrar: get UrlHint addr jsonrpc: "2.0", - method: "eth_sendTransaction", - params: [ { "to": '0x' + deploymentDialog.urlHintContract, "gas": 30000, "data": "0x4983e19c" + deploymentDialog.packageHash + paramUrlHttp.encodeValueAsString() } ], + method: "eth_call", + params: [ { "to": '0x' + deploymentDialog.eth, "from": deploymentDialog.currentAccount, "gas": "0xfffff", "data": "0x3b3b57de" + urlHint }, "pending" ], id: jsonRpcRequestId++ }); rpcCall(requests, function (httpRequest, response) { - deploymentComplete(); + var res = JSON.parse(response); + callBack(normalizeAddress(res[0].result)); }); }