/**asset includes amount and currency symbol*/structasset:fc::reflect_init{// 通过给定的符号名称以及资产数量构建一个新的资产对象。explicitasset(share_type a =0, symbol id =symbol(CORE_SYMBOL)):amount(a),sym(id){eosio_assert(is_amount_within_range(), asset_type_exception,"magnitude of asset amount must be less than 2^62");eosio_assert( sym.valid(), asset_type_exception,"invalid symbol");share_type amount;// 资产数量symbol_type symbol;// 资产符号名称,详见以下symbol_type源码分析。staticconstexprint64_t max_amount =(1LL<<62)-1;//资产数量最大值,取决于int64_t类型的取值范围。// 检查资产数量是否在范围以内,是否超过了最大限额。boolis_amount_within_range()const{return-max_amount <= amount && amount <= max_amount;}// 检查资产对象是否有效,有效资产的数量应该小于等于最大限额同时它的符号名称也是有效的。boolis_valid()const{returnis_amount_within_range()&& symbol.is_valid();}// 设置资产的数量voidset_amount(int64_t a){amount = a;eosio_assert(is_amount_within_range(),"magnitude of asset amount must be less than 2^62");}//资产对象的运算符重载 ...// 打印资产voidprint()const{int64_t p =(int64_t)symbol.precision();int64_t p10 =1;while(p >0){p10 *=10;--p;}p =(int64_t)symbol.precision();char fraction[p +1];fraction[p]='\0';auto change = amount % p10;for(int64_t i = p -1; i >=0;--i){fraction[i]=(change %10)+'0';change /=10;}printi(amount / p10);prints(".");prints_l(fraction,uint32_t(p));prints(" ");symbol.print(false);}EOSLIB_SERIALIZE(asset,(amount)(symbol))}voidreflector_init()const{eosio_assert(is_amount_within_range(), asset_type_exception,"magnitude of asset amount must be less than 2^62");eosio_assert( sym.valid(), asset_type_exception,"invalid symbol");}};//using share_type = int64_t;structextended_asset{// 默认构造器,构造一个扩展资产对象extended_asset(){}// 通过给定的数量和扩展符号构造一个扩展资产对象。extended_asset( asset a, text_name n ):quantity(a),contract(n){}asset quantity;text_name contract;// 资产拥有者};