88//!
99//! Note that this code is unaudited and not fit for production use.
1010
11- use alloc:: { string:: String , vec:: Vec } ;
12- use alloy_primitives:: { Address , U256 } ;
13- use alloy_sol_types:: { sol, SolError } ;
14- use core:: { borrow:: BorrowMut , marker:: PhantomData } ;
15- use stylus_sdk:: { abi:: Bytes , evm, msg, prelude:: * } ;
11+ use alloc:: {
12+ string:: String ,
13+ vec:: Vec ,
14+ } ;
15+ use alloy_primitives:: {
16+ Address ,
17+ U256 ,
18+ } ;
19+ use alloy_sol_types:: {
20+ sol,
21+ SolError ,
22+ } ;
23+ use core:: {
24+ borrow:: BorrowMut ,
25+ marker:: PhantomData ,
26+ } ;
27+ use stylus_sdk:: {
28+ abi:: Bytes ,
29+ evm,
30+ msg,
31+ prelude:: * ,
32+ } ;
1633
1734pub trait ERC1155Params {
1835 fn uri ( id : U256 ) -> String ;
@@ -100,10 +117,8 @@ impl<T: ERC1155Params> ERC1155<T> {
100117 if u32:: from_be_bytes ( received) != 0xf23a6e61 {
101118 return Err ( ERC1155Error :: UnsafeRecipient ( UnsafeRecipient { } ) ) ;
102119 }
103- } else {
104- if to == Address :: ZERO {
105- return Err ( ERC1155Error :: UnsafeRecipient ( UnsafeRecipient { } ) ) ;
106- }
120+ } else if to == Address :: ZERO {
121+ return Err ( ERC1155Error :: UnsafeRecipient ( UnsafeRecipient { } ) ) ;
107122 }
108123
109124 Ok ( ( ) )
@@ -127,10 +142,8 @@ impl<T: ERC1155Params> ERC1155<T> {
127142 if u32:: from_be_bytes ( received) != 0xbc197c81 {
128143 return Err ( ERC1155Error :: UnsafeRecipient ( UnsafeRecipient { } ) ) ;
129144 }
130- } else {
131- if to == Address :: ZERO {
132- return Err ( ERC1155Error :: UnsafeRecipient ( UnsafeRecipient { } ) ) ;
133- }
145+ } else if to == Address :: ZERO {
146+ return Err ( ERC1155Error :: UnsafeRecipient ( UnsafeRecipient { } ) ) ;
134147 }
135148
136149 Ok ( ( ) )
@@ -151,9 +164,9 @@ impl<T: ERC1155Params> ERC1155<T> {
151164 evm:: log ( TransferSingle {
152165 operator : msg:: sender ( ) ,
153166 from : Address :: ZERO ,
154- to : to ,
155- id : id ,
156- amount : amount ,
167+ to,
168+ id,
169+ amount,
157170 } ) ;
158171
159172 Self :: call_receiver ( storage, id, Address :: ZERO , to, amount, data. 0 ) ?;
@@ -184,7 +197,7 @@ impl<T: ERC1155Params> ERC1155<T> {
184197 evm:: log ( TransferBatch {
185198 operator : msg:: sender ( ) ,
186199 from : Address :: ZERO ,
187- to : to ,
200+ to,
188201 ids : ids. clone ( ) ,
189202 amounts : amounts. clone ( ) ,
190203 } ) ;
@@ -207,10 +220,10 @@ impl<T: ERC1155Params> ERC1155<T> {
207220
208221 evm:: log ( TransferBatch {
209222 operator : msg:: sender ( ) ,
210- from : from ,
223+ from,
211224 to : Address :: ZERO ,
212- ids : ids ,
213- amounts : amounts ,
225+ ids,
226+ amounts,
214227 } ) ;
215228
216229 Ok ( ( ) )
@@ -223,10 +236,10 @@ impl<T: ERC1155Params> ERC1155<T> {
223236
224237 evm:: log ( TransferSingle {
225238 operator : msg:: sender ( ) ,
226- from : from ,
239+ from,
227240 to : Address :: ZERO ,
228- id : id ,
229- amount : amount ,
241+ id,
242+ amount,
230243 } ) ;
231244
232245 Ok ( ( ) )
@@ -255,8 +268,8 @@ impl<T: ERC1155Params> ERC1155<T> {
255268
256269 evm:: log ( ApprovalForAll {
257270 owner : msg:: sender ( ) ,
258- operator : operator ,
259- approved : approved ,
271+ operator,
272+ approved,
260273 } ) ;
261274
262275 Ok ( ( ) )
@@ -290,10 +303,10 @@ impl<T: ERC1155Params> ERC1155<T> {
290303
291304 evm:: log ( TransferSingle {
292305 operator : msg:: sender ( ) ,
293- from : from ,
294- to : to ,
295- id : id ,
296- amount : amount ,
306+ from,
307+ to,
308+ id,
309+ amount,
297310 } ) ;
298311
299312 Self :: call_receiver ( storage, id, from, to, amount, data. 0 )
@@ -336,8 +349,8 @@ impl<T: ERC1155Params> ERC1155<T> {
336349
337350 evm:: log ( TransferBatch {
338351 operator : msg:: sender ( ) ,
339- from : from ,
340- to : to ,
352+ from,
353+ to,
341354 ids : ids. clone ( ) ,
342355 amounts : amounts. clone ( ) ,
343356 } ) ;
0 commit comments