native.hpp 4.5 KB
Newer Older
1 2 3 4 5 6
/**
 *  @file
 *  @copyright defined in eos/LICENSE.txt
 */
#pragma once

7 8
#include <eosiolib/action.hpp>
#include <eosiolib/public_key.hpp>
9
#include <eosiolib/types.hpp>
D
Daniel Larimer 已提交
10 11
#include <eosiolib/print.hpp>
#include <eosiolib/privileged.h>
D
Daniel Larimer 已提交
12 13 14
#include <eosiolib/optional.hpp>
#include <eosiolib/producer_schedule.hpp>
#include <eosiolib/contract.hpp>
15 16

namespace eosiosystem {
17 18
   using eosio::permission_level;
   using eosio::public_key;
19 20 21 22 23 24

   typedef std::vector<char> bytes;

   struct permission_level_weight {
      permission_level  permission;
      weight_type       weight;
25

A
Anton Perkov 已提交
26
      // explicit serialization macro is not necessary, used here only to improve compilation time
27 28 29 30 31 32
      EOSLIB_SERIALIZE( permission_level_weight, (permission)(weight) )
   };

   struct key_weight {
      public_key   key;
      weight_type  weight;
33

A
Anton Perkov 已提交
34
      // explicit serialization macro is not necessary, used here only to improve compilation time
35 36 37 38 39
      EOSLIB_SERIALIZE( key_weight, (key)(weight) )
   };

   struct authority {
      uint32_t                              threshold;
40
      uint32_t                              delay_sec;
41 42
      std::vector<key_weight>               keys;
      std::vector<permission_level_weight>  accounts;
43

A
Anton Perkov 已提交
44
      // explicit serialization macro is not necessary, used here only to improve compilation time
45
      EOSLIB_SERIALIZE( authority, (threshold)(delay_sec)(keys)(accounts) )
46 47
   };

D
Daniel Larimer 已提交
48
   struct block_header {
D
Daniel Larimer 已提交
49 50
      uint32_t                                  timestamp;
      account_name                              producer;
51 52
      uint16_t                                  confirmed = 0;
      block_id_type                             previous;
D
Daniel Larimer 已提交
53 54
      checksum256                               transaction_mroot;
      checksum256                               action_mroot;
55
      uint32_t                                  schedule_version = 0;
D
Daniel Larimer 已提交
56 57 58
      eosio::optional<eosio::producer_schedule> new_producers;

      // explicit serialization macro is not necessary, used here only to improve compilation time
59 60
      EOSLIB_SERIALIZE(block_header, (timestamp)(producer)(confirmed)(previous)(transaction_mroot)(action_mroot)
                                     (schedule_version)(new_producers))
D
Daniel Larimer 已提交
61 62 63
   };


64 65 66
   /*
    * Method parameters commented out to prevent generation of code that parses input data.
    */
D
Daniel Larimer 已提交
67
   class native : public eosio::contract {
68
      public:
69

D
Daniel Larimer 已提交
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
         using eosio::contract::contract;

         /**
          *  Called after a new account is created. This code enforces resource-limits rules
          *  for new accounts as well as new account naming conventions.
          *
          *  1. accounts cannot contain '.' symbols which forces all acccounts to be 12
          *  characters long without '.' until a future account auction process is implemented
          *  which prevents name squatting.
          *
          *  2. new accounts must stake a minimal number of tokens (as set in system parameters)
          *     therefore, this method will execute an inline buyram from receiver for newacnt in
          *     an amount equal to the current new account creation fee. 
          */
         void newaccount( account_name     creator,
                          account_name     newact
86 87 88
                          /*  no need to parse authorites
                          const authority& owner,
                          const authority& active*/ );
D
Daniel Larimer 已提交
89

D
Daniel Larimer 已提交
90

D
Daniel Larimer 已提交
91 92 93 94
         void updateauth( /*account_name     account,
                                 permission_name  permission,
                                 permission_name  parent,
                                 const authority& data*/ ) {}
95

D
Daniel Larimer 已提交
96
         void deleteauth( /*account_name account, permission_name permission*/ ) {}
97

D
Daniel Larimer 已提交
98 99 100 101
         void linkauth( /*account_name    account,
                               account_name    code,
                               action_name     type,
                               permission_name requirement*/ ) {}
102

D
Daniel Larimer 已提交
103 104 105
         void unlinkauth( /*account_name account,
                                 account_name code,
                                 action_name  type*/ ) {}
106

D
Daniel Larimer 已提交
107 108 109
         void postrecovery( /*account_name       account,
                                   const authority&   data,
                                   const std::string& memo*/ ) {}
110

D
Daniel Larimer 已提交
111
         void passrecovery( /*account_name account*/ ) {}
112

D
Daniel Larimer 已提交
113
         void vetorecovery( /*account_name account*/ ) {}
114

D
Daniel Larimer 已提交
115
         void onerror( /*const bytes&*/ ) {}
116

D
Daniel Larimer 已提交
117
         void canceldelay( /*permission_level canceling_auth, transaction_id_type trx_id*/ ) {}
118

119

120 121
   };
}