Skip to content

Commit

Permalink
Remove generic Salt
Browse files Browse the repository at this point in the history
  • Loading branch information
cmichi committed Dec 20, 2024
1 parent c13398b commit abe1df3
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 91 deletions.
9 changes: 5 additions & 4 deletions crates/e2e/src/backend_calls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,8 @@ where
self.value,
gas_limit,

// todo: use dry_run.storage_deposit_limit here, otherwise when someone
// doesn't run `.dry_run()` beforehand this would have `0u32`.
balance_to_deposit_limit::<E>(self.storage_deposit_limit),
// todo: the `bare_call` converts this value back, this is unnecessary work
DepositLimit::Balance(dry_run.exec_result.storage_deposit.charge_or_zero())
)
.await?;

Expand Down Expand Up @@ -382,7 +381,9 @@ where
client,
contract_name,
caller,
storage_deposit_limit: 100_000_000u32.into(), // todo should be 0
storage_deposit_limit: 0u32.into(), // todo should be 0
//storage_deposit_limit: <E as ink_env::Environment>::Balance::MAX, // todo should be 0
//storage_deposit_limit: u32::MAX.into(), // todo should be 0
}
}

Expand Down
3 changes: 1 addition & 2 deletions crates/e2e/src/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ pub type CreateBuilderPartial<E, ContractRef, Args, R> = CreateBuilder<
Set<LimitParamsV2<E>>,
Unset<<E as Environment>::Balance>,
Set<ExecutionInput<Args>>,
Unset<ink_env::call::state::Salt>,
Set<ReturnType<R>>,
>;

Expand All @@ -51,7 +50,7 @@ where
builder
.endowment(0u32.into())
.code_hash(H256::zero())
.salt_bytes(Vec::new())
.salt_bytes(None)
.params()
.exec_input()
.encode()
Expand Down
8 changes: 5 additions & 3 deletions crates/e2e/src/subxt_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,11 @@ where
&mut self,
signer: &Keypair,
code: Vec<u8>,
storage_deposit_limit: E::Balance,
_storage_deposit_limit: E::Balance,
) -> Result<UploadResult<E, ExtrinsicEvents<C>>, Error> {
// dry run instantiate to calculate the gas limit
// todo
let storage_deposit_limit: E::Balance = unsafe {
core::mem::transmute_copy::<u128, <E as Environment>::Balance>(&u128::MAX) };
let dry_run = self
.api
.upload_dry_run(signer, code.clone(), storage_deposit_limit)
Expand Down Expand Up @@ -614,7 +616,7 @@ where
{
// todo beware side effect! this is wrong, we have to batch up the `map_account`
// into the RPC dry run instead
let _ = self.map_account(caller).await;
let _ = self.map_account(caller).await;

let dest = *message.clone().params().callee();
let exec_input = Encode::encode(message.clone().params().exec_input());
Expand Down
7 changes: 5 additions & 2 deletions crates/e2e/src/xts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ where
{
origin: C::AccountId,
code: Vec<u8>,
storage_deposit_limit: E::Balance,
storage_deposit_limit: Option<E::Balance>,
}

/// A struct that encodes RPC parameters required for a call to a smart contract.
Expand Down Expand Up @@ -428,7 +428,8 @@ where
let call_request = RpcCodeUploadRequest::<C, E> {
origin: Signer::<C>::account_id(signer),
code,
storage_deposit_limit,
//storage_deposit_limit,
storage_deposit_limit: None
};
let func = "ReviveApi_upload_code";
let params = scale::Encode::encode(&call_request);
Expand All @@ -453,12 +454,14 @@ where
code: Vec<u8>,
storage_deposit_limit: E::Balance,
) -> ExtrinsicEvents<C> {
eprintln!("_________upload");
let call = subxt::tx::DefaultPayload::new(
"Revive",
"upload_code",
UploadCode::<E> {
code,
storage_deposit_limit,
//storage_deposit_limit: None
},
)
.unvalidated();
Expand Down
7 changes: 3 additions & 4 deletions crates/env/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,20 +327,19 @@ where
/// - If the instantiation process runs out of gas.
/// - If given insufficient endowment.
/// - If the returned account ID failed to decode properly.
pub fn instantiate_contract<E, ContractRef, Args, Salt, R>(
params: &CreateParams<E, ContractRef, LimitParamsV2<E>, Args, Salt, R>,
pub fn instantiate_contract<E, ContractRef, Args, R>(
params: &CreateParams<E, ContractRef, LimitParamsV2<E>, Args, R>,
) -> Result<
ink_primitives::ConstructorResult<<R as ConstructorReturnType<ContractRef>>::Output>,
>
where
E: Environment,
ContractRef: FromAddr,
Args: scale::Encode,
Salt: AsRef<[u8]>,
R: ConstructorReturnType<ContractRef>,
{
<EnvInstance as OnInstance>::on_instance(|instance| {
TypedEnvBackend::instantiate_contract::<E, ContractRef, Args, Salt, R>(
TypedEnvBackend::instantiate_contract::<E, ContractRef, Args, R>(
instance, params,
)
})
Expand Down
5 changes: 2 additions & 3 deletions crates/env/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ pub trait TypedEnvBackend: EnvBackend {
/// # Note
///
/// For more details visit: [`instantiate_contract`][`crate::instantiate_contract`]
fn instantiate_contract<E, ContractRef, Args, Salt, R>(
fn instantiate_contract<E, ContractRef, Args, R>(
&mut self,
params: &CreateParams<E, ContractRef, LimitParamsV2<E>, Args, Salt, R>,
params: &CreateParams<E, ContractRef, LimitParamsV2<E>, Args, R>,
) -> Result<
ink_primitives::ConstructorResult<
<R as ConstructorReturnType<ContractRef>>::Output,
Expand All @@ -340,7 +340,6 @@ pub trait TypedEnvBackend: EnvBackend {
E: Environment,
ContractRef: FromAddr,
Args: scale::Encode,
Salt: AsRef<[u8]>,
R: ConstructorReturnType<ContractRef>;

/// Terminates a smart contract.
Expand Down
Loading

0 comments on commit abe1df3

Please sign in to comment.