@@ -62,6 +62,7 @@ pub struct ReleaseInboundArgs {
62
62
pub struct ReleaseInboundMint < ' info > {
63
63
#[ account(
64
64
constraint = common. config. mode == Mode :: Burning @ NTTError :: InvalidMode ,
65
+ constraint = common. mint. mint_authority. unwrap( ) == common. token_authority. key( )
65
66
) ]
66
67
common : ReleaseInbound < ' info > ,
67
68
}
@@ -77,11 +78,6 @@ pub fn release_inbound_mint<'info>(
77
78
ctx : Context < ' _ , ' _ , ' _ , ' info , ReleaseInboundMint < ' info > > ,
78
79
args : ReleaseInboundArgs ,
79
80
) -> Result < ( ) > {
80
- if ctx. accounts . common . mint . mint_authority . unwrap ( ) != ctx. accounts . common . token_authority . key ( )
81
- {
82
- return Err ( NTTError :: InvalidMintAuthority . into ( ) ) ;
83
- }
84
-
85
81
let inbox_item = release_inbox_item ( & mut ctx. accounts . common . inbox_item , args. revert_on_delay ) ?;
86
82
87
83
// NOTE: minting tokens is a two-step process:
@@ -99,6 +95,11 @@ pub fn release_inbound_mint<'info>(
99
95
// The [`transfer_burn`] function operates in a similar way
100
96
// (transfer to custody from sender, *then* burn).
101
97
98
+ let token_authority_sig: & [ & [ & [ u8 ] ] ] = & [ & [
99
+ crate :: TOKEN_AUTHORITY_SEED ,
100
+ & [ ctx. bumps . common . token_authority ] ,
101
+ ] ] ;
102
+
102
103
// Step 1: mint tokens to the custody account
103
104
token_interface:: mint_to (
104
105
CpiContext :: new_with_signer (
@@ -108,10 +109,7 @@ pub fn release_inbound_mint<'info>(
108
109
to : ctx. accounts . common . custody . to_account_info ( ) ,
109
110
authority : ctx. accounts . common . token_authority . to_account_info ( ) ,
110
111
} ,
111
- & [ & [
112
- crate :: TOKEN_AUTHORITY_SEED ,
113
- & [ ctx. bumps . common . token_authority ] ,
114
- ] ] ,
112
+ token_authority_sig,
115
113
) ,
116
114
inbox_item. amount ,
117
115
) ?;
@@ -126,10 +124,7 @@ pub fn release_inbound_mint<'info>(
126
124
ctx. remaining_accounts ,
127
125
inbox_item. amount ,
128
126
ctx. accounts . common . mint . decimals ,
129
- & [ & [
130
- crate :: TOKEN_AUTHORITY_SEED ,
131
- & [ ctx. bumps . common . token_authority ] ,
132
- ] ] ,
127
+ token_authority_sig,
133
128
) ?;
134
129
Ok ( ( ) )
135
130
}
@@ -167,27 +162,28 @@ pub fn release_inbound_mint_multisig<'info>(
167
162
// The [`transfer_burn`] function operates in a similar way
168
163
// (transfer to custody from sender, *then* burn).
169
164
165
+ let token_authority_sig: & [ & [ & [ u8 ] ] ] = & [ & [
166
+ crate :: TOKEN_AUTHORITY_SEED ,
167
+ & [ ctx. bumps . common . token_authority ] ,
168
+ ] ] ;
169
+
170
170
// Step 1: mint tokens to the custody account
171
- let ix = spl_token_2022:: instruction:: mint_to (
172
- & ctx. accounts . common . token_program . key ( ) ,
173
- & ctx. accounts . common . mint . key ( ) ,
174
- & ctx. accounts . common . custody . key ( ) ,
175
- & ctx. accounts . multisig . key ( ) ,
176
- & [ & ctx. accounts . common . token_authority . key ( ) ] ,
177
- inbox_item. amount ,
178
- ) ?;
179
171
solana_program:: program:: invoke_signed (
180
- & ix,
172
+ & spl_token_2022:: instruction:: mint_to (
173
+ & ctx. accounts . common . token_program . key ( ) ,
174
+ & ctx. accounts . common . mint . key ( ) ,
175
+ & ctx. accounts . common . custody . key ( ) ,
176
+ & ctx. accounts . multisig . key ( ) ,
177
+ & [ & ctx. accounts . common . token_authority . key ( ) ] ,
178
+ inbox_item. amount ,
179
+ ) ?,
181
180
& [
182
181
ctx. accounts . common . custody . to_account_info ( ) ,
183
182
ctx. accounts . common . mint . to_account_info ( ) ,
184
183
ctx. accounts . common . token_authority . to_account_info ( ) ,
185
184
ctx. accounts . multisig . to_account_info ( ) ,
186
185
] ,
187
- & [ & [
188
- crate :: TOKEN_AUTHORITY_SEED ,
189
- & [ ctx. bumps . common . token_authority ] ,
190
- ] ] ,
186
+ token_authority_sig,
191
187
) ?;
192
188
193
189
// Step 2: transfer the tokens from the custody account to the recipient
@@ -200,10 +196,7 @@ pub fn release_inbound_mint_multisig<'info>(
200
196
ctx. remaining_accounts ,
201
197
inbox_item. amount ,
202
198
ctx. accounts . common . mint . decimals ,
203
- & [ & [
204
- crate :: TOKEN_AUTHORITY_SEED ,
205
- & [ ctx. bumps . common . token_authority ] ,
206
- ] ] ,
199
+ token_authority_sig,
207
200
) ?;
208
201
Ok ( ( ) )
209
202
}
@@ -250,17 +243,12 @@ pub fn release_inbound_unlock<'info>(
250
243
}
251
244
252
245
fn release_inbox_item ( inbox_item : & mut InboxItem , revert_on_delay : bool ) -> Result < & mut InboxItem > {
253
- let released = inbox_item. try_release ( ) ?;
254
-
255
- if !released {
256
- if revert_on_delay {
257
- return Err ( NTTError :: CantReleaseYet . into ( ) ) ;
258
- } else {
259
- return Ok ( inbox_item) ;
260
- }
246
+ if inbox_item. try_release ( ) ? {
247
+ assert ! ( inbox_item. release_status == ReleaseStatus :: Released ) ;
248
+ Ok ( inbox_item)
249
+ } else if revert_on_delay {
250
+ Err ( NTTError :: CantReleaseYet . into ( ) )
251
+ } else {
252
+ Ok ( inbox_item)
261
253
}
262
-
263
- assert ! ( inbox_item. release_status == ReleaseStatus :: Released ) ;
264
-
265
- Ok ( inbox_item)
266
254
}
0 commit comments