transaction.hpp 1.6 KB
Newer Older
1 2 3 4
/**
 *  @file
 *  @copyright defined in eos/LICENSE.txt
 */
5
#pragma once
6 7 8 9 10
#include <eosiolib/transaction.h>
#include <eosiolib/action.hpp>
#include <eosiolib/print.hpp>
#include <eosiolib/types.hpp>
#include <eosiolib/serialize.hpp>
11

P
Pravin 已提交
12
namespace eosio {
13 14

   /**
15
    * @defgroup transactioncppapi Transaction C++ API
16
    * @ingroup transactionapi
17
    * @brief Type-safe C++ wrappers for transaction C API
18 19 20 21 22 23
    *
    * @note There are some methods from the @ref transactioncapi that can be used directly from C++
    *
    * @{ 
    */

24

25
   class transaction {
26
   public:
27
      transaction(time expiration = now() + 60, region_id region = 0)
28
      :expiration(expiration),region(region)
29 30
      {}

31
      void send(uint32_t sender_id, time delay_until = 0) const {
32
         auto serialize = pack(*this);
33
         send_deferred(sender_id, delay_until, serialize.data(), serialize.size());
34 35
      }

36 37 38 39
      time            expiration;
      region_id       region;
      uint16_t        ref_block_num;
      uint32_t        ref_block_id;
40

41
      vector<action>  actions;
42

43
      EOSLIB_SERIALIZE( transaction, (expiration)(region)(ref_block_num)(ref_block_id)(actions) );
44 45
   };

46
   class deferred_transaction : public transaction {
47
      public:
48 49 50
         uint32_t     sender_id;
         account_name sender;
         time         delay_until;
51

52 53
         static deferred_transaction from_current_action() {
            return unpack_action<deferred_transaction>();
54 55
         }

56
         EOSLIB_SERIALIZE_DERIVED( deferred_transaction, transaction, (sender_id)(sender)(delay_until) )
57
   };
58 59 60 61

 ///@} transactioncpp api

} // namespace eos
62