@@ -44,7 +44,7 @@ pub struct ReleaseInbound<'info> {
44
44
45
45
#[ derive( AnchorDeserialize , AnchorSerialize ) ]
46
46
pub struct ReleaseInboundArgs {
47
- pub revert_on_delay : bool ,
47
+ pub revert_when_not_ready : bool ,
48
48
}
49
49
50
50
// Burn/mint
@@ -55,8 +55,8 @@ pub struct ReleaseInboundMint<'info> {
55
55
}
56
56
57
57
/// Release an inbound transfer and mint the tokens to the recipient.
58
- /// When `revert_on_delay ` is true, the transaction will revert if the
59
- /// release timestamp has not been reached. When `revert_on_delay ` is false, the
58
+ /// When `revert_when_not_ready ` is true, the transaction will revert if the
59
+ /// release timestamp has not been reached. When `revert_when_not_ready ` is false, the
60
60
/// transaction succeeds, but the minting is not performed.
61
61
/// Setting this flag to `false` is useful when bundling this instruction
62
62
/// together with [`crate::instructions::redeem`] in a transaction, so that the minting
@@ -70,8 +70,14 @@ pub fn release_inbound_mint(
70
70
let released = inbox_item. try_release ( ) ?;
71
71
72
72
if !released {
73
- if args. revert_on_delay {
74
- return Err ( NTTError :: CantReleaseYet . into ( ) ) ;
73
+ if args. revert_when_not_ready {
74
+ match inbox_item. release_status {
75
+ ReleaseStatus :: NotApproved => return Err ( NTTError :: TransferNotApproved . into ( ) ) ,
76
+ ReleaseStatus :: ReleaseAfter ( _) => return Err ( NTTError :: CantReleaseYet . into ( ) ) ,
77
+ // Unreachable: if released, [`InboxItem::try_release`] will return an Error immediately
78
+ // rather than Ok(bool).
79
+ ReleaseStatus :: Released => return Err ( NTTError :: TransferAlreadyRedeemed . into ( ) ) ,
80
+ }
75
81
} else {
76
82
return Ok ( ( ) ) ;
77
83
}
@@ -113,8 +119,8 @@ pub struct ReleaseInboundUnlock<'info> {
113
119
}
114
120
115
121
/// Release an inbound transfer and unlock the tokens to the recipient.
116
- /// When `revert_on_delay ` is true, the transaction will revert if the
117
- /// release timestamp has not been reached. When `revert_on_delay ` is false, the
122
+ /// When `revert_when_not_ready ` is true, the transaction will revert if the
123
+ /// release timestamp has not been reached. When `revert_when_not_ready ` is false, the
118
124
/// transaction succeeds, but the unlocking is not performed.
119
125
/// Setting this flag to `false` is useful when bundling this instruction
120
126
/// together with [`crate::instructions::redeem`], so that the unlocking
@@ -128,8 +134,14 @@ pub fn release_inbound_unlock(
128
134
let released = inbox_item. try_release ( ) ?;
129
135
130
136
if !released {
131
- if args. revert_on_delay {
132
- return Err ( NTTError :: CantReleaseYet . into ( ) ) ;
137
+ if args. revert_when_not_ready {
138
+ match inbox_item. release_status {
139
+ ReleaseStatus :: NotApproved => return Err ( NTTError :: TransferNotApproved . into ( ) ) ,
140
+ ReleaseStatus :: ReleaseAfter ( _) => return Err ( NTTError :: CantReleaseYet . into ( ) ) ,
141
+ // Unreachable: if released, [`InboxItem::try_release`] will return an Error immediately
142
+ // rather than Ok(bool).
143
+ ReleaseStatus :: Released => return Err ( NTTError :: TransferAlreadyRedeemed . into ( ) ) ,
144
+ }
133
145
} else {
134
146
return Ok ( ( ) ) ;
135
147
}
0 commit comments