Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SON-307] Create PBTC asset #326

Merged
merged 13 commits into from
Apr 1, 2020
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ stages:
build:
stage: build
script:
- rm -rf .git/modules/* ./docs ./libraries/fc
- git submodule sync
- git submodule update --init --recursive
- cmake .
Expand Down
30 changes: 29 additions & 1 deletion libraries/chain/db_maint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1853,12 +1853,40 @@ void perform_son_tasks(database& db)
a.lifetime_referrer_fee_percentage = GRAPHENE_100_PERCENT - GRAPHENE_DEFAULT_NETWORK_PERCENT_OF_FEE;
});

db.modify( gpo, [&]( global_property_object& gpo ) {
db.modify( gpo, [&son_account]( global_property_object& gpo ) {
gpo.parameters.extensions.value.son_account = son_account.get_id();
if( gpo.pending_parameters )
gpo.pending_parameters->extensions.value.son_account = son_account.get_id();
});
}
// create BTC asset here because son_account is the issuer of the BTC
if (gpo.parameters.btc_asset() == asset_id_type())
gladcow marked this conversation as resolved.
Show resolved Hide resolved
{
const asset_dynamic_data_object& dyn_asset =
db.create<asset_dynamic_data_object>([](asset_dynamic_data_object& a) {
a.current_supply = 0;
});

const asset_object& btc_asset =
db.create<asset_object>( [&gpo, &dyn_asset]( asset_object& a ) {
a.symbol = "BTC";
a.options.max_supply = GRAPHENE_MAX_SHARE_SUPPLY;
a.precision = 8;
a.options.flags = 0;
a.options.issuer_permissions = 0;
a.issuer = *gpo.parameters.extensions.value.son_account;
a.options.core_exchange_rate.base.amount = 1;
a.options.core_exchange_rate.base.asset_id = asset_id_type(0);
a.options.core_exchange_rate.quote.amount = 1;
a.options.core_exchange_rate.quote.asset_id = asset_id_type(0);
a.dynamic_asset_data_id = dyn_asset.id;
});
db.modify( gpo, [&btc_asset]( global_property_object& gpo ) {
gpo.parameters.extensions.value.btc_asset = btc_asset.get_id();
if( gpo.pending_parameters )
gpo.pending_parameters->extensions.value.btc_asset = btc_asset.get_id();
});
}
}

void database::perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace graphene { namespace chain {
optional < uint32_t > son_heartbeat_frequency;
optional < uint32_t > son_down_time;
optional < account_id_type > son_account;
optional < asset_id_type > btc_asset;
};

struct chain_parameters
Expand Down Expand Up @@ -178,6 +179,9 @@ namespace graphene { namespace chain {
inline account_id_type son_account() const {
return extensions.value.son_account.valid() ? *extensions.value.son_account : GRAPHENE_NULL_ACCOUNT;
}
inline asset_id_type btc_asset() const {
return extensions.value.btc_asset.valid() ? *extensions.value.btc_asset : asset_id_type();
}
};

} } // graphene::chain
Expand All @@ -204,6 +208,7 @@ FC_REFLECT( graphene::chain::parameter_extension,
(son_heartbeat_frequency)
(son_down_time)
(son_account)
(btc_asset)
)

FC_REFLECT( graphene::chain::chain_parameters,
Expand Down