Skip to content

Commit e3cb964

Browse files
update 3rd party include
1 parent 72784d1 commit e3cb964

18 files changed

Lines changed: 121 additions & 17324 deletions

3rd-party-components/include/fc/io/json_relaxed.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ namespace fc { namespace json_relaxed
724724
FC_RETHROW_EXCEPTIONS( warn, "Atempting to use @fname for ${fname}", ("fname", fname ) );
725725
}
726726

727-
template<typename T, bool strict, bool cmdline = false>
727+
template<typename T, bool strict, bool cmdline>
728728
variant variant_from_stream( T& in )
729729
{
730730
skip_white_space(in);

3rd-party-components/include/fc/reflect/typename.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace fc {
1515
class exception;
1616
namespace ip { class address; }
1717

18-
template<typename T> class get_typename{};
18+
template<typename ...T> struct get_typename;
1919
template<> struct get_typename<int32_t> { static const char* name() { return "int32_t"; } };
2020
template<> struct get_typename<int64_t> { static const char* name() { return "int64_t"; } };
2121
template<> struct get_typename<int16_t> { static const char* name() { return "int16_t"; } };

3rd-party-components/include/fc/static_variant.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,5 +382,5 @@ struct visitor {
382382
s.visit( to_static_variant(ar[1]) );
383383
}
384384

385-
template<typename... T> struct get_typename<T...> { static const char* name() { return typeid(static_variant<T...>).name(); } };
385+
template<typename... T> struct get_typename { static const char* name() { return typeid(static_variant<T...>).name(); } };
386386
} // namespace fc

3rd-party-components/include/fc/variant.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace fc
4444

4545
struct blob { std::vector<char> data; };
4646

47-
void bto_variant( const blob& var, variant& vo );
47+
void to_variant( const blob& var, variant& vo );
4848
void from_variant( const variant& var, blob& vo );
4949

5050

3rd-party-components/include/graphene/chain/IFMHostImpl.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ struct IFMHostImpl: IFMHost
3333

3434
// { IFMHost
3535
virtual bool stg_get(const TStgKey& key, TStgVal& val_out) override;
36-
virtual std::vector<TStgVal> stg_get(const TStgKey& key, uint32_t num_of_keys) override;
37-
virtual void stg_set(const TStgKey& key, const TStgVal& val) override;
36+
virtual uint32_t stg_get(const IFMHost::TStgKey& key, uint32_t num_of_keys, std::vector<IFMHost::TStgVal>& data) override;
37+
virtual bool stg_set(const TStgKey& key, const TStgVal& val) override;
38+
virtual uint32_t stg_set(const TStgKey& key, const std::vector<TStgVal>& vals);
39+
virtual uint32_t stg_del(const TStgKey& key, uint32_t num_of_keys);
3840
virtual TAccountID env_get_caller() override
3941
{ return(get_caller().operator uint64_t()); }
4042
virtual TAccountID env_get_contract_id() override
@@ -59,6 +61,7 @@ struct IFMHostImpl: IFMHost
5961
virtual void block_hash (TNumberBlock& numberBlock, TBlockHash blockHash[5]) override;
6062
virtual const std::vector<char> env_get_contract_code(const TAccountID contract_id) override;
6163
virtual const std::vector<char> env_get_contract_code(const std::string& contract_name) override;
64+
virtual bool env_map_address(const TAddr& addr, TAccountID& account, bool *create) override;
6265

6366
virtual TPDAddr construct_address(TAssetID assetID, TAccountID accountID) override;
6467
virtual bool parse_address(const TPDAddr& address, TAssetID& assetID, TAccountID& accountID) override;

3rd-party-components/include/graphene/chain/account_evaluator.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ class account_create_evaluator : public evaluator<account_create_evaluator>
3636
object_id_type do_apply( const account_create_operation& o ) ;
3737
};
3838

39+
class account_auto_create_evaluator : public evaluator<account_create_evaluator>
40+
{
41+
public:
42+
typedef account_auto_create_operation operation_type;
43+
44+
void_result do_evaluate( const account_auto_create_operation& o );
45+
object_id_type do_apply( const account_auto_create_operation& o ) ;
46+
47+
string name;
48+
};
49+
3950
class account_update_evaluator : public evaluator<account_update_evaluator>
4051
{
4152
public:

3rd-party-components/include/graphene/chain/account_object.hpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <graphene/chain/protocol/operations.hpp>
2626
#include <graphene/db/generic_index.hpp>
2727
#include <boost/multi_index/composite_key.hpp>
28+
#include <boost/multi_index/hashed_index.hpp>
2829

2930
namespace graphene { namespace chain {
3031
class database;
@@ -155,6 +156,9 @@ namespace graphene { namespace chain {
155156
/// The account's name. This name must be unique among all account names on the graph. May not be empty.
156157
string name;
157158

159+
/// The account's address. Must be unique among all account addresses if valid. Allows for Etherium-compatible account addressing.
160+
optional<address> addr;
161+
158162
/**
159163
* The owner authority represents absolute control over the account. Usually the keys in this authority will
160164
* be kept in cold storage, as they should not be needed very often and compromise of these keys constitutes
@@ -316,6 +320,23 @@ namespace graphene { namespace chain {
316320
map< account_id_type, set<account_id_type> > referred_by;
317321
};
318322

323+
/**
324+
* @brief This secondary index will allow a reverse lookup of accounts by their address.
325+
* (To provide Etherium compatibility)
326+
*/
327+
class account_address_index : public secondary_index
328+
{
329+
public:
330+
virtual void object_inserted( const object& obj ) override;
331+
virtual void object_removed( const object& obj ) override;
332+
virtual void about_to_modify( const object& before ) override;
333+
virtual void object_modified( const object& after ) override;
334+
335+
typedef unordered_map< address, account_id_type > TAddressesCont;
336+
/** maps the address to the account */
337+
TAddressesCont addresses;
338+
};
339+
319340
struct by_account_asset;
320341
struct by_asset_balance;
321342
/**
@@ -379,7 +400,7 @@ FC_REFLECT_DERIVED( graphene::chain::account_object,
379400
(graphene::db::object),
380401
(membership_expiration_date)(registrar)(referrer)(lifetime_referrer)
381402
(network_fee_percentage)(lifetime_referrer_fee_percentage)(referrer_rewards_percentage)
382-
(name)(owner)(active)(options)(contract_opts)(statistics)(whitelisting_accounts)(blacklisting_accounts)
403+
(name)(addr)(owner)(active)(options)(contract_opts)(statistics)(whitelisting_accounts)(blacklisting_accounts)
383404
(whitelisted_accounts)(blacklisted_accounts)
384405
(cashback_vb)
385406
(owner_special_authority)(active_special_authority)

3rd-party-components/include/graphene/chain/confidential_evaluator.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class transfer_from_blind_evaluator : public evaluator<transfer_from_blind_evalu
4747
typedef transfer_from_blind_operation operation_type;
4848

4949
void_result do_evaluate( const transfer_from_blind_operation& o );
50+
void pre_apply( const transfer_from_blind_operation& op );
5051
void_result do_apply( const transfer_from_blind_operation& o ) ;
5152

5253
virtual void pay_fee() override;
@@ -58,6 +59,7 @@ class blind_transfer_evaluator : public evaluator<blind_transfer_evaluator>
5859
typedef blind_transfer_operation operation_type;
5960

6061
void_result do_evaluate( const blind_transfer_operation& o );
62+
void pre_apply( const blind_transfer_operation& op );
6163
void_result do_apply( const blind_transfer_operation& o ) ;
6264

6365
virtual void pay_fee() override;

3rd-party-components/include/graphene/chain/evaluator.hpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ namespace graphene { namespace chain {
137137

138138
safe<uint32_t> gas_left = 0;
139139
asset gas_fee_used;
140+
asset gas_fee_refund;
140141
share_type core_gas_fee_used;
141142
share_type core_gas_fee_refund;
142143

@@ -203,25 +204,30 @@ namespace graphene { namespace chain {
203204
auto* eval = static_cast<DerivedEvaluator*>(this);
204205
const auto& op = o.get<typename DerivedEvaluator::operation_type>();
205206

207+
eval->pre_apply(op);
208+
206209
convert_fee();
210+
{
211+
asset fee = (gas_limit_from_account == 0) ?
212+
fee_from_account : (fee_from_account + gas_fee_limit);
213+
db_adjust_balance(op.fee_payer(), -fee);
214+
}
207215

208216
auto result = eval->do_apply(op);
209217

210218
if(gas_limit_from_account != 0)
211219
{
212220
prepare_gas_fee_refund();
213221
convert_gas_fee_refund();
222+
db_adjust_balance(op.fee_payer(), gas_fee_refund);
214223
}
215224

216225
pay_fee();
217226

218-
// XXX does it check that account can pay the fee before the very end of operation? (might matter for contract calls)
219-
// XXX may be it should be taken before applying the operation?
220-
asset fee = (gas_limit_from_account == 0) ?
221-
fee_from_account : (fee_from_account + gas_fee_used);
222-
db_adjust_balance(op.fee_payer(), -fee);
223-
224227
return result;
225228
}
229+
230+
protected:
231+
void pre_apply(const base_operation& op) {}
226232
};
227233
} }

3rd-party-components/include/graphene/chain/protocol/account.hpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,42 @@ namespace graphene { namespace chain {
110110
}
111111
};
112112

113+
/**
114+
* @ingroup operations
115+
*/
116+
struct account_auto_create_operation : public base_operation
117+
{
118+
struct fee_parameters_type
119+
{
120+
uint64_t fee = 5*GRAPHENE_BLOCKCHAIN_PRECISION; ///< the cost to register the cheapest non-free account
121+
};
122+
123+
asset fee;
124+
account_id_type caller;
125+
/// Must be a lifetime member.
126+
account_id_type registrar;
127+
/// This account receives a portion of the fee split between registrar and referrer. Must be a member.
128+
account_id_type referrer;
129+
/// Of the fee split between registrar and referrer, this percentage goes to the referrer. The rest goes to the
130+
/// registrar.
131+
uint16_t referrer_percent = 0;
132+
133+
address addr;
134+
135+
extensions_type extensions;
136+
137+
account_id_type fee_payer()const { FC_ASSERT( !"virtual operation" ); return account_id_type(); /*return caller;*/ }
138+
void validate()const;
139+
//share_type calculate_fee(const fee_parameters_type& )const;
140+
141+
// void get_required_authorities( vector<authority>& auth)const { auth.emplace_back(1, addr, 1); }
142+
/*void get_required_active_authorities( flat_set<account_id_type>& a )const
143+
{
144+
// caller should be required anyway as it is the fee_payer(), but we insert it here just to be sure
145+
a.insert( caller );
146+
}*/
147+
};
148+
113149
/**
114150
* @ingroup operations
115151
* @brief Update an existing account
@@ -274,6 +310,12 @@ FC_REFLECT( graphene::chain::account_create_operation,
274310
(name)(owner)(active)(options)(extensions)
275311
)
276312

313+
FC_REFLECT( graphene::chain::account_auto_create_operation,
314+
(fee)(caller)(registrar)
315+
(referrer)(referrer_percent)
316+
(addr)(extensions)
317+
)
318+
277319
FC_REFLECT(graphene::chain::account_update_operation::ext, (null_ext)(owner_special_authority)(active_special_authority) )
278320
FC_REFLECT( graphene::chain::account_update_operation,
279321
(fee)(account)(owner)(active)(new_options)(extensions)
@@ -285,6 +327,7 @@ FC_REFLECT( graphene::chain::account_upgrade_operation,
285327
FC_REFLECT( graphene::chain::account_whitelist_operation, (fee)(authorizing_account)(account_to_list)(new_listing)(extensions))
286328

287329
FC_REFLECT( graphene::chain::account_create_operation::fee_parameters_type, (basic_fee)(premium_fee)(price_per_kbyte) )
330+
FC_REFLECT( graphene::chain::account_auto_create_operation::fee_parameters_type, (fee) )
288331
FC_REFLECT( graphene::chain::account_whitelist_operation::fee_parameters_type, (fee) )
289332
FC_REFLECT( graphene::chain::account_update_operation::fee_parameters_type, (fee)(price_per_kbyte) )
290333
FC_REFLECT( graphene::chain::account_upgrade_operation::fee_parameters_type, (membership_annual_fee)(membership_lifetime_fee) )

0 commit comments

Comments
 (0)