This repository was archived by the owner on Jan 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathget_transactions_to_approve.py
67 lines (48 loc) · 1.82 KB
/
get_transactions_to_approve.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
# coding=utf-8
from __future__ import absolute_import, division, print_function, \
unicode_literals
import filters as f
from iota.commands import FilterCommand, RequestFilter, ResponseFilter
from iota.filters import Trytes
from iota.transaction.types import TransactionHash
__all__ = [
'GetTransactionsToApproveCommand',
]
class GetTransactionsToApproveCommand(FilterCommand):
"""
Executes ``getTransactionsToApprove`` command.
See :py:meth:`iota.api.StrictIota.get_transactions_to_approve`.
"""
command = 'getTransactionsToApprove'
def get_request_filter(self):
return GetTransactionsToApproveRequestFilter()
def get_response_filter(self):
return GetTransactionsToApproveResponseFilter()
class GetTransactionsToApproveRequestFilter(RequestFilter):
def __init__(self):
super(GetTransactionsToApproveRequestFilter, self).__init__(
{
'depth': f.Required | f.Type(int) | f.Min(1),
'reference': Trytes(result_type=TransactionHash),
},
allow_missing_keys={
'reference',
})
def _apply(self, value):
value = super(GetTransactionsToApproveRequestFilter, self)._apply(
value,
) # type: dict
if self._has_errors:
return value
# Remove reference if null.
if value['reference'] is None:
del value['reference']
return value
class GetTransactionsToApproveResponseFilter(ResponseFilter):
def __init__(self):
super(GetTransactionsToApproveResponseFilter, self).__init__({
'branchTransaction':
f.ByteString(encoding='ascii') | Trytes(TransactionHash),
'trunkTransaction':
f.ByteString(encoding='ascii') | Trytes(TransactionHash),
})