add constants api to codegen (#402)

* add constants api to codegen

Signed-off-by: Gregory Hill <gregorydhill@outlook.com>

* handle constant decoding error

Signed-off-by: Gregory Hill <gregorydhill@outlook.com>

* fix clippy and remove extra constants allocation

Signed-off-by: Gregory Hill <gregorydhill@outlook.com>
This commit is contained in:
Greg Hill
2022-01-27 14:27:20 +00:00
committed by GitHub
parent 3dded0c600
commit 5f5a7ef5f7
3 changed files with 97 additions and 0 deletions
+8
View File
@@ -261,4 +261,12 @@ async fn constant_existential_deposit() {
let constant_metadata = balances_metadata.constant("ExistentialDeposit").unwrap();
let existential_deposit = u128::decode(&mut &constant_metadata.value[..]).unwrap();
assert_eq!(existential_deposit, 100_000_000_000_000);
assert_eq!(
existential_deposit,
cxt.api
.constants()
.balances()
.existential_deposit()
.unwrap()
);
}