async fn on_token_received(
    transfer_from: &TransferFrom,
    receiver: &TokenReceiver,
    _value: &Nat,
) -> ActorResult<bool> {
    let get_did_method_name = "__get_candid_interface_tmp_hack";
    let on_token_received_method_name = "onTokenReceived";
    let on_token_received_method_sig = "onTokenReceived:(TransferFrom,nat)->(bool)query";

    // check receiver
    if let TokenHolder::Principal(cid) = receiver {
        if is_canister(cid) {
            let did_res: Result<(String,), _> =
                api::call::call(*cid, get_did_method_name, ()).await;

            if let Ok((did,)) = did_res {
                let _support = is_support_interface(did, on_token_received_method_sig.to_string());

                if _support {
                    let _check_res: Result<(bool,), _> = api::call::call(
                        *cid,
                        on_token_received_method_name,
                        (transfer_from, _value),
                    )
                    .await;

                    match _check_res {
                        Ok((is_notify_succeed,)) => {
                            if !is_notify_succeed {
                                return Err(DFTError::NotificationFailed.into());
                            } else {
                                return Ok(true);
                            }
                        }
                        _ => return Err(DFTError::NotificationFailed.into()),
                    }
                }
            }
            return Err(DFTError::NotificationFailed.into());
        }
    }
    Ok(true)
}
// call it after transfer, notify receiver with (from,value)
call it after transfer, notify receiver with (from,value)
call it after transfer notify receiver with ( from value )
async fn on_token_received(
    transfer_from: &TransferFrom,
    receiver: &TokenReceiver,
    _value: &Nat,
) -> ActorResult<bool> {
    let get_did_method_name = "__get_candid_interface_tmp_hack";
    let on_token_received_method_name = "onTokenReceived";
    let on_token_received_method_sig = "onTokenReceived:(TransferFrom,nat)->(bool)query";
    // check receiver
    if let TokenHolder::Principal(cid) = receiver {
        if is_canister(cid) {
            let did_res: Result<(String,), _> =
                api::call::call(*cid, get_did_method_name, ()).await;
            if let Ok((did,)) = did_res {
                let _support = is_support_interface(did, on_token_received_method_sig.to_string());
                if _support {
                    let _check_res: Result<(bool,), _> = api::call::call(
                        *cid,
                        on_token_received_method_name,
                        (transfer_from, _value),
                    )
                    .await;
                    match _check_res {
                        Ok((is_notify_succeed,)) => {
                            if !is_notify_succeed {
                                return Err(DFTError::NotificationFailed.into());
                            } else {
                                return Ok(true);
                            }
                        }
                        _ => return Err(DFTError::NotificationFailed.into()),
                    }
                }
            }
            return Err(DFTError::NotificationFailed.into());
        }
    }
    Ok(true)
}
async fn on_token_received ( transfer_from : & TransferFrom , receiver : & TokenReceiver , _value : & Nat , ) -> ActorResult < bool > { let get_did_method_name = " " ; let on_token_received_method_name = " " ; let on_token_received_method_sig = " " ; // check receiver if let TokenHolder :: Principal ( cid ) = receiver { if is_canister ( cid ) { let did_res : Result < ( String , ) , _ > = api :: call :: call ( * cid , get_did_method_name , ( ) ) . await ; if let Ok ( ( did , ) ) = did_res { let _support = is_support_interface ( did , on_token_received_method_sig . to_string ( ) ) ; if _support { let _check_res : Result < ( bool , ) , _ > = api :: call :: call ( * cid , on_token_received_method_name , ( transfer_from , _value ) , ) . await ; match _check_res { Ok ( ( is_notify_succeed , ) ) => { if ! is_notify_succeed { return Err ( DFTError :: NotificationFailed . into ( ) ) ; } else { return Ok ( true ) ; } } _ => return Err ( DFTError :: NotificationFailed . into ( ) ) , } } } return Err ( DFTError :: NotificationFailed . into ( ) ) ; } } Ok ( true ) }
call it after transfer, notify receiver with (from,value)
call it after transfer notify receiver with ( from value )
transfer_from
&TransferFrom
receiver
&TokenReceiver
_value
&Nat
transfer_from
&TransferFrom
receiver
&TokenReceiver
_value
&Nat