-
Notifications
You must be signed in to change notification settings - Fork 1
/
marketplace_payload.py
159 lines (109 loc) · 5.55 KB
/
marketplace_payload.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Copyright 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -----------------------------------------------------------------------------
from protocompiled import payload_pb2
import coloredlogs, logging
coloredlogs.install()
class MarketplacePayload(object):
def __init__(self, payload):
self._transaction = payload_pb2.TransactionPayload()
self._transaction.ParseFromString(payload)
def create_organization_account(self):
"""Returns the value set in the create_account.
which will be the details of the account class published as a payload
Returns:
payload_pb2.CREATE_ORGANIZATION_ACCOUNT
"""
#logging.debug(f"This is the create account payload in \
#TransactionPayload {self._transaction.create_account}")
return self._transaction.create_organization_account
def is_organization_account(self):
create_organization_account = \
payload_pb2.TransactionPayload.CREATE_ORGANIZATION_ACCOUNT
return self._transaction.payload_type == create_organization_account
def create_user_account(self):
#logging.debug(f"This is the create float account payload in \
#TransactionPayload {self._transaction.create_float_account}")
return self._transaction.create_user_account
def is_user_account(self):
user_account = payload_pb2.TransactionPayload.CREATE_USER_ACCOUNT
return self._transaction.payload_type == user_account
def create_share_secret(self):
#logging.debug(f"This is the create float account payload in \
#TransactionPayload {self._transaction.create_float_account}")
return self._transaction.share_secret
def is_share_secret(self):
share_secret = payload_pb2.TransactionPayload.SHARE_SECRET
return self._transaction.payload_type == share_secret
def create_activate_secret(self):
#logging.debug(f"This is the create float account payload in \
#TransactionPayload {self._transaction.create_float_account}")
return self._transaction.activate_secret
def is_activate_secret(self):
activate_secret = payload_pb2.TransactionPayload.ACTIVATE_SECRET
return self._transaction.payload_type == activate_secret
def create_execute_shares(self):
#logging.debug(f"This is the create float account payload in \
#TransactionPayload {self._transaction.create_float_account}")
return self._transaction.execute_secret
def is_execute_shares(self):
execute_secret = payload_pb2.TransactionPayload.EXECUTE_SECRET
return self._transaction.payload_type == execute_secret
def create_receive_secret(self):
#logging.debug(f"This is the create float account payload in \
#TransactionPayload {self._transaction.create_float_account}")
return self._transaction.receive_secret
def is_receive_secret(self):
receive_secret = payload_pb2.TransactionPayload.RECEIVE_SECRET
return self._transaction.payload_type == receive_secret
def create_conclude_secret(self):
#logging.debug(f"This is the create float account payload in \
#TransactionPayload {self._transaction.create_float_account}")
return self._transaction.conclude_secret
def is_conclude_secret(self):
conclude_secret = payload_pb2.TransactionPayload.CONCLUDE_SECRET
return self._transaction.payload_type == conclude_secret
def create_child_account(self):
#logging.debug(f"This is the create float account payload in \
#TransactionPayload {self._transaction.create_float_account}")
return self._transaction.create_child_account
def is_child_account(self):
child_account = payload_pb2.TransactionPayload.CREATE_CHILD_ACCOUNT
return self._transaction.payload_type == child_account
def create_asset(self):
#logging.debug(f"This is the create asset payload in \
# TransactionPayload {self._transaction.create_asset}")
return self._transaction.create_asset
def is_asset(self):
create_asset = payload_pb2.TransactionPayload.CREATE_ASSET
return self._transaction.payload_type == create_asset
def transfer_asset(self):
"""
logging.debug(f"This is the transfer asset payload in \
TransactionPayload {self._transaction.transfer_asset}")
"""
return self._transaction.transfer_asset
def is_transfer_asset(self):
transfer_asset = payload_pb2.TransactionPayload.TRANSFER_ASSET
return self._transaction.payload_type == transfer_asset
def share_asset(self):
return self._transaction.share_asset
def is_share_asset(self):
share_asset = payload_pb2.TransactionPayload.SHARE_ASSET
return self._transaction.payload_type == share_asset
def receive_asset(self):
return self._transaction.receive_asset
def is_receive_asset(self):
receive_asset = payload_pb2.TransactionPayload.RECEIVE_ASSET
return self._transaction.payload_type == receive_asset