@@ -188,26 +188,26 @@ where
188188 }
189189}
190190
191- impl < Api , To , Payment , Callback > Tx < TxScEnv < Api > , ( ) , To , Payment , ( ) , FunctionCall < Api > , Callback >
191+ impl < Api , To , Payment , GasValue , Callback >
192+ Tx < TxScEnv < Api > , ( ) , To , Payment , ExplicitGas < GasValue > , ( ) , Callback >
192193where
193194 Api : CallTypeApi ,
194195 To : TxToSpecified < TxScEnv < Api > > ,
195196 Payment : TxPayment < TxScEnv < Api > > ,
197+ GasValue : TxGasValue < TxScEnv < Api > > ,
196198 Callback : TxPromisesCallback < Api > ,
197199{
198- /// ## Incorrect call
199- ///
200- /// Must set **gas** in order to call `register_promise`.
200+ /// Launches a transaction as an asynchronous promise (async v2 mechanism),
201+ /// but without calling any function on the destination.
201202 ///
202- /// ## Safety
203- ///
204- /// This version of the method must never be called. It is only here to provide a more readable error.
205- pub unsafe fn register_promise ( self ) {
206- ErrorHelper :: < Api > :: signal_error_with_message ( "register_promise requires explicit gas" ) ;
203+ /// Such calls are useful for appending callbacks to simple transfers,
204+ /// mitigating edge cases such as non-payable SCs and frozen assets.
205+ pub fn register_promise ( self ) {
206+ self . raw_call ( "" ) . register_promise ( ) ;
207207 }
208208}
209209
210- impl < Api , To , Payment , Callback > Tx < TxScEnv < Api > , ( ) , To , Payment , ( ) , ( ) , Callback >
210+ impl < Api , To , Payment , Callback > Tx < TxScEnv < Api > , ( ) , To , Payment , ( ) , FunctionCall < Api > , Callback >
211211where
212212 Api : CallTypeApi ,
213213 To : TxToSpecified < TxScEnv < Api > > ,
@@ -216,36 +216,34 @@ where
216216{
217217 /// ## Incorrect call
218218 ///
219- /// Must set **gas** and **function call** in order to call `register_promise`.
219+ /// Must set **gas** in order to call `register_promise`.
220220 ///
221221 /// ## Safety
222222 ///
223223 /// This version of the method must never be called. It is only here to provide a more readable error.
224224 pub unsafe fn register_promise ( self ) {
225- ErrorHelper :: < Api > :: signal_error_with_message (
226- "register_promise requires explicit gas and function call" ,
227- ) ;
225+ ErrorHelper :: < Api > :: signal_error_with_message ( "register_promise requires explicit gas" ) ;
228226 }
229227}
230228
231- impl < Api , To , Payment , GasValue , Callback >
232- Tx < TxScEnv < Api > , ( ) , To , Payment , ExplicitGas < GasValue > , ( ) , Callback >
229+ impl < Api , To , Payment , Callback > Tx < TxScEnv < Api > , ( ) , To , Payment , ( ) , ( ) , Callback >
233230where
234231 Api : CallTypeApi ,
235232 To : TxToSpecified < TxScEnv < Api > > ,
236233 Payment : TxPayment < TxScEnv < Api > > ,
237- GasValue : TxGasValue < TxScEnv < Api > > ,
238234 Callback : TxPromisesCallback < Api > ,
239235{
240236 /// ## Incorrect call
241237 ///
242- /// Must set **function call ** in order to call `register_promise`.
238+ /// Must set **gas ** in order to call `register_promise`, even when no SC endpoint is called .
243239 ///
244240 /// ## Safety
245241 ///
246242 /// This version of the method must never be called. It is only here to provide a more readable error.
247243 pub unsafe fn register_promise ( self ) {
248- ErrorHelper :: < Api > :: signal_error_with_message ( "register_promise requires function call" ) ;
244+ ErrorHelper :: < Api > :: signal_error_with_message (
245+ "register_promise requires explicit gas (even when no SC endpoint is called)" ,
246+ ) ;
249247 }
250248}
251249
0 commit comments