@@ -39,13 +39,15 @@ abstract contract UTXOToken is ERC20, IUTXOERC20 {
39
39
* @param tokenId The identifier of the token transaction.
40
40
* @param value The amount of tokens to transfer.
41
41
* @param signature The signature associated with the transaction.
42
+ * @param extraData The extra data for transaction output.
42
43
*/
43
44
function _transfer (
44
45
address from ,
45
46
address to ,
46
47
bytes32 tokenId ,
47
48
uint256 value ,
48
- bytes memory signature
49
+ bytes memory signature ,
50
+ bytes32 extraData
49
51
) internal virtual {
50
52
uint256 txvalue = _UTXO.transactionValue (tokenId);
51
53
if (txvalue < value) {
@@ -58,7 +60,8 @@ abstract contract UTXOToken is ERC20, IUTXOERC20 {
58
60
UnspentTransactionOutput.TransactionOutput (value, to),
59
61
tokenId,
60
62
UnspentTransactionOutput.calculateTransactionHash (from, _UTXO.transactionCount (from)),
61
- from
63
+ from,
64
+ extraData
62
65
);
63
66
}
64
67
_update (from, to, value);
@@ -68,13 +71,15 @@ abstract contract UTXOToken is ERC20, IUTXOERC20 {
68
71
* @dev Internal function to mint tokens and create a transaction for the minted tokens.
69
72
* @param account The address that will receive the minted tokens.
70
73
* @param value The amount of tokens to mint and transfer.
74
+ * @param extraData The extra data for transaction output.
71
75
*/
72
- function _mintTransaction (address account , uint256 value ) internal {
76
+ function _mintTransaction (address account , uint256 value , bytes32 extraData ) internal {
73
77
_UTXO.createTransaction (
74
78
UnspentTransactionOutput.TransactionOutput (value, account),
75
79
bytes32 (0 ),
76
80
UnspentTransactionOutput.calculateTransactionHash (address (0 ), _UTXO.transactionCount (address (0 ))),
77
- address (0 )
81
+ address (0 ),
82
+ extraData
78
83
);
79
84
_mint (account, value);
80
85
}
@@ -84,8 +89,9 @@ abstract contract UTXOToken is ERC20, IUTXOERC20 {
84
89
* @param account The address from which tokens will be burned.
85
90
* @param tokenId The identifier of the token transaction to be burned.
86
91
* @param value The amount of tokens to burn.
92
+ * @param extraData The extra data for transaction output.
87
93
*/
88
- function _burnTransaction (address account , bytes32 tokenId , uint256 value ) internal {
94
+ function _burnTransaction (address account , bytes32 tokenId , uint256 value , bytes32 extraData ) internal {
89
95
if (value == _UTXO.transactionValue (tokenId)) {
90
96
_UTXO.consumeTransaction (tokenId, account);
91
97
} else {
@@ -94,7 +100,8 @@ abstract contract UTXOToken is ERC20, IUTXOERC20 {
94
100
UnspentTransactionOutput.TransactionOutput (value, account),
95
101
tokenId,
96
102
UnspentTransactionOutput.calculateTransactionHash (account, _UTXO.transactionCount (account)),
97
- account
103
+ account,
104
+ extraData
98
105
);
99
106
}
100
107
_burn (account, value);
@@ -145,6 +152,15 @@ abstract contract UTXOToken is ERC20, IUTXOERC20 {
145
152
return _UTXO.transactionOwner (tokenId);
146
153
}
147
154
155
+ /**
156
+ * @dev Function to fetch the extra data of a UTXO transaction identified by its token ID.
157
+ * @param tokenId The identifier of the UTXO transaction.
158
+ * @return The extra data of the UTXO associated with the specified token ID.
159
+ */
160
+ function transactionExtraData (bytes32 tokenId ) public view returns (bytes32 ) {
161
+ return _UTXO.transactionExtraData (tokenId);
162
+ }
163
+
148
164
/**
149
165
* @dev Function to checks whether a UTXO transaction has been spent, identified by its token ID.
150
166
* @param tokenId The identifier of the UTXO transaction.
@@ -170,7 +186,7 @@ abstract contract UTXOToken is ERC20, IUTXOERC20 {
170
186
uint256 value ,
171
187
bytes memory signature
172
188
) public virtual override returns (bool ) {
173
- _transfer (msg .sender , to, tokenId, value, signature);
189
+ _transfer (msg .sender , to, tokenId, value, signature, bytes32 ( "" ) );
174
190
return true ;
175
191
}
176
192
@@ -192,7 +208,7 @@ abstract contract UTXOToken is ERC20, IUTXOERC20 {
192
208
bytes memory signature
193
209
) public virtual override returns (bool ) {
194
210
_spendAllowance (from, msg .sender , value);
195
- _transfer (from, to, tokenId, value, signature);
211
+ _transfer (from, to, tokenId, value, signature, bytes32 ( "" ) );
196
212
return true ;
197
213
}
198
214
}
0 commit comments