@@ -3,19 +3,18 @@ pub mod AccountComponent {
33 // *************************************************************************
44 // IMPORTS
55 // *************************************************************************
6- use starknet :: storage :: StoragePointerReadAccess ;
7- use core :: {
8- result :: ResultTrait , hash :: HashStateTrait , pedersen :: PedersenTrait , num :: traits :: zero :: Zero
9- };
10- use starknet :: {
11- get_tx_info, get_contract_address, ContractAddress , account :: Call ,
12- syscalls :: call_contract_syscall, storage :: StoragePointerWriteAccess
13- };
14- use token_bound_accounts :: utils :: array_ext :: ArrayExt ;
15- use token_bound_accounts :: interfaces :: IAccount :: {IAccount , TBA_INTERFACE_ID };
16-
6+ use core :: hash :: HashStateTrait ;
7+ use core :: num :: traits :: zero :: Zero ;
8+ use core :: pedersen :: PedersenTrait ;
9+ use core :: result :: ResultTrait ;
1710 use openzeppelin_introspection :: src5 :: SRC5Component ;
18- use openzeppelin_introspection :: src5 :: SRC5Component :: {SRC5Impl , InternalImpl };
11+ use openzeppelin_introspection :: src5 :: SRC5Component :: {InternalImpl , SRC5Impl };
12+ use starknet :: account :: Call ;
13+ use starknet :: storage :: {StoragePointerReadAccess , StoragePointerWriteAccess };
14+ use starknet :: syscalls :: call_contract_syscall;
15+ use starknet :: {ContractAddress , get_contract_address, get_tx_info};
16+ use token_bound_accounts :: interfaces :: IAccount :: {IAccount , TBA_INTERFACE_ID };
17+ use token_bound_accounts :: utils :: array_ext :: ArrayExt ;
1918
2019 // *************************************************************************
2120 // STORAGE
@@ -25,7 +24,7 @@ pub mod AccountComponent {
2524 account_token_contract : ContractAddress , // contract address of NFT
2625 account_token_id : u256 , // token ID of NFT
2726 context : Context , // account deployment details
28- state : u256 , // account state
27+ state : u256 // account state
2928 }
3029
3130 // *************************************************************************
@@ -35,7 +34,7 @@ pub mod AccountComponent {
3534 #[derive(Drop , starknet:: Event )]
3635 pub enum Event {
3736 TBACreated : TBACreated ,
38- TransactionExecuted : TransactionExecuted
37+ TransactionExecuted : TransactionExecuted ,
3938 }
4039
4140 /// @notice Emitted exactly once when the account is initialized
@@ -46,7 +45,7 @@ pub mod AccountComponent {
4645 pub account_address : ContractAddress ,
4746 pub parent_account : ContractAddress ,
4847 pub token_contract : ContractAddress ,
49- pub token_id : u256
48+ pub token_id : u256 ,
5049 }
5150
5251 /// @notice Emitted when the account executes a transaction
@@ -58,7 +57,7 @@ pub mod AccountComponent {
5857 pub hash : felt252 ,
5958 #[key]
6059 pub account_address : ContractAddress ,
61- pub response : Span <Span <felt252 >>
60+ pub response : Span <Span <felt252 >>,
6261 }
6362
6463 // *************************************************************************
@@ -68,7 +67,7 @@ pub mod AccountComponent {
6867 struct Context {
6968 registry : ContractAddress ,
7069 implementation_hash : felt252 ,
71- salt : felt252
70+ salt : felt252 ,
7271 }
7372
7473 // *************************************************************************
@@ -88,7 +87,7 @@ pub mod AccountComponent {
8887 TContractState ,
8988 + HasComponent <TContractState >,
9089 + Drop <TContractState >,
91- impl SRC5 : SRC5Component :: HasComponent <TContractState >
90+ impl SRC5 : SRC5Component :: HasComponent <TContractState >,
9291 > of IAccount <ComponentState <TContractState >> {
9392 /// @notice gets the NFT owner
9493 /// @param token_contract the contract address of the NFT
@@ -112,7 +111,7 @@ pub mod AccountComponent {
112111 // @notice check that account supports TBA interface
113112 // @param interface_id interface to be checked against
114113 fn supports_interface (
115- self : @ ComponentState <TContractState >, interface_id : felt252
114+ self : @ ComponentState <TContractState >, interface_id : felt252 ,
116115 ) -> bool {
117116 get_dep_component! (self , SRC5 ). supports_interface (interface_id )
118117 }
@@ -126,7 +125,7 @@ pub mod AccountComponent {
126125 TContractState ,
127126 + HasComponent <TContractState >,
128127 + Drop <TContractState >,
129- impl SRC5 : SRC5Component :: HasComponent <TContractState >
128+ impl SRC5 : SRC5Component :: HasComponent <TContractState >,
130129 > of AccountPrivateTrait <TContractState > {
131130 /// @notice initializes the account by setting the initial token contract and token id
132131 fn initializer (
@@ -135,7 +134,7 @@ pub mod AccountComponent {
135134 token_id : u256 ,
136135 registry : ContractAddress ,
137136 implementation_hash : felt252 ,
138- salt : felt252
137+ salt : felt252 ,
139138 ) {
140139 let owner = self . _get_owner (token_contract , token_id );
141140 assert (owner . is_non_zero (), Errors :: UNAUTHORIZED );
@@ -159,16 +158,16 @@ pub mod AccountComponent {
159158 account_address : get_contract_address (),
160159 parent_account : owner ,
161160 token_contract ,
162- token_id
163- }
161+ token_id ,
162+ },
164163 );
165164 }
166165
167166 // @notice executes a transaction
168167 // @notice this should be called within an `execute` method in implementation contracts
169168 // @param calls an array of transactions to be executed
170169 fn _execute (
171- ref self : ComponentState <TContractState >, mut calls : Array <Call >
170+ ref self : ComponentState <TContractState >, mut calls : Array <Call >,
172171 ) -> Array <Span <felt252 >> {
173172 // update state
174173 self . _update_state ();
@@ -183,7 +182,7 @@ pub mod AccountComponent {
183182 let response = retdata . span ();
184183 self
185184 . emit (
186- TransactionExecuted { hash , account_address : get_contract_address (), response }
185+ TransactionExecuted { hash , account_address : get_contract_address (), response },
187186 );
188187 retdata
189188 }
@@ -207,12 +206,12 @@ pub mod AccountComponent {
207206 // Should work for contracts which implements CamelCase but not snake_case until starknet
208207 // v0.15.
209208 fn _get_owner (
210- self : @ ComponentState <TContractState >, token_contract : ContractAddress , token_id : u256
209+ self : @ ComponentState <TContractState >, token_contract : ContractAddress , token_id : u256 ,
211210 ) -> ContractAddress {
212211 let mut calldata : Array <felt252 > = ArrayTrait :: new ();
213212 Serde :: serialize (@ token_id , ref calldata );
214213 let mut res = call_contract_syscall (
215- token_contract , selector! (" ownerOf" ), calldata . span ()
214+ token_contract , selector! (" ownerOf" ), calldata . span (),
216215 );
217216 if (res . is_err ()) {
218217 res = call_contract_syscall (token_contract , selector! (" owner_of" ), calldata . span ());
@@ -237,7 +236,7 @@ pub mod AccountComponent {
237236 token_id : u256 ,
238237 registry : ContractAddress ,
239238 implementation : felt252 ,
240- salt : felt252
239+ salt : felt252 ,
241240 ) -> bool {
242241 let constructor_calldata_hash = PedersenTrait :: new (0 )
243242 . update (token_contract . into ())
@@ -274,7 +273,7 @@ pub mod AccountComponent {
274273 /// @notice internal function for executing transactions
275274 /// @param calls An array of transactions to be executed
276275 fn _execute_calls (
277- ref self : ComponentState <TContractState >, mut calls : Array <Call >
276+ ref self : ComponentState <TContractState >, mut calls : Array <Call >,
278277 ) -> Array <Span <felt252 >> {
279278 let mut result : Array <Span <felt252 >> = ArrayTrait :: new ();
280279 let mut calls = calls ;
@@ -292,12 +291,12 @@ pub mod AccountComponent {
292291 let mut data = array! [' multicall-failed' , index ];
293292 data . append_all (err . span ());
294293 panic (data );
295- }
294+ },
296295 }
297296 },
298- Option :: None (_ ) => { break (); }
297+ Option :: None (_ ) => { break (); },
299298 };
300- };
299+ }
301300 result
302301 }
303302 }
0 commit comments