@@ -11,8 +11,8 @@ use crate::{
1111 event:: {
1212 EmergencyDeleteRootBundle , EnabledDepositRoute , PausedDeposits , PausedFills , RelayedRootBundle , SetXDomainAdmin ,
1313 } ,
14- initialize_current_time, set_seed,
1514 state:: { RootBundle , Route , State } ,
15+ utils:: { initialize_current_time, set_seed} ,
1616} ;
1717
1818#[ derive( Accounts ) ]
@@ -35,13 +35,13 @@ pub struct Initialize<'info> {
3535
3636pub fn initialize (
3737 ctx : Context < Initialize > ,
38- seed : u64 ,
39- initial_number_of_deposits : u32 ,
40- chain_id : u64 , // Across definition of chainId for Solana.
41- remote_domain : u32 , // CCTP domain for Mainnet Ethereum.
42- cross_domain_admin : Pubkey , // HubPool on Mainnet Ethereum.
43- deposit_quote_time_buffer : u32 , // Deposit quote times can't be set more than this amount into the past/future.
44- fill_deadline_buffer : u32 , // Fill deadlines can't be set more than this amount into the future.
38+ seed : u64 , // Seed used to derive a new state to enable testing to reset between runs.
39+ initial_number_of_deposits : u32 , // Starting number of deposits to offset deposit_id.
40+ chain_id : u64 , // Across definition of chainId for Solana.
41+ remote_domain : u32 , // CCTP domain for Mainnet Ethereum.
42+ cross_domain_admin : Pubkey , // HubPool on Mainnet Ethereum.
43+ deposit_quote_time_buffer : u32 , // Deposit quote times can't be set more than this amount into the past/future.
44+ fill_deadline_buffer : u32 , // Fill deadlines can't be set more than this amount into the future.
4545) -> Result < ( ) > {
4646 let state = & mut ctx. accounts . state ;
4747 state. owner = * ctx. accounts . signer . key ;
@@ -99,11 +99,11 @@ pub fn pause_fills(ctx: Context<PauseFills>, pause: bool) -> Result<()> {
9999
100100#[ derive( Accounts ) ]
101101pub struct TransferOwnership < ' info > {
102- #[ account( mut , seeds = [ b"state" , state. seed. to_le_bytes( ) . as_ref( ) ] , bump) ]
103- pub state : Account < ' info , State > ,
104-
105102 #[ account( address = state. owner @ SvmError :: NotOwner ) ]
106103 pub signer : Signer < ' info > ,
104+
105+ #[ account( mut , seeds = [ b"state" , state. seed. to_le_bytes( ) . as_ref( ) ] , bump) ]
106+ pub state : Account < ' info , State > ,
107107}
108108
109109pub fn transfer_ownership ( ctx : Context < TransferOwnership > , new_owner : Pubkey ) -> Result < ( ) > {
@@ -158,7 +158,7 @@ pub struct SetEnableRoute<'info> {
158158 ] ,
159159 bump
160160 ) ]
161- pub route : Account < ' info , Route > ,
161+ pub route : Account < ' info , Route > , // PDA to store route information for this particular token & chainId pair.
162162
163163 #[ account(
164164 init_if_needed,
@@ -167,11 +167,11 @@ pub struct SetEnableRoute<'info> {
167167 associated_token:: authority = state,
168168 associated_token:: token_program = token_program
169169 ) ]
170- pub vault : InterfaceAccount < ' info , TokenAccount > ,
170+ pub vault : InterfaceAccount < ' info , TokenAccount > , // ATA, owned by the state, to store the origin token for spoke.
171171
172172 #[ account(
173173 mint:: token_program = token_program,
174- // IDL build fails when requiring ` address = origin_token` for mint, thus using a custom constraint.
174+ // IDL build fails when requiring address = origin_token for mint, thus using a custom constraint.
175175 constraint = origin_token_mint. key( ) == origin_token @ SvmError :: InvalidMint
176176 ) ]
177177 pub origin_token_mint : InterfaceAccount < ' info , Mint > ,
@@ -211,7 +211,7 @@ pub struct RelayRootBundle<'info> {
211211 pub state : Account < ' info , State > ,
212212
213213 #[ account(
214- init, // Init to create root bundle account. Prevents re-initialization.
214+ init, // Init to create root bundle account. Prevents re-initialization for a given root. .
215215 payer = payer,
216216 space = DISCRIMINATOR_SIZE + RootBundle :: INIT_SPACE ,
217217 seeds = [ b"root_bundle" , state. seed. to_le_bytes( ) . as_ref( ) , state. root_bundle_id. to_le_bytes( ) . as_ref( ) ] ,
0 commit comments