-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathtransaction_data_encoder.py
More file actions
65 lines (55 loc) · 2.17 KB
/
transaction_data_encoder.py
File metadata and controls
65 lines (55 loc) · 2.17 KB
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
from crypto.enums.abi_function import AbiFunction
from crypto.enums.contract_abi_type import ContractAbiType
from crypto.utils.abi_encoder import AbiEncoder
class TransactionDataEncoder:
@staticmethod
def multi_payment(recipients, amounts):
return AbiEncoder(ContractAbiType.MULTIPAYMENT).encode_function_call_hex(
AbiFunction.MULTIPAYMENT.value, [recipients, amounts]
)
@staticmethod
def update_validator(validator_public_key):
key = validator_public_key
if not key.startswith('0x'):
key = '0x' + key
return AbiEncoder(ContractAbiType.CONSENSUS).encode_function_call_hex(
AbiFunction.UPDATE_VALIDATOR.value, [key]
)
@staticmethod
def username_registration(username):
return AbiEncoder(ContractAbiType.USERNAMES).encode_function_call_hex(
AbiFunction.USERNAME_REGISTRATION.value, [username]
)
@staticmethod
def username_resignation():
return AbiEncoder(ContractAbiType.USERNAMES).encode_function_call_hex(
AbiFunction.USERNAME_RESIGNATION.value, []
)
@staticmethod
def validator_registration(validator_public_key):
key = validator_public_key
if not key.startswith('0x'):
key = '0x' + key
return AbiEncoder(ContractAbiType.CONSENSUS).encode_function_call_hex(
AbiFunction.VALIDATOR_REGISTRATION.value, [key]
)
@staticmethod
def validator_resignation():
return AbiEncoder(ContractAbiType.CONSENSUS).encode_function_call_hex(
AbiFunction.VALIDATOR_RESIGNATION.value, []
)
@staticmethod
def token_transfer(recipient_address, amount):
return AbiEncoder(ContractAbiType.TOKEN).encode_function_call_hex(
AbiFunction.TRANSFER.value, [recipient_address, amount]
)
@staticmethod
def vote(vote_address):
return AbiEncoder(ContractAbiType.CONSENSUS).encode_function_call_hex(
AbiFunction.VOTE.value, [vote_address]
)
@staticmethod
def unvote():
return AbiEncoder(ContractAbiType.CONSENSUS).encode_function_call_hex(
AbiFunction.UNVOTE.value, []
)