eosio.system.hpp 1.5 KB
Newer Older
1 2 3 4
/**
 *  @file
 *  @copyright defined in eos/LICENSE.txt
 */
5
#include <eosiolib/eosio.hpp>
6 7 8
#include <eosiolib/token.hpp>
#include <eosiolib/db.hpp>
#include <eosiolib/reflect.hpp>
9

10 11 12
#include <eosiolib/generic_currency.hpp>
#include <eosiolib/datastream.hpp>
#include <eosiolib/serialize.hpp>
13

14 15
namespace eosiosystem {

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
   template<account_name SystemAccount>
   class contract {
      public:
         static const account_name system_account = N(eosio.system);
         typedef eosio::generic_currency< eosio::token<system_account,S(4,EOS)> > currency;

         ACTION( SystemAccount, regproducer ) {
            account_name producer_to_register;

            EOSLIB_SERIALIZE( regproducer, (producer_to_register) );
         };

         ACTION( SystemAccount, regproxy ) {
            account_name proxy_to_register;

            EOSLIB_SERIALIZE( regproxy, (proxy_to_register) );
         };

         static void on( const regproducer& reg ) {
            require_auth( reg.producer_to_register );
         }

         static void on( const regproxy& reg ) {
            require_auth( reg.proxy_to_register );
         }


         static void apply( account_name code, action_name act ) {
            if( !eosio::dispatch<contract, 
//                   typename currency::transfer_memo, 
 //                  typename currency::issue,
                   regproducer,
                   regproxy
                   >( code, act) ) 
            {
               assert( false, "received unexpected action" );
            }
         } /// apply 
   };
55

56 57
} /// eosiosystem