2015-06-08 15:50:35 +00:00
|
|
|
/*
|
2015-10-12 17:48:40 +00:00
|
|
|
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
|
|
|
|
|
*
|
2016-01-06 09:51:18 +00:00
|
|
|
* The MIT License
|
2015-10-12 17:48:40 +00:00
|
|
|
*
|
2016-01-06 09:51:18 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2015-10-12 17:48:40 +00:00
|
|
|
*
|
2016-01-06 09:51:18 +00:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
|
* all copies or substantial portions of the Software.
|
2015-10-12 17:02:59 +00:00
|
|
|
*
|
2016-01-06 09:51:18 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
* THE SOFTWARE.
|
2015-06-08 15:50:35 +00:00
|
|
|
*/
|
|
|
|
|
#include <graphene/chain/asset_evaluator.hpp>
|
|
|
|
|
#include <graphene/chain/asset_object.hpp>
|
|
|
|
|
#include <graphene/chain/account_object.hpp>
|
[SON-107] Merge develop branch to SONs-base (#166)
* fix rng and get_winner_numbers implemented
* coipied code for bitshares fixing 429 and 433 isuues
* ticket_purchase_operation implemented. added lottery_options to asset
* lottery end implemented
* minor logic changes. added db_api and cli_wallet methods
* fix reindex on peerplays network
* fix some tests. add gitlab-ci.yml
* add pull to gitlab-ci
* fix
* fix and comment some tests
* added owner to lottery_asset_options. commented async call in on_applied_block callback
* added get_account_lotteries method to db_api and cli, lottery end_date and ticket_price verification
* merge get_account_lotteries branch. fix create_witness test
* fix test genesis and end_date verification
* fixed indices sorting and lottery end checking by date
* update db_version for replay and removed duplicate include files
* Added ntp and upgraded boost version
* Revert "GPOS protocol"
* need to remove backup files
* virtual-op-fix for deterministic virtual_op number
* Merged beatrice into 5050
* Updated gitmodules, changes to allow voting on lottery fee
* Removed submodule libraries/fc
* Added libraries/fc
* added missing , in types.hpp
* Added sweeps parameters to parameter_extension
* added missing comma in operations.hpp, small changes to config.hpp
* fixed returntype in chain_parameters.hpp
* removed sweeps_parameter_extensions
* Changed fc library
* fixed asset_object
* Changed peerplays-fc submodule
* Changed fc submodule to ubuntu 18.04 upgrade
* Removed submodule libraries/fc
* Added fc library back
* fix casting in overloaded function
* Removed blind_sign and unblind_signature functions
* Added new lottery_asset_create_operation
* Changed sweeps hardfork time
* Removed redundant if from asset_evaluator and fixed db_notify
* fixed duplicate code in fee_tests
* removed redundant tgenesis file
* Enable building on Ubuntu 18.04 using GCC 7 compiler
* fix: is_benefactor_reward had the default value of true when not set
* Docker file for Ubuntu 18.04
Base image updated to Unbuntu 18.04
Prerequisite list updated
Basic configuration updated
* Quick fix: Added missing package pkg-config
* Docker file updates
* 5050 fee update and compilation error fix
* Dockerfile, set system locale
Prevents locale::facet::_S_create_c_locale name error
* Update README.md
Fix typo
* Update README.md
* Changed hardfork time for SWEEPS and Core-429
* revert master changes that were brought in previous commit
* Fixed error when account_history_object with id 0 doesnt exist
* Fixed error while loading object database
* test for zero id object in account history
* Reorder operations in Dockerfile, to make image creation faster
- Reorder prevents unnecessary building of Boost libraries
* Fix for irrelevant signature included issue
* fix copyrigth messages order
* remove double empty lines
* Backport fix for `get_account_history` from https://github.com/bitshares/bitshares-core/pull/628 and add additional account history test case
* NTP client back
* GRPH-53-Log_format_error
* Merge pull request #1036 from jmjatlanta/issue_730
Add fail_reason to proposal_object
* Unit test case fixes and prepared SONs base
* Use offsetof instead of custom macro
* Hide some compiler warnings
* Make all the tests compile
* Add nullptr check in api.cpp for easier testing
* Add test case for broadcast_trx_with_callback API
* Unit test case fixes and prepared SONs base
* Merge pull request #714 from pmconrad/json_fix
JSON fix
* Increase max depth for trx confirmation callback
* Adapt to variant API with `max_depth` argument
* Update fc submodule
* Created unit test for #325
* remove needless find()
* GRPH-4-CliWallet_crash_ctrlD
* fix copyright message
* Make all the tests compile
* increase delay for node connection
* Increase block creation timeout to 2500ms
* remove cache from cli get_account
* add cli tests framework
* Adjust newly merged code to new API
* Improved resilience of block database against corruption
* Merged changes from Bitshares PR 1036
* GRPH-76 - Short-cut long sequences of missed blocks
Fixes database::update_global_dynamic_data to speed up counting missed blocks.
(This also fixes a minor issue with counting - the previous algorithm would skip missed blocks for the witness who signed the first block after the gap.)
* Moved reindex logic into database / chain_database, make use of additional blocks in block_database
Fixed tests wrt db.open
* Enable undo + fork database for final blocks in a replay
Dont remove blocks from block db when popping blocks, handle edge case in replay wrt fork_db, adapted unit tests
* Log starting block number of replay
* Prevent unsigned integer underflow
* Fixed lock detection
* Dont leave _data_dir empty if db is locked
* Writing the object_database is now almost atomic
* Improved consistency check for block_log
* Cut back block_log index file if inconsistent
* Fixed undo_database
* Added test case for broken merge on empty undo_db
* Merge pull request #938 from bitshares/fix-block-storing
Store correct block ID when switching forks
* exclude second undo_db.enable() call in some cases
* Add missing change
* change bitshares to core in message
* Fixed integer overflow issue
* Fix for for history ID mismatch ( Bitshares PR #875 )
* Update the FC submodule with the changes for GRPH-4
* Fix #436 object_database created outside of witness data directory
* supplement more comments on database::_opened variable
* prevent segfault when destructing application obj
* Fixed duplicate ops returned from get_account_history
* minor performance improvement
* Added comment
* Merged Bitshares PR #1462 and compilation fixes
* Support/gitlab (#123)
* Updated gitlab process
* Fix undefined references in cli test
* Fixed test failures and compilation issue
* Fixed account_history_pagination test
* Fix compilation in debug mode
* Removed unrelated comment
* Skip auth check when pushing self-generated blocks
* Extract public keys before pushing a transaction
* Dereference chain_database shared_ptr
* Updated transaction::signees to mutable
and
* updated get_signature_keys() to return a const reference,
* get_signature_keys() will update signees on first call,
* modified test cases and wallet.cpp accordingly,
* no longer construct a new signed_transaction object before pushing
* Added get_asset_count API
* Allow sufficient space for new undo_session
* Throw for deep nesting
* No longer extract public keys before pushing a trx
and removed unused new added constructor and _get_signature_keys() function from signed_transaction struct
* Added cli_test to CI
* use random port numbers in app_test (#154)
* proposal fail_reason bug fixed (#157)
* Added Sonarcloud code_quality to CI (#159)
* Added sonarcloud analysis (#158)
* fix for lottery end
* fix declarations
* fix declarations
* fix boost integer
* fix compilation
* fix chain tests
* fix app_test
* try to fix cli test
* fix incorrect max_depth param
* working cli test
* correct fc version
2019-10-08 01:25:03 +00:00
|
|
|
#include <graphene/chain/balance_object.hpp>
|
2016-01-08 15:37:22 +00:00
|
|
|
#include <graphene/chain/market_object.hpp>
|
2015-06-08 15:50:35 +00:00
|
|
|
#include <graphene/chain/database.hpp>
|
2015-07-07 21:39:38 +00:00
|
|
|
#include <graphene/chain/exceptions.hpp>
|
2015-10-08 18:59:43 +00:00
|
|
|
#include <graphene/chain/hardfork.hpp>
|
Make is_authorized_asset a free-floating method #566
The following sed commands were used to port existing call sites to the new interface:
sed -i -e 's/\([a-zA-Z0-9_]\+\)->is_authorized_asset[(] \([a-zA-Z0-9_*]\+\), d [)]/is_authorized_asset( d, *\1, \2 )/' libraries/chain/*.cpp
sed -i -e 's/\([a-zA-Z0-9_]\+\)[.]is_authorized_asset[(] \([a-zA-Z0-9_*]\+\), d [)]/is_authorized_asset( d, \1, \2 )/' libraries/chain/*.cpp
sed -i -e 's/\([a-zA-Z0-9_]\+\)[(]db[)][.]is_authorized_asset[(]\([a-zA-Z0-9_*]\+\)[(]db[)], db[)]/is_authorized_asset( db, \1(db), \2(db) )/' tests/tests/uia_tests.cpp
sed -i -e 's/\([a-zA-Z0-9_]\+\)[.]is_authorized_asset[(]\([a-zA-Z0-9_*]\+\), db[)]/is_authorized_asset( db, \1, \2 )/' tests/tests/uia_tests.cpp
No new functionality is added by this commit, it is simply re-organizing the existing code in a different place.
2016-02-10 21:24:56 +00:00
|
|
|
#include <graphene/chain/is_authorized_asset.hpp>
|
2015-06-08 15:50:35 +00:00
|
|
|
|
|
|
|
|
#include <functional>
|
|
|
|
|
|
2016-06-26 19:41:07 +00:00
|
|
|
#include <boost/algorithm/string/case_conv.hpp>
|
|
|
|
|
|
2015-06-08 15:50:35 +00:00
|
|
|
namespace graphene { namespace chain {
|
2015-10-08 18:59:43 +00:00
|
|
|
|
2015-06-23 21:33:06 +00:00
|
|
|
void_result asset_create_evaluator::do_evaluate( const asset_create_operation& op )
|
2015-06-08 15:50:35 +00:00
|
|
|
{ try {
|
2015-10-08 18:59:43 +00:00
|
|
|
|
2015-06-08 15:50:35 +00:00
|
|
|
database& d = db();
|
|
|
|
|
|
|
|
|
|
const auto& chain_parameters = d.get_global_properties().parameters;
|
|
|
|
|
FC_ASSERT( op.common_options.whitelist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities );
|
|
|
|
|
FC_ASSERT( op.common_options.blacklist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities );
|
|
|
|
|
|
|
|
|
|
// Check that all authorities do exist
|
|
|
|
|
for( auto id : op.common_options.whitelist_authorities )
|
|
|
|
|
d.get_object(id);
|
|
|
|
|
for( auto id : op.common_options.blacklist_authorities )
|
|
|
|
|
d.get_object(id);
|
|
|
|
|
|
2015-10-30 13:32:28 +00:00
|
|
|
auto& asset_indx = d.get_index_type<asset_index>().indices().get<by_symbol>();
|
2015-06-08 15:50:35 +00:00
|
|
|
auto asset_symbol_itr = asset_indx.find( op.symbol );
|
|
|
|
|
FC_ASSERT( asset_symbol_itr == asset_indx.end() );
|
|
|
|
|
|
2015-11-02 15:09:24 +00:00
|
|
|
if( d.head_block_time() > HARDFORK_385_TIME )
|
|
|
|
|
{
|
2019-04-12 15:53:09 +00:00
|
|
|
|
|
|
|
|
if( d.head_block_time() <= HARDFORK_409_TIME )
|
|
|
|
|
{
|
|
|
|
|
auto dotpos = op.symbol.find( '.' );
|
|
|
|
|
if( dotpos != std::string::npos )
|
2015-10-30 13:32:28 +00:00
|
|
|
{
|
2019-04-12 15:53:09 +00:00
|
|
|
auto prefix = op.symbol.substr( 0, dotpos );
|
|
|
|
|
auto asset_symbol_itr = asset_indx.find( op.symbol );
|
|
|
|
|
FC_ASSERT( asset_symbol_itr != asset_indx.end(), "Asset ${s} may only be created by issuer of ${p}, but ${p} has not been registered",
|
|
|
|
|
("s",op.symbol)("p",prefix) );
|
|
|
|
|
FC_ASSERT( asset_symbol_itr->issuer == op.issuer, "Asset ${s} may only be created by issuer of ${p}, ${i}",
|
|
|
|
|
("s",op.symbol)("p",prefix)("i", op.issuer(d).name) );
|
2015-10-30 13:32:28 +00:00
|
|
|
}
|
2019-04-12 15:53:09 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
auto dotpos = op.symbol.rfind( '.' );
|
|
|
|
|
if( dotpos != std::string::npos )
|
[SON-107] Merge develop branch to SONs-base (#166)
* fix rng and get_winner_numbers implemented
* coipied code for bitshares fixing 429 and 433 isuues
* ticket_purchase_operation implemented. added lottery_options to asset
* lottery end implemented
* minor logic changes. added db_api and cli_wallet methods
* fix reindex on peerplays network
* fix some tests. add gitlab-ci.yml
* add pull to gitlab-ci
* fix
* fix and comment some tests
* added owner to lottery_asset_options. commented async call in on_applied_block callback
* added get_account_lotteries method to db_api and cli, lottery end_date and ticket_price verification
* merge get_account_lotteries branch. fix create_witness test
* fix test genesis and end_date verification
* fixed indices sorting and lottery end checking by date
* update db_version for replay and removed duplicate include files
* Added ntp and upgraded boost version
* Revert "GPOS protocol"
* need to remove backup files
* virtual-op-fix for deterministic virtual_op number
* Merged beatrice into 5050
* Updated gitmodules, changes to allow voting on lottery fee
* Removed submodule libraries/fc
* Added libraries/fc
* added missing , in types.hpp
* Added sweeps parameters to parameter_extension
* added missing comma in operations.hpp, small changes to config.hpp
* fixed returntype in chain_parameters.hpp
* removed sweeps_parameter_extensions
* Changed fc library
* fixed asset_object
* Changed peerplays-fc submodule
* Changed fc submodule to ubuntu 18.04 upgrade
* Removed submodule libraries/fc
* Added fc library back
* fix casting in overloaded function
* Removed blind_sign and unblind_signature functions
* Added new lottery_asset_create_operation
* Changed sweeps hardfork time
* Removed redundant if from asset_evaluator and fixed db_notify
* fixed duplicate code in fee_tests
* removed redundant tgenesis file
* Enable building on Ubuntu 18.04 using GCC 7 compiler
* fix: is_benefactor_reward had the default value of true when not set
* Docker file for Ubuntu 18.04
Base image updated to Unbuntu 18.04
Prerequisite list updated
Basic configuration updated
* Quick fix: Added missing package pkg-config
* Docker file updates
* 5050 fee update and compilation error fix
* Dockerfile, set system locale
Prevents locale::facet::_S_create_c_locale name error
* Update README.md
Fix typo
* Update README.md
* Changed hardfork time for SWEEPS and Core-429
* revert master changes that were brought in previous commit
* Fixed error when account_history_object with id 0 doesnt exist
* Fixed error while loading object database
* test for zero id object in account history
* Reorder operations in Dockerfile, to make image creation faster
- Reorder prevents unnecessary building of Boost libraries
* Fix for irrelevant signature included issue
* fix copyrigth messages order
* remove double empty lines
* Backport fix for `get_account_history` from https://github.com/bitshares/bitshares-core/pull/628 and add additional account history test case
* NTP client back
* GRPH-53-Log_format_error
* Merge pull request #1036 from jmjatlanta/issue_730
Add fail_reason to proposal_object
* Unit test case fixes and prepared SONs base
* Use offsetof instead of custom macro
* Hide some compiler warnings
* Make all the tests compile
* Add nullptr check in api.cpp for easier testing
* Add test case for broadcast_trx_with_callback API
* Unit test case fixes and prepared SONs base
* Merge pull request #714 from pmconrad/json_fix
JSON fix
* Increase max depth for trx confirmation callback
* Adapt to variant API with `max_depth` argument
* Update fc submodule
* Created unit test for #325
* remove needless find()
* GRPH-4-CliWallet_crash_ctrlD
* fix copyright message
* Make all the tests compile
* increase delay for node connection
* Increase block creation timeout to 2500ms
* remove cache from cli get_account
* add cli tests framework
* Adjust newly merged code to new API
* Improved resilience of block database against corruption
* Merged changes from Bitshares PR 1036
* GRPH-76 - Short-cut long sequences of missed blocks
Fixes database::update_global_dynamic_data to speed up counting missed blocks.
(This also fixes a minor issue with counting - the previous algorithm would skip missed blocks for the witness who signed the first block after the gap.)
* Moved reindex logic into database / chain_database, make use of additional blocks in block_database
Fixed tests wrt db.open
* Enable undo + fork database for final blocks in a replay
Dont remove blocks from block db when popping blocks, handle edge case in replay wrt fork_db, adapted unit tests
* Log starting block number of replay
* Prevent unsigned integer underflow
* Fixed lock detection
* Dont leave _data_dir empty if db is locked
* Writing the object_database is now almost atomic
* Improved consistency check for block_log
* Cut back block_log index file if inconsistent
* Fixed undo_database
* Added test case for broken merge on empty undo_db
* Merge pull request #938 from bitshares/fix-block-storing
Store correct block ID when switching forks
* exclude second undo_db.enable() call in some cases
* Add missing change
* change bitshares to core in message
* Fixed integer overflow issue
* Fix for for history ID mismatch ( Bitshares PR #875 )
* Update the FC submodule with the changes for GRPH-4
* Fix #436 object_database created outside of witness data directory
* supplement more comments on database::_opened variable
* prevent segfault when destructing application obj
* Fixed duplicate ops returned from get_account_history
* minor performance improvement
* Added comment
* Merged Bitshares PR #1462 and compilation fixes
* Support/gitlab (#123)
* Updated gitlab process
* Fix undefined references in cli test
* Fixed test failures and compilation issue
* Fixed account_history_pagination test
* Fix compilation in debug mode
* Removed unrelated comment
* Skip auth check when pushing self-generated blocks
* Extract public keys before pushing a transaction
* Dereference chain_database shared_ptr
* Updated transaction::signees to mutable
and
* updated get_signature_keys() to return a const reference,
* get_signature_keys() will update signees on first call,
* modified test cases and wallet.cpp accordingly,
* no longer construct a new signed_transaction object before pushing
* Added get_asset_count API
* Allow sufficient space for new undo_session
* Throw for deep nesting
* No longer extract public keys before pushing a trx
and removed unused new added constructor and _get_signature_keys() function from signed_transaction struct
* Added cli_test to CI
* use random port numbers in app_test (#154)
* proposal fail_reason bug fixed (#157)
* Added Sonarcloud code_quality to CI (#159)
* Added sonarcloud analysis (#158)
* fix for lottery end
* fix declarations
* fix declarations
* fix boost integer
* fix compilation
* fix chain tests
* fix app_test
* try to fix cli test
* fix incorrect max_depth param
* working cli test
* correct fc version
2019-10-08 01:25:03 +00:00
|
|
|
|
2015-10-30 13:32:28 +00:00
|
|
|
{
|
2019-04-12 15:53:09 +00:00
|
|
|
auto prefix = op.symbol.substr( 0, dotpos );
|
|
|
|
|
auto asset_symbol_itr = asset_indx.find( prefix );
|
|
|
|
|
FC_ASSERT( asset_symbol_itr != asset_indx.end(), "Asset ${s} may only be created by issuer of ${p}, but ${p} has not been registered",
|
|
|
|
|
("s",op.symbol)("p",prefix) );
|
|
|
|
|
FC_ASSERT( asset_symbol_itr->issuer == op.issuer, "Asset ${s} may only be created by issuer of ${p}, ${i}",
|
|
|
|
|
("s",op.symbol)("p",prefix)("i", op.issuer(d).name) );
|
2015-10-30 13:32:28 +00:00
|
|
|
}
|
2015-10-19 20:46:26 +00:00
|
|
|
}
|
2019-04-12 15:53:09 +00:00
|
|
|
|
|
|
|
|
}
|
2015-11-02 15:09:24 +00:00
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
auto dotpos = op.symbol.find( '.' );
|
|
|
|
|
if( dotpos != std::string::npos )
|
|
|
|
|
wlog( "Asset ${s} has a name which requires hardfork 385", ("s",op.symbol) );
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-09 17:50:47 +00:00
|
|
|
if( op.bitasset_opts )
|
2015-06-08 15:50:35 +00:00
|
|
|
{
|
2015-07-09 17:50:47 +00:00
|
|
|
const asset_object& backing = op.bitasset_opts->short_backing_asset(d);
|
2015-06-08 15:50:35 +00:00
|
|
|
if( backing.is_market_issued() )
|
|
|
|
|
{
|
|
|
|
|
const asset_bitasset_data_object& backing_bitasset_data = backing.bitasset_data(d);
|
|
|
|
|
const asset_object& backing_backing = backing_bitasset_data.options.short_backing_asset(d);
|
|
|
|
|
FC_ASSERT( !backing_backing.is_market_issued(),
|
|
|
|
|
"May not create a bitasset backed by a bitasset backed by a bitasset." );
|
2015-06-26 19:11:41 +00:00
|
|
|
FC_ASSERT( op.issuer != GRAPHENE_COMMITTEE_ACCOUNT || backing_backing.get_id() == asset_id_type(),
|
|
|
|
|
"May not create a blockchain-controlled market asset which is not backed by CORE.");
|
|
|
|
|
} else
|
|
|
|
|
FC_ASSERT( op.issuer != GRAPHENE_COMMITTEE_ACCOUNT || backing.get_id() == asset_id_type(),
|
|
|
|
|
"May not create a blockchain-controlled market asset which is not backed by CORE.");
|
2015-07-09 17:50:47 +00:00
|
|
|
FC_ASSERT( op.bitasset_opts->feed_lifetime_sec > chain_parameters.block_interval &&
|
|
|
|
|
op.bitasset_opts->force_settlement_delay_sec > chain_parameters.block_interval );
|
2015-06-08 15:50:35 +00:00
|
|
|
}
|
2015-06-26 14:42:40 +00:00
|
|
|
if( op.is_prediction_market )
|
2015-06-25 18:46:53 +00:00
|
|
|
{
|
2015-07-09 17:50:47 +00:00
|
|
|
FC_ASSERT( op.bitasset_opts );
|
|
|
|
|
FC_ASSERT( op.precision == op.bitasset_opts->short_backing_asset(d).precision );
|
2015-06-25 18:46:53 +00:00
|
|
|
}
|
[SON-107] Merge develop branch to SONs-base (#166)
* fix rng and get_winner_numbers implemented
* coipied code for bitshares fixing 429 and 433 isuues
* ticket_purchase_operation implemented. added lottery_options to asset
* lottery end implemented
* minor logic changes. added db_api and cli_wallet methods
* fix reindex on peerplays network
* fix some tests. add gitlab-ci.yml
* add pull to gitlab-ci
* fix
* fix and comment some tests
* added owner to lottery_asset_options. commented async call in on_applied_block callback
* added get_account_lotteries method to db_api and cli, lottery end_date and ticket_price verification
* merge get_account_lotteries branch. fix create_witness test
* fix test genesis and end_date verification
* fixed indices sorting and lottery end checking by date
* update db_version for replay and removed duplicate include files
* Added ntp and upgraded boost version
* Revert "GPOS protocol"
* need to remove backup files
* virtual-op-fix for deterministic virtual_op number
* Merged beatrice into 5050
* Updated gitmodules, changes to allow voting on lottery fee
* Removed submodule libraries/fc
* Added libraries/fc
* added missing , in types.hpp
* Added sweeps parameters to parameter_extension
* added missing comma in operations.hpp, small changes to config.hpp
* fixed returntype in chain_parameters.hpp
* removed sweeps_parameter_extensions
* Changed fc library
* fixed asset_object
* Changed peerplays-fc submodule
* Changed fc submodule to ubuntu 18.04 upgrade
* Removed submodule libraries/fc
* Added fc library back
* fix casting in overloaded function
* Removed blind_sign and unblind_signature functions
* Added new lottery_asset_create_operation
* Changed sweeps hardfork time
* Removed redundant if from asset_evaluator and fixed db_notify
* fixed duplicate code in fee_tests
* removed redundant tgenesis file
* Enable building on Ubuntu 18.04 using GCC 7 compiler
* fix: is_benefactor_reward had the default value of true when not set
* Docker file for Ubuntu 18.04
Base image updated to Unbuntu 18.04
Prerequisite list updated
Basic configuration updated
* Quick fix: Added missing package pkg-config
* Docker file updates
* 5050 fee update and compilation error fix
* Dockerfile, set system locale
Prevents locale::facet::_S_create_c_locale name error
* Update README.md
Fix typo
* Update README.md
* Changed hardfork time for SWEEPS and Core-429
* revert master changes that were brought in previous commit
* Fixed error when account_history_object with id 0 doesnt exist
* Fixed error while loading object database
* test for zero id object in account history
* Reorder operations in Dockerfile, to make image creation faster
- Reorder prevents unnecessary building of Boost libraries
* Fix for irrelevant signature included issue
* fix copyrigth messages order
* remove double empty lines
* Backport fix for `get_account_history` from https://github.com/bitshares/bitshares-core/pull/628 and add additional account history test case
* NTP client back
* GRPH-53-Log_format_error
* Merge pull request #1036 from jmjatlanta/issue_730
Add fail_reason to proposal_object
* Unit test case fixes and prepared SONs base
* Use offsetof instead of custom macro
* Hide some compiler warnings
* Make all the tests compile
* Add nullptr check in api.cpp for easier testing
* Add test case for broadcast_trx_with_callback API
* Unit test case fixes and prepared SONs base
* Merge pull request #714 from pmconrad/json_fix
JSON fix
* Increase max depth for trx confirmation callback
* Adapt to variant API with `max_depth` argument
* Update fc submodule
* Created unit test for #325
* remove needless find()
* GRPH-4-CliWallet_crash_ctrlD
* fix copyright message
* Make all the tests compile
* increase delay for node connection
* Increase block creation timeout to 2500ms
* remove cache from cli get_account
* add cli tests framework
* Adjust newly merged code to new API
* Improved resilience of block database against corruption
* Merged changes from Bitshares PR 1036
* GRPH-76 - Short-cut long sequences of missed blocks
Fixes database::update_global_dynamic_data to speed up counting missed blocks.
(This also fixes a minor issue with counting - the previous algorithm would skip missed blocks for the witness who signed the first block after the gap.)
* Moved reindex logic into database / chain_database, make use of additional blocks in block_database
Fixed tests wrt db.open
* Enable undo + fork database for final blocks in a replay
Dont remove blocks from block db when popping blocks, handle edge case in replay wrt fork_db, adapted unit tests
* Log starting block number of replay
* Prevent unsigned integer underflow
* Fixed lock detection
* Dont leave _data_dir empty if db is locked
* Writing the object_database is now almost atomic
* Improved consistency check for block_log
* Cut back block_log index file if inconsistent
* Fixed undo_database
* Added test case for broken merge on empty undo_db
* Merge pull request #938 from bitshares/fix-block-storing
Store correct block ID when switching forks
* exclude second undo_db.enable() call in some cases
* Add missing change
* change bitshares to core in message
* Fixed integer overflow issue
* Fix for for history ID mismatch ( Bitshares PR #875 )
* Update the FC submodule with the changes for GRPH-4
* Fix #436 object_database created outside of witness data directory
* supplement more comments on database::_opened variable
* prevent segfault when destructing application obj
* Fixed duplicate ops returned from get_account_history
* minor performance improvement
* Added comment
* Merged Bitshares PR #1462 and compilation fixes
* Support/gitlab (#123)
* Updated gitlab process
* Fix undefined references in cli test
* Fixed test failures and compilation issue
* Fixed account_history_pagination test
* Fix compilation in debug mode
* Removed unrelated comment
* Skip auth check when pushing self-generated blocks
* Extract public keys before pushing a transaction
* Dereference chain_database shared_ptr
* Updated transaction::signees to mutable
and
* updated get_signature_keys() to return a const reference,
* get_signature_keys() will update signees on first call,
* modified test cases and wallet.cpp accordingly,
* no longer construct a new signed_transaction object before pushing
* Added get_asset_count API
* Allow sufficient space for new undo_session
* Throw for deep nesting
* No longer extract public keys before pushing a trx
and removed unused new added constructor and _get_signature_keys() function from signed_transaction struct
* Added cli_test to CI
* use random port numbers in app_test (#154)
* proposal fail_reason bug fixed (#157)
* Added Sonarcloud code_quality to CI (#159)
* Added sonarcloud analysis (#158)
* fix for lottery end
* fix declarations
* fix declarations
* fix boost integer
* fix compilation
* fix chain tests
* fix app_test
* try to fix cli test
* fix incorrect max_depth param
* working cli test
* correct fc version
2019-10-08 01:25:03 +00:00
|
|
|
|
2015-06-23 21:33:06 +00:00
|
|
|
return void_result();
|
2015-06-08 15:50:35 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
|
|
|
|
|
[SON-107] Merge develop branch to SONs-base (#166)
* fix rng and get_winner_numbers implemented
* coipied code for bitshares fixing 429 and 433 isuues
* ticket_purchase_operation implemented. added lottery_options to asset
* lottery end implemented
* minor logic changes. added db_api and cli_wallet methods
* fix reindex on peerplays network
* fix some tests. add gitlab-ci.yml
* add pull to gitlab-ci
* fix
* fix and comment some tests
* added owner to lottery_asset_options. commented async call in on_applied_block callback
* added get_account_lotteries method to db_api and cli, lottery end_date and ticket_price verification
* merge get_account_lotteries branch. fix create_witness test
* fix test genesis and end_date verification
* fixed indices sorting and lottery end checking by date
* update db_version for replay and removed duplicate include files
* Added ntp and upgraded boost version
* Revert "GPOS protocol"
* need to remove backup files
* virtual-op-fix for deterministic virtual_op number
* Merged beatrice into 5050
* Updated gitmodules, changes to allow voting on lottery fee
* Removed submodule libraries/fc
* Added libraries/fc
* added missing , in types.hpp
* Added sweeps parameters to parameter_extension
* added missing comma in operations.hpp, small changes to config.hpp
* fixed returntype in chain_parameters.hpp
* removed sweeps_parameter_extensions
* Changed fc library
* fixed asset_object
* Changed peerplays-fc submodule
* Changed fc submodule to ubuntu 18.04 upgrade
* Removed submodule libraries/fc
* Added fc library back
* fix casting in overloaded function
* Removed blind_sign and unblind_signature functions
* Added new lottery_asset_create_operation
* Changed sweeps hardfork time
* Removed redundant if from asset_evaluator and fixed db_notify
* fixed duplicate code in fee_tests
* removed redundant tgenesis file
* Enable building on Ubuntu 18.04 using GCC 7 compiler
* fix: is_benefactor_reward had the default value of true when not set
* Docker file for Ubuntu 18.04
Base image updated to Unbuntu 18.04
Prerequisite list updated
Basic configuration updated
* Quick fix: Added missing package pkg-config
* Docker file updates
* 5050 fee update and compilation error fix
* Dockerfile, set system locale
Prevents locale::facet::_S_create_c_locale name error
* Update README.md
Fix typo
* Update README.md
* Changed hardfork time for SWEEPS and Core-429
* revert master changes that were brought in previous commit
* Fixed error when account_history_object with id 0 doesnt exist
* Fixed error while loading object database
* test for zero id object in account history
* Reorder operations in Dockerfile, to make image creation faster
- Reorder prevents unnecessary building of Boost libraries
* Fix for irrelevant signature included issue
* fix copyrigth messages order
* remove double empty lines
* Backport fix for `get_account_history` from https://github.com/bitshares/bitshares-core/pull/628 and add additional account history test case
* NTP client back
* GRPH-53-Log_format_error
* Merge pull request #1036 from jmjatlanta/issue_730
Add fail_reason to proposal_object
* Unit test case fixes and prepared SONs base
* Use offsetof instead of custom macro
* Hide some compiler warnings
* Make all the tests compile
* Add nullptr check in api.cpp for easier testing
* Add test case for broadcast_trx_with_callback API
* Unit test case fixes and prepared SONs base
* Merge pull request #714 from pmconrad/json_fix
JSON fix
* Increase max depth for trx confirmation callback
* Adapt to variant API with `max_depth` argument
* Update fc submodule
* Created unit test for #325
* remove needless find()
* GRPH-4-CliWallet_crash_ctrlD
* fix copyright message
* Make all the tests compile
* increase delay for node connection
* Increase block creation timeout to 2500ms
* remove cache from cli get_account
* add cli tests framework
* Adjust newly merged code to new API
* Improved resilience of block database against corruption
* Merged changes from Bitshares PR 1036
* GRPH-76 - Short-cut long sequences of missed blocks
Fixes database::update_global_dynamic_data to speed up counting missed blocks.
(This also fixes a minor issue with counting - the previous algorithm would skip missed blocks for the witness who signed the first block after the gap.)
* Moved reindex logic into database / chain_database, make use of additional blocks in block_database
Fixed tests wrt db.open
* Enable undo + fork database for final blocks in a replay
Dont remove blocks from block db when popping blocks, handle edge case in replay wrt fork_db, adapted unit tests
* Log starting block number of replay
* Prevent unsigned integer underflow
* Fixed lock detection
* Dont leave _data_dir empty if db is locked
* Writing the object_database is now almost atomic
* Improved consistency check for block_log
* Cut back block_log index file if inconsistent
* Fixed undo_database
* Added test case for broken merge on empty undo_db
* Merge pull request #938 from bitshares/fix-block-storing
Store correct block ID when switching forks
* exclude second undo_db.enable() call in some cases
* Add missing change
* change bitshares to core in message
* Fixed integer overflow issue
* Fix for for history ID mismatch ( Bitshares PR #875 )
* Update the FC submodule with the changes for GRPH-4
* Fix #436 object_database created outside of witness data directory
* supplement more comments on database::_opened variable
* prevent segfault when destructing application obj
* Fixed duplicate ops returned from get_account_history
* minor performance improvement
* Added comment
* Merged Bitshares PR #1462 and compilation fixes
* Support/gitlab (#123)
* Updated gitlab process
* Fix undefined references in cli test
* Fixed test failures and compilation issue
* Fixed account_history_pagination test
* Fix compilation in debug mode
* Removed unrelated comment
* Skip auth check when pushing self-generated blocks
* Extract public keys before pushing a transaction
* Dereference chain_database shared_ptr
* Updated transaction::signees to mutable
and
* updated get_signature_keys() to return a const reference,
* get_signature_keys() will update signees on first call,
* modified test cases and wallet.cpp accordingly,
* no longer construct a new signed_transaction object before pushing
* Added get_asset_count API
* Allow sufficient space for new undo_session
* Throw for deep nesting
* No longer extract public keys before pushing a trx
and removed unused new added constructor and _get_signature_keys() function from signed_transaction struct
* Added cli_test to CI
* use random port numbers in app_test (#154)
* proposal fail_reason bug fixed (#157)
* Added Sonarcloud code_quality to CI (#159)
* Added sonarcloud analysis (#158)
* fix for lottery end
* fix declarations
* fix declarations
* fix boost integer
* fix compilation
* fix chain tests
* fix app_test
* try to fix cli test
* fix incorrect max_depth param
* working cli test
* correct fc version
2019-10-08 01:25:03 +00:00
|
|
|
// copied from bitshares. (https://github.com/bitshares/bitshares-core/issues/429)
|
2017-10-18 22:01:32 +00:00
|
|
|
void asset_create_evaluator::pay_fee()
|
|
|
|
|
{
|
2017-10-21 11:11:21 +00:00
|
|
|
fee_is_odd = core_fee_paid.value & 1;
|
2017-10-18 22:01:32 +00:00
|
|
|
core_fee_paid -= core_fee_paid.value/2;
|
|
|
|
|
generic_evaluator::pay_fee();
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-08 15:50:35 +00:00
|
|
|
object_id_type asset_create_evaluator::do_apply( const asset_create_operation& op )
|
[SON-107] Merge develop branch to SONs-base (#166)
* fix rng and get_winner_numbers implemented
* coipied code for bitshares fixing 429 and 433 isuues
* ticket_purchase_operation implemented. added lottery_options to asset
* lottery end implemented
* minor logic changes. added db_api and cli_wallet methods
* fix reindex on peerplays network
* fix some tests. add gitlab-ci.yml
* add pull to gitlab-ci
* fix
* fix and comment some tests
* added owner to lottery_asset_options. commented async call in on_applied_block callback
* added get_account_lotteries method to db_api and cli, lottery end_date and ticket_price verification
* merge get_account_lotteries branch. fix create_witness test
* fix test genesis and end_date verification
* fixed indices sorting and lottery end checking by date
* update db_version for replay and removed duplicate include files
* Added ntp and upgraded boost version
* Revert "GPOS protocol"
* need to remove backup files
* virtual-op-fix for deterministic virtual_op number
* Merged beatrice into 5050
* Updated gitmodules, changes to allow voting on lottery fee
* Removed submodule libraries/fc
* Added libraries/fc
* added missing , in types.hpp
* Added sweeps parameters to parameter_extension
* added missing comma in operations.hpp, small changes to config.hpp
* fixed returntype in chain_parameters.hpp
* removed sweeps_parameter_extensions
* Changed fc library
* fixed asset_object
* Changed peerplays-fc submodule
* Changed fc submodule to ubuntu 18.04 upgrade
* Removed submodule libraries/fc
* Added fc library back
* fix casting in overloaded function
* Removed blind_sign and unblind_signature functions
* Added new lottery_asset_create_operation
* Changed sweeps hardfork time
* Removed redundant if from asset_evaluator and fixed db_notify
* fixed duplicate code in fee_tests
* removed redundant tgenesis file
* Enable building on Ubuntu 18.04 using GCC 7 compiler
* fix: is_benefactor_reward had the default value of true when not set
* Docker file for Ubuntu 18.04
Base image updated to Unbuntu 18.04
Prerequisite list updated
Basic configuration updated
* Quick fix: Added missing package pkg-config
* Docker file updates
* 5050 fee update and compilation error fix
* Dockerfile, set system locale
Prevents locale::facet::_S_create_c_locale name error
* Update README.md
Fix typo
* Update README.md
* Changed hardfork time for SWEEPS and Core-429
* revert master changes that were brought in previous commit
* Fixed error when account_history_object with id 0 doesnt exist
* Fixed error while loading object database
* test for zero id object in account history
* Reorder operations in Dockerfile, to make image creation faster
- Reorder prevents unnecessary building of Boost libraries
* Fix for irrelevant signature included issue
* fix copyrigth messages order
* remove double empty lines
* Backport fix for `get_account_history` from https://github.com/bitshares/bitshares-core/pull/628 and add additional account history test case
* NTP client back
* GRPH-53-Log_format_error
* Merge pull request #1036 from jmjatlanta/issue_730
Add fail_reason to proposal_object
* Unit test case fixes and prepared SONs base
* Use offsetof instead of custom macro
* Hide some compiler warnings
* Make all the tests compile
* Add nullptr check in api.cpp for easier testing
* Add test case for broadcast_trx_with_callback API
* Unit test case fixes and prepared SONs base
* Merge pull request #714 from pmconrad/json_fix
JSON fix
* Increase max depth for trx confirmation callback
* Adapt to variant API with `max_depth` argument
* Update fc submodule
* Created unit test for #325
* remove needless find()
* GRPH-4-CliWallet_crash_ctrlD
* fix copyright message
* Make all the tests compile
* increase delay for node connection
* Increase block creation timeout to 2500ms
* remove cache from cli get_account
* add cli tests framework
* Adjust newly merged code to new API
* Improved resilience of block database against corruption
* Merged changes from Bitshares PR 1036
* GRPH-76 - Short-cut long sequences of missed blocks
Fixes database::update_global_dynamic_data to speed up counting missed blocks.
(This also fixes a minor issue with counting - the previous algorithm would skip missed blocks for the witness who signed the first block after the gap.)
* Moved reindex logic into database / chain_database, make use of additional blocks in block_database
Fixed tests wrt db.open
* Enable undo + fork database for final blocks in a replay
Dont remove blocks from block db when popping blocks, handle edge case in replay wrt fork_db, adapted unit tests
* Log starting block number of replay
* Prevent unsigned integer underflow
* Fixed lock detection
* Dont leave _data_dir empty if db is locked
* Writing the object_database is now almost atomic
* Improved consistency check for block_log
* Cut back block_log index file if inconsistent
* Fixed undo_database
* Added test case for broken merge on empty undo_db
* Merge pull request #938 from bitshares/fix-block-storing
Store correct block ID when switching forks
* exclude second undo_db.enable() call in some cases
* Add missing change
* change bitshares to core in message
* Fixed integer overflow issue
* Fix for for history ID mismatch ( Bitshares PR #875 )
* Update the FC submodule with the changes for GRPH-4
* Fix #436 object_database created outside of witness data directory
* supplement more comments on database::_opened variable
* prevent segfault when destructing application obj
* Fixed duplicate ops returned from get_account_history
* minor performance improvement
* Added comment
* Merged Bitshares PR #1462 and compilation fixes
* Support/gitlab (#123)
* Updated gitlab process
* Fix undefined references in cli test
* Fixed test failures and compilation issue
* Fixed account_history_pagination test
* Fix compilation in debug mode
* Removed unrelated comment
* Skip auth check when pushing self-generated blocks
* Extract public keys before pushing a transaction
* Dereference chain_database shared_ptr
* Updated transaction::signees to mutable
and
* updated get_signature_keys() to return a const reference,
* get_signature_keys() will update signees on first call,
* modified test cases and wallet.cpp accordingly,
* no longer construct a new signed_transaction object before pushing
* Added get_asset_count API
* Allow sufficient space for new undo_session
* Throw for deep nesting
* No longer extract public keys before pushing a trx
and removed unused new added constructor and _get_signature_keys() function from signed_transaction struct
* Added cli_test to CI
* use random port numbers in app_test (#154)
* proposal fail_reason bug fixed (#157)
* Added Sonarcloud code_quality to CI (#159)
* Added sonarcloud analysis (#158)
* fix for lottery end
* fix declarations
* fix declarations
* fix boost integer
* fix compilation
* fix chain tests
* fix app_test
* try to fix cli test
* fix incorrect max_depth param
* working cli test
* correct fc version
2019-10-08 01:25:03 +00:00
|
|
|
{ try {
|
|
|
|
|
// includes changes from bitshares. (https://github.com/bitshares/bitshares-core/issues/429)
|
|
|
|
|
bool hf_429 = fee_is_odd && db().head_block_time() > HARDFORK_CORE_429_TIME;
|
|
|
|
|
|
|
|
|
|
const asset_dynamic_data_object& dyn_asset =
|
|
|
|
|
db().create<asset_dynamic_data_object>( [&]( asset_dynamic_data_object& a ) {
|
|
|
|
|
a.current_supply = 0;
|
|
|
|
|
a.fee_pool = core_fee_paid - (hf_429 ? 1 : 0);
|
|
|
|
|
});
|
|
|
|
|
if( fee_is_odd && !hf_429 )
|
|
|
|
|
{
|
|
|
|
|
const auto& core_dd = db().get<asset_object>( asset_id_type() ).dynamic_data( db() );
|
|
|
|
|
db().modify( core_dd, [=]( asset_dynamic_data_object& dd ) {
|
|
|
|
|
dd.current_supply++;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
asset_bitasset_data_id_type bit_asset_id;
|
|
|
|
|
if( op.bitasset_opts.valid() )
|
|
|
|
|
bit_asset_id = db().create<asset_bitasset_data_object>( [&]( asset_bitasset_data_object& a ) {
|
|
|
|
|
a.options = *op.bitasset_opts;
|
|
|
|
|
a.is_prediction_market = op.is_prediction_market;
|
|
|
|
|
}).id;
|
|
|
|
|
|
|
|
|
|
auto next_asset_id = db().get_index_type<asset_index>().get_next_id();
|
|
|
|
|
|
|
|
|
|
const asset_object& new_asset =
|
|
|
|
|
db().create<asset_object>( [&]( asset_object& a ) {
|
|
|
|
|
a.issuer = op.issuer;
|
|
|
|
|
a.symbol = op.symbol;
|
|
|
|
|
a.precision = op.precision;
|
|
|
|
|
a.options = op.common_options;
|
|
|
|
|
|
|
|
|
|
if( a.options.core_exchange_rate.base.asset_id.instance.value == 0 )
|
|
|
|
|
a.options.core_exchange_rate.quote.asset_id = next_asset_id;
|
|
|
|
|
else
|
|
|
|
|
a.options.core_exchange_rate.base.asset_id = next_asset_id;
|
|
|
|
|
|
|
|
|
|
a.dynamic_asset_data_id = dyn_asset.id;
|
|
|
|
|
|
|
|
|
|
if( op.bitasset_opts.valid() )
|
|
|
|
|
a.bitasset_data_id = bit_asset_id;
|
|
|
|
|
});
|
|
|
|
|
assert( new_asset.id == next_asset_id );
|
|
|
|
|
|
|
|
|
|
return new_asset.id;
|
|
|
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
|
|
|
|
|
|
|
|
|
void_result lottery_asset_create_evaluator::do_evaluate( const lottery_asset_create_operation& op )
|
|
|
|
|
{ try {
|
|
|
|
|
|
|
|
|
|
database& d = db();
|
|
|
|
|
|
|
|
|
|
const auto& chain_parameters = d.get_global_properties().parameters;
|
|
|
|
|
FC_ASSERT( op.common_options.whitelist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities );
|
|
|
|
|
FC_ASSERT( op.common_options.blacklist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities );
|
|
|
|
|
|
|
|
|
|
// Check that all authorities do exist
|
|
|
|
|
for( auto id : op.common_options.whitelist_authorities )
|
|
|
|
|
d.get_object(id);
|
|
|
|
|
for( auto id : op.common_options.blacklist_authorities )
|
|
|
|
|
d.get_object(id);
|
|
|
|
|
|
|
|
|
|
auto& asset_indx = d.get_index_type<asset_index>().indices().get<by_symbol>();
|
|
|
|
|
auto asset_symbol_itr = asset_indx.find( op.symbol );
|
|
|
|
|
FC_ASSERT( asset_symbol_itr == asset_indx.end() );
|
|
|
|
|
|
|
|
|
|
if( d.head_block_time() > HARDFORK_385_TIME )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if( d.head_block_time() <= HARDFORK_409_TIME )
|
|
|
|
|
{
|
|
|
|
|
auto dotpos = op.symbol.find( '.' );
|
|
|
|
|
if( dotpos != std::string::npos )
|
|
|
|
|
{
|
|
|
|
|
auto prefix = op.symbol.substr( 0, dotpos );
|
|
|
|
|
auto asset_symbol_itr = asset_indx.find( op.symbol );
|
|
|
|
|
FC_ASSERT( asset_symbol_itr != asset_indx.end(), "Asset ${s} may only be created by issuer of ${p}, but ${p} has not been registered",
|
|
|
|
|
("s",op.symbol)("p",prefix) );
|
|
|
|
|
FC_ASSERT( asset_symbol_itr->issuer == op.issuer, "Asset ${s} may only be created by issuer of ${p}, ${i}",
|
|
|
|
|
("s",op.symbol)("p",prefix)("i", op.issuer(d).name) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
auto dotpos = op.symbol.rfind( '.' );
|
|
|
|
|
if( dotpos != std::string::npos )
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
auto prefix = op.symbol.substr( 0, dotpos );
|
|
|
|
|
auto asset_symbol_itr = asset_indx.find( prefix );
|
|
|
|
|
FC_ASSERT( asset_symbol_itr != asset_indx.end(), "Asset ${s} may only be created by issuer of ${p}, but ${p} has not been registered",
|
|
|
|
|
("s",op.symbol)("p",prefix) );
|
|
|
|
|
FC_ASSERT( asset_symbol_itr->issuer == op.issuer, "Asset ${s} may only be created by issuer of ${p}, ${i}",
|
|
|
|
|
("s",op.symbol)("p",prefix)("i", op.issuer(d).name) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
auto dotpos = op.symbol.find( '.' );
|
|
|
|
|
if( dotpos != std::string::npos )
|
|
|
|
|
wlog( "Asset ${s} has a name which requires hardfork 385", ("s",op.symbol) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// core_fee_paid -= core_fee_paid.value/2;
|
|
|
|
|
|
|
|
|
|
if( op.bitasset_opts )
|
|
|
|
|
{
|
|
|
|
|
const asset_object& backing = op.bitasset_opts->short_backing_asset(d);
|
|
|
|
|
if( backing.is_market_issued() )
|
|
|
|
|
{
|
|
|
|
|
const asset_bitasset_data_object& backing_bitasset_data = backing.bitasset_data(d);
|
|
|
|
|
const asset_object& backing_backing = backing_bitasset_data.options.short_backing_asset(d);
|
|
|
|
|
FC_ASSERT( !backing_backing.is_market_issued(),
|
|
|
|
|
"May not create a bitasset backed by a bitasset backed by a bitasset." );
|
|
|
|
|
FC_ASSERT( op.issuer != GRAPHENE_COMMITTEE_ACCOUNT || backing_backing.get_id() == asset_id_type(),
|
|
|
|
|
"May not create a blockchain-controlled market asset which is not backed by CORE.");
|
|
|
|
|
} else
|
|
|
|
|
FC_ASSERT( op.issuer != GRAPHENE_COMMITTEE_ACCOUNT || backing.get_id() == asset_id_type(),
|
|
|
|
|
"May not create a blockchain-controlled market asset which is not backed by CORE.");
|
|
|
|
|
FC_ASSERT( op.bitasset_opts->feed_lifetime_sec > chain_parameters.block_interval &&
|
|
|
|
|
op.bitasset_opts->force_settlement_delay_sec > chain_parameters.block_interval );
|
|
|
|
|
}
|
|
|
|
|
if( op.is_prediction_market )
|
|
|
|
|
{
|
|
|
|
|
FC_ASSERT( op.bitasset_opts );
|
|
|
|
|
FC_ASSERT( op.precision == op.bitasset_opts->short_backing_asset(d).precision );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FC_ASSERT( op.common_options.max_supply >= 5 );
|
|
|
|
|
auto lottery_options = op.extensions;
|
|
|
|
|
lottery_options.validate();
|
|
|
|
|
FC_ASSERT( lottery_options.end_date > d.head_block_time() || lottery_options.end_date == time_point_sec() );
|
|
|
|
|
|
|
|
|
|
return void_result();
|
|
|
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
|
|
|
|
|
|
|
|
|
// copied from bitshares. (https://github.com/bitshares/bitshares-core/issues/429)
|
|
|
|
|
void lottery_asset_create_evaluator::pay_fee()
|
|
|
|
|
{
|
|
|
|
|
fee_is_odd = core_fee_paid.value & 1;
|
|
|
|
|
core_fee_paid -= core_fee_paid.value/2;
|
|
|
|
|
generic_evaluator::pay_fee();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_id_type lottery_asset_create_evaluator::do_apply( const lottery_asset_create_operation& op )
|
2015-06-23 21:33:06 +00:00
|
|
|
{ try {
|
2015-06-08 15:50:35 +00:00
|
|
|
const asset_dynamic_data_object& dyn_asset =
|
|
|
|
|
db().create<asset_dynamic_data_object>( [&]( asset_dynamic_data_object& a ) {
|
|
|
|
|
a.current_supply = 0;
|
2018-03-23 14:13:45 +00:00
|
|
|
a.fee_pool = core_fee_paid - (fee_is_odd ? 1 : 0);
|
2015-06-08 15:50:35 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
asset_bitasset_data_id_type bit_asset_id;
|
2015-07-09 17:50:47 +00:00
|
|
|
if( op.bitasset_opts.valid() )
|
2015-06-08 15:50:35 +00:00
|
|
|
bit_asset_id = db().create<asset_bitasset_data_object>( [&]( asset_bitasset_data_object& a ) {
|
2015-07-09 17:50:47 +00:00
|
|
|
a.options = *op.bitasset_opts;
|
2015-06-08 15:50:35 +00:00
|
|
|
a.is_prediction_market = op.is_prediction_market;
|
|
|
|
|
}).id;
|
|
|
|
|
|
|
|
|
|
auto next_asset_id = db().get_index_type<asset_index>().get_next_id();
|
|
|
|
|
|
|
|
|
|
const asset_object& new_asset =
|
|
|
|
|
db().create<asset_object>( [&]( asset_object& a ) {
|
|
|
|
|
a.issuer = op.issuer;
|
|
|
|
|
a.symbol = op.symbol;
|
|
|
|
|
a.precision = op.precision;
|
|
|
|
|
a.options = op.common_options;
|
[SON-107] Merge develop branch to SONs-base (#166)
* fix rng and get_winner_numbers implemented
* coipied code for bitshares fixing 429 and 433 isuues
* ticket_purchase_operation implemented. added lottery_options to asset
* lottery end implemented
* minor logic changes. added db_api and cli_wallet methods
* fix reindex on peerplays network
* fix some tests. add gitlab-ci.yml
* add pull to gitlab-ci
* fix
* fix and comment some tests
* added owner to lottery_asset_options. commented async call in on_applied_block callback
* added get_account_lotteries method to db_api and cli, lottery end_date and ticket_price verification
* merge get_account_lotteries branch. fix create_witness test
* fix test genesis and end_date verification
* fixed indices sorting and lottery end checking by date
* update db_version for replay and removed duplicate include files
* Added ntp and upgraded boost version
* Revert "GPOS protocol"
* need to remove backup files
* virtual-op-fix for deterministic virtual_op number
* Merged beatrice into 5050
* Updated gitmodules, changes to allow voting on lottery fee
* Removed submodule libraries/fc
* Added libraries/fc
* added missing , in types.hpp
* Added sweeps parameters to parameter_extension
* added missing comma in operations.hpp, small changes to config.hpp
* fixed returntype in chain_parameters.hpp
* removed sweeps_parameter_extensions
* Changed fc library
* fixed asset_object
* Changed peerplays-fc submodule
* Changed fc submodule to ubuntu 18.04 upgrade
* Removed submodule libraries/fc
* Added fc library back
* fix casting in overloaded function
* Removed blind_sign and unblind_signature functions
* Added new lottery_asset_create_operation
* Changed sweeps hardfork time
* Removed redundant if from asset_evaluator and fixed db_notify
* fixed duplicate code in fee_tests
* removed redundant tgenesis file
* Enable building on Ubuntu 18.04 using GCC 7 compiler
* fix: is_benefactor_reward had the default value of true when not set
* Docker file for Ubuntu 18.04
Base image updated to Unbuntu 18.04
Prerequisite list updated
Basic configuration updated
* Quick fix: Added missing package pkg-config
* Docker file updates
* 5050 fee update and compilation error fix
* Dockerfile, set system locale
Prevents locale::facet::_S_create_c_locale name error
* Update README.md
Fix typo
* Update README.md
* Changed hardfork time for SWEEPS and Core-429
* revert master changes that were brought in previous commit
* Fixed error when account_history_object with id 0 doesnt exist
* Fixed error while loading object database
* test for zero id object in account history
* Reorder operations in Dockerfile, to make image creation faster
- Reorder prevents unnecessary building of Boost libraries
* Fix for irrelevant signature included issue
* fix copyrigth messages order
* remove double empty lines
* Backport fix for `get_account_history` from https://github.com/bitshares/bitshares-core/pull/628 and add additional account history test case
* NTP client back
* GRPH-53-Log_format_error
* Merge pull request #1036 from jmjatlanta/issue_730
Add fail_reason to proposal_object
* Unit test case fixes and prepared SONs base
* Use offsetof instead of custom macro
* Hide some compiler warnings
* Make all the tests compile
* Add nullptr check in api.cpp for easier testing
* Add test case for broadcast_trx_with_callback API
* Unit test case fixes and prepared SONs base
* Merge pull request #714 from pmconrad/json_fix
JSON fix
* Increase max depth for trx confirmation callback
* Adapt to variant API with `max_depth` argument
* Update fc submodule
* Created unit test for #325
* remove needless find()
* GRPH-4-CliWallet_crash_ctrlD
* fix copyright message
* Make all the tests compile
* increase delay for node connection
* Increase block creation timeout to 2500ms
* remove cache from cli get_account
* add cli tests framework
* Adjust newly merged code to new API
* Improved resilience of block database against corruption
* Merged changes from Bitshares PR 1036
* GRPH-76 - Short-cut long sequences of missed blocks
Fixes database::update_global_dynamic_data to speed up counting missed blocks.
(This also fixes a minor issue with counting - the previous algorithm would skip missed blocks for the witness who signed the first block after the gap.)
* Moved reindex logic into database / chain_database, make use of additional blocks in block_database
Fixed tests wrt db.open
* Enable undo + fork database for final blocks in a replay
Dont remove blocks from block db when popping blocks, handle edge case in replay wrt fork_db, adapted unit tests
* Log starting block number of replay
* Prevent unsigned integer underflow
* Fixed lock detection
* Dont leave _data_dir empty if db is locked
* Writing the object_database is now almost atomic
* Improved consistency check for block_log
* Cut back block_log index file if inconsistent
* Fixed undo_database
* Added test case for broken merge on empty undo_db
* Merge pull request #938 from bitshares/fix-block-storing
Store correct block ID when switching forks
* exclude second undo_db.enable() call in some cases
* Add missing change
* change bitshares to core in message
* Fixed integer overflow issue
* Fix for for history ID mismatch ( Bitshares PR #875 )
* Update the FC submodule with the changes for GRPH-4
* Fix #436 object_database created outside of witness data directory
* supplement more comments on database::_opened variable
* prevent segfault when destructing application obj
* Fixed duplicate ops returned from get_account_history
* minor performance improvement
* Added comment
* Merged Bitshares PR #1462 and compilation fixes
* Support/gitlab (#123)
* Updated gitlab process
* Fix undefined references in cli test
* Fixed test failures and compilation issue
* Fixed account_history_pagination test
* Fix compilation in debug mode
* Removed unrelated comment
* Skip auth check when pushing self-generated blocks
* Extract public keys before pushing a transaction
* Dereference chain_database shared_ptr
* Updated transaction::signees to mutable
and
* updated get_signature_keys() to return a const reference,
* get_signature_keys() will update signees on first call,
* modified test cases and wallet.cpp accordingly,
* no longer construct a new signed_transaction object before pushing
* Added get_asset_count API
* Allow sufficient space for new undo_session
* Throw for deep nesting
* No longer extract public keys before pushing a trx
and removed unused new added constructor and _get_signature_keys() function from signed_transaction struct
* Added cli_test to CI
* use random port numbers in app_test (#154)
* proposal fail_reason bug fixed (#157)
* Added Sonarcloud code_quality to CI (#159)
* Added sonarcloud analysis (#158)
* fix for lottery end
* fix declarations
* fix declarations
* fix boost integer
* fix compilation
* fix chain tests
* fix app_test
* try to fix cli test
* fix incorrect max_depth param
* working cli test
* correct fc version
2019-10-08 01:25:03 +00:00
|
|
|
a.precision = 0;
|
|
|
|
|
a.lottery_options = op.extensions;
|
|
|
|
|
//a.lottery_options->balance = asset( 0, a.lottery_options->ticket_price.asset_id );
|
|
|
|
|
a.lottery_options->owner = a.id;
|
|
|
|
|
db().create<lottery_balance_object>([&](lottery_balance_object& lbo) {
|
|
|
|
|
lbo.lottery_id = a.id;
|
|
|
|
|
});
|
2015-06-08 15:50:35 +00:00
|
|
|
if( a.options.core_exchange_rate.base.asset_id.instance.value == 0 )
|
|
|
|
|
a.options.core_exchange_rate.quote.asset_id = next_asset_id;
|
|
|
|
|
else
|
|
|
|
|
a.options.core_exchange_rate.base.asset_id = next_asset_id;
|
|
|
|
|
a.dynamic_asset_data_id = dyn_asset.id;
|
2015-07-09 17:50:47 +00:00
|
|
|
if( op.bitasset_opts.valid() )
|
2015-06-08 15:50:35 +00:00
|
|
|
a.bitasset_data_id = bit_asset_id;
|
|
|
|
|
});
|
|
|
|
|
assert( new_asset.id == next_asset_id );
|
|
|
|
|
|
2015-06-23 21:33:06 +00:00
|
|
|
return new_asset.id;
|
|
|
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_issue_evaluator::do_evaluate( const asset_issue_operation& o )
|
2015-06-08 15:50:35 +00:00
|
|
|
{ try {
|
2015-10-30 17:10:09 +00:00
|
|
|
const database& d = db();
|
2015-06-08 15:50:35 +00:00
|
|
|
|
|
|
|
|
const asset_object& a = o.asset_to_issue.asset_id(d);
|
|
|
|
|
FC_ASSERT( o.issuer == a.issuer );
|
|
|
|
|
FC_ASSERT( !a.is_market_issued(), "Cannot manually issue a market-issued asset." );
|
[SON-107] Merge develop branch to SONs-base (#166)
* fix rng and get_winner_numbers implemented
* coipied code for bitshares fixing 429 and 433 isuues
* ticket_purchase_operation implemented. added lottery_options to asset
* lottery end implemented
* minor logic changes. added db_api and cli_wallet methods
* fix reindex on peerplays network
* fix some tests. add gitlab-ci.yml
* add pull to gitlab-ci
* fix
* fix and comment some tests
* added owner to lottery_asset_options. commented async call in on_applied_block callback
* added get_account_lotteries method to db_api and cli, lottery end_date and ticket_price verification
* merge get_account_lotteries branch. fix create_witness test
* fix test genesis and end_date verification
* fixed indices sorting and lottery end checking by date
* update db_version for replay and removed duplicate include files
* Added ntp and upgraded boost version
* Revert "GPOS protocol"
* need to remove backup files
* virtual-op-fix for deterministic virtual_op number
* Merged beatrice into 5050
* Updated gitmodules, changes to allow voting on lottery fee
* Removed submodule libraries/fc
* Added libraries/fc
* added missing , in types.hpp
* Added sweeps parameters to parameter_extension
* added missing comma in operations.hpp, small changes to config.hpp
* fixed returntype in chain_parameters.hpp
* removed sweeps_parameter_extensions
* Changed fc library
* fixed asset_object
* Changed peerplays-fc submodule
* Changed fc submodule to ubuntu 18.04 upgrade
* Removed submodule libraries/fc
* Added fc library back
* fix casting in overloaded function
* Removed blind_sign and unblind_signature functions
* Added new lottery_asset_create_operation
* Changed sweeps hardfork time
* Removed redundant if from asset_evaluator and fixed db_notify
* fixed duplicate code in fee_tests
* removed redundant tgenesis file
* Enable building on Ubuntu 18.04 using GCC 7 compiler
* fix: is_benefactor_reward had the default value of true when not set
* Docker file for Ubuntu 18.04
Base image updated to Unbuntu 18.04
Prerequisite list updated
Basic configuration updated
* Quick fix: Added missing package pkg-config
* Docker file updates
* 5050 fee update and compilation error fix
* Dockerfile, set system locale
Prevents locale::facet::_S_create_c_locale name error
* Update README.md
Fix typo
* Update README.md
* Changed hardfork time for SWEEPS and Core-429
* revert master changes that were brought in previous commit
* Fixed error when account_history_object with id 0 doesnt exist
* Fixed error while loading object database
* test for zero id object in account history
* Reorder operations in Dockerfile, to make image creation faster
- Reorder prevents unnecessary building of Boost libraries
* Fix for irrelevant signature included issue
* fix copyrigth messages order
* remove double empty lines
* Backport fix for `get_account_history` from https://github.com/bitshares/bitshares-core/pull/628 and add additional account history test case
* NTP client back
* GRPH-53-Log_format_error
* Merge pull request #1036 from jmjatlanta/issue_730
Add fail_reason to proposal_object
* Unit test case fixes and prepared SONs base
* Use offsetof instead of custom macro
* Hide some compiler warnings
* Make all the tests compile
* Add nullptr check in api.cpp for easier testing
* Add test case for broadcast_trx_with_callback API
* Unit test case fixes and prepared SONs base
* Merge pull request #714 from pmconrad/json_fix
JSON fix
* Increase max depth for trx confirmation callback
* Adapt to variant API with `max_depth` argument
* Update fc submodule
* Created unit test for #325
* remove needless find()
* GRPH-4-CliWallet_crash_ctrlD
* fix copyright message
* Make all the tests compile
* increase delay for node connection
* Increase block creation timeout to 2500ms
* remove cache from cli get_account
* add cli tests framework
* Adjust newly merged code to new API
* Improved resilience of block database against corruption
* Merged changes from Bitshares PR 1036
* GRPH-76 - Short-cut long sequences of missed blocks
Fixes database::update_global_dynamic_data to speed up counting missed blocks.
(This also fixes a minor issue with counting - the previous algorithm would skip missed blocks for the witness who signed the first block after the gap.)
* Moved reindex logic into database / chain_database, make use of additional blocks in block_database
Fixed tests wrt db.open
* Enable undo + fork database for final blocks in a replay
Dont remove blocks from block db when popping blocks, handle edge case in replay wrt fork_db, adapted unit tests
* Log starting block number of replay
* Prevent unsigned integer underflow
* Fixed lock detection
* Dont leave _data_dir empty if db is locked
* Writing the object_database is now almost atomic
* Improved consistency check for block_log
* Cut back block_log index file if inconsistent
* Fixed undo_database
* Added test case for broken merge on empty undo_db
* Merge pull request #938 from bitshares/fix-block-storing
Store correct block ID when switching forks
* exclude second undo_db.enable() call in some cases
* Add missing change
* change bitshares to core in message
* Fixed integer overflow issue
* Fix for for history ID mismatch ( Bitshares PR #875 )
* Update the FC submodule with the changes for GRPH-4
* Fix #436 object_database created outside of witness data directory
* supplement more comments on database::_opened variable
* prevent segfault when destructing application obj
* Fixed duplicate ops returned from get_account_history
* minor performance improvement
* Added comment
* Merged Bitshares PR #1462 and compilation fixes
* Support/gitlab (#123)
* Updated gitlab process
* Fix undefined references in cli test
* Fixed test failures and compilation issue
* Fixed account_history_pagination test
* Fix compilation in debug mode
* Removed unrelated comment
* Skip auth check when pushing self-generated blocks
* Extract public keys before pushing a transaction
* Dereference chain_database shared_ptr
* Updated transaction::signees to mutable
and
* updated get_signature_keys() to return a const reference,
* get_signature_keys() will update signees on first call,
* modified test cases and wallet.cpp accordingly,
* no longer construct a new signed_transaction object before pushing
* Added get_asset_count API
* Allow sufficient space for new undo_session
* Throw for deep nesting
* No longer extract public keys before pushing a trx
and removed unused new added constructor and _get_signature_keys() function from signed_transaction struct
* Added cli_test to CI
* use random port numbers in app_test (#154)
* proposal fail_reason bug fixed (#157)
* Added Sonarcloud code_quality to CI (#159)
* Added sonarcloud analysis (#158)
* fix for lottery end
* fix declarations
* fix declarations
* fix boost integer
* fix compilation
* fix chain tests
* fix app_test
* try to fix cli test
* fix incorrect max_depth param
* working cli test
* correct fc version
2019-10-08 01:25:03 +00:00
|
|
|
FC_ASSERT( !a.is_lottery(), "Cannot manually issue a lottery asset." );
|
2015-06-08 15:50:35 +00:00
|
|
|
|
|
|
|
|
to_account = &o.issue_to_account(d);
|
2016-02-11 08:12:18 +00:00
|
|
|
FC_ASSERT( is_authorized_asset( d, *to_account, a ) );
|
2015-06-08 15:50:35 +00:00
|
|
|
|
|
|
|
|
asset_dyn_data = &a.dynamic_asset_data_id(d);
|
|
|
|
|
FC_ASSERT( (asset_dyn_data->current_supply + o.asset_to_issue.amount) <= a.options.max_supply );
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-08 15:50:35 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_issue_evaluator::do_apply( const asset_issue_operation& o )
|
2015-06-23 21:33:06 +00:00
|
|
|
{ try {
|
2015-06-08 15:50:35 +00:00
|
|
|
db().adjust_balance( o.issue_to_account, o.asset_to_issue );
|
|
|
|
|
|
|
|
|
|
db().modify( *asset_dyn_data, [&]( asset_dynamic_data_object& data ){
|
|
|
|
|
data.current_supply += o.asset_to_issue.amount;
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-23 21:33:06 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-07-01 18:43:17 +00:00
|
|
|
void_result asset_reserve_evaluator::do_evaluate( const asset_reserve_operation& o )
|
2015-06-08 15:50:35 +00:00
|
|
|
{ try {
|
2015-10-30 17:10:09 +00:00
|
|
|
const database& d = db();
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-07-01 18:43:17 +00:00
|
|
|
const asset_object& a = o.amount_to_reserve.asset_id(d);
|
2015-07-17 19:13:17 +00:00
|
|
|
GRAPHENE_ASSERT(
|
|
|
|
|
!a.is_market_issued(),
|
|
|
|
|
asset_reserve_invalid_on_mia,
|
|
|
|
|
"Cannot reserve ${sym} because it is a market-issued asset",
|
|
|
|
|
("sym", a.symbol)
|
|
|
|
|
);
|
2015-06-08 15:50:35 +00:00
|
|
|
|
|
|
|
|
from_account = &o.payer(d);
|
2016-02-11 08:12:18 +00:00
|
|
|
FC_ASSERT( is_authorized_asset( d, *from_account, a ) );
|
2015-06-08 15:50:35 +00:00
|
|
|
|
|
|
|
|
asset_dyn_data = &a.dynamic_asset_data_id(d);
|
2015-07-01 18:43:17 +00:00
|
|
|
FC_ASSERT( (asset_dyn_data->current_supply - o.amount_to_reserve.amount) >= 0 );
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-08 15:50:35 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
|
|
|
|
|
2015-07-01 18:43:17 +00:00
|
|
|
void_result asset_reserve_evaluator::do_apply( const asset_reserve_operation& o )
|
2015-06-23 21:33:06 +00:00
|
|
|
{ try {
|
2015-07-01 18:43:17 +00:00
|
|
|
db().adjust_balance( o.payer, -o.amount_to_reserve );
|
2015-06-08 15:50:35 +00:00
|
|
|
|
|
|
|
|
db().modify( *asset_dyn_data, [&]( asset_dynamic_data_object& data ){
|
2015-07-01 18:43:17 +00:00
|
|
|
data.current_supply -= o.amount_to_reserve.amount;
|
2015-06-08 15:50:35 +00:00
|
|
|
});
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-23 21:33:06 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_fund_fee_pool_evaluator::do_evaluate(const asset_fund_fee_pool_operation& o)
|
2015-06-08 15:50:35 +00:00
|
|
|
{ try {
|
|
|
|
|
database& d = db();
|
|
|
|
|
|
|
|
|
|
const asset_object& a = o.asset_id(d);
|
|
|
|
|
|
|
|
|
|
asset_dyn_data = &a.dynamic_asset_data_id(d);
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-08 15:50:35 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_fund_fee_pool_evaluator::do_apply(const asset_fund_fee_pool_operation& o)
|
2015-06-23 21:33:06 +00:00
|
|
|
{ try {
|
2015-06-08 15:50:35 +00:00
|
|
|
db().adjust_balance(o.from_account, -o.amount);
|
|
|
|
|
|
|
|
|
|
db().modify( *asset_dyn_data, [&]( asset_dynamic_data_object& data ) {
|
|
|
|
|
data.fee_pool += o.amount;
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-23 21:33:06 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_update_evaluator::do_evaluate(const asset_update_operation& o)
|
2015-06-08 15:50:35 +00:00
|
|
|
{ try {
|
|
|
|
|
database& d = db();
|
|
|
|
|
|
|
|
|
|
const asset_object& a = o.asset_to_update(d);
|
|
|
|
|
auto a_copy = a;
|
|
|
|
|
a_copy.options = o.new_options;
|
|
|
|
|
a_copy.validate();
|
|
|
|
|
|
2015-06-26 19:11:41 +00:00
|
|
|
if( o.new_issuer )
|
|
|
|
|
{
|
|
|
|
|
FC_ASSERT(d.find_object(*o.new_issuer));
|
|
|
|
|
if( a.is_market_issued() && *o.new_issuer == GRAPHENE_COMMITTEE_ACCOUNT )
|
|
|
|
|
{
|
|
|
|
|
const asset_object& backing = a.bitasset_data(d).options.short_backing_asset(d);
|
|
|
|
|
if( backing.is_market_issued() )
|
|
|
|
|
{
|
|
|
|
|
const asset_object& backing_backing = backing.bitasset_data(d).options.short_backing_asset(d);
|
|
|
|
|
FC_ASSERT( backing_backing.get_id() == asset_id_type(),
|
|
|
|
|
"May not create a blockchain-controlled market asset which is not backed by CORE.");
|
|
|
|
|
} else
|
|
|
|
|
FC_ASSERT( backing.get_id() == asset_id_type(),
|
|
|
|
|
"May not create a blockchain-controlled market asset which is not backed by CORE.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-15 01:28:37 +00:00
|
|
|
if( (d.head_block_time() < HARDFORK_572_TIME) || (a.dynamic_asset_data_id(d).current_supply != 0) )
|
|
|
|
|
{
|
|
|
|
|
// new issuer_permissions must be subset of old issuer permissions
|
|
|
|
|
FC_ASSERT(!(o.new_options.issuer_permissions & ~a.options.issuer_permissions),
|
|
|
|
|
"Cannot reinstate previously revoked issuer permissions on an asset.");
|
|
|
|
|
}
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-07-21 19:44:08 +00:00
|
|
|
// changed flags must be subset of old issuer permissions
|
|
|
|
|
FC_ASSERT(!((o.new_options.flags ^ a.options.flags) & ~a.options.issuer_permissions),
|
|
|
|
|
"Flag change is forbidden by issuer permissions");
|
|
|
|
|
|
2015-06-08 15:50:35 +00:00
|
|
|
asset_to_update = &a;
|
|
|
|
|
FC_ASSERT( o.issuer == a.issuer, "", ("o.issuer", o.issuer)("a.issuer", a.issuer) );
|
|
|
|
|
|
|
|
|
|
const auto& chain_parameters = d.get_global_properties().parameters;
|
|
|
|
|
|
|
|
|
|
FC_ASSERT( o.new_options.whitelist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities );
|
|
|
|
|
for( auto id : o.new_options.whitelist_authorities )
|
|
|
|
|
d.get_object(id);
|
|
|
|
|
FC_ASSERT( o.new_options.blacklist_authorities.size() <= chain_parameters.maximum_asset_whitelist_authorities );
|
|
|
|
|
for( auto id : o.new_options.blacklist_authorities )
|
|
|
|
|
d.get_object(id);
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-08 15:50:35 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW((o)) }
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_update_evaluator::do_apply(const asset_update_operation& o)
|
2015-06-23 21:33:06 +00:00
|
|
|
{ try {
|
2015-06-08 15:50:35 +00:00
|
|
|
database& d = db();
|
|
|
|
|
|
|
|
|
|
// If we are now disabling force settlements, cancel all open force settlement orders
|
|
|
|
|
if( o.new_options.flags & disable_force_settle && asset_to_update->can_force_settle() )
|
|
|
|
|
{
|
|
|
|
|
const auto& idx = d.get_index_type<force_settlement_index>().indices().get<by_expiration>();
|
|
|
|
|
// Funky iteration code because we're removing objects as we go. We have to re-initialize itr every loop instead
|
|
|
|
|
// of simply incrementing it.
|
|
|
|
|
for( auto itr = idx.lower_bound(o.asset_to_update);
|
|
|
|
|
itr != idx.end() && itr->settlement_asset_id() == o.asset_to_update;
|
|
|
|
|
itr = idx.lower_bound(o.asset_to_update) )
|
|
|
|
|
d.cancel_order(*itr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d.modify(*asset_to_update, [&](asset_object& a) {
|
|
|
|
|
if( o.new_issuer )
|
|
|
|
|
a.issuer = *o.new_issuer;
|
|
|
|
|
a.options = o.new_options;
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-23 21:33:06 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_update_bitasset_evaluator::do_evaluate(const asset_update_bitasset_operation& o)
|
2015-06-23 21:33:06 +00:00
|
|
|
{ try {
|
2015-06-08 15:50:35 +00:00
|
|
|
database& d = db();
|
|
|
|
|
|
|
|
|
|
const asset_object& a = o.asset_to_update(d);
|
|
|
|
|
|
|
|
|
|
FC_ASSERT(a.is_market_issued(), "Cannot update BitAsset-specific settings on a non-BitAsset.");
|
|
|
|
|
|
|
|
|
|
const asset_bitasset_data_object& b = a.bitasset_data(d);
|
2015-06-19 13:57:23 +00:00
|
|
|
FC_ASSERT( !b.has_settlement(), "Cannot update a bitasset after a settlement has executed" );
|
2015-06-08 15:50:35 +00:00
|
|
|
if( o.new_options.short_backing_asset != b.options.short_backing_asset )
|
|
|
|
|
{
|
|
|
|
|
FC_ASSERT(a.dynamic_asset_data_id(d).current_supply == 0);
|
|
|
|
|
FC_ASSERT(d.find_object(o.new_options.short_backing_asset));
|
2015-06-26 19:11:41 +00:00
|
|
|
|
|
|
|
|
if( a.issuer == GRAPHENE_COMMITTEE_ACCOUNT )
|
|
|
|
|
{
|
|
|
|
|
const asset_object& backing = a.bitasset_data(d).options.short_backing_asset(d);
|
|
|
|
|
if( backing.is_market_issued() )
|
|
|
|
|
{
|
|
|
|
|
const asset_object& backing_backing = backing.bitasset_data(d).options.short_backing_asset(d);
|
|
|
|
|
FC_ASSERT( backing_backing.get_id() == asset_id_type(),
|
|
|
|
|
"May not create a blockchain-controlled market asset which is not backed by CORE.");
|
|
|
|
|
} else
|
|
|
|
|
FC_ASSERT( backing.get_id() == asset_id_type(),
|
|
|
|
|
"May not create a blockchain-controlled market asset which is not backed by CORE.");
|
|
|
|
|
}
|
2015-06-08 15:50:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bitasset_to_update = &b;
|
|
|
|
|
FC_ASSERT( o.issuer == a.issuer, "", ("o.issuer", o.issuer)("a.issuer", a.issuer) );
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-23 21:33:06 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_update_bitasset_evaluator::do_apply(const asset_update_bitasset_operation& o)
|
2015-06-23 21:33:06 +00:00
|
|
|
{ try {
|
2015-06-30 15:59:53 +00:00
|
|
|
bool should_update_feeds = false;
|
|
|
|
|
// If the minimum number of feeds to calculate a median has changed, we need to recalculate the median
|
|
|
|
|
if( o.new_options.minimum_feeds != bitasset_to_update->options.minimum_feeds )
|
|
|
|
|
should_update_feeds = true;
|
|
|
|
|
|
|
|
|
|
db().modify(*bitasset_to_update, [&](asset_bitasset_data_object& b) {
|
2015-06-08 15:50:35 +00:00
|
|
|
b.options = o.new_options;
|
2015-06-30 15:59:53 +00:00
|
|
|
|
|
|
|
|
if( should_update_feeds )
|
|
|
|
|
b.update_median_feeds(db().head_block_time());
|
2015-06-08 15:50:35 +00:00
|
|
|
});
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-23 21:33:06 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2016-06-26 19:41:07 +00:00
|
|
|
void_result asset_update_dividend_evaluator::do_evaluate(const asset_update_dividend_operation& o)
|
|
|
|
|
{ try {
|
|
|
|
|
database& d = db();
|
|
|
|
|
|
|
|
|
|
const asset_object& a = o.asset_to_update(d);
|
|
|
|
|
asset_to_update = &a;
|
|
|
|
|
|
|
|
|
|
FC_ASSERT( o.issuer == a.issuer, "", ("o.issuer", o.issuer)("a.issuer", a.issuer) );
|
|
|
|
|
auto& params = db().get_global_properties().parameters;
|
|
|
|
|
if (o.new_options.payout_interval &&
|
|
|
|
|
*o.new_options.payout_interval < params.maintenance_interval)
|
|
|
|
|
FC_THROW("New payout interval may not be less than the maintenance interval",
|
|
|
|
|
("new_payout_interval", o.new_options.payout_interval)("maintenance_interval", params.maintenance_interval));
|
|
|
|
|
return void_result();
|
|
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
|
|
|
|
|
|
|
|
|
void_result asset_update_dividend_evaluator::do_apply( const asset_update_dividend_operation& op )
|
|
|
|
|
{ try {
|
|
|
|
|
database& d = db();
|
|
|
|
|
if (!asset_to_update->dividend_data_id)
|
|
|
|
|
{
|
|
|
|
|
// this was not a dividend-paying asset, we're converting it to a dividend-paying asset
|
|
|
|
|
std::string dividend_distribution_account_name(boost::to_lower_copy(asset_to_update->symbol) + "-dividend-distribution");
|
|
|
|
|
|
|
|
|
|
const auto& new_acnt_object = db().create<account_object>( [&]( account_object& obj ){
|
|
|
|
|
obj.registrar = op.issuer;
|
|
|
|
|
obj.referrer = op.issuer;
|
|
|
|
|
obj.lifetime_referrer = op.issuer(db()).lifetime_referrer;
|
|
|
|
|
|
|
|
|
|
auto& params = db().get_global_properties().parameters;
|
|
|
|
|
obj.network_fee_percentage = GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
|
|
|
|
|
obj.lifetime_referrer_fee_percentage = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE;
|
|
|
|
|
obj.referrer_rewards_percentage = GRAPHENE_DEFAULT_LIFETIME_REFERRER_PERCENT_OF_FEE;
|
|
|
|
|
|
|
|
|
|
obj.name = dividend_distribution_account_name;
|
|
|
|
|
obj.owner.weight_threshold = 1;
|
|
|
|
|
obj.active.weight_threshold = 1;
|
|
|
|
|
obj.statistics = db().create<account_statistics_object>([&](account_statistics_object& s){s.owner = obj.id;}).id;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const asset_dividend_data_object& dividend_data = d.create<asset_dividend_data_object>( [&]( asset_dividend_data_object& dividend_data_obj ) {
|
|
|
|
|
dividend_data_obj.options = op.new_options;
|
|
|
|
|
dividend_data_obj.dividend_distribution_account = new_acnt_object.id;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
d.modify(*asset_to_update, [&](asset_object& a) {
|
|
|
|
|
a.dividend_data_id = dividend_data.id;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const asset_dividend_data_object& dividend_data = asset_to_update->dividend_data(d);
|
|
|
|
|
d.modify(dividend_data, [&]( asset_dividend_data_object& dividend_data_obj ) {
|
|
|
|
|
dividend_data_obj.options = op.new_options;
|
2016-08-25 14:41:01 +00:00
|
|
|
// whenever new options are set, clear out the scheduled payout/distribution times
|
|
|
|
|
// this will reset and cause the next distribution to happen at the next maintenance
|
|
|
|
|
// interval and a payout at the next_payout_time
|
|
|
|
|
dividend_data_obj.last_scheduled_payout_time.reset();
|
|
|
|
|
dividend_data_obj.last_scheduled_distribution_time.reset();
|
2016-06-26 19:41:07 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return void_result();
|
|
|
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_update_feed_producers_evaluator::do_evaluate(const asset_update_feed_producers_evaluator::operation_type& o)
|
2015-06-23 21:33:06 +00:00
|
|
|
{ try {
|
2015-06-08 15:50:35 +00:00
|
|
|
database& d = db();
|
|
|
|
|
|
|
|
|
|
FC_ASSERT( o.new_feed_producers.size() <= d.get_global_properties().parameters.maximum_asset_feed_publishers );
|
|
|
|
|
for( auto id : o.new_feed_producers )
|
|
|
|
|
d.get_object(id);
|
|
|
|
|
|
|
|
|
|
const asset_object& a = o.asset_to_update(d);
|
|
|
|
|
|
|
|
|
|
FC_ASSERT(a.is_market_issued(), "Cannot update feed producers on a non-BitAsset.");
|
2015-10-09 15:07:10 +00:00
|
|
|
FC_ASSERT(!(a.options.flags & committee_fed_asset), "Cannot set feed producers on a committee-fed asset.");
|
|
|
|
|
FC_ASSERT(!(a.options.flags & witness_fed_asset), "Cannot set feed producers on a witness-fed asset.");
|
2015-06-08 15:50:35 +00:00
|
|
|
|
|
|
|
|
const asset_bitasset_data_object& b = a.bitasset_data(d);
|
|
|
|
|
bitasset_to_update = &b;
|
|
|
|
|
FC_ASSERT( a.issuer == o.issuer );
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-23 21:33:06 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_update_feed_producers_evaluator::do_apply(const asset_update_feed_producers_evaluator::operation_type& o)
|
2015-06-23 21:33:06 +00:00
|
|
|
{ try {
|
2015-06-08 15:50:35 +00:00
|
|
|
db().modify(*bitasset_to_update, [&](asset_bitasset_data_object& a) {
|
|
|
|
|
//This is tricky because I have a set of publishers coming in, but a map of publisher to feed is stored.
|
|
|
|
|
//I need to update the map such that the keys match the new publishers, but not munge the old price feeds from
|
|
|
|
|
//publishers who are being kept.
|
|
|
|
|
//First, remove any old publishers who are no longer publishers
|
|
|
|
|
for( auto itr = a.feeds.begin(); itr != a.feeds.end(); )
|
|
|
|
|
{
|
|
|
|
|
if( !o.new_feed_producers.count(itr->first) )
|
|
|
|
|
itr = a.feeds.erase(itr);
|
|
|
|
|
else
|
|
|
|
|
++itr;
|
|
|
|
|
}
|
|
|
|
|
//Now, add any new publishers
|
|
|
|
|
for( auto itr = o.new_feed_producers.begin(); itr != o.new_feed_producers.end(); ++itr )
|
|
|
|
|
if( !a.feeds.count(*itr) )
|
|
|
|
|
a.feeds[*itr];
|
|
|
|
|
a.update_median_feeds(db().head_block_time());
|
|
|
|
|
});
|
2015-06-25 18:33:46 +00:00
|
|
|
db().check_call_orders( o.asset_to_update(db()) );
|
2015-06-18 22:42:44 +00:00
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-23 21:33:06 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_global_settle_evaluator::do_evaluate(const asset_global_settle_evaluator::operation_type& op)
|
2015-06-23 21:33:06 +00:00
|
|
|
{ try {
|
2015-06-08 15:50:35 +00:00
|
|
|
const database& d = db();
|
|
|
|
|
asset_to_settle = &op.asset_to_settle(d);
|
|
|
|
|
FC_ASSERT(asset_to_settle->is_market_issued());
|
|
|
|
|
FC_ASSERT(asset_to_settle->can_global_settle());
|
|
|
|
|
FC_ASSERT(asset_to_settle->issuer == op.issuer );
|
|
|
|
|
FC_ASSERT(asset_to_settle->dynamic_data(d).current_supply > 0);
|
|
|
|
|
const auto& idx = d.get_index_type<call_order_index>().indices().get<by_collateral>();
|
|
|
|
|
assert( !idx.empty() );
|
|
|
|
|
auto itr = idx.lower_bound(boost::make_tuple(price::min(asset_to_settle->bitasset_data(d).options.short_backing_asset,
|
|
|
|
|
op.asset_to_settle)));
|
|
|
|
|
assert( itr != idx.end() && itr->debt_type() == op.asset_to_settle );
|
|
|
|
|
const call_order_object& least_collateralized_short = *itr;
|
|
|
|
|
FC_ASSERT(least_collateralized_short.get_debt() * op.settle_price <= least_collateralized_short.get_collateral(),
|
|
|
|
|
"Cannot force settle at supplied price: least collateralized short lacks sufficient collateral to settle.");
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-23 21:33:06 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_global_settle_evaluator::do_apply(const asset_global_settle_evaluator::operation_type& op)
|
2015-06-23 21:33:06 +00:00
|
|
|
{ try {
|
2015-06-08 15:50:35 +00:00
|
|
|
database& d = db();
|
|
|
|
|
d.globally_settle_asset( op.asset_to_settle(db()), op.settle_price );
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-23 21:33:06 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-06-23 21:33:06 +00:00
|
|
|
void_result asset_settle_evaluator::do_evaluate(const asset_settle_evaluator::operation_type& op)
|
|
|
|
|
{ try {
|
2015-06-08 15:50:35 +00:00
|
|
|
const database& d = db();
|
|
|
|
|
asset_to_settle = &op.amount.asset_id(d);
|
|
|
|
|
FC_ASSERT(asset_to_settle->is_market_issued());
|
2015-06-19 13:57:23 +00:00
|
|
|
const auto& bitasset = asset_to_settle->bitasset_data(d);
|
|
|
|
|
FC_ASSERT(asset_to_settle->can_force_settle() || bitasset.has_settlement() );
|
2015-06-23 21:33:06 +00:00
|
|
|
if( bitasset.is_prediction_market )
|
2015-06-19 19:57:08 +00:00
|
|
|
FC_ASSERT( bitasset.has_settlement(), "global settlement must occur before force settling a prediction market" );
|
2015-07-07 21:39:38 +00:00
|
|
|
else if( bitasset.current_feed.settlement_price.is_null() )
|
|
|
|
|
FC_THROW_EXCEPTION(insufficient_feeds, "Cannot force settle with no price feed.");
|
2015-06-08 15:50:35 +00:00
|
|
|
FC_ASSERT(d.get_balance(d.get(op.account), *asset_to_settle) >= op.amount);
|
|
|
|
|
|
2015-06-23 21:33:06 +00:00
|
|
|
return void_result();
|
|
|
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-06-19 13:57:23 +00:00
|
|
|
operation_result asset_settle_evaluator::do_apply(const asset_settle_evaluator::operation_type& op)
|
2015-06-23 21:33:06 +00:00
|
|
|
{ try {
|
2015-06-08 15:50:35 +00:00
|
|
|
database& d = db();
|
|
|
|
|
d.adjust_balance(op.account, -op.amount);
|
2015-06-19 13:57:23 +00:00
|
|
|
|
|
|
|
|
const auto& bitasset = asset_to_settle->bitasset_data(d);
|
|
|
|
|
if( bitasset.has_settlement() )
|
|
|
|
|
{
|
|
|
|
|
auto settled_amount = op.amount * bitasset.settlement_price;
|
|
|
|
|
FC_ASSERT( settled_amount.amount <= bitasset.settlement_fund );
|
|
|
|
|
|
|
|
|
|
d.modify( bitasset, [&]( asset_bitasset_data_object& obj ){
|
|
|
|
|
obj.settlement_fund -= settled_amount.amount;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
d.adjust_balance(op.account, settled_amount);
|
|
|
|
|
|
2015-06-19 18:47:42 +00:00
|
|
|
const auto& mia_dyn = asset_to_settle->dynamic_asset_data_id(d);
|
|
|
|
|
|
|
|
|
|
d.modify( mia_dyn, [&]( asset_dynamic_data_object& obj ){
|
|
|
|
|
obj.current_supply -= op.amount.amount;
|
|
|
|
|
});
|
|
|
|
|
|
2015-06-19 13:57:23 +00:00
|
|
|
return settled_amount;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return d.create<force_settlement_object>([&](force_settlement_object& s) {
|
|
|
|
|
s.owner = op.account;
|
|
|
|
|
s.balance = op.amount;
|
|
|
|
|
s.settlement_date = d.head_block_time() + asset_to_settle->bitasset_data(d).options.force_settlement_delay_sec;
|
|
|
|
|
}).id;
|
|
|
|
|
}
|
2015-06-23 21:33:06 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_publish_feeds_evaluator::do_evaluate(const asset_publish_feed_operation& o)
|
2015-06-08 15:50:35 +00:00
|
|
|
{ try {
|
|
|
|
|
database& d = db();
|
|
|
|
|
|
2015-06-18 19:17:48 +00:00
|
|
|
const asset_object& base = o.asset_id(d);
|
2015-06-08 15:50:35 +00:00
|
|
|
//Verify that this feed is for a market-issued asset and that asset is backed by the base
|
2015-06-18 19:17:48 +00:00
|
|
|
FC_ASSERT(base.is_market_issued());
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-06-18 19:17:48 +00:00
|
|
|
const asset_bitasset_data_object& bitasset = base.bitasset_data(d);
|
2015-06-19 13:57:23 +00:00
|
|
|
FC_ASSERT( !bitasset.has_settlement(), "No further feeds may be published after a settlement event" );
|
2015-10-08 19:00:11 +00:00
|
|
|
|
2015-10-13 13:29:48 +00:00
|
|
|
FC_ASSERT( o.feed.settlement_price.quote.asset_id == bitasset.options.short_backing_asset );
|
2015-12-15 16:38:40 +00:00
|
|
|
if( d.head_block_time() > HARDFORK_480_TIME )
|
|
|
|
|
{
|
|
|
|
|
if( !o.feed.core_exchange_rate.is_null() )
|
|
|
|
|
{
|
|
|
|
|
FC_ASSERT( o.feed.core_exchange_rate.quote.asset_id == asset_id_type() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if( (!o.feed.settlement_price.is_null()) && (!o.feed.core_exchange_rate.is_null()) )
|
|
|
|
|
{
|
|
|
|
|
FC_ASSERT( o.feed.settlement_price.quote.asset_id == o.feed.core_exchange_rate.quote.asset_id );
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-10-08 19:00:11 +00:00
|
|
|
|
2015-06-08 15:50:35 +00:00
|
|
|
//Verify that the publisher is authoritative to publish a feed
|
2015-10-09 15:07:10 +00:00
|
|
|
if( base.options.flags & witness_fed_asset )
|
2015-09-21 21:02:59 +00:00
|
|
|
{
|
2015-10-09 15:07:10 +00:00
|
|
|
FC_ASSERT( d.get(GRAPHENE_WITNESS_ACCOUNT).active.account_auths.count(o.publisher) );
|
|
|
|
|
}
|
|
|
|
|
else if( base.options.flags & committee_fed_asset )
|
|
|
|
|
{
|
|
|
|
|
FC_ASSERT( d.get(GRAPHENE_COMMITTEE_ACCOUNT).active.account_auths.count(o.publisher) );
|
2015-09-21 21:02:59 +00:00
|
|
|
}
|
|
|
|
|
else
|
2015-06-08 15:50:35 +00:00
|
|
|
{
|
|
|
|
|
FC_ASSERT(bitasset.feeds.count(o.publisher));
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-08 15:50:35 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW((o)) }
|
|
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
void_result asset_publish_feeds_evaluator::do_apply(const asset_publish_feed_operation& o)
|
2015-06-08 15:50:35 +00:00
|
|
|
{ try {
|
2015-10-08 19:00:11 +00:00
|
|
|
|
2015-06-08 15:50:35 +00:00
|
|
|
database& d = db();
|
|
|
|
|
|
2015-06-18 19:17:48 +00:00
|
|
|
const asset_object& base = o.asset_id(d);
|
2015-07-01 22:17:49 +00:00
|
|
|
const asset_bitasset_data_object& bad = base.bitasset_data(d);
|
|
|
|
|
|
|
|
|
|
auto old_feed = bad.current_feed;
|
2015-06-08 15:50:35 +00:00
|
|
|
// Store medians for this asset
|
2015-07-01 22:17:49 +00:00
|
|
|
d.modify(bad , [&o,&d](asset_bitasset_data_object& a) {
|
2015-06-08 15:50:35 +00:00
|
|
|
a.feeds[o.publisher] = make_pair(d.head_block_time(), o.feed);
|
|
|
|
|
a.update_median_feeds(d.head_block_time());
|
|
|
|
|
});
|
|
|
|
|
|
2015-07-01 22:17:49 +00:00
|
|
|
if( !(old_feed == bad.current_feed) )
|
|
|
|
|
db().check_call_orders(base);
|
2015-06-18 22:42:44 +00:00
|
|
|
|
2015-06-09 20:53:14 +00:00
|
|
|
return void_result();
|
2015-06-23 21:33:06 +00:00
|
|
|
} FC_CAPTURE_AND_RETHROW((o)) }
|
2015-06-08 15:50:35 +00:00
|
|
|
|
2015-10-27 15:05:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void_result asset_claim_fees_evaluator::do_evaluate( const asset_claim_fees_operation& o )
|
|
|
|
|
{ try {
|
2015-10-30 17:02:44 +00:00
|
|
|
FC_ASSERT( db().head_block_time() > HARDFORK_413_TIME );
|
2015-10-27 15:05:59 +00:00
|
|
|
FC_ASSERT( o.amount_to_claim.asset_id(db()).issuer == o.issuer, "Asset fees may only be claimed by the issuer" );
|
|
|
|
|
return void_result();
|
|
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void_result asset_claim_fees_evaluator::do_apply( const asset_claim_fees_operation& o )
|
|
|
|
|
{ try {
|
|
|
|
|
database& d = db();
|
|
|
|
|
|
|
|
|
|
const asset_object& a = o.amount_to_claim.asset_id(d);
|
|
|
|
|
const asset_dynamic_data_object& addo = a.dynamic_asset_data_id(d);
|
|
|
|
|
FC_ASSERT( o.amount_to_claim.amount <= addo.accumulated_fees, "Attempt to claim more fees than have accumulated", ("addo",addo) );
|
|
|
|
|
|
|
|
|
|
d.modify( addo, [&]( asset_dynamic_data_object& _addo ) {
|
|
|
|
|
_addo.accumulated_fees -= o.amount_to_claim.amount;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
d.adjust_balance( o.issuer, o.amount_to_claim );
|
|
|
|
|
|
|
|
|
|
return void_result();
|
|
|
|
|
} FC_CAPTURE_AND_RETHROW( (o) ) }
|
|
|
|
|
|
|
|
|
|
|
2015-06-08 15:50:35 +00:00
|
|
|
} } // graphene::chain
|