-
Notifications
You must be signed in to change notification settings - Fork 3
/
token_management_transactions_factory_test.py
150 lines (128 loc) · 6.67 KB
/
token_management_transactions_factory_test.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
from multiversx_sdk_core import Address
from multiversx_sdk_core.transaction_factories.token_management_transactions_factory import (
RegisterAndSetAllRolesTokenType, TokenManagementTransactionsFactory)
from multiversx_sdk_core.transaction_factories.transactions_factory_config import \
TransactionsFactoryConfig
frank = Address.new_from_bech32("erd1kdl46yctawygtwg2k462307dmz2v55c605737dp3zkxh04sct7asqylhyv")
grace = Address.new_from_bech32("erd1r69gk66fmedhhcg24g2c5kn2f2a5k4kvpr6jfw67dn2lyydd8cfswy6ede")
alice = Address.new_from_bech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th")
factory = TokenManagementTransactionsFactory(TransactionsFactoryConfig("T"))
def test_create_transaction_for_registering_and_setting_roles():
transaction = factory.create_transaction_for_registering_and_setting_roles(
sender=frank,
token_name="TEST",
token_ticker="TEST",
token_type=RegisterAndSetAllRolesTokenType.FNG,
num_decimals=2
)
assert transaction.data
assert transaction.data.decode() == "registerAndSetAllRoles@54455354@54455354@464e47@02"
assert transaction.sender == frank.to_bech32()
assert transaction.receiver == "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u"
assert transaction.amount == 50000000000000000
def test_create_transaction_for_issuing_fungible():
transaction = factory.create_transaction_for_issuing_fungible(
sender=frank,
token_name="FRANK",
token_ticker="FRANK",
initial_supply=100,
num_decimals=0,
can_freeze=True,
can_wipe=True,
can_pause=True,
can_change_owner=True,
can_upgrade=False,
can_add_special_roles=False
)
assert transaction.data
assert transaction.data.decode() == "issue@4652414e4b@4652414e4b@64@@63616e467265657a65@74727565@63616e57697065@74727565@63616e5061757365@74727565@63616e4368616e67654f776e6572@74727565@63616e55706772616465@66616c7365@63616e4164645370656369616c526f6c6573@66616c7365"
assert transaction.sender == frank.to_bech32()
assert transaction.receiver == "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u"
assert transaction.amount == 50000000000000000
def test_create_transaction_for_issuing_semi_fungible():
transaction = factory.create_transaction_for_issuing_semi_fungible(
sender=frank,
token_name="FRANK",
token_ticker="FRANK",
can_freeze=True,
can_wipe=True,
can_pause=True,
can_transfer_nft_create_role=True,
can_change_owner=True,
can_upgrade=False,
can_add_special_roles=False
)
assert transaction.data
assert transaction.data.decode() == "issueSemiFungible@4652414e4b@4652414e4b@63616e467265657a65@74727565@63616e57697065@74727565@63616e5061757365@74727565@63616e5472616e736665724e4654437265617465526f6c65@74727565@63616e4368616e67654f776e6572@74727565@63616e55706772616465@66616c7365@63616e4164645370656369616c526f6c6573@66616c7365"
assert transaction.sender == frank.to_bech32()
assert transaction.receiver == "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u"
assert transaction.amount == 50000000000000000
def test_create_transaction_for_issuing_non_fungible():
transaction = factory.create_transaction_for_issuing_non_fungible(
sender=frank,
token_name="FRANK",
token_ticker="FRANK",
can_freeze=True,
can_wipe=True,
can_pause=True,
can_transfer_nft_create_role=True,
can_change_owner=True,
can_upgrade=False,
can_add_special_roles=False
)
assert transaction.data
assert transaction.data.decode() == "issueNonFungible@4652414e4b@4652414e4b@63616e467265657a65@74727565@63616e57697065@74727565@63616e5061757365@74727565@63616e5472616e736665724e4654437265617465526f6c65@74727565@63616e4368616e67654f776e6572@74727565@63616e55706772616465@66616c7365@63616e4164645370656369616c526f6c6573@66616c7365"
assert transaction.sender == frank.to_bech32()
assert transaction.receiver == "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u"
assert transaction.amount == 50000000000000000
def test_create_transaction_for_registering_meta_esdt():
transaction = factory.create_transaction_for_registering_meta_esdt(
sender=frank,
token_name="FRANK",
token_ticker="FRANK",
num_decimals=10,
can_freeze=True,
can_wipe=True,
can_pause=True,
can_transfer_nft_create_role=True,
can_change_owner=True,
can_upgrade=False,
can_add_special_roles=False
)
assert transaction.data
assert transaction.data.decode() == "registerMetaESDT@4652414e4b@4652414e4b@0a@63616e467265657a65@74727565@63616e57697065@74727565@63616e5061757365@74727565@63616e5472616e736665724e4654437265617465526f6c65@74727565@63616e4368616e67654f776e6572@74727565@63616e55706772616465@66616c7365@63616e4164645370656369616c526f6c6573@66616c7365"
assert transaction.sender == frank.to_bech32()
assert transaction.receiver == "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u"
assert transaction.amount == 50000000000000000
def test_create_transaction_for_setting_special_role_on_non_fungible_token():
transaction = factory.create_transaction_for_setting_special_role_on_non_fungible_token(
sender=frank,
user=grace,
token_identifier="FRANK-11ce3e",
add_role_nft_create=True,
add_role_nft_burn=False,
add_role_nft_update_attributes=True,
add_role_nft_add_uri=True,
add_role_esdt_transfer_role=False
)
assert transaction.data
assert transaction.data.decode() == "setSpecialRole@4652414e4b2d313163653365@1e8a8b6b49de5b7be10aaa158a5a6a4abb4b56cc08f524bb5e6cd5f211ad3e13@45534454526f6c654e4654437265617465@45534454526f6c654e465455706461746541747472696275746573@45534454526f6c654e4654416464555249"
assert transaction.sender == frank.to_bech32()
assert transaction.receiver == "erd1qqqqqqqqqqqqqqqpqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzllls8a5w6u"
assert transaction.amount == 0
def test_create_transaction_for_creating_nft():
transaction = factory.create_transaction_for_creating_nft(
sender=grace,
token_identifier="FRANK-aa9e8d",
initial_quantity=1,
name="test",
royalties=1000,
hash="abba",
attributes=bytes("test", "utf-8"),
uris=["a", "b"]
)
assert transaction.data
assert transaction.data.decode() == "ESDTNFTCreate@4652414e4b2d616139653864@01@74657374@03e8@61626261@74657374@61@62"
assert transaction.sender == grace.to_bech32()
assert transaction.receiver == grace.to_bech32()
assert transaction.amount == 0