-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils.hpp
40 lines (34 loc) · 1.04 KB
/
utils.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
#pragma once
#include <eosiolib/asset.hpp>
#include <eosiolib/multi_index.hpp>
#include <eosiolib/name.hpp>
#include <string>
namespace proxy {
std::string gen_proxy_memo(eosio::name recipient, const std::string& memo)
{
return recipient.to_string() + " " + memo;
}
eosio::extended_asset get_transfer_fee(const eosio::extended_asset& value)
{
auto fee = value;
fee.quantity.amount = (fee.quantity.amount + 999LL) /1000LL; // 0.1% rounded up
return fee;
}
struct token
{
token(eosio::name tkn) : _self(tkn) {}
struct account
{
eosio::asset balance;
uint64_t primary_key()const { return balance.symbol.code().raw(); }
};
using accounts = eosio::multi_index<"accounts"_n, account>;
bool has_balance(eosio::name owner, eosio::symbol sym) const
{
accounts acnt(_self, owner.value);
return acnt.find(sym.code().raw()) != acnt.end();
}
private:
eosio::name _self;
};
}