Skip to content

Commit

Permalink
Compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
pmikolajczyk41 committed Apr 13, 2023
1 parent e8a0961 commit 1b7da96
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 36 deletions.
3 changes: 2 additions & 1 deletion crates/e2e/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ where
Error::CallDryRun(_) => f.write_str("CallDryRun"),
Error::CallExtrinsic(_) => f.write_str("CallExtrinsic"),
Error::Balance(msg) => write!(f, "Balance: {msg}"),
Error::Decoding(err) => write!(f, "Decoding: {err}"),
}
}
}
Expand Down Expand Up @@ -742,7 +743,7 @@ where
let tx_events = self
.api
.call(
sp_runtime::MultiAddress::Id(message.account_id().clone()),
subxt::utils::MultiAddress::Id(message.account_id().clone()),
value,
dry_run.exec_result.gas_required,
storage_deposit_limit,
Expand Down
63 changes: 28 additions & 35 deletions crates/e2e/src/xts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,48 +33,40 @@ use subxt::{
blocks::ExtrinsicEvents,
config::ExtrinsicParams,
rpc_params,
utils::MultiAddress,
OnlineClient,
};

/// A raw call to `pallet-contracts`'s `instantiate_with_code`.
#[derive(Debug, scale::Encode, scale::Decode, scale_decode::DecodeAsType)]
pub struct InstantiateWithCode<B: scale_decode::DecodeAsType> {
#[derive(Debug, scale::Encode, scale::Decode, scale_encode::EncodeAsType)]
#[encode_as_type(trait_bounds = "")]
pub struct InstantiateWithCode<E: Environment> {
#[codec(compact)]
value: B,
gas_limit: Weight,
storage_deposit_limit: Option<B>,
value: E::Balance,
gas_limit: subxt::utils::Static<Weight>,
storage_deposit_limit: Option<E::Balance>,
code: Vec<u8>,
data: Vec<u8>,
salt: Vec<u8>,
}

/// A raw call to `pallet-contracts`'s `call`.
#[derive(Debug, scale::Decode, scale::Encode, scale_decode::DecodeAsType)]
pub struct Call<E: Environment, B: scale_decode::DecodeAsType> {
dest: sp_runtime::MultiAddress<E::AccountId, ()>,
#[derive(Debug, scale::Decode, scale::Encode, scale_encode::EncodeAsType)]
#[encode_as_type(trait_bounds = "")]
pub struct Call<E: Environment> {
dest: MultiAddress<E::AccountId, ()>,
#[codec(compact)]
value: B,
gas_limit: Weight,
storage_deposit_limit: Option<B>,
value: E::Balance,
gas_limit: subxt::utils::Static<Weight>,
storage_deposit_limit: Option<E::Balance>,
data: Vec<u8>,
}

/// A raw call to `pallet-contracts`'s `call`.
#[derive(
Debug,
scale::Decode,
scale::Encode,
scale_decode::DecodeAsType,
scale_encode::EncodeAsType,
)]
#[decode_as_type(
trait_bounds = "C::Address: scale_decode::DecodeAsType, E::Balance: scale_decode::DecodeAsType"
)]
#[encode_as_type(
trait_bounds = "C::Address: scale_encode::EncodeAsType, E::Balance: scale_encode::EncodeAsType"
)]
#[derive(Debug, scale::Decode, scale::Encode, scale_encode::EncodeAsType)]
#[encode_as_type(trait_bounds = "")]
pub struct Transfer<E: Environment, C: subxt::Config> {
dest: C::Address,
dest: subxt::utils::Static<C::Address>,
#[codec(compact)]
value: E::Balance,
}
Expand All @@ -88,7 +80,7 @@ pub struct Transfer<E: Environment, C: subxt::Config> {
serde::Serialize,
scale::Decode,
scale::Encode,
scale_decode::DecodeAsType,
scale_encode::EncodeAsType,
)]
pub enum Determinism {
/// The execution should be deterministic and hence no indeterministic instructions
Expand All @@ -109,10 +101,11 @@ pub enum Determinism {
}

/// A raw call to `pallet-contracts`'s `upload`.
#[derive(Debug, scale::Encode, scale::Decode, scale_decode::DecodeAsType)]
pub struct UploadCode<B: scale_decode::DecodeAsType> {
#[derive(Debug, scale::Encode, scale::Decode, scale_encode::EncodeAsType)]
#[encode_as_type(trait_bounds = "")]
pub struct UploadCode<E: Environment> {
code: Vec<u8>,
storage_deposit_limit: Option<B>,
storage_deposit_limit: Option<E::Balance>,
determinism: Determinism,
}

Expand Down Expand Up @@ -206,7 +199,7 @@ where
"Balances",
"transfer",
Transfer::<E, C> {
dest: dest.into(),
dest: subxt::utils::Static(dest.into()),
value,
},
Default::default(),
Expand Down Expand Up @@ -316,7 +309,7 @@ where
"instantiate_with_code",
InstantiateWithCode::<E> {
value,
gas_limit,
gas_limit: subxt::utils::Static(gas_limit),
storage_deposit_limit,
code,
data,
Expand Down Expand Up @@ -369,7 +362,7 @@ where
let call = subxt::tx::Payload::new_static(
"Contracts",
"upload_code",
UploadCode::<E::Balance> {
UploadCode::<E> {
code,
storage_deposit_limit,
determinism: Determinism::Deterministic,
Expand Down Expand Up @@ -417,7 +410,7 @@ where
/// contains all events that are associated with this transaction.
pub async fn call(
&self,
contract: sp_runtime::MultiAddress<E::AccountId, ()>,
contract: MultiAddress<E::AccountId, ()>,
value: E::Balance,
gas_limit: Weight,
storage_deposit_limit: Option<E::Balance>,
Expand All @@ -427,10 +420,10 @@ where
let call = subxt::tx::Payload::new_static(
"Contracts",
"call",
Call::<E, E::Balance> {
Call::<E> {
dest: contract,
value,
gas_limit,
gas_limit: subxt::utils::Static(gas_limit),
storage_deposit_limit,
data,
},
Expand Down

0 comments on commit 1b7da96

Please sign in to comment.