-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirewall.hpp
43 lines (34 loc) · 1.58 KB
/
firewall.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <eosiolib/eosio.hpp>
#include <eosiolib/asset.hpp>
#include <eosiolib/types.hpp>
#include <eosiolib/symbol.hpp>
#include <eosiolib/multi_index.hpp>
class firewall : public eosio::contract {
public:
firewall(account_name self) : eosio::contract(self) {}
// @abi action
void transfer( account_name from, account_name to,eosio::asset quantity,std::string memo );
// @abi action
void addrule(std::string param, std::string ftype,std::string val);
// @abi action
void delrule(uint64_t id);
private:
void check_filter(uint32_t ftype, std::string param, std::string val,account_name third_party, eosio::asset quantity, std::string memo);
void check_whitelist( account_name third_party, std::string authorized );
void check_blacklist( account_name third_party, std::string blocked );
void check_limit( eosio::asset transfer_amount, std::string limit_amount);
void check_memo( std::string regex, std::string memo);
bool check_regex(std::string reg, std::string memo);
struct rule {
uint64_t id;
std::string parameter; // from, to, greater, memo
uint32_t filter_type; // whitelist, blacklist, greater than,memo.
std::string value; //account_name to blacklist, amount of eos, wildcards for default
auto get_parameter() const { return parameter; }
auto get_filter_type() const { return filter_type; }
auto get_value() const { return value; }
auto primary_key() const { return id; }
EOSLIB_SERIALIZE( rule, (id)( parameter )( filter_type )( value ) );
};
typedef eosio::multi_index<N(rule), rule> rules;
};