@@ -79,6 +79,11 @@ pub fn release_inbound_mint<'info>(
79
79
args : ReleaseInboundArgs ,
80
80
) -> Result < ( ) > {
81
81
let inbox_item = release_inbox_item ( & mut ctx. accounts . common . inbox_item , args. revert_on_delay ) ?;
82
+ if inbox_item. is_none ( ) {
83
+ return Ok ( ( ) ) ;
84
+ }
85
+ let inbox_item = inbox_item. unwrap ( ) ;
86
+ assert ! ( inbox_item. release_status == ReleaseStatus :: Released ) ;
82
87
83
88
// NOTE: minting tokens is a two-step process:
84
89
// 1. Mint tokens to the custody account
@@ -149,6 +154,11 @@ pub fn release_inbound_mint_multisig<'info>(
149
154
args : ReleaseInboundArgs ,
150
155
) -> Result < ( ) > {
151
156
let inbox_item = release_inbox_item ( & mut ctx. accounts . common . inbox_item , args. revert_on_delay ) ?;
157
+ if inbox_item. is_none ( ) {
158
+ return Ok ( ( ) ) ;
159
+ }
160
+ let inbox_item = inbox_item. unwrap ( ) ;
161
+ assert ! ( inbox_item. release_status == ReleaseStatus :: Released ) ;
152
162
153
163
// NOTE: minting tokens is a two-step process:
154
164
// 1. Mint tokens to the custody account
@@ -226,6 +236,11 @@ pub fn release_inbound_unlock<'info>(
226
236
args : ReleaseInboundArgs ,
227
237
) -> Result < ( ) > {
228
238
let inbox_item = release_inbox_item ( & mut ctx. accounts . common . inbox_item , args. revert_on_delay ) ?;
239
+ if inbox_item. is_none ( ) {
240
+ return Ok ( ( ) ) ;
241
+ }
242
+ let inbox_item = inbox_item. unwrap ( ) ;
243
+ assert ! ( inbox_item. release_status == ReleaseStatus :: Released ) ;
229
244
230
245
onchain:: invoke_transfer_checked (
231
246
& ctx. accounts . common . token_program . key ( ) ,
@@ -243,14 +258,15 @@ pub fn release_inbound_unlock<'info>(
243
258
) ?;
244
259
Ok ( ( ) )
245
260
}
246
-
247
- fn release_inbox_item ( inbox_item : & mut InboxItem , revert_on_delay : bool ) -> Result < & mut InboxItem > {
261
+ fn release_inbox_item (
262
+ inbox_item : & mut InboxItem ,
263
+ revert_on_delay : bool ,
264
+ ) -> Result < Option < & mut InboxItem > > {
248
265
if inbox_item. try_release ( ) ? {
249
- assert ! ( inbox_item. release_status == ReleaseStatus :: Released ) ;
250
- Ok ( inbox_item)
266
+ Ok ( Some ( inbox_item) )
251
267
} else if revert_on_delay {
252
268
Err ( NTTError :: CantReleaseYet . into ( ) )
253
269
} else {
254
- Ok ( inbox_item )
270
+ Ok ( None )
255
271
}
256
272
}
0 commit comments