Remove unwrap and format code (#62)

* Remove unwrap from metadata fetch

* Format code
This commit is contained in:
Andrew Jones
2020-01-09 17:26:50 +00:00
committed by GitHub
parent b159d0dae1
commit f998444619
4 changed files with 37 additions and 12 deletions
+14 -6
View File
@@ -15,8 +15,12 @@
// along with substrate-subxt. If not, see <http://www.gnu.org/licenses/>.
use futures::future::Future;
use substrate_subxt::{balances, system::System, DefaultNodeRuntime as Runtime};
use sp_keyring::AccountKeyring;
use substrate_subxt::{
balances,
system::System,
DefaultNodeRuntime as Runtime,
};
type AccountId = <Runtime as System>::AccountId;
type Balance = <Runtime as balances::Balances>::Balance;
@@ -42,13 +46,17 @@ fn main() {
let mut rt = tokio::runtime::Runtime::new().unwrap();
match rt.block_on(fut) {
Ok(extrinsic_success) => {
match extrinsic_success.find_event::<(AccountId, AccountId, Balance, Balance)>("Balances", "Transfer") {
Some(Ok((_from, _to, value, _fees))) =>
println!("Balance transfer success: value: {:?}", value),
match extrinsic_success
.find_event::<(AccountId, AccountId, Balance, Balance)>(
"Balances", "Transfer",
) {
Some(Ok((_from, _to, value, _fees))) => {
println!("Balance transfer success: value: {:?}", value)
}
Some(Err(err)) => println!("Failed to decode code hash: {}", err),
None => println!("Failed to find Contracts::CodeStored Event"),
}
},
Err(err) => println!("Error: {}", err)
}
Err(err) => println!("Error: {}", err),
}
}