forked from hiero-ledger/hiero-contracts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTokenManagementContract.sol
More file actions
196 lines (153 loc) · 6.98 KB
/
Copy pathTokenManagementContract.sol
File metadata and controls
196 lines (153 loc) · 6.98 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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// SPDX-License-Identifier: Apache-2.0
pragma solidity >=0.5.0 <0.9.0;
pragma experimental ABIEncoderV2;
import "../../token-service/HederaTokenService.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
contract TokenManagementContract is HederaTokenService {
event ResponseCode(int responseCode);
event PausedToken(bool paused);
event UnpausedToken(bool unpaused);
function deleteTokenPublic(address token) public returns (int responseCode) {
responseCode = HederaTokenService.deleteToken(token);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert();
}
}
function freezeTokenPublic(address token, address account) public returns (int responseCode) {
responseCode = HederaTokenService.freezeToken(token, account);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert();
}
}
function unfreezeTokenPublic(address token, address account) public returns (int responseCode) {
responseCode = HederaTokenService.unfreezeToken(token, account);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert();
}
}
function revokeTokenKycPublic(address token, address account) external returns (int64 responseCode) {
(responseCode) = HederaTokenService.revokeTokenKyc(token, account);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert();
}
}
function pauseTokenPublic(address token) public returns (int responseCode) {
responseCode = HederaTokenService.pauseToken(token);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert();
}
emit PausedToken(true);
}
function unpauseTokenPublic(address token) public returns (int responseCode) {
responseCode = HederaTokenService.unpauseToken(token);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert();
}
emit UnpausedToken(true);
}
function wipeTokenAccountPublic(address token, address account, int64 amount) public returns (int responseCode) {
responseCode = HederaTokenService.wipeTokenAccount(token, account, amount);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert ();
}
}
function wipeTokenAccountNFTPublic(address token, address account, int64[] memory serialNumbers) public returns (int responseCode) {
responseCode = HederaTokenService.wipeTokenAccountNFT(token, account, serialNumbers);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert ();
}
}
function updateTokenInfoPublic(address token, IHederaTokenService.HederaToken memory tokenInfo)external returns (int responseCode) {
(responseCode) = HederaTokenService.updateTokenInfo(token, tokenInfo);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert();
}
}
function updateTokenExpiryInfoPublic(address token, IHederaTokenService.Expiry memory expiryInfo)external returns (int responseCode) {
(responseCode) = HederaTokenService.updateTokenExpiryInfo(token, expiryInfo);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert();
}
}
function updateTokenKeysPublic(address token, IHederaTokenService.TokenKey[] memory keys) public returns (int64 responseCode) {
(responseCode) = HederaTokenService.updateTokenKeys(token, keys);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert();
}
}
function burnTokenPublic(address token, int64 amount, int64[] memory serialNumbers) external returns (int256 responseCode, int64 newTotalSupply) {
(responseCode, newTotalSupply) = HederaTokenService.burnToken(token, amount, serialNumbers);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert ();
}
}
function dissociateTokensPublic(address account, address[] memory tokens) external returns (int256 responseCode) {
(responseCode) = HederaTokenService.dissociateTokens(account, tokens);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert ();
}
}
function dissociateTokenPublic(address account, address token) public returns (int responseCode) {
responseCode = HederaTokenService.dissociateToken(account, token);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert ();
}
}
function approvePublic(address token, address spender, uint256 amount) public returns (int responseCode) {
responseCode = HederaTokenService.approve(token, spender, amount);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert ();
}
}
function approveNFTPublic(address token, address approved, uint256 serialNumber) public returns (int responseCode) {
responseCode = HederaTokenService.approveNFT(token, approved, serialNumber);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert ();
}
}
function setApprovalForAllPublic(address token, address operator, bool approved) public returns (int responseCode) {
responseCode = HederaTokenService.setApprovalForAll(token, operator, approved);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert();
}
}
function updateFungibleTokenCustomFeesPublic(
address token,
IHederaTokenService.FixedFee[] memory fixedFees,
IHederaTokenService.FractionalFee[] memory fractionalFees
) public returns (int responseCode) {
responseCode = HederaTokenService.updateFungibleTokenCustomFees(token, fixedFees, fractionalFees);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert(Strings.toString(uint(responseCode)));
}
}
function updateNonFungibleTokenCustomFeesPublic(
address token,
IHederaTokenService.FixedFee[] memory fixedFees,
IHederaTokenService.RoyaltyFee[] memory royaltyFees
) public returns (int responseCode) {
responseCode = HederaTokenService.updateNonFungibleTokenCustomFees(token, fixedFees, royaltyFees);
emit ResponseCode(responseCode);
if (responseCode != HederaResponseCodes.SUCCESS) {
revert(Strings.toString(uint(responseCode)));
}
}
}