Skip to content

Commit

Permalink
fix metadata constants (paritytech#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulormart authored Oct 15, 2021
1 parent d0b0bb1 commit 567ce0e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,16 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
.collect()
});

let constants = pallet.constants.iter().map(|constant|
(constant.name.clone(), constant.clone()))
.collect();

let pallet_metadata = PalletMetadata {
index: pallet.index,
name: pallet.name.to_string(),
calls,
storage,
constants: Default::default(), // todo: [AJ] constants
constants,
};

Ok((pallet.name.to_string(), pallet_metadata))
Expand Down
15 changes: 15 additions & 0 deletions tests/src/frame/balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,18 @@ async fn transfer_subscription() {
balances::events::Transfer(alice.account_id().clone(), bob.clone(), 10_000,)
);
}

#[async_std::test]
async fn constant_existential_deposit() {
let cxt = test_context().await;
let balances_metadata = cxt
.client()
.metadata()
.pallet("Balances").unwrap();
let constant_metadata = balances_metadata
.constant("ExistentialDeposit")
.unwrap();
let existential_deposit = u128::decode(&mut &constant_metadata.value[..])
.unwrap();
assert_eq!(existential_deposit, 10_000_000_000);
}

0 comments on commit 567ce0e

Please sign in to comment.