11use anchor_lang:: prelude:: * ;
22
3+ // TODO: standardize imports across all files
34use anchor_spl:: associated_token:: AssociatedToken ;
45use anchor_spl:: token_interface:: { Mint , TokenAccount , TokenInterface } ;
56
7+ // TODO: check that the discriminator size is used everywhere
68use crate :: constants:: DISCRIMINATOR_SIZE ;
79use crate :: constraints:: is_local_or_remote_owner;
810
@@ -13,15 +15,13 @@ use crate::{
1315 state:: { RootBundle , Route , State } ,
1416} ;
1517
16- //TODO: there is too much in this file now and it should be split up somewhat.
17-
1818#[ derive( Accounts ) ]
1919#[ instruction( seed: u64 ) ]
2020pub struct Initialize < ' info > {
2121 #[ account( init, // Use init, not init_if_needed to prevent re-initialization.
2222 payer = signer,
23- space = DISCRIMINATOR_SIZE + State :: INIT_SPACE ,
24- seeds = [ b"state" , seed. to_le_bytes( ) . as_ref( ) ] ,
23+ space = DISCRIMINATOR_SIZE + State :: INIT_SPACE , // TODO: check that INIT_SPACE is used everywhere
24+ seeds = [ b"state" , seed. to_le_bytes( ) . as_ref( ) ] , // TODO: can we set a blank seed? or something better?
2525 bump) ]
2626 pub state : Account < ' info , State > ,
2727
@@ -107,11 +107,12 @@ pub struct TransferOwnership<'info> {
107107
108108 #[ account(
109109 mut ,
110- address = state. owner @ CustomError :: NotOwner
110+ address = state. owner @ CustomError :: NotOwner // TODO: test permissioning with a multi-sig and Squads
111111 ) ]
112112 pub signer : Signer < ' info > ,
113113}
114114
115+ // TODO: check that the recovery flow is similar to the one in EVM
115116pub fn transfer_ownership ( ctx : Context < TransferOwnership > , new_owner : Pubkey ) -> Result < ( ) > {
116117 let state = & mut ctx. accounts . state ;
117118 state. owner = new_owner;
@@ -138,6 +139,7 @@ pub fn set_cross_domain_admin(
138139 let state = & mut ctx. accounts . state ;
139140 state. cross_domain_admin = cross_domain_admin;
140141
142+ // TODO: add lint to make this a 1-liner
141143 emit_cpi ! ( SetXDomainAdmin {
142144 new_admin: cross_domain_admin,
143145 } ) ;
@@ -147,7 +149,7 @@ pub fn set_cross_domain_admin(
147149
148150#[ event_cpi]
149151#[ derive( Accounts ) ]
150- #[ instruction( origin_token: [ u8 ; 32 ] , destination_chain_id: u64 ) ]
152+ #[ instruction( origin_token: [ u8 ; 32 ] , destination_chain_id: u64 ) ] // TODO: is it possible to replace origin_token with Pubkey?
151153pub struct SetEnableRoute < ' info > {
152154 #[ account(
153155 mut ,
@@ -158,6 +160,7 @@ pub struct SetEnableRoute<'info> {
158160 #[ account( mut ) ]
159161 pub payer : Signer < ' info > ,
160162
163+ // TODO: check if state needs to be mut here and in other places
161164 #[ account( mut , seeds = [ b"state" , state. seed. to_le_bytes( ) . as_ref( ) ] , bump) ]
162165 pub state : Account < ' info , State > ,
163166
@@ -216,11 +219,12 @@ pub struct RelayRootBundle<'info> {
216219 ) ]
217220 pub signer : Signer < ' info > ,
218221
222+ // TODO: standardize usage of state.seed vs state.key()
219223 #[ account( mut , seeds = [ b"state" , state. seed. to_le_bytes( ) . as_ref( ) ] , bump) ]
220224 pub state : Account < ' info , State > ,
221225
222226 // TODO: consider deriving seed from state.seed instead of state.key() as this could be cheaper (need to verify).
223- #[ account( init,
227+ #[ account( init, // TODO: add comment explaining why init
224228 payer = signer,
225229 space = DISCRIMINATOR_SIZE + RootBundle :: INIT_SPACE ,
226230 seeds =[ b"root_bundle" , state. key( ) . as_ref( ) , state. root_bundle_id. to_le_bytes( ) . as_ref( ) ] ,
@@ -240,5 +244,9 @@ pub fn relay_root_bundle(
240244 root_bundle. relayer_refund_root = relayer_refund_root;
241245 root_bundle. slow_relay_root = slow_relay_root;
242246 state. root_bundle_id += 1 ;
247+
248+ // TODO: add event
243249 Ok ( ( ) )
244250}
251+
252+ // TODO: add emergency_delete_root_bundle
0 commit comments