IoTeX client
wallets.h
1#ifndef WALLETS_H
2#define WALLETS_H
3
4#include "api/base.h"
5#include "api/rpc.h"
6#include "protobuf/pb_api.h"
7
8#include <map>
9#include <string>
10
11namespace iotex
12{
13namespace api
14{
19class IWallets : public Base
20{
21 public:
22 virtual ~IWallets()
23 {
24 }
25
33 virtual ResultCode getAccount(const char* const address,
34 responsetypes::AccountMeta& metadata) = 0;
35
43 virtual ResultCode getBalance(const char* const address, IotexString& balance) = 0;
44
53 virtual ResultCode getTransactionByHash(const char* const hash,
55
63 virtual ResultCode getExecutionByHash(const char* const hash,
65
76 virtual ResultCode sendTokenTransfer(const uint8_t senderPubKey[IOTEX_PUBLIC_KEY_SIZE],
77 const uint8_t signature[IOTEX_SIGNATURE_SIZE],
79 uint8_t hash[IOTEX_HASH_SIZE]) = 0;
80
91 virtual ResultCode sendExecution(const uint8_t senderPubKey[IOTEX_PUBLIC_KEY_SIZE],
92 const uint8_t signature[IOTEX_SIGNATURE_SIZE],
94 uint8_t hash[IOTEX_HASH_SIZE]) = 0;
95
105 virtual ResultCode readContract(const responsetypes::Execution& execution,
106 const IotexString callerAddress, uint64_t gasLimit,
108
109 protected:
110 IWallets(Host& host, IHTTP& http) : Base(host, http)
111 {
112 }
113}; // class IWallets
114
119class Wallets : public IWallets
120{
121 public:
122 Wallets(Host& host, IHTTP& http) : IWallets(host, http)
123 {
124 }
125
126 virtual ResultCode getAccount(const char* const address,
127 responsetypes::AccountMeta& data) override;
128
129 virtual ResultCode getBalance(const char* const address, IotexString& balance) override;
130
131 virtual ResultCode getTransactionByHash(const char* const address,
132 responsetypes::ActionInfo_Transfer& action) override;
133
134 virtual ResultCode getExecutionByHash(const char* const address,
135 responsetypes::ActionInfo_Execution& action) override;
136
137 virtual ResultCode sendTokenTransfer(const uint8_t senderPubKey[IOTEX_PUBLIC_KEY_SIZE],
138 const uint8_t signature[IOTEX_SIGNATURE_SIZE],
140 uint8_t hash[IOTEX_HASH_SIZE]) override;
141
142 virtual ResultCode sendExecution(const uint8_t senderPubKey[IOTEX_PUBLIC_KEY_SIZE],
143 const uint8_t signature[IOTEX_SIGNATURE_SIZE],
145 uint8_t hash[IOTEX_HASH_SIZE]) override;
146
147 virtual ResultCode readContract(const responsetypes::Execution& execution,
148 const IotexString callerAddress, uint64_t gasLimit,
149 responsetypes::ReadContractResponse* response) override;
150}; // class Wallets : public IWallets
151
152} // namespace api
153} // namespace iotex
154
155#endif
Definition: host.h:17
Definition: http.h:40
Definition: base.h:13
Interface for the Wallets API.
Definition: wallets.h:20
virtual ResultCode readContract(const responsetypes::Execution &execution, const IotexString callerAddress, uint64_t gasLimit, responsetypes::ReadContractResponse *response)=0
Reads a contract.
virtual ResultCode getBalance(const char *const address, IotexString &balance)=0
Gets the account balance from the blockchain.
virtual ResultCode getExecutionByHash(const char *const hash, responsetypes::ActionInfo_Execution &actionInfo)=0
Gets the action info for a execution action hash from the blockchain.
virtual ResultCode sendTokenTransfer(const uint8_t senderPubKey[IOTEX_PUBLIC_KEY_SIZE], const uint8_t signature[IOTEX_SIGNATURE_SIZE], const responsetypes::ActionCore_Transfer &transfer, uint8_t hash[IOTEX_HASH_SIZE])=0
Sends a token transfer action to the blockchain.
virtual ResultCode getAccount(const char *const address, responsetypes::AccountMeta &metadata)=0
Gets the account metadata from the blockchain.
virtual ResultCode getTransactionByHash(const char *const hash, responsetypes::ActionInfo_Transfer &actionInfo)=0
Gets the action info for a transaction action hash from the blockchain.
virtual ResultCode sendExecution(const uint8_t senderPubKey[IOTEX_PUBLIC_KEY_SIZE], const uint8_t signature[IOTEX_SIGNATURE_SIZE], const responsetypes::ActionCore_Execution &transfer, uint8_t hash[IOTEX_HASH_SIZE])=0
Sends an execution action to the blockchain.
A class that represents the Wallets API.
Definition: wallets.h:120
virtual ResultCode getExecutionByHash(const char *const address, responsetypes::ActionInfo_Execution &action) override
Gets the action info for a execution action hash from the blockchain.
Definition: wallets.cpp:72
virtual ResultCode getTransactionByHash(const char *const address, responsetypes::ActionInfo_Transfer &action) override
Gets the action info for a transaction action hash from the blockchain.
Definition: wallets.cpp:53
virtual ResultCode getBalance(const char *const address, IotexString &balance) override
Gets the account balance from the blockchain.
Definition: wallets.cpp:34
virtual ResultCode sendTokenTransfer(const uint8_t senderPubKey[IOTEX_PUBLIC_KEY_SIZE], const uint8_t signature[IOTEX_SIGNATURE_SIZE], const responsetypes::ActionCore_Transfer &transfer, uint8_t hash[IOTEX_HASH_SIZE]) override
Sends a token transfer action to the blockchain.
Definition: wallets.cpp:91
virtual ResultCode readContract(const responsetypes::Execution &execution, const IotexString callerAddress, uint64_t gasLimit, responsetypes::ReadContractResponse *response) override
Reads a contract.
Definition: wallets.cpp:139
virtual ResultCode sendExecution(const uint8_t senderPubKey[IOTEX_PUBLIC_KEY_SIZE], const uint8_t signature[IOTEX_SIGNATURE_SIZE], const responsetypes::ActionCore_Execution &transfer, uint8_t hash[IOTEX_HASH_SIZE]) override
Sends an execution action to the blockchain.
Definition: wallets.cpp:112
virtual ResultCode getAccount(const char *const address, responsetypes::AccountMeta &data) override
Gets the account metadata from the blockchain.
Definition: wallets.cpp:12
Definition: abi.h:12
Definition: pb_api.h:32
Definition: pb_api.h:55