contracts/rem.system/src/rem.system.cpp
/**
    *  Called after a new account is created. This code enforces resource-limits rules
    *  for new accounts as well as new account naming conventions.
    *
    *  Account names containing '.' symbols must have a suffix equal to the name of the creator.
    *  This allows users who buy a premium name (shorter than 12 characters with no dots) to be the only ones
    *  who can create accounts with the creator's name as a suffix.
    *
    */
Called after a new account is created. This code enforces resource-limits rules
for new accounts as well as new account naming conventions.

Account names containing '.' symbols must have a suffix equal to the name of the creator.
This allows users who buy a premium name (shorter than 12 characters with no dots) to be the only ones
who can create accounts with the creator's name as a suffix.
Called after a new account is created . This code enforces resource - limits rules for new accounts as well as new account naming conventions . Account names containing ' . ' symbols must have a suffix equal to the name of the creator . This allows users who buy a premium name ( shorter than 12 characters with no dots ) to be the only ones who can create accounts with the creator ' s name as a suffix .
void system_contract::newaccount( const name&        creator,
                                     const name&        newact,
                                     ignore<authority>  owner,
                                     ignore<authority>  active ) {
      if( creator != get_self() ) {
         uint64_t tmp = newact.value >> 4;
         bool has_dot = false;
         for( uint32_t i = 0; i < 12; ++i ) {
           has_dot |= !(tmp & 0x1f);
           tmp >>= 5;
         }
         if( has_dot ) { 
            auto suffix = newact.suffix();
            if( suffix == newact ) {
               name_bid_table bids(get_self(), get_self().value);
               auto current = bids.find( newact.value );
               check( current != bids.end(), "no active bid for name" );
               check( current->high_bidder == creator, "only highest bidder can claim" );
               check( current->high_bid < 0, "auction for name is not closed yet" );
               bids.erase( current );
            } else {
               check( creator == suffix, "only suffix may create this account" );
            }
         }
      }
      int64_t free_stake_amount = 0;
      int64_t free_gift_bytes   = 0;
      if ( eosio::attribute::has_attribute( _gremstate.gifter_attr_contract, _gremstate.gifter_attr_issuer, creator, _gremstate.gifter_attr_name ) ) {
         const auto discount = eosio::attribute::get_attribute< int64_t >( _gremstate.gifter_attr_contract, _gremstate.gifter_attr_issuer, creator, _gremstate.gifter_attr_name );
         check( (discount >= 0) && (discount <= 100'0000), "discount value should be in range[0, 100'0000]" );
         const auto discount_rate = discount / 100'0000.0;
         const auto system_token_max_supply = eosio::token::get_max_supply(token_account, system_contract::get_core_symbol().code() );
         const double bytes_per_token       = (double)_gstate.max_ram_size / (double)system_token_max_supply.amount;
         free_stake_amount                  = discount_rate * _gstate.min_account_stake;
         free_gift_bytes                    = bytes_per_token * free_stake_amount;
      }
      user_resources_table  userres( get_self(), newact.value );
      userres.emplace( newact, [&]( auto& res ) {
        res.owner = newact;
        res.net_weight = asset( 0, system_contract::get_core_symbol() );
        res.cpu_weight = asset( 0, system_contract::get_core_symbol() );
        res.free_stake_amount = free_stake_amount;
      });
      set_resource_limits( newact, free_gift_bytes, 0, 0 );
   }
void system_contract :: newaccount ( const name & creator , const name & newact , ignore < authority > owner , ignore < authority > active ) { if ( creator != get_self ( ) ) { uint64_t tmp = newact . value >> 4 ; bool has_dot = false ; for ( uint32_t i = 0 ; i < 12 ; ++ i ) { has_dot |= ! ( tmp & 0x1f ) ; tmp >>= 5 ; } if ( has_dot ) { auto suffix = newact . suffix ( ) ; if ( suffix == newact ) { name_bid_table bids ( get_self ( ) , get_self ( ) . value ) ; auto current = bids . find ( newact . value ) ; check ( current != bids . end ( ) , " " ) ; check ( current -> high_bidder == creator , " " ) ; check ( current -> high_bid < 0 , " " ) ; bids . erase ( current ) ; } else { check ( creator == suffix , " " ) ; } } } int64_t free_stake_amount = 0 ; int64_t free_gift_bytes = 0 ; if ( eosio :: attribute :: has_attribute ( _gremstate . gifter_attr_contract , _gremstate . gifter_attr_issuer , creator , _gremstate . gifter_attr_name ) ) { const auto discount = eosio :: attribute :: get_attribute < int64_t > ( _gremstate . gifter_attr_contract , _gremstate . gifter_attr_issuer , creator , _gremstate . gifter_attr_name ) ; check ( ( discount >= 0 ) && ( discount <= 100'0000 ) , " " ) ; const auto discount_rate = discount / 100'0000.0 ; const auto system_token_max_supply = eosio :: token :: get_max_supply ( token_account , system_contract :: get_core_symbol ( ) . code ( ) ) ; const double bytes_per_token = ( double ) _gstate . max_ram_size / ( double ) system_token_max_supply . amount ; free_stake_amount = discount_rate * _gstate . min_account_stake ; free_gift_bytes = bytes_per_token * free_stake_amount ; } user_resources_table userres ( get_self ( ) , newact . value ) ; userres . emplace ( newact , [ & ] ( auto & res ) { res . owner = newact ; res . net_weight = asset ( 0 , system_contract :: get_core_symbol ( ) ) ; res . cpu_weight = asset ( 0 , system_contract :: get_core_symbol ( ) ) ; res . free_stake_amount = free_stake_amount ; } ) ; set_resource_limits ( newact , free_gift_bytes , 0 , 0 ) ; }
Called after a new account is created.
Called after a new account is created .
// or is less than 12 characters // discount attribute is set as percent with precision of 4 symbols // 0 - 0.0000%, 100'0000 - 100.0000%