Browse Source

Merge branch 'develop' of https://github.com/ethereum/cpp-ethereum into mix_blockchain

cl-refactor
arkpar 10 years ago
parent
commit
edfa7eaa74
  1. 13
      cmake/EthExecutableHelper.cmake
  2. 12
      libethereum/CanonBlockChain.cpp
  3. 12
      libethereum/CanonBlockChain.h
  4. 2
      libjsqrc/ethereumjs/dist/ethereum.js
  5. 2
      libjsqrc/ethereumjs/dist/ethereum.js.map
  6. 2
      libjsqrc/ethereumjs/dist/ethereum.min.js
  7. 2
      libjsqrc/ethereumjs/lib/jsonrpc.js
  8. 15
      libjsqrc/ethereumjs/test/jsonrpc.isValidResponse.js
  9. 12
      libjsqrc/natspec.js
  10. 45
      macdeployfix.sh
  11. 7
      mix/AppContext.cpp
  12. 1
      mix/ClientModel.cpp
  13. 5
      mix/ClientModel.h
  14. 1
      mix/qml/main.qml
  15. 28
      test/SolidityEndToEndTest.cpp
  16. 18
      test/SolidityParser.cpp

13
cmake/EthExecutableHelper.cmake

@ -71,8 +71,9 @@ macro(eth_install_executable EXECUTABLE)
if (APPLE) if (APPLE)
# First have qt5 install plugins and frameworks # First have qt5 install plugins and frameworks
add_custom_command(TARGET ${EXECUTABLE} POST_BUILD add_custom_command(TARGET ${EXECUTABLE} POST_BUILD
COMMAND ${MACDEPLOYQT_APP} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app ${eth_qml_dir} COMMAND ${MACDEPLOYQT_APP} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app -executable=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app/Contents/MacOS/${EXECUTABLE} ${eth_qml_dir}
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
COMMAND sh ${CMAKE_SOURCE_DIR}/macdeployfix.sh ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${EXECUTABLE}.app/Contents
) )
# This tool and next will inspect linked libraries in order to determine which dependencies are required # This tool and next will inspect linked libraries in order to determine which dependencies are required
@ -82,19 +83,11 @@ macro(eth_install_executable EXECUTABLE)
set(APP_BUNDLE_PATH "${CMAKE_CURRENT_BINARY_DIR}/\$ENV{CONFIGURATION}/${EXECUTABLE}.app") set(APP_BUNDLE_PATH "${CMAKE_CURRENT_BINARY_DIR}/\$ENV{CONFIGURATION}/${EXECUTABLE}.app")
endif () endif ()
# TODO check, how fixup_bundle works and if it is required
install(CODE " install(CODE "
include(BundleUtilities) include(BundleUtilities)
set(BU_CHMOD_BUNDLE_ITEMS 1) set(BU_CHMOD_BUNDLE_ITEMS 1)
fixup_bundle(\"${APP_BUNDLE_PATH}\" \"${BUNDLELIBS}\" \"../libqethereum ../libethereum ../secp256k1\") verify_app(\"${APP_BUNDLE_PATH}\")
" COMPONENT RUNTIME ) " COMPONENT RUNTIME )
# Cleanup duplicate libs from macdeployqt
install(CODE "
file(GLOB LINGER_RM \"${APP_BUNDLE_PATH}/Contents/Frameworks/*.dylib\")
if (LINGER_RM)
file(REMOVE \${LINGER_RM})
endif ()
")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# copy all dlls to executable directory # copy all dlls to executable directory

12
libethereum/CanonBlockChain.cpp

@ -0,0 +1,12 @@
#include "CanonBlockChain.h"
CanonBlockChain::CanonBlockChain()
{
}
CanonBlockChain::~CanonBlockChain()
{
}

12
libethereum/CanonBlockChain.h

@ -0,0 +1,12 @@
#ifndef CANONBLOCKCHAIN_H
#define CANONBLOCKCHAIN_H
class CanonBlockChain
{
public:
CanonBlockChain();
~CanonBlockChain();
};
#endif // CANONBLOCKCHAIN_H

2
libjsqrc/ethereumjs/dist/ethereum.js

@ -979,7 +979,7 @@ var isValidResponse = function (response) {
!response.error && !response.error &&
response.jsonrpc === '2.0' && response.jsonrpc === '2.0' &&
typeof response.id === 'number' && typeof response.id === 'number' &&
(!!response.result || typeof response.result === 'boolean'); response.result !== undefined; // only undefined is not valid json object
}; };
/// Should be called to create batch payload object /// Should be called to create batch payload object

2
libjsqrc/ethereumjs/dist/ethereum.js.map

File diff suppressed because one or more lines are too long

2
libjsqrc/ethereumjs/dist/ethereum.min.js

File diff suppressed because one or more lines are too long

2
libjsqrc/ethereumjs/lib/jsonrpc.js

@ -45,7 +45,7 @@ var isValidResponse = function (response) {
!response.error && !response.error &&
response.jsonrpc === '2.0' && response.jsonrpc === '2.0' &&
typeof response.id === 'number' && typeof response.id === 'number' &&
(!!response.result || typeof response.result === 'boolean'); response.result !== undefined; // only undefined is not valid json object
}; };
/// Should be called to create batch payload object /// Should be called to create batch payload object

15
libjsqrc/ethereumjs/test/jsonrpc.isValidResponse.js

@ -124,5 +124,20 @@ describe('jsonrpc', function () {
assert.equal(valid, true); assert.equal(valid, true);
}); });
it('should validate jsonrpc response with result field === 0', function () {
// given
var response = {
jsonrpc: '2.0',
id: 1,
result: 0
};
// when
var valid = jsonrpc.isValidResponse(response);
// then
assert.equal(valid, true);
});
}); });
}); });

12
libjsqrc/natspec.js

@ -29,10 +29,20 @@ var getContractMethods = function (address, abi) {
return web3.eth.contract(address, abi); return web3.eth.contract(address, abi);
}; };
var getMethodWithName = function(abi, name) {
for (var i = 0; i < abi.length; i++) {
if (abi[i].name === name) {
return abi[i];
}
}
console.warn('could not find method with name: ' + name);
return undefined;
};
/// Function called to get all contract method input variables /// Function called to get all contract method input variables
/// @returns hashmap with all contract's method input variables /// @returns hashmap with all contract's method input variables
var getContractInputParams = function (abi, methodName, params) { var getContractInputParams = function (abi, methodName, params) {
var method = web3.abi.getMethodWithName(abi, methodName); var method = getMethodWithName(abi, methodName);
return method.inputs.reduce(function (acc, current, index) { return method.inputs.reduce(function (acc, current, index) {
acc[current.name] = params[index]; acc[current.name] = params[index];
return acc; return acc;

45
macdeployfix.sh

@ -0,0 +1,45 @@
#!/bin/bash
# solves problem with macdeployqt on Qt 5.4 RC
# http://qt-project.org/forums/viewthread/50118
BUILD_FOLDER_PATH=$1
BUILD_QML_FOLDER_PATH="$BUILD_FOLDER_PATH/Resources/qml"
BUILD_PLUGINS_FOLDER_PATH="$BUILD_FOLDER_PATH/PlugIns"
if [ ! -d ${BUILD_QML_FOLDER_PATH} ]; then
# we are not using any qml files
# gracefully exit
exit 0
fi
declare -a BROKEN_FILES;
k=0;
for j in $(find ${BUILD_QML_FOLDER_PATH} -name *.dylib); do
BROKEN_FILES[${k}]=$j
((k=k+1))
done
for i in "${BROKEN_FILES[@]}"; do
REPLACE_STRING="$BUILD_FOLDER_PATH/"
APP_CONTENT_FILE=${i//$REPLACE_STRING/""}
IFS='/' read -a array <<< "$APP_CONTENT_FILE"
LENGTH=${#array[@]}
LAST_ITEM_INDEX=$((LENGTH-1))
FILE=${array[${LENGTH} - 1]}
ORIGINE_PATH=$(find ${BUILD_PLUGINS_FOLDER_PATH} -name ${FILE})
ORIGINE_PATH=${ORIGINE_PATH//$REPLACE_STRING/""}
s=""
for((l=0;l<${LAST_ITEM_INDEX};l++)) do
s=$s"../"
done
s=$s$ORIGINE_PATH
echo "s: $s"
REMOVE_BROKEN_ALIAS=$(rm -rf $i)
RESULT=$(ln -s $s $i)
done

7
mix/AppContext.cpp

@ -27,15 +27,16 @@
#include <QQmlComponent> #include <QQmlComponent>
#include <QQmlContext> #include <QQmlContext>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QQuickWindow> #include <QWindow>
#include "CodeModel.h" #include "CodeModel.h"
#include "FileIo.h" #include "FileIo.h"
#include "ClientModel.h" #include "ClientModel.h"
#include "CodeEditorExtensionManager.h" #include "CodeEditorExtensionManager.h"
#include "Exceptions.h" #include "Exceptions.h"
#include "AppContext.h"
#include "QEther.h" #include "QEther.h"
#include "QVariableDefinition.h"
#include "HttpServer.h" #include "HttpServer.h"
#include "AppContext.h"
using namespace dev; using namespace dev;
using namespace dev::eth; using namespace dev::eth;
@ -82,7 +83,7 @@ void AppContext::load()
qmlRegisterType<CodeEditorExtensionManager>("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager"); qmlRegisterType<CodeEditorExtensionManager>("CodeEditorExtensionManager", 1, 0, "CodeEditorExtensionManager");
qmlRegisterType<HttpServer>("HttpServer", 1, 0, "HttpServer"); qmlRegisterType<HttpServer>("HttpServer", 1, 0, "HttpServer");
m_applicationEngine->load(QUrl("qrc:/qml/main.qml")); m_applicationEngine->load(QUrl("qrc:/qml/main.qml"));
QQuickWindow *window = qobject_cast<QQuickWindow *>(m_applicationEngine->rootObjects().at(0)); QWindow *window = qobject_cast<QWindow *>(m_applicationEngine->rootObjects().at(0));
window->setIcon(QIcon(":/res/mix_256x256x32.png")); window->setIcon(QIcon(":/res/mix_256x256x32.png"));
appLoaded(); appLoaded();
} }

1
mix/ClientModel.cpp

@ -31,6 +31,7 @@
#include "Exceptions.h" #include "Exceptions.h"
#include "QContractDefinition.h" #include "QContractDefinition.h"
#include "QVariableDeclaration.h" #include "QVariableDeclaration.h"
#include "QVariableDefinition.h"
#include "ContractCallDataEncoder.h" #include "ContractCallDataEncoder.h"
#include "CodeModel.h" #include "CodeModel.h"
#include "ClientModel.h" #include "ClientModel.h"

5
mix/ClientModel.h

@ -26,8 +26,7 @@
#include <atomic> #include <atomic>
#include <map> #include <map>
#include <QString> #include <QString>
#include "MixClient.h" #include "MachineStates.h"
#include "QVariableDefinition.h"
namespace dev namespace dev
{ {
@ -39,6 +38,8 @@ class Web3Server;
class RpcConnector; class RpcConnector;
class QEther; class QEther;
class QDebugData; class QDebugData;
class MixClient;
class QVariableDefinition;
/// Backend transaction config class /// Backend transaction config class
struct TransactionSettings struct TransactionSettings

1
mix/qml/main.qml

@ -4,6 +4,7 @@ import QtQuick.Controls.Styles 1.1
import QtQuick.Dialogs 1.1 import QtQuick.Dialogs 1.1
import QtQuick.Layouts 1.1 import QtQuick.Layouts 1.1
import QtQuick.Window 2.1 import QtQuick.Window 2.1
import QtQuick.PrivateWidgets 1.1
import Qt.labs.settings 1.0 import Qt.labs.settings 1.0
import org.ethereum.qml.QEther 1.0 import org.ethereum.qml.QEther 1.0

28
test/SolidityEndToEndTest.cpp

@ -92,6 +92,26 @@ BOOST_AUTO_TEST_CASE(multiple_functions)
BOOST_CHECK(callContractFunction("i_am_not_there()", bytes()) == bytes()); BOOST_CHECK(callContractFunction("i_am_not_there()", bytes()) == bytes());
} }
BOOST_AUTO_TEST_CASE(named_args)
{
char const* sourceCode = "contract test {\n"
" function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }\n"
" function b() returns (uint r) { r = a({a: 1, b: 2, c: 3}); }\n"
"}\n";
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("b()", bytes()) == toBigEndian(u256(123)));
}
BOOST_AUTO_TEST_CASE(disorder_named_args)
{
char const* sourceCode = "contract test {\n"
" function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }\n"
" function b() returns (uint r) { r = a({c: 3, a: 1, b: 2}); }\n"
"}\n";
compileAndRun(sourceCode);
BOOST_CHECK(callContractFunction("b()", bytes()) == toBigEndian(u256(123)));
}
BOOST_AUTO_TEST_CASE(while_loop) BOOST_AUTO_TEST_CASE(while_loop)
{ {
char const* sourceCode = "contract test {\n" char const* sourceCode = "contract test {\n"
@ -921,10 +941,10 @@ BOOST_AUTO_TEST_CASE(multiple_elementary_accessors)
BOOST_AUTO_TEST_CASE(complex_accessors) BOOST_AUTO_TEST_CASE(complex_accessors)
{ {
char const* sourceCode = "contract test {\n" char const* sourceCode = "contract test {\n"
" mapping(uint256 => string4) to_string_map;\n" " mapping(uint256 => string4) public to_string_map;\n"
" mapping(uint256 => bool) to_bool_map;\n" " mapping(uint256 => bool) public to_bool_map;\n"
" mapping(uint256 => uint256) to_uint_map;\n" " mapping(uint256 => uint256) public to_uint_map;\n"
" mapping(uint256 => mapping(uint256 => uint256)) to_multiple_map;\n" " mapping(uint256 => mapping(uint256 => uint256)) public to_multiple_map;\n"
" function test() {\n" " function test() {\n"
" to_string_map[42] = \"24\";\n" " to_string_map[42] = \"24\";\n"
" to_bool_map[42] = false;\n" " to_bool_map[42] = false;\n"

18
test/SolidityParser.cpp

@ -124,6 +124,24 @@ BOOST_AUTO_TEST_CASE(single_function_param)
BOOST_CHECK_NO_THROW(parseText(text)); BOOST_CHECK_NO_THROW(parseText(text));
} }
BOOST_AUTO_TEST_CASE(missing_parameter_name_in_named_args)
{
char const* text = "contract test {\n"
" function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }\n"
" function b() returns (uint r) { r = a({: 1, : 2, : 3}); }\n"
"}\n";
BOOST_CHECK_THROW(parseText(text), ParserError);
}
BOOST_AUTO_TEST_CASE(missing_argument_in_named_args)
{
char const* text = "contract test {\n"
" function a(uint a, uint b, uint c) returns (uint r) { r = a * 100 + b * 10 + c * 1; }\n"
" function b() returns (uint r) { r = a({a: , b: , c: }); }\n"
"}\n";
BOOST_CHECK_THROW(parseText(text), ParserError);
}
BOOST_AUTO_TEST_CASE(function_natspec_documentation) BOOST_AUTO_TEST_CASE(function_natspec_documentation)
{ {
ASTPointer<ContractDefinition> contract; ASTPointer<ContractDefinition> contract;

Loading…
Cancel
Save