Skip to content

Commit

Permalink
Merge pull request EOSIO#92 from enumivo/staging
Browse files Browse the repository at this point in the history
rename eosio msig
  • Loading branch information
Enumivo authored May 14, 2018
2 parents d6c958e + 88d45d5 commit 511e1de
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion contracts/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ add_subdirectory(musl)
add_subdirectory(libc++)
add_subdirectory(simple.token)
add_subdirectory(eosio.token)
add_subdirectory(eosio.msig)
add_subdirectory(enumivo.msig)
add_subdirectory(multi_index_test)
add_subdirectory(eosio.system)
add_subdirectory(identity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
file(GLOB ABI_FILES "*.abi")
configure_file("${ABI_FILES}" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)

add_wast_executable(TARGET eosio.msig
add_wast_executable(TARGET enumivo.msig
INCLUDE_FOLDERS "${STANDARD_INCLUDE_FOLDERS}"
LIBRARIES libc++ libc enumivolib
DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR}
Expand Down
20 changes: 10 additions & 10 deletions contracts/eosio.msig/README.md → contracts/enumivo.msig/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
eosio.msig
enumivo.msig
--------

Actions:
The naming convention is codeaccount::actionname followed by a list of paramters.

Create a proposal
## eosio.msig::propose proposer proposal_name requested trx
## enumivo.msig::propose proposer proposal_name requested trx
- **proposer** account proposing a transaction
- **proposal_name** name of the proposal (should be unique for proposer)
- **requested** permission levels expected to approve the proposal
Expand All @@ -14,29 +14,29 @@ Create a proposal
Storage changes are billed to 'proposer'

Aprrove a proposal
## eosio.msig::approve proposer proposal_name level
## enumivo.msig::approve proposer proposal_name level
- **proposer** account proposing a transaction
- **proposal_name** name of the proposal
- **level** permission level approving the transaction

Storage changes are billed to 'proposer'

Revoke an approval of transaction
## eosio.msig::unapprove proposer proposal_name level
## enumivo.msig::unapprove proposer proposal_name level
- **proposer** account proposing a transaction
- **proposal_name** name of the proposal
- **level** permission level revoking approval from the transaction

Storage changes are billed to 'proposer'

Cancel a proposal
## eosio.msig::cancel proposer proposal_name canceler
## enumivo.msig::cancel proposer proposal_name canceler
- **proposer** account proposing a transaction
- **proposal_name** name of the proposal
- **canceler** account canceling the transaction (only proposer can cancel not expired transaction)

Execute a proposal
## eosio.msig::exec proposer proposal_name executer
## enumivo.msig::exec proposer proposal_name executer
- **proposer** account proposing a transaction
- **proposal_name** name of the proposal
- **executer** account executing the transaction
Expand All @@ -45,7 +45,7 @@ Execute a proposal
Cleos usage example.

Prerequisites:
- eosio.token contract installed to eosio.token accountm, eosio.msig contract installed on eosio.msig account which is a priviliged account.
- eosio.token contract installed to eosio.token accountm, enumivo.msig contract installed on enumivo.msig account which is a priviliged account.
- account 'treasury' is the issuer of EOS token.
- account 'tester' exists.
- keys to accounts 'treasury' and 'tester' imported into local wallet, the wallet is unlocked.
Expand All @@ -54,7 +54,7 @@ One user creates a proposal:
````
$ cleos multisig propose test '[{"actor": "treasury", "permission": "active"}]' '[{"actor": "treasury", "permission": "active"}]' eosio.token issue '{"to": "tester", "quantity": "1000.0000 EOS", "memo": ""}' -p tester
executed transaction: e26f3a3a7cba524a7b15a0b6c77c7daa73d3ba9bf84e83f9c2cdf27fcb183d61 336 bytes 107520 cycles
# eosio.msig <= eosio.msig::propose {"proposer":"tester","proposal_name":"test","requested":[{"actor":"treasury","permission":"active"}]...
# enumivo.msig <= enumivo.msig::propose {"proposer":"tester","proposal_name":"test","requested":[{"actor":"treasury","permission":"active"}]...
````

Another user reviews the transaction:
Expand Down Expand Up @@ -102,12 +102,12 @@ And then approves it:
````
$ cleos multisig approve tester test '{"actor": "treasury", "permission": "active"}' -p treasury
executed transaction: 475970a4b0016368d0503d1ce01577376f91f5a5ba63dd4353683bd95101b88d 256 bytes 108544 cycles
# eosio.msig <= eosio.msig::approve {"proposer":"tester","proposal_name":"test","level":{"actor":"treasury","permission":"active"}}
# enumivo.msig <= enumivo.msig::approve {"proposer":"tester","proposal_name":"test","level":{"actor":"treasury","permission":"active"}}
````

First user initiates execution:
````
$ cleos multisig exec tester test -p tester
executed transaction: 64e5eaceb77362694055f572ae35876111e87b637a55250de315b1b55e56d6c2 248 bytes 109568 cycles
# eosio.msig <= eosio.msig::exec {"proposer":"tester","proposal_name":"test","executer":"tester"}
# enumivo.msig <= enumivo.msig::exec {"proposer":"tester","proposal_name":"test","executer":"tester"}
````
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <eosio.msig/eosio.msig.hpp>
#include <enumivo.msig/enumivo.msig.hpp>
#include <enumivolib/action.hpp>
#include <enumivolib/permission.hpp>

Expand Down
File renamed without changes.
18 changes: 9 additions & 9 deletions programs/cleos/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2134,7 +2134,7 @@ int main( int argc, char** argv ) {
fc::to_variant(trx, trx_var);

arg = fc::mutable_variant_object()
("code", "eosio.msig")
("code", "enumivo.msig")
("action", "propose")
("args", fc::mutable_variant_object()
("proposer", proposer )
Expand All @@ -2143,7 +2143,7 @@ int main( int argc, char** argv ) {
("trx", trx_var)
);
result = call(json_to_bin_func, arg);
send_actions({chain::action{accountPermissions, "eosio.msig", "propose", result.get_object()["binargs"].as<bytes>()}});
send_actions({chain::action{accountPermissions, "enumivo.msig", "propose", result.get_object()["binargs"].as<bytes>()}});
});

//resolver for ABI serializer to decode actions in proposed transaction in multisig contract
Expand All @@ -2166,7 +2166,7 @@ int main( int argc, char** argv ) {

review->set_callback([&] {
auto result = call(get_table_func, fc::mutable_variant_object("json", true)
("code", "eosio.msig")
("code", "enumivo.msig")
("scope", proposer)
("table", "proposal")
("table_key", "")
Expand Down Expand Up @@ -2206,7 +2206,7 @@ int main( int argc, char** argv ) {
perm_var = json_from_file_or_string(perm);
} EOS_RETHROW_EXCEPTIONS(transaction_type_exception, "Fail to parse permissions JSON '${data}'", ("data",perm))
auto arg = fc::mutable_variant_object()
("code", "eosio.msig")
("code", "enumivo.msig")
("action", action)
("args", fc::mutable_variant_object()
("proposer", proposer)
Expand All @@ -2215,7 +2215,7 @@ int main( int argc, char** argv ) {
);
auto result = call(json_to_bin_func, arg);
auto accountPermissions = tx_permission.empty() ? vector<chain::permission_level>{{sender,config::active_name}} : get_account_permissions(tx_permission);
send_actions({chain::action{accountPermissions, "eosio.msig", action, result.get_object()["binargs"].as<bytes>()}});
send_actions({chain::action{accountPermissions, "enumivo.msig", action, result.get_object()["binargs"].as<bytes>()}});
};

// multisig approve
Expand Down Expand Up @@ -2254,15 +2254,15 @@ int main( int argc, char** argv ) {
canceler = name(accountPermissions.at(0).actor).to_string();
}
auto arg = fc::mutable_variant_object()
("code", "eosio.msig")
("code", "enumivo.msig")
("action", "cancel")
("args", fc::mutable_variant_object()
("proposer", proposer)
("proposal_name", proposal_name)
("canceler", canceler)
);
auto result = call(json_to_bin_func, arg);
send_actions({chain::action{accountPermissions, "eosio.msig", "cancel", result.get_object()["binargs"].as<bytes>()}});
send_actions({chain::action{accountPermissions, "enumivo.msig", "cancel", result.get_object()["binargs"].as<bytes>()}});
}
);

Expand All @@ -2287,7 +2287,7 @@ int main( int argc, char** argv ) {
}

auto arg = fc::mutable_variant_object()
("code", "eosio.msig")
("code", "enumivo.msig")
("action", "exec")
("args", fc::mutable_variant_object()
("proposer", proposer )
Expand All @@ -2296,7 +2296,7 @@ int main( int argc, char** argv ) {
);
auto result = call(json_to_bin_func, arg);
//std::cout << "Result: " << result << std::endl;
send_actions({chain::action{accountPermissions, "eosio.msig", "exec", result.get_object()["binargs"].as<bytes>()}});
send_actions({chain::action{accountPermissions, "enumivo.msig", "exec", result.get_object()["binargs"].as<bytes>()}});
}
);

Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ add_executable( plugin_test ${UNIT_TESTS} ${WASM_UNIT_TESTS} main.cpp)
target_link_libraries( plugin_test eosio_testing eosio_chain chainbase eos_utilities chain_plugin wallet_plugin abi_generator fc ${PLATFORM_SPECIFIC_LIBS} )

target_include_directories( plugin_test PUBLIC ${CMAKE_SOURCE_DIR}/plugins/net_plugin/include )
add_dependencies(plugin_test asserter test_api test_api_mem test_api_db test_api_multi_index exchange proxy identity identity_test stltest infinite eosio.system eosio.token enumivo.bios test.inline multi_index_test noop dice eosio.msig)
add_dependencies(plugin_test asserter test_api test_api_mem test_api_db test_api_multi_index exchange proxy identity identity_test stltest infinite eosio.system eosio.token enumivo.bios test.inline multi_index_test noop dice enumivo.msig)

#
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/p2p_tests/sync/test.sh ${CMAKE_CURRENT_BINARY_DIR}/p2p_tests/sync/test.sh COPYONLY)
Expand Down
2 changes: 1 addition & 1 deletion unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ target_link_libraries( unit_test eosio_chain chainbase eosio_testing eos_utiliti
target_include_directories( unit_test PUBLIC ${CMAKE_BINARY_DIR}/contracts ${CMAKE_CURRENT_BINARY_DIR}/tests/contracts )
target_include_directories( unit_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/wasm_tests )
target_include_directories( unit_test PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include )
add_dependencies(unit_test asserter test_api test_api_mem test_api_db test_api_multi_index exchange eosio.token proxy identity identity_test stltest infinite eosio.system eosio.token enumivo.bios test.inline multi_index_test noop dice eosio.msig payloadless tic_tac_toe)
add_dependencies(unit_test asserter test_api test_api_mem test_api_db test_api_multi_index exchange eosio.token proxy identity identity_test stltest infinite eosio.system eosio.token enumivo.bios test.inline multi_index_test noop dice enumivo.msig payloadless tic_tac_toe)

#Manually run unit_test for all supported runtimes
#To run unit_test with all log from blockchain displayed, put --verbose after --, i.e. unit_test -- --verbose
Expand Down
18 changes: 9 additions & 9 deletions unittests/bootseq_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include <enumivo.bios/enumivo.bios.abi.hpp>
#include <eosio.token/eosio.token.wast.hpp>
#include <eosio.token/eosio.token.abi.hpp>
#include <eosio.msig/eosio.msig.wast.hpp>
#include <eosio.msig/eosio.msig.abi.hpp>
#include <enumivo.msig/enumivo.msig.wast.hpp>
#include <enumivo.msig/enumivo.msig.abi.hpp>

#include <Runtime/Runtime.h>

Expand Down Expand Up @@ -171,17 +171,17 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {
//set_code_abi(config::system_account_name, enumivo_bios_wast, enumivo_bios_abi);

// Create the following accounts:
// eosio.msig
// enumivo.msig
// eosio.token
create_accounts({N(eosio.msig), N(eosio.token)});
create_accounts({N(enumivo.msig), N(eosio.token)});
/*
auto eosio_active = authority( 1, {}, {{{N(eosio),N(active)},1}} );
auto eosio_active_pk = get_private_key( N(eosio), "active" );
base_tester::push_action( N(eosio), N(newaccount), vector<permission_level>{{N(eosio),config::active_name}},
fc::variant(newaccount{
.creator = N(eosio),
.name = N(eosio.msig),
.name = N(enumivo.msig),
.owner = eosio_active,
.active = eosio_active,
.recovery = eosio_active
Expand All @@ -199,16 +199,16 @@ BOOST_FIXTURE_TEST_CASE( bootseq_test, bootseq_tester ) {

// Set code for the following accounts:
// eosio.system (code: enumivo.bios)
// eosio.msig (code: eosio.msig)
// enumivo.msig (code: enumivo.msig)
// eosio.token (code: eosio.token)
set_code_abi(N(eosio.msig), eosio_msig_wast, eosio_msig_abi);//, &eosio_active_pk);
set_code_abi(N(enumivo.msig), enumivo_msig_wast, enumivo_msig_abi);//, &eosio_active_pk);
set_code_abi(N(eosio.token), eosio_token_wast, eosio_token_abi); //, &eosio_active_pk);

ilog(".");
// Set privileges for eosio.msig
// Set privileges for enumivo.msig
auto trace = base_tester::push_action(config::system_account_name, N(setpriv),
config::system_account_name, mutable_variant_object()
("account", "eosio.msig")
("account", "enumivo.msig")
("is_priv", 1)
);

Expand Down
36 changes: 18 additions & 18 deletions unittests/multisig_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <enumivo/chain/abi_serializer.hpp>
#include <enumivo/chain/wast_to_wasm.hpp>

#include <eosio.msig/eosio.msig.wast.hpp>
#include <eosio.msig/eosio.msig.abi.hpp>
#include <enumivo.msig/enumivo.msig.wast.hpp>
#include <enumivo.msig/enumivo.msig.abi.hpp>

#include <exchange/exchange.wast.hpp>
#include <exchange/exchange.abi.hpp>
Expand All @@ -21,24 +21,24 @@ using namespace fc;

using mvo = fc::mutable_variant_object;

class eosio_msig_tester : public tester {
class enumivo_msig_tester : public tester {
public:

eosio_msig_tester() {
create_accounts( { N(eosio.msig), N(alice), N(bob), N(carol) } );
enumivo_msig_tester() {
create_accounts( { N(enumivo.msig), N(alice), N(bob), N(carol) } );
produce_block();

auto trace = base_tester::push_action(config::system_account_name, N(setpriv),
config::system_account_name, mutable_variant_object()
("account", "eosio.msig")
("account", "enumivo.msig")
("is_priv", 1)
);

set_code( N(eosio.msig), eosio_msig_wast );
set_abi( N(eosio.msig), eosio_msig_abi );
set_code( N(enumivo.msig), enumivo_msig_wast );
set_abi( N(enumivo.msig), enumivo_msig_abi );

produce_blocks();
const auto& accnt = control->db().get<account_object,by_name>( N(eosio.msig) );
const auto& accnt = control->db().get<account_object,by_name>( N(enumivo.msig) );
abi_def abi;
BOOST_REQUIRE_EQUAL(abi_serializer::to_abi(accnt.abi, abi), true);
abi_ser.set_abi(abi);
Expand All @@ -48,7 +48,7 @@ class eosio_msig_tester : public tester {
vector<account_name> accounts;
if( auth )
accounts.push_back( signer );
auto trace = base_tester::push_action( N(eosio.msig), name, accounts, data );
auto trace = base_tester::push_action( N(enumivo.msig), name, accounts, data );
produce_block();
BOOST_REQUIRE_EQUAL( true, chain_has_transaction(trace->id) );
return trace;
Expand All @@ -57,7 +57,7 @@ class eosio_msig_tester : public tester {
string action_type_name = abi_ser.get_action_type(name);
action act;
act.account = N(eosio.msig);
act.account = N(enumivo.msig);
act.name = name;
act.data = abi_ser.variant_to_binary( action_type_name, data );
//std::cout << "test:\n" << fc::to_hex(act.data.data(), act.data.size()) << " size = " << act.data.size() << std::endl;
Expand All @@ -71,7 +71,7 @@ class eosio_msig_tester : public tester {
abi_serializer abi_ser;
};

transaction eosio_msig_tester::reqauth( account_name from, const vector<permission_level>& auths ) {
transaction enumivo_msig_tester::reqauth( account_name from, const vector<permission_level>& auths ) {
fc::variants v;
for ( auto& level : auths ) {
v.push_back(fc::mutable_variant_object()
Expand Down Expand Up @@ -99,9 +99,9 @@ transaction eosio_msig_tester::reqauth( account_name from, const vector<permissi
return trx;
}

BOOST_AUTO_TEST_SUITE(eosio_msig_tests)
BOOST_AUTO_TEST_SUITE(enumivo_msig_tests)

BOOST_FIXTURE_TEST_CASE( propose_approve_execute, eosio_msig_tester ) try {
BOOST_FIXTURE_TEST_CASE( propose_approve_execute, enumivo_msig_tester ) try {
auto trx = reqauth("alice", {permission_level{N(alice), config::active_name}} );

push_action( N(alice), N(propose), mvo()
Expand Down Expand Up @@ -142,7 +142,7 @@ BOOST_FIXTURE_TEST_CASE( propose_approve_execute, eosio_msig_tester ) try {
} FC_LOG_AND_RETHROW()


BOOST_FIXTURE_TEST_CASE( propose_approve_unapprove, eosio_msig_tester ) try {
BOOST_FIXTURE_TEST_CASE( propose_approve_unapprove, enumivo_msig_tester ) try {
auto trx = reqauth("alice", {permission_level{N(alice), config::active_name}} );

push_action( N(alice), N(propose), mvo()
Expand Down Expand Up @@ -176,7 +176,7 @@ BOOST_FIXTURE_TEST_CASE( propose_approve_unapprove, eosio_msig_tester ) try {
} FC_LOG_AND_RETHROW()


BOOST_FIXTURE_TEST_CASE( propose_approve_by_two, eosio_msig_tester ) try {
BOOST_FIXTURE_TEST_CASE( propose_approve_by_two, enumivo_msig_tester ) try {
auto trx = reqauth("alice", vector<permission_level>{ { N(alice), config::active_name }, { N(bob), config::active_name } } );
push_action( N(alice), N(propose), mvo()
("proposer", "alice")
Expand Down Expand Up @@ -224,7 +224,7 @@ BOOST_FIXTURE_TEST_CASE( propose_approve_by_two, eosio_msig_tester ) try {
} FC_LOG_AND_RETHROW()


BOOST_FIXTURE_TEST_CASE( propose_with_wrong_requested_auth, eosio_msig_tester ) try {
BOOST_FIXTURE_TEST_CASE( propose_with_wrong_requested_auth, enumivo_msig_tester ) try {
auto trx = reqauth("alice", vector<permission_level>{ { N(alice), config::active_name }, { N(bob), config::active_name } } );
//try with not enough requested auth
BOOST_REQUIRE_EXCEPTION( push_action( N(alice), N(propose), mvo()
Expand All @@ -240,7 +240,7 @@ BOOST_FIXTURE_TEST_CASE( propose_with_wrong_requested_auth, eosio_msig_tester )
} FC_LOG_AND_RETHROW()


BOOST_FIXTURE_TEST_CASE( big_transaction, eosio_msig_tester ) try {
BOOST_FIXTURE_TEST_CASE( big_transaction, enumivo_msig_tester ) try {
vector<permission_level> perm = { { N(alice), config::active_name }, { N(bob), config::active_name } };
auto wasm = wast_to_wasm( exchange_wast );

Expand Down

0 comments on commit 511e1de

Please sign in to comment.