@@ -95,6 +95,12 @@ pub struct TransferBurn<'info> {
95
95
96
96
// TODO: fees for relaying?
97
97
pub fn transfer_burn ( ctx : Context < TransferBurn > , args : TransferArgs ) -> Result < ( ) > {
98
+ require_eq ! (
99
+ ctx. accounts. common. config. mode,
100
+ Mode :: Burning ,
101
+ NTTError :: InvalidMode
102
+ ) ;
103
+
98
104
let accs = ctx. accounts ;
99
105
let TransferArgs {
100
106
amount,
@@ -106,24 +112,21 @@ pub fn transfer_burn(ctx: Context<TransferBurn>, args: TransferArgs) -> Result<(
106
112
// TODO: should we revert if we have dust?
107
113
let amount = NormalizedAmount :: remove_dust ( amount, accs. common . mint . decimals ) ;
108
114
109
- match accs. common . config . mode {
110
- Mode :: Burning => token_interface:: burn (
111
- CpiContext :: new_with_signer (
112
- accs. common . token_program . to_account_info ( ) ,
113
- token_interface:: Burn {
114
- mint : accs. common . mint . to_account_info ( ) ,
115
- from : accs. common . from . to_account_info ( ) ,
116
- authority : accs. common . token_authority . to_account_info ( ) ,
117
- } ,
118
- & [ & [
119
- crate :: TOKEN_AUTHORITY_SEED ,
120
- & [ ctx. bumps . common . token_authority ] ,
121
- ] ] ,
122
- ) ,
123
- amount,
124
- ) ?,
125
- Mode :: Locking => return Err ( NTTError :: InvalidMode . into ( ) ) ,
126
- }
115
+ token_interface:: burn (
116
+ CpiContext :: new_with_signer (
117
+ accs. common . token_program . to_account_info ( ) ,
118
+ token_interface:: Burn {
119
+ mint : accs. common . mint . to_account_info ( ) ,
120
+ from : accs. common . from . to_account_info ( ) ,
121
+ authority : accs. common . token_authority . to_account_info ( ) ,
122
+ } ,
123
+ & [ & [
124
+ crate :: TOKEN_AUTHORITY_SEED ,
125
+ & [ ctx. bumps . common . token_authority ] ,
126
+ ] ] ,
127
+ ) ,
128
+ amount,
129
+ ) ?;
127
130
128
131
insert_into_outbox (
129
132
& mut accs. common ,
@@ -162,6 +165,12 @@ pub struct TransferLock<'info> {
162
165
// TODO: fees for relaying?
163
166
// TODO: factor out common bits
164
167
pub fn transfer_lock ( ctx : Context < TransferLock > , args : TransferArgs ) -> Result < ( ) > {
168
+ require_eq ! (
169
+ ctx. accounts. common. config. mode,
170
+ Mode :: Locking ,
171
+ NTTError :: InvalidMode
172
+ ) ;
173
+
165
174
let accs = ctx. accounts ;
166
175
let TransferArgs {
167
176
amount,
@@ -173,26 +182,23 @@ pub fn transfer_lock(ctx: Context<TransferLock>, args: TransferArgs) -> Result<(
173
182
// TODO: should we revert if we have dust?
174
183
let amount = NormalizedAmount :: remove_dust ( amount, accs. common . mint . decimals ) ;
175
184
176
- match accs. common . config . mode {
177
- Mode :: Burning => return Err ( NTTError :: InvalidMode . into ( ) ) ,
178
- Mode :: Locking => token_interface:: transfer_checked (
179
- CpiContext :: new_with_signer (
180
- accs. common . token_program . to_account_info ( ) ,
181
- token_interface:: TransferChecked {
182
- from : accs. common . from . to_account_info ( ) ,
183
- to : accs. custody . to_account_info ( ) ,
184
- authority : accs. common . token_authority . to_account_info ( ) ,
185
- mint : accs. common . mint . to_account_info ( ) ,
186
- } ,
187
- & [ & [
188
- crate :: TOKEN_AUTHORITY_SEED ,
189
- & [ ctx. bumps . common . token_authority ] ,
190
- ] ] ,
191
- ) ,
192
- amount,
193
- accs. common . mint . decimals ,
194
- ) ?,
195
- }
185
+ token_interface:: transfer_checked (
186
+ CpiContext :: new_with_signer (
187
+ accs. common . token_program . to_account_info ( ) ,
188
+ token_interface:: TransferChecked {
189
+ from : accs. common . from . to_account_info ( ) ,
190
+ to : accs. custody . to_account_info ( ) ,
191
+ authority : accs. common . token_authority . to_account_info ( ) ,
192
+ mint : accs. common . mint . to_account_info ( ) ,
193
+ } ,
194
+ & [ & [
195
+ crate :: TOKEN_AUTHORITY_SEED ,
196
+ & [ ctx. bumps . common . token_authority ] ,
197
+ ] ] ,
198
+ ) ,
199
+ amount,
200
+ accs. common . mint . decimals ,
201
+ ) ?;
196
202
197
203
insert_into_outbox (
198
204
& mut accs. common ,
0 commit comments