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