@@ -64,30 +64,44 @@ ApprovalForAll: event({
64
64
_approved: bool
65
65
})
66
66
67
+ # @dev MUST emit when the URI is updated for a token ID.
68
+ # URIs are defined in RFC 3986.
69
+ # The URI MUST point to a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".
70
+ # event URI(string _value, uint256 indexed _id);
71
+ URI: event ({
72
+ # https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers
73
+ _value: string [MAX_URI_SIZE],
74
+ _id: indexed (uint256 )
75
+ })
67
76
68
77
69
- supportedInterfaces: map (bytes32 , bool )
78
+ # TODO: decide which batch size to use
79
+ BATCH_SIZE: constant (uint256 ) = 5
80
+ MAX_URI_SIZE: constant (uint256 ) = 1024
70
81
71
82
# https://eips.ethereum.org/EIPS/eip-165
72
- ERC165_INTERFACE_ID: constant (bytes32 ) = 0x0000000000000000000000000000000000000000000000000000000001ffc9a7
73
- ERC1155_INTERFACE_ID: constant (bytes32 ) = 0x00000000000000000000000000000000000000000000000000000000d9b67a26
83
+ INTERFACE_ID_ERC165: constant (bytes32 ) = 0x0000000000000000000000000000000000000000000000000000000001ffc9a7
84
+ INTERFACE_ID_ERC1155: constant (bytes32 ) = 0x00000000000000000000000000000000000000000000000000000000d9b67a26
85
+ INTERFACE_ID_ERC1155_METADATA: constant (bytes32 ) = 0x000000000000000000000000000000000000000000000000000000000e89341c
86
+
87
+ supportedInterfaces: map (bytes32 , bool )
74
88
75
89
tokensIdCount: uint256
76
90
77
91
_balanceOf: map (address , map (uint256 , uint256 ))
78
92
79
- operators : map (address , map ( address , bool ) )
93
+ _uri : map (uint256 , string [MAX_URI_SIZE] )
80
94
81
- # TODO: decide which batch size to use
82
- BATCH_SIZE: constant (uint256 ) = 5
95
+ operators: map (address , map (address , bool ))
83
96
84
97
85
98
86
99
@public
87
100
def __init__ ():
88
101
self .tokensIdCount = 0
89
- self .supportedInterfaces[ERC165_INTERFACE_ID] = True
90
- self .supportedInterfaces[ERC1155_INTERFACE_ID] = True
102
+ self .supportedInterfaces[INTERFACE_ID_ERC165] = True
103
+ self .supportedInterfaces[INTERFACE_ID_ERC1155] = True
104
+ self .supportedInterfaces[INTERFACE_ID_ERC1155_METADATA] = True
91
105
92
106
93
107
@public
@@ -181,6 +195,26 @@ def balanceOf(
181
195
return self ._balanceOf[_owner][_id]
182
196
183
197
198
+ # NOTE: This is not part of the standard
199
+ # TODO: Right now everyone can set/change an uri
200
+ # https://www.ietf.org/rfc/rfc3986.txt
201
+ @public
202
+ def setUri (_id: uint256 , _newUri: string [MAX_URI_SIZE]):
203
+ self ._uri[_id] = _newUri
204
+ log.URI (_newUri, _id)
205
+
206
+
207
+ # @notice A distinct Uniform Resource Identifier (URI) for a given token.
208
+ # @dev URIs are defined in RFC 3986. (https://www.ietf.org/rfc/rfc3986.txt)
209
+ # The URI MUST point to a JSON file that conforms to the "ERC-1155 Metadata URI JSON Schema".
210
+ # @return URI string
211
+ # function uri(uint256 _id) external view returns (string memory);
212
+ @public
213
+ @constant
214
+ def uri (_id: uint256 ) -> string [MAX_URI_SIZE]:
215
+ return self ._uri[_id]
216
+
217
+
184
218
# @notice Get the balance of multiple account/token pairs
185
219
# @param _owners The addresses of the token holders
186
220
# @param _ids ID of the tokens
0 commit comments