Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to substrate alpha.7 release #105

Merged
merged 6 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ serde_json = "1.0"
url = "2.1"
codec = { package = "parity-scale-codec", version = "1.2", default-features = false, features = ["derive", "full"] }

frame-metadata = { version = "11.0.0-alpha.6", package = "frame-metadata" }
frame-support = { version = "2.0.0-alpha.6", package = "frame-support" }
sp-runtime = { version = "2.0.0-alpha.6", package = "sp-runtime" }
sp-version = { version = "2.0.0-alpha.6", package = "sp-version" }
pallet-indices = { version = "2.0.0-alpha.6", package = "pallet-indices" }
frame-metadata = { version = "11.0.0-alpha.7", package = "frame-metadata" }
frame-support = { version = "2.0.0-alpha.7", package = "frame-support" }
sp-runtime = { version = "2.0.0-alpha.7", package = "sp-runtime" }
sp-version = { version = "2.0.0-alpha.7", package = "sp-version" }
pallet-indices = { version = "2.0.0-alpha.7", package = "pallet-indices" }
hex = "0.4.0"
sp-rpc = { version = "2.0.0-alpha.6", package = "sp-rpc" }
sp-core = { version = "2.0.0-alpha.6", package = "sp-core" }
sp-transaction-pool = { version = "2.0.0-alpha.6", package = "sp-transaction-pool" }
sp-rpc = { version = "2.0.0-alpha.7", package = "sp-rpc" }
sp-core = { version = "2.0.0-alpha.7", package = "sp-core" }
sp-transaction-pool = { version = "2.0.0-alpha.7", package = "sp-transaction-pool" }

[dev-dependencies]
async-std = { version = "1.5.0", features = ["attributes"] }
env_logger = "0.7"
wabt = "0.9"
frame-system = { version = "2.0.0-alpha.6", package = "frame-system" }
pallet-balances = { version = "2.0.0-alpha.6", package = "pallet-balances" }
sp-keyring = { version = "2.0.0-alpha.6", package = "sp-keyring" }
frame-system = { version = "2.0.0-alpha.7", package = "frame-system" }
pallet-balances = { version = "2.0.0-alpha.7", package = "pallet-balances" }
sp-keyring = { version = "2.0.0-alpha.7", package = "sp-keyring" }
8 changes: 4 additions & 4 deletions proc-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ synstructure = "0.12.3"
async-std = { version = "1.5.0", features = ["attributes"] }
codec = { package = "parity-scale-codec", version = "1.2", default-features = false, features = ["derive", "full"] }
env_logger = "0.7.1"
frame-support = "2.0.0-alpha.6"
frame-support = "2.0.0-alpha.7"
pretty_assertions = "0.6.1"
sp-core = "2.0.0-alpha.6"
sp-keyring = "2.0.0-alpha.6"
sp-runtime = "2.0.0-alpha.6"
sp-core = "2.0.0-alpha.7"
sp-keyring = "2.0.0-alpha.7"
sp-runtime = "2.0.0-alpha.7"
substrate-subxt = { path = ".." }
trybuild = "1.0.25"

Expand Down
17 changes: 11 additions & 6 deletions src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ impl<T: System> TryFrom<Metadata> for EventsDecoder<T> {
type_sizes: HashMap::new(),
marker: PhantomData,
};
// REMOVE when https://github.com/paritytech/substrate-subxt/pull/102 is merged
// Balance type will be registered by the proc macro.
decoder.register_type_size::<u128>("Balance")?;

// register default event arg type sizes for dynamic decoding of events
decoder.register_type_size::<bool>("bool")?;
decoder.register_type_size::<u32>("ReferendumIndex")?;
Expand Down Expand Up @@ -225,19 +229,20 @@ impl<T: System> EventsDecoder<T> {
let event_variant = input.read_byte()?;
let event_metadata = module.event(event_variant)?;

log::debug!(
"received event '{}::{}'",
module.name(),
event_metadata.name
);

let mut event_data = Vec::<u8>::new();
self.decode_raw_bytes(
&event_metadata.arguments(),
input,
&mut event_data,
)?;

log::debug!(
"received event '{}::{}', raw bytes: {}",
module.name(),
event_metadata.name,
hex::encode(&event_data),
);
log::debug!("raw bytes: {}", hex::encode(&event_data),);

RuntimeEvent::Raw(RawEvent {
module: module.name().to_string(),
Expand Down
24 changes: 9 additions & 15 deletions src/frame/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ pub trait Contracts: System + Balances {}
/// You can instantiate contracts only with stored code.
#[derive(Debug, Encode)]
pub struct PutCodeCall<'a> {
/// Gas limit.
#[codec(compact)]
pub gas_limit: Gas,
/// Wasm blob.
pub code: &'a [u8],
}
Expand Down Expand Up @@ -171,13 +168,7 @@ mod tests {

let xt = client.xt(signer, None).await?;

let result = xt
.watch()
.submit(PutCodeCall {
gas_limit: 500_000,
code: &wasm,
})
.await?;
let result = xt.watch().submit(PutCodeCall { code: &wasm }).await?;
let code_hash = result
.find_event::<CodeStoredEvent<T>>()?
.ok_or(Error::Other("Failed to find CodeStored event".into()))?
Expand All @@ -190,16 +181,19 @@ mod tests {
#[ignore] // requires locally running substrate node
fn tx_put_code() {
env_logger::try_init().ok();
let code_hash: Result<_, Error> = async_std::task::block_on(async move {
let code_hash_result: Result<_, Error> = async_std::task::block_on(async move {
let signer = AccountKeyring::Alice.pair();
let client = test_client().await;
let code_hash = put_code(&client, signer).await?;
Ok(code_hash)
});

assert!(
code_hash.is_ok(),
"Contracts CodeStored event should be received and decoded"
code_hash_result.is_ok(),
format!(
"Error calling put_code and receiving CodeStored Event: {:?}",
code_hash_result
)
);
}

Expand All @@ -220,7 +214,7 @@ mod tests {
.watch()
.submit(InstantiateCall {
endowment: 100_000_000_000_000,
gas_limit: 500_000,
gas_limit: 500_000_000,
code_hash: &code_hash,
data: &[],
})
Expand All @@ -235,7 +229,7 @@ mod tests {

assert!(
result.is_ok(),
"Contract should be instantiated successfully"
format!("Error instantiating contract: {:?}", result)
);
}
}
2 changes: 1 addition & 1 deletion src/frame/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pub enum SystemEvent<T: System> {
/// A new account was created.
NewAccount(T::AccountId),
/// An account was reaped.
ReapedAccount(T::AccountId),
KilledAccount(T::AccountId),
}

/// A phase of a block's execution.
Expand Down