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

#include <eosiolib/types.hpp>

namespace eosiosystem {
10 11 12 13 14 15 16 17

   typedef std::vector<char> bytes;
   typedef std::string type_name;
   typedef std::string field_name;

   struct permission_level_weight {
      permission_level  permission;
      weight_type       weight;
18

19 20 21 22 23 24
      EOSLIB_SERIALIZE( permission_level_weight, (permission)(weight) )
   };

   struct key_weight {
      public_key   key;
      weight_type  weight;
25

26 27 28 29 30 31 32
      EOSLIB_SERIALIZE( key_weight, (key)(weight) )
   };

   struct authority {
      uint32_t                              threshold;
      std::vector<key_weight>               keys;
      std::vector<permission_level_weight>  accounts;
33

34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
      EOSLIB_SERIALIZE( authority, (threshold)(keys)(accounts) )
   };

   struct type_def {
      type_name   new_type_name;
      type_name   type;

      EOSLIB_SERIALIZE( type_def, (new_type_name)(type) )
   };

   struct field_def {
      field_name name;
      type_name  type;

      EOSLIB_SERIALIZE( field_def, (name)(type) )
   };

   struct struct_def {
      type_name              name;
      type_name              base;
      std::vector<field_def> fields;
55

56 57 58 59 60 61
      EOSLIB_SERIALIZE( struct_def, (name)(base)(fields) )
   };

   struct action_def {
      action_name name;
      type_name   type;
62

63 64 65 66 67 68 69 70 71
      EOSLIB_SERIALIZE(action_def, (name)(type) )
   };

   struct table_def {
      table_name              name;
      type_name               index_type;
      std::vector<field_name> key_names;
      std::vector<type_name>  key_types;
      type_name               type;
72

73 74 75 76 77 78 79 80
      EOSLIB_SERIALIZE(table_def, (name)(index_type)(key_names)(key_types)(type) )
   };

   struct abi_def {
      std::vector<type_def>     types;
      std::vector<struct_def>   structs;
      std::vector<action_def>   actions;
      std::vector<table_def>    tables;
81

82 83 84
      EOSLIB_SERIALIZE( abi_def, (types)(structs)(actions)(tables) )
   };

85 86 87
   template <account_name SystemAccount>
   class native {
      public:
88 89 90 91 92 93 94 95
         ACTION( SystemAccount, newaccount ) {
            account_name                     creator;
            account_name                     name;
            authority                        owner;
            authority                        active;
            authority                        recovery;

            EOSLIB_SERIALIZE( newaccount, (creator)(name)(owner)(active)(recovery) )
96 97 98 99 100 101
         };

         static void on( const newaccount& ) {
         }

         ACTION( SystemAccount, updateauth ) {
102 103 104 105 106 107
            account_name                      account;
            permission_name                   permission;
            permission_name                   parent;
            authority                         data;

            EOSLIB_SERIALIZE( updateauth, (account)(permission)(parent)(data) )
108 109 110 111 112 113
         };

         static void on( const updateauth& ) {
         }

         ACTION( SystemAccount, deleteauth ) {
114 115 116 117
            account_name                      account;
            permission_name                   permission;

            EOSLIB_SERIALIZE( deleteauth, (account)(permission) )
118 119 120 121 122 123
         };

         static void on( const deleteauth& ) {
         }

         ACTION( SystemAccount, linkauth ) {
124 125 126 127 128 129
            account_name                      account;
            account_name                      code;
            action_name                       type;
            permission_name                   requirement;

            EOSLIB_SERIALIZE( linkauth, (account)(code)(type)(requirement) )
130 131 132 133
         };

         static void on( const linkauth& ) {
         }
134

135
         ACTION( SystemAccount, unlinkauth ) {
136 137 138
            account_name                      account;
            account_name                      code;
            action_name                       type;
139

140
            EOSLIB_SERIALIZE( unlinkauth, (account)(code)(type) )
141 142 143 144 145 146
         };

         static void on( const unlinkauth& ) {
         }

         ACTION( SystemAccount, postrecovery ) {
147 148 149 150 151
            account_name       account;
            authority          data;
            std::string        memo;

            EOSLIB_SERIALIZE( postrecovery, (account)(data)(memo) )
152 153 154 155 156 157
         };

         static void on( const postrecovery& ) {
         }

         ACTION( SystemAccount, passrecovery ) {
158 159 160
            account_name   account;

            EOSLIB_SERIALIZE( passrecovery, (account) )
161 162 163 164 165 166
         };

         static void on( const passrecovery& ) {
         }

         ACTION( SystemAccount, vetorecovery ) {
167 168 169
            account_name   account;

            EOSLIB_SERIALIZE( vetorecovery, (account) )
170 171 172 173 174 175
         };

         static void on( const vetorecovery& ) {
         }

         ACTION( SystemAccount, setabi ) {
176 177
            account_name                     account;
            abi_def                          abi;
178

179
            EOSLIB_SERIALIZE( setabi, (account)(abi) )
180 181 182 183 184
         };

         static void on( const setabi& ) {
         }

185 186
         struct onerror: eosio::action_meta<SystemAccount, N(onerror)>, bytes {
            EOSLIB_SERIALIZE_DERIVED( onerror, bytes, BOOST_PP_SEQ_NIL )
187 188 189 190
         };

         static void on( const onerror& ) {
         }
191

192 193
         ACTION( SystemAccount, canceldelay ) {
            uint32_t   sender_id;
194

195 196
            EOSLIB_SERIALIZE( canceldelay, (sender_id) )
         };
197

198 199 200
         static void on( const canceldelay& ) {
         }
         
201 202
   };
}