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
96 protected:
97 IWallets(Host& host, IHTTP& http) : Base(host, http)
98 {
99 }
100}; // class IWallets
101
106class Wallets : public IWallets
107{
108 public:
109 Wallets(Host& host, IHTTP& http) : IWallets(host, http)
110 {
111 }
112
113 virtual ResultCode getAccount(const char* const address,
114 ResponseTypes::AccountMeta& data) override;
115
116 virtual ResultCode getBalance(const char* const address, IotexString& balance) override;
117
118 virtual ResultCode getTransactionByHash(const char* const address,
119 ResponseTypes::ActionInfo_Transfer& action) override;
120
121 virtual ResultCode getExecutionByHash(const char* const address,
122 ResponseTypes::ActionInfo_Execution& action) override;
123
124 virtual ResultCode sendTokenTransfer(const uint8_t senderPubKey[IOTEX_PUBLIC_KEY_SIZE],
125 const uint8_t signature[IOTEX_SIGNATURE_SIZE],
127 uint8_t hash[IOTEX_HASH_SIZE]) override;
128
129 virtual ResultCode sendExecution(const uint8_t senderPubKey[IOTEX_PUBLIC_KEY_SIZE],
130 const uint8_t signature[IOTEX_SIGNATURE_SIZE],
132 uint8_t hash[IOTEX_HASH_SIZE]) override;
133}; // class Wallets : public IWallets
134
135} // namespace api
136} // namespace iotex
137
138#endif
Definition: host.h:17
Definition: http.h:40
Definition: base.h:13
Interface for the Wallets API.
Definition: wallets.h:20
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 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 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 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.
virtual ResultCode getAccount(const char *const address, ResponseTypes::AccountMeta &metadata)=0
Gets the account metadata from the blockchain.
A class that represents the Wallets API.
Definition: wallets.h:107
virtual ResultCode getAccount(const char *const address, ResponseTypes::AccountMeta &data) override
Gets the account metadata from the blockchain.
Definition: wallets.cpp:12
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 getBalance(const char *const address, IotexString &balance) override
Gets the account balance from the blockchain.
Definition: wallets.cpp:34
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 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 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
Definition: abi.h:12
Definition: pb_api.h:32