move storage keys computation to primitivs (#1254)

This commit is contained in:
Svyatoslav Nikolsky
2021-12-17 13:29:51 +03:00
committed by Bastian Köcher
parent 3aff81a707
commit 22b1e456ab
16 changed files with 240 additions and 123 deletions
@@ -20,6 +20,7 @@ use crate::cli::{
};
use codec::Encode;
use frame_support::Twox64Concat;
use num_traits::Zero;
use polkadot_parachain::primitives::{
HeadData as ParaHeadData, Id as ParaId, ValidationCode as ParaValidationCode,
@@ -202,7 +203,7 @@ impl RegisterParachain {
log::info!(target: "bridge", "Registered parachain: {:?}. Waiting for onboarding", para_id);
// wait until parathread is onboarded
let para_state_key = bp_runtime::storage_map_final_key_twox64_concat(
let para_state_key = bp_runtime::storage_map_final_key::<Twox64Concat>(
PARAS_PALLET_NAME,
PARAS_LIFECYCLES_STORAGE_NAME,
&para_id.encode(),
@@ -32,7 +32,7 @@ use relay_substrate_client::{
Client, Error as SubstrateError, HashOf, SignParam, SignatureOf, Subscription,
TransactionSignScheme, TransactionStatusOf, UnsignedTransaction,
};
use sp_core::{blake2_256, storage::StorageKey, Bytes, Pair, H256, U256};
use sp_core::{blake2_256, storage::StorageKey, Bytes, Pair, U256};
use sp_runtime::traits::{Convert, Header as HeaderT};
use crate::cli::{
@@ -266,11 +266,10 @@ impl SwapTokens {
.await?;
// read state of swap after it has been created
let token_swap_hash: H256 = token_swap.using_encoded(blake2_256).into();
let token_swap_storage_key = bp_runtime::storage_map_final_key_identity(
let token_swap_hash = token_swap.hash();
let token_swap_storage_key = bp_token_swap::storage_keys::pending_swaps_key(
TOKEN_SWAP_PALLET_NAME,
pallet_bridge_token_swap::PENDING_SWAPS_MAP_NAME,
token_swap_hash.as_ref(),
token_swap_hash,
);
match read_token_swap_state(&source_client, swap_created_at, &token_swap_storage_key)
.await?