feat: make `user.call` not use PendingContractTx
@@ -154,15 +154,32 @@ impl UserAccount {
/// Make a contract call. `pending_tx` includes the receiver, the method to call as well as its arguments.
/// Note: You will most likely not be using this method directly but rather the [`call!`](./macro.call.html) macro.
- pub fn call(
+ pub fn function_call(
&self,
pending_tx: PendingContractTx,
deposit: Balance,
gas: Gas,
) -> ExecutionResult {
- self.submit_transaction(self.transaction(pending_tx.receiver_id).function_call(
- pending_tx.method.to_string(),
- pending_tx.args,
+ self.call(pending_tx.receiver_id.clone(),
+ &pending_tx.method,
+ &pending_tx.args,
+ gas,
+ deposit,
+ )
+
+ }
+
+ pub fn call(
+ &self,
+ receiver_id: AccountId,
+ method: &str,
+ args: &[u8],
+ gas: Gas,
+ deposit: Balance,
+ ) -> ExecutionResult {
+ self.submit_transaction(self.transaction(receiver_id).function_call(
+ method.to_string(),
+ args.into(),
gas,
deposit,
))
@@ -246,14 +263,22 @@ impl UserAccount {
/// Call a view method on a contract.
/// Note: You will most likely not be using this method directly but rather the [`view!`](./macros.view.html) macro.
- pub fn view(&self, pending_tx: PendingContractTx) -> ViewResult {
- (*self.runtime).borrow().view_method_call(
- &pending_tx.receiver_id,
+ pub fn view_method_call(&self, pending_tx: PendingContractTx) -> ViewResult {
+ self.view(
+ pending_tx.receiver_id,
&pending_tx.method,
&pending_tx.args,
)
}
+ pub fn view(&self, receiver_id: AccountId, method: &str, args: &[u8]) -> ViewResult {
+ (*self.runtime).borrow().view_method_call(
+ &receiver_id,
+ method,
+ args,
+ )
+ }
+
/// Creates a user and is signed by the `signer_user`
pub fn create_user_from(
&self,
@@ -439,7 +464,7 @@ macro_rules! deploy {
#[macro_export]
macro_rules! call {
($signer:expr, $deposit: expr, $gas: expr, $contract: ident, $method:ident, $($arg:expr),*) => {
- $signer.call((&$contract).contract.$method($($arg),*), $deposit, $gas)
+ $signer.function_call((&$contract).contract.$method($($arg),*), $deposit, $gas)
};
($signer:expr, $contract: ident.$method:ident($($arg:expr),*), $deposit: expr, $gas: expr) => {
call!($signer, $deposit, $gas, $contract, $method, $($arg),*)
@@ -484,6 +509,6 @@ macro_rules! call {
#[macro_export]
macro_rules! view {
($contract: ident.$method:ident($($arg:expr),*)) => {
- (&$contract).user_account.view((&$contract).contract.$method($($arg),*))
+ (&$contract).user_account.view_method_call((&$contract).contract.$method($($arg),*))
};
}
