diff --git a/drink/src/contract_api.rs b/drink/src/contract_api.rs index 2af2b29..bfb40f1 100644 --- a/drink/src/contract_api.rs +++ b/drink/src/contract_api.rs @@ -11,13 +11,16 @@ use crate::{runtime::Runtime, EventRecordOf, Sandbox}; /// Interface for contract-related operations. pub trait ContractApi { /// Interface for `bare_instantiate` contract call. + #[allow(clippy::too_many_arguments)] fn deploy_contract( &mut self, contract_bytes: Vec, + value: u128, data: Vec, salt: Vec, origin: AccountId32, gas_limit: Weight, + storage_deposit_limit: Option, ) -> ContractInstantiateResult>; /// Interface for `bare_upload_code` contract call. @@ -25,15 +28,18 @@ pub trait ContractApi { &mut self, contract_bytes: Vec, origin: AccountId32, + storage_deposit_limit: Option, ) -> CodeUploadResult<::Hash, u128>; /// Interface for `bare_call` contract call. fn call_contract( &mut self, address: AccountId32, + value: u128, data: Vec, origin: AccountId32, gas_limit: Weight, + storage_deposit_limit: Option, ) -> ContractExecResult>; } @@ -41,17 +47,19 @@ impl ContractApi for Sandbox { fn deploy_contract( &mut self, contract_bytes: Vec, + value: u128, data: Vec, salt: Vec, origin: AccountId32, gas_limit: Weight, + storage_deposit_limit: Option, ) -> ContractInstantiateResult> { self.externalities.execute_with(|| { pallet_contracts::Pallet::::bare_instantiate( origin, - 0, + value, gas_limit, - None, + storage_deposit_limit, Code::Upload(contract_bytes), data, salt, @@ -65,12 +73,13 @@ impl ContractApi for Sandbox { &mut self, contract_bytes: Vec, origin: AccountId32, + storage_deposit_limit: Option, ) -> CodeUploadResult<::Hash, u128> { self.externalities.execute_with(|| { pallet_contracts::Pallet::::bare_upload_code( origin, contract_bytes, - None, + storage_deposit_limit, Determinism::Enforced, ) }) @@ -79,17 +88,19 @@ impl ContractApi for Sandbox { fn call_contract( &mut self, address: AccountId32, + value: u128, data: Vec, origin: AccountId32, gas_limit: Weight, + storage_deposit_limit: Option, ) -> ContractExecResult> { self.externalities.execute_with(|| { pallet_contracts::Pallet::::bare_call( origin, address, - 0, + value, gas_limit, - None, + storage_deposit_limit, data, DebugInfo::UnsafeDebug, CollectEvents::UnsafeCollect, diff --git a/drink/src/session.rs b/drink/src/session.rs index 1d88abd..76dca03 100644 --- a/drink/src/session.rs +++ b/drink/src/session.rs @@ -13,6 +13,9 @@ use crate::{ Sandbox, DEFAULT_ACTOR, DEFAULT_GAS_LIMIT, }; +const ZERO_TRANSFER: u128 = 0; +const DEFAULT_STORAGE_DEPOSIT_LIMIT: Option = None; + /// Session specific errors. #[derive(Error, Debug)] pub enum SessionError { @@ -201,10 +204,12 @@ impl Session { let result = self.sandbox.deploy_contract( contract_bytes, + ZERO_TRANSFER, data, salt, self.actor.clone(), self.gas_limit, + DEFAULT_STORAGE_DEPOSIT_LIMIT, ); let ret = match &result.result { @@ -277,9 +282,14 @@ impl Session { .clone(), }; - let result = self - .sandbox - .call_contract(address, data, self.actor.clone(), self.gas_limit); + let result = self.sandbox.call_contract( + address, + ZERO_TRANSFER, + data, + self.actor.clone(), + self.gas_limit, + DEFAULT_STORAGE_DEPOSIT_LIMIT, + ); let ret = match &result.result { Ok(exec_result) if exec_result.did_revert() => Err(SessionError::CallReverted),