forked from fincubator/control_center
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_schemes.py
70 lines (52 loc) · 1.87 KB
/
data_schemes.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
from marshmallow import Schema, fields, ValidationError
class BoolLowerCase(fields.Field):
"""
Field that serializes bool value to lower case string
True -> "true", False -> "false"
"""
def _serialize(self, value, attr, obj, **kwargs):
return str(value).lower()
class ConfirmationSchema(fields.Field):
"""
If confirmations == 0, this mean that transactions are considered confirmed when "irreversible" blockchains
time has come.
If confirmations > 0, this mean that gateway need to counting "value" of next blocks after goal transaction block
"""
def _serialize(self, value, attr, obj, **kwargs):
if value == 0:
return {"type": "irreversible"}
else:
return {"type": "block", "value": value}
class AssetDataSchema(Schema):
class Meta:
ordered = True
name = fields.Str(required=True)
unified_cryptoasset_id = fields.Str()
can_deposit = BoolLowerCase()
can_withdraw = BoolLowerCase()
min_withdraw = fields.Str()
max_withdraw = fields.Str()
maker_fee = fields.Str()
taker_fee = fields.Str()
class CoinDataSchema(Schema):
class Meta:
ordered = True
name = fields.Str(required=True)
description = fields.Str(required=True)
backing_coin = fields.Str()
symbol = fields.Str()
deposit_allowed = fields.Bool()
withdrawal_allowed = fields.Bool()
memo_support = fields.Bool()
memo_version = fields.Int(load_only=True)
precision = fields.Int()
issuer = fields.Str()
issuer_id = fields.Str()
gateway_wallet = fields.Str(load_only=True)
wallet_type = fields.Str()
min_amount = fields.Int()
withdraw_fee = fields.Int()
deposit_fee = fields.Int()
# gate_fee do not store in database, and calculated as withdraw_fee / 10 ** precision
gate_fee = fields.Str()
confirmations = ConfirmationSchema()