@@ -44,8 +44,6 @@ pub struct CurrentAggKey;
44
44
pub struct CurrentOnChainKey ;
45
45
#[ derive( Clone , Encode , Decode , PartialEq , Debug , TypeInfo ) ]
46
46
pub struct SolanaAddressLookupTables ( pub SwapRequestId ) ;
47
- #[ derive( Clone , Encode , Decode , PartialEq , Debug , TypeInfo ) ]
48
- pub struct ChainflipAddressLookupTable ;
49
47
50
48
pub type DurableNonceAndAccount = ( SolAddress , SolHash ) ;
51
49
@@ -78,7 +76,6 @@ pub trait SolanaEnvironment:
78
76
+ ChainEnvironment < DurableNonce , DurableNonceAndAccount >
79
77
+ ChainEnvironment < AllNonceAccounts , Vec < DurableNonceAndAccount > >
80
78
+ ChainEnvironment < SolanaAddressLookupTables , Vec < SolAddressLookupTableAccount > >
81
- + ChainEnvironment < ChainflipAddressLookupTable , SolAddressLookupTableAccount >
82
79
+ RecoverDurableNonce
83
80
{
84
81
fn compute_price ( ) -> Result < SolAmount , SolanaTransactionBuildingError > {
@@ -110,18 +107,9 @@ pub trait SolanaEnvironment:
110
107
. ok_or ( SolanaTransactionBuildingError :: NoNonceAccountsSet )
111
108
}
112
109
113
- /// Get all relevant Address lookup tables from the Environment.
114
- /// Returns Chainflip's ALT proceeded with user's ALTs.
115
- fn get_address_lookup_tables ( id : Option < SwapRequestId > ) -> Vec < SolAddressLookupTableAccount > {
116
- let mut alts = Self :: get_cf_address_lookup_table ( ) . map ( |alt| vec ! [ alt] ) . unwrap_or_default ( ) ;
117
- if let Some ( id) = id {
118
- alts. extend ( Self :: lookup ( SolanaAddressLookupTables ( id) ) . unwrap_or_default ( ) ) ;
119
- }
120
- alts
121
- }
122
-
123
- fn get_cf_address_lookup_table ( ) -> Option < SolAddressLookupTableAccount > {
124
- Self :: lookup ( ChainflipAddressLookupTable )
110
+ /// Get any relevant Address lookup tables from the Environment. Those are user-defined.
111
+ fn get_address_lookup_tables ( id : SwapRequestId ) -> Vec < SolAddressLookupTableAccount > {
112
+ Self :: lookup ( SolanaAddressLookupTables ( id) ) . unwrap_or_default ( )
125
113
}
126
114
}
127
115
@@ -329,7 +317,6 @@ impl<Environment: SolanaEnvironment> SolanaApi<Environment> {
329
317
let nonce_accounts = Environment :: all_nonce_accounts ( ) ?;
330
318
let compute_price = Environment :: compute_price ( ) ?;
331
319
let durable_nonce = Environment :: nonce_account ( ) ?;
332
- let address_lookup_tables = Environment :: get_address_lookup_tables ( None ) ;
333
320
334
321
// Build the transaction
335
322
let transaction = SolanaTransactionBuilder :: rotate_agg_key (
@@ -341,7 +328,7 @@ impl<Environment: SolanaEnvironment> SolanaApi<Environment> {
341
328
sol_api_environment. alt_manager_program ,
342
329
durable_nonce,
343
330
compute_price,
344
- address_lookup_tables ,
331
+ vec ! [ sol_api_environment . address_lookup_table_account ] ,
345
332
)
346
333
. inspect_err ( |e| {
347
334
// Vault Rotation call building NOT transactional - meaning when this fails,
@@ -409,7 +396,10 @@ impl<Environment: SolanaEnvironment> SolanaApi<Environment> {
409
396
let sol_api_environment = Environment :: api_environment ( ) ?;
410
397
let agg_key = Environment :: current_agg_key ( ) ?;
411
398
// TODO roy: Coordinate with Ramiz on the interface for getting ALTS
412
- let address_lookup_tables = Environment :: get_address_lookup_tables ( Some ( swap_request_id) ) ;
399
+ let user_address_lookup_tables = Environment :: get_address_lookup_tables ( swap_request_id) ;
400
+
401
+ let mut address_lookup_tables = vec ! [ sol_api_environment. address_lookup_table_account] ;
402
+ address_lookup_tables. extend ( user_address_lookup_tables) ;
413
403
414
404
// Ensure the CCM parameters do not contain blacklisted accounts.
415
405
check_ccm_for_blacklisted_accounts (
@@ -507,7 +497,6 @@ impl<Environment: SolanaEnvironment> SolanaApi<Environment> {
507
497
let sol_api_environment = Environment :: api_environment ( ) ?;
508
498
let compute_price = Environment :: compute_price ( ) ?;
509
499
let durable_nonce = Environment :: nonce_account ( ) ?;
510
- let address_lookup_tables = Environment :: get_address_lookup_tables ( None ) ;
511
500
512
501
// Build the transaction
513
502
let transaction = SolanaTransactionBuilder :: fetch_and_close_vault_swap_accounts (
@@ -518,7 +507,7 @@ impl<Environment: SolanaEnvironment> SolanaApi<Environment> {
518
507
agg_key,
519
508
durable_nonce,
520
509
compute_price,
521
- address_lookup_tables ,
510
+ vec ! [ sol_api_environment . address_lookup_table_account ] ,
522
511
) ?;
523
512
524
513
Ok ( Self {
@@ -541,7 +530,6 @@ impl<Environment: SolanaEnvironment> SolanaApi<Environment> {
541
530
let sol_api_environment = Environment :: api_environment ( ) ?;
542
531
let compute_price = Environment :: compute_price ( ) ?;
543
532
let durable_nonce = Environment :: nonce_account ( ) ?;
544
- let address_lookup_tables = Environment :: get_address_lookup_tables ( None ) ;
545
533
546
534
// Build the transaction
547
535
let transaction = SolanaTransactionBuilder :: set_program_swaps_parameters (
@@ -557,7 +545,7 @@ impl<Environment: SolanaEnvironment> SolanaApi<Environment> {
557
545
agg_key,
558
546
durable_nonce,
559
547
compute_price,
560
- address_lookup_tables ,
548
+ vec ! [ sol_api_environment . address_lookup_table_account ] ,
561
549
) ?;
562
550
563
551
Ok ( Self {
@@ -576,7 +564,6 @@ impl<Environment: SolanaEnvironment> SolanaApi<Environment> {
576
564
let sol_api_environment = Environment :: api_environment ( ) ?;
577
565
let compute_price = Environment :: compute_price ( ) ?;
578
566
let durable_nonce = Environment :: nonce_account ( ) ?;
579
- let address_lookup_tables = Environment :: get_address_lookup_tables ( None ) ;
580
567
581
568
// Build the transaction
582
569
let transaction = SolanaTransactionBuilder :: enable_token_support (
@@ -589,7 +576,7 @@ impl<Environment: SolanaEnvironment> SolanaApi<Environment> {
589
576
agg_key,
590
577
durable_nonce,
591
578
compute_price,
592
- address_lookup_tables ,
579
+ vec ! [ sol_api_environment . address_lookup_table_account ] ,
593
580
) ?;
594
581
595
582
Ok ( Self {
0 commit comments