#[ink(message)]
pub fn create_new_better_payment(
&mut self,
_value: Balance,
_arbiter_provider: AccountId,
_deadline: u64,
//this deadline is deadline that will be added to current time once the audit is assigned to an auditor.
) -> Result<()> {
let _now = self.env().block_timestamp();
let x = PaymentInfo {
value: _value,
starttime: _now,
auditor: self.env().caller(),
arbiterprovider: _arbiter_provider,
patron: self.env().caller(),
deadline: _deadline,
currentstatus: AuditStatus::AuditCreated,
};
assert_ne!(_value, 0);
let xyz = ink::env::call::build_call::<Environment>()
.call(self.stablecoin_address)
.gas_limit(0)
.exec_input(
ink::env::call::ExecutionInput::new(ink::env::call::Selector::new(
ink::selector_bytes!("transfer_from"),
))
.push_arg(self.env().caller())
.push_arg(self.env().account_id())
.push_arg(_value),
)
.returns::<bool>()
.invoke();
if xyz {
self.env().emit_event(TokenIncoming {
id: self.current_audit_id,
});
self.audit_id_to_payment_info
.insert(&self.current_audit_id, &x);
self.env().emit_event(AuditInfoUpdated {
id: Some(self.current_audit_id),
payment_info: Some(x),
updated_by: Some(self.env().caller()),
});
self.current_audit_id = self.current_audit_id + 1;
return Ok(());
} else {
return Err(Error::InsufficientBalance);
}
}
Why is this function misbehaving?
I am trying to send the caller's ERC20
tokens to this contract in the above function, The rest of everything is working, but not the cross-contract calling.
What am I doing wrong here?
This function will update the state of its contract but won't transfer the ERC20
tokens of other contract.