From 47585a6b9aa03fdddad5a25ac8bd49fa1ddb02cb Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Wed, 18 Nov 2015 17:49:13 -0500 Subject: [PATCH 1/5] Fix cli_wallet referrer percentage type #449 --- libraries/wallet/include/graphene/wallet/wallet.hpp | 7 ++++--- libraries/wallet/wallet.cpp | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 952b1b33..61b82711 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -620,8 +620,9 @@ class wallet_api * portion of the user's transaction fees. This can be the * same as the registrar_account if there is no referrer. * @param referrer_percent the percentage (0 - 100) of the new user's transaction fees - * not claimed by the blockchain that will be distributed to the - * referrer; the rest will be sent to the registrar + * not claimed by the blockchain that will be distributed to the + * referrer; the rest will be sent to the registrar. Will be + * multiplied by GRAPHENE_1_PERCENT when constructing the transaction. * @param broadcast true to broadcast the transaction on the network * @returns the signed transaction registering the account */ @@ -630,7 +631,7 @@ class wallet_api public_key_type active, string registrar_account, string referrer_account, - uint8_t referrer_percent, + uint32_t referrer_percent, bool broadcast = false); /** diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 3858f4c1..cc7f54a9 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -849,13 +849,17 @@ public: public_key_type active, string registrar_account, string referrer_account, - uint8_t referrer_percent, + uint32_t referrer_percent, bool broadcast = false) { try { FC_ASSERT( !self.is_locked() ); FC_ASSERT( is_valid_name(name) ); account_create_operation account_create_op; + // #449 referrer_percent is on 0-100 scale, if user has larger + // number it means their script is using GRAPHENE_100_PERCENT scale + // instead of 0-100 scale. + FC_ASSERT( referrer_percent <= 100 ); // TODO: process when pay_from_account is ID account_object registrar_account_object = @@ -867,7 +871,7 @@ public: account_object referrer_account_object = this->get_account( referrer_account ); account_create_op.referrer = referrer_account_object.id; - account_create_op.referrer_percent = referrer_percent; + account_create_op.referrer_percent = uint16_t( referrer_percent * GRAPHENE_1_PERCENT ); account_create_op.registrar = registrar_account_id; account_create_op.name = name; @@ -2876,7 +2880,7 @@ signed_transaction wallet_api::register_account(string name, public_key_type active_pubkey, string registrar_account, string referrer_account, - uint8_t referrer_percent, + uint32_t referrer_percent, bool broadcast) { return my->register_account( name, owner_pubkey, active_pubkey, registrar_account, referrer_account, referrer_percent, broadcast ); From 228d9b5a931fd0e136f5ba3a1ad34fc043b90fc1 Mon Sep 17 00:00:00 2001 From: James Calfee Date: Mon, 9 Nov 2015 17:26:51 -0600 Subject: [PATCH 2/5] JavaScript serilizer generator updates #439 --- programs/js_operation_serializer/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/js_operation_serializer/main.cpp b/programs/js_operation_serializer/main.cpp index a5eda145..980231e8 100644 --- a/programs/js_operation_serializer/main.cpp +++ b/programs/js_operation_serializer/main.cpp @@ -109,9 +109,9 @@ template struct js_name< fc::safe > { static std::string name(){ template<> struct js_name< std::vector > { static std::string name(){ return "bytes()"; } }; -template<> struct js_name< op_wrapper > { static std::string name(){ return "operation "; } }; template<> struct js_name { static std::string name(){ return "bytes 20"; } }; template<> struct js_name { static std::string name(){ return "bytes 28"; } }; +template<> struct js_name { static std::string name(){ return "bytes 32"; } }; template<> struct js_name { static std::string name(){ return "varuint32"; } }; template<> struct js_name { static std::string name(){ return "varint32"; } }; template<> struct js_name< vote_id_type > { static std::string name(){ return "vote_id"; } }; From 699144c173bd80a53beb1c0d9f45353630e1c696 Mon Sep 17 00:00:00 2001 From: Scott Howard Date: Fri, 30 Oct 2015 17:11:34 -0400 Subject: [PATCH 3/5] add cancel_order to wallet api --- libraries/wallet/include/graphene/wallet/wallet.hpp | 9 +++++++++ libraries/wallet/wallet.cpp | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/libraries/wallet/include/graphene/wallet/wallet.hpp b/libraries/wallet/include/graphene/wallet/wallet.hpp index 952b1b33..4d2c2d82 100644 --- a/libraries/wallet/include/graphene/wallet/wallet.hpp +++ b/libraries/wallet/include/graphene/wallet/wallet.hpp @@ -847,6 +847,14 @@ class wallet_api signed_transaction borrow_asset(string borrower_name, string amount_to_borrow, string asset_symbol, string amount_of_collateral, bool broadcast = false); + /** Cancel an existing order + * + * @param order_id the id of order to be cancelled + * @param broadcast true to broadcast the transaction on the network + * @returns the signed transaction canceling the order + */ + signed_transaction cancel_order(object_id_type order_id, bool broadcast = false); + /** Creates a new user-issued or market-issued asset. * * Many options can be changed later using \c update_asset() @@ -1488,6 +1496,7 @@ FC_API( graphene::wallet::wallet_api, (create_account_with_brain_key) (sell_asset) (borrow_asset) + (cancel_order) (transfer) (transfer2) (get_transaction_id) diff --git a/libraries/wallet/wallet.cpp b/libraries/wallet/wallet.cpp index 3858f4c1..96c8263b 100644 --- a/libraries/wallet/wallet.cpp +++ b/libraries/wallet/wallet.cpp @@ -3453,6 +3453,12 @@ signed_transaction wallet_api::borrow_asset(string seller_name, string amount_to return my->borrow_asset(seller_name, amount_to_sell, asset_symbol, amount_of_collateral, broadcast); } +signed_transaction wallet_api::cancel_order(object_id_type order_id, bool broadcast) +{ + FC_ASSERT(!is_locked()); + return my->cancel_order(order_id, broadcast); +} + string wallet_api::get_key_label( public_key_type key )const { auto key_itr = my->_wallet.labeled_keys.get().find(key); From 5b99cd4faa9ef0e24a5c9cdf3973dbf56e6f2e00 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Mon, 7 Dec 2015 14:33:24 -0500 Subject: [PATCH 4/5] Allow zero_second_vbo test to run at any timestamp #437 --- tests/tests/operation_tests2.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/tests/operation_tests2.cpp b/tests/tests/operation_tests2.cpp index 9021f621..b7e9cf11 100644 --- a/tests/tests/operation_tests2.cpp +++ b/tests/tests/operation_tests2.cpp @@ -1229,6 +1229,11 @@ BOOST_AUTO_TEST_CASE(zero_second_vbo) upgrade_to_lifetime_member(alice_id); generate_block(); + // Wait for a maintenance interval to ensure we have a full day's budget to work with. + // Otherwise we may not have enough to feed the witnesses and the worker will end up starved if we start late in the day. + generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); + generate_block(); + auto check_vesting_1b = [&](vesting_balance_id_type vbid) { // this function checks that Alice can't draw any right now, @@ -1304,8 +1309,6 @@ BOOST_AUTO_TEST_CASE(zero_second_vbo) // vote it in, wait for one maint. for vote to take effect vesting_balance_id_type vbid = wid(db).worker.get().balance; - generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); - generate_block(); // wait for another maint. for worker to be paid generate_blocks(db.get_dynamic_global_properties().next_maintenance_time); BOOST_CHECK( vbid(db).get_allowed_withdraw(db.head_block_time()) == asset(0) ); From 6feadd77a5e35d2b3baffc5a866238a8c397f6f8 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Mon, 7 Dec 2015 14:38:05 -0500 Subject: [PATCH 5/5] Fix GRAPHENE_TESTING_GENESIS_TIMESTAMP behavior of asset_claim_fees_test #413 #437 --- tests/tests/fee_tests.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/tests/fee_tests.cpp b/tests/tests/fee_tests.cpp index e65cb92b..643caaf5 100644 --- a/tests/tests/fee_tests.cpp +++ b/tests/tests/fee_tests.cpp @@ -163,6 +163,7 @@ BOOST_AUTO_TEST_CASE(asset_claim_fees_test) } + if( db.head_block_time() <= HARDFORK_413_TIME ) { // can't claim before hardfork GRAPHENE_REQUIRE_THROW( claim_fees( izzy_id, _izzy(1) ), fc::exception );