@@ -4,15 +4,33 @@ use crate::{shimless::initialize::AuctionParametersConfig, utils::Chain};
4
4
use anchor_lang:: prelude:: * ;
5
5
use solana_sdk:: signature:: Keypair ;
6
6
7
+ pub trait InstructionConfig : Default {
8
+ fn expected_error ( & self ) -> Option < & ExpectedError > ;
9
+ }
10
+
11
+ /// A type alias for an optional value that overwrites the current state
7
12
pub type OverwriteCurrentState < T > = Option < T > ;
8
13
14
+ /// A struct representing an expected error
15
+ ///
16
+ /// # Fields
17
+ ///
18
+ /// * `instruction_index` - The index of the instruction that is expected to error
19
+ /// * `error_code` - The error code that is expected to be returned
20
+ /// * `error_string` - The error string that is expected to be returned
9
21
#[ derive( Clone ) ]
10
22
pub struct ExpectedError {
11
23
pub instruction_index : u8 ,
12
24
pub error_code : u32 ,
13
25
pub error_string : String ,
14
26
}
15
27
28
+ /// A struct representing an expected log
29
+ ///
30
+ /// # Fields
31
+ ///
32
+ /// * `log_message` - The log message that is expected to be returned
33
+ /// * `count` - The number of times the log message is expected to appear
16
34
#[ derive( Clone ) ]
17
35
pub struct ExpectedLog {
18
36
pub log_message : String ,
@@ -25,6 +43,11 @@ pub struct InitializeInstructionConfig {
25
43
pub expected_error : Option < ExpectedError > ,
26
44
}
27
45
46
+ impl InstructionConfig for InitializeInstructionConfig {
47
+ fn expected_error ( & self ) -> Option < & ExpectedError > {
48
+ self . expected_error . as_ref ( )
49
+ }
50
+ }
28
51
pub struct CreateCctpRouterEndpointsInstructionConfig {
29
52
pub chains : HashSet < Chain > ,
30
53
pub payer_signer : Option < Rc < Keypair > > ,
@@ -42,6 +65,13 @@ impl Default for CreateCctpRouterEndpointsInstructionConfig {
42
65
}
43
66
}
44
67
}
68
+
69
+ impl InstructionConfig for CreateCctpRouterEndpointsInstructionConfig {
70
+ fn expected_error ( & self ) -> Option < & ExpectedError > {
71
+ self . expected_error . as_ref ( )
72
+ }
73
+ }
74
+
45
75
#[ derive( Clone , Default ) ]
46
76
pub struct InitializeFastMarketOrderShimInstructionConfig {
47
77
pub fast_market_order_id : u32 ,
@@ -50,6 +80,12 @@ pub struct InitializeFastMarketOrderShimInstructionConfig {
50
80
pub expected_error : Option < ExpectedError > ,
51
81
}
52
82
83
+ impl InstructionConfig for InitializeFastMarketOrderShimInstructionConfig {
84
+ fn expected_error ( & self ) -> Option < & ExpectedError > {
85
+ self . expected_error . as_ref ( )
86
+ }
87
+ }
88
+
53
89
#[ derive( Clone , Default ) ]
54
90
pub struct PrepareOrderInstructionConfig {
55
91
pub fast_market_order_address : OverwriteCurrentState < Pubkey > ,
@@ -59,6 +95,12 @@ pub struct PrepareOrderInstructionConfig {
59
95
pub expected_log_messages : Option < Vec < ExpectedLog > > ,
60
96
}
61
97
98
+ impl InstructionConfig for PrepareOrderInstructionConfig {
99
+ fn expected_error ( & self ) -> Option < & ExpectedError > {
100
+ self . expected_error . as_ref ( )
101
+ }
102
+ }
103
+
62
104
#[ derive( Clone , Default ) ]
63
105
pub struct ExecuteOrderInstructionConfig {
64
106
pub fast_market_order_address : OverwriteCurrentState < Pubkey > ,
@@ -67,19 +109,37 @@ pub struct ExecuteOrderInstructionConfig {
67
109
pub expected_error : Option < ExpectedError > ,
68
110
}
69
111
112
+ impl InstructionConfig for ExecuteOrderInstructionConfig {
113
+ fn expected_error ( & self ) -> Option < & ExpectedError > {
114
+ self . expected_error . as_ref ( )
115
+ }
116
+ }
117
+
70
118
#[ derive( Clone , Default ) ]
71
119
pub struct SettleAuctionInstructionConfig {
72
120
pub payer_signer : Option < Rc < Keypair > > ,
73
121
pub expected_error : Option < ExpectedError > ,
74
122
}
75
123
124
+ impl InstructionConfig for SettleAuctionInstructionConfig {
125
+ fn expected_error ( & self ) -> Option < & ExpectedError > {
126
+ self . expected_error . as_ref ( )
127
+ }
128
+ }
129
+
76
130
#[ derive( Clone , Default ) ]
77
131
pub struct CloseFastMarketOrderShimInstructionConfig {
78
132
pub close_account_refund_recipient_keypair : Option < Rc < Keypair > > , // If none, will use the solver 0 keypair
79
133
pub fast_market_order_address : OverwriteCurrentState < Pubkey > , // If none, will use the fast market order address from the current state
80
134
pub expected_error : Option < ExpectedError > ,
81
135
}
82
136
137
+ impl InstructionConfig for CloseFastMarketOrderShimInstructionConfig {
138
+ fn expected_error ( & self ) -> Option < & ExpectedError > {
139
+ self . expected_error . as_ref ( )
140
+ }
141
+ }
142
+
83
143
pub struct PlaceInitialOfferInstructionConfig {
84
144
pub solver_index : usize ,
85
145
pub offer_price : u64 ,
@@ -100,6 +160,12 @@ impl Default for PlaceInitialOfferInstructionConfig {
100
160
}
101
161
}
102
162
163
+ impl InstructionConfig for PlaceInitialOfferInstructionConfig {
164
+ fn expected_error ( & self ) -> Option < & ExpectedError > {
165
+ self . expected_error . as_ref ( )
166
+ }
167
+ }
168
+
103
169
pub struct ImproveOfferInstructionConfig {
104
170
pub solver_index : usize ,
105
171
pub offer_price : u64 ,
@@ -117,3 +183,9 @@ impl Default for ImproveOfferInstructionConfig {
117
183
}
118
184
}
119
185
}
186
+
187
+ impl InstructionConfig for ImproveOfferInstructionConfig {
188
+ fn expected_error ( & self ) -> Option < & ExpectedError > {
189
+ self . expected_error . as_ref ( )
190
+ }
191
+ }
0 commit comments