Skip to content

Commit

Permalink
rename field
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Jan 1, 2025
1 parent 5495c86 commit 73cf0dd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion modules/pallets/ismp/src/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use sp_runtime::traits::{AccountIdConversion, Zero};
#[scale_info(skip_type_params(T))]
pub struct RequestMetadata<T: Config> {
/// Information about where it's stored in the offchain db
pub mmr: LeafIndexAndPos,
pub offchain: LeafIndexAndPos,
/// Other metadata about the request
pub fee: FeeMetadata<T>,
/// Has fee been claimed?
Expand Down
12 changes: 6 additions & 6 deletions modules/pallets/ismp/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl<T: Config> Pallet<T> {
.map(|commitment| {
let val = RequestCommitments::<T>::get(commitment)
.ok_or_else(|| sp_mmr_primitives::Error::LeafNotFound)?
.mmr;
.offchain;
Ok(val)
})
.collect::<Result<Vec<_>, _>>()?,
Expand All @@ -57,7 +57,7 @@ impl<T: Config> Pallet<T> {
.map(|commitment| {
let val = ResponseCommitments::<T>::get(commitment)
.ok_or_else(|| sp_mmr_primitives::Error::LeafNotFound)?
.mmr;
.offchain;
Ok(val)
})
.collect::<Result<Vec<_>, _>>()?,
Expand Down Expand Up @@ -139,7 +139,7 @@ impl<T: Config> Pallet<T> {
RequestCommitments::<T>::insert(
commitment,
RequestMetadata {
mmr: LeafIndexAndPos {
offchain: LeafIndexAndPos {
leaf_index: leaf_index_and_pos.index,
pos: leaf_index_and_pos.position,
},
Expand Down Expand Up @@ -179,7 +179,7 @@ impl<T: Config> Pallet<T> {
ResponseCommitments::<T>::insert(
commitment,
RequestMetadata {
mmr: LeafIndexAndPos {
offchain: LeafIndexAndPos {
leaf_index: leaf_index_and_pos.index,
pos: leaf_index_and_pos.position,
},
Expand All @@ -193,7 +193,7 @@ impl<T: Config> Pallet<T> {

/// Gets the request from the offchain storage
pub fn request(commitment: H256) -> Option<Request> {
let pos = RequestCommitments::<T>::get(commitment)?.mmr.pos;
let pos = RequestCommitments::<T>::get(commitment)?.offchain.pos;
match T::OffchainDB::leaf(pos) {
Ok(Some(Leaf::Request(req))) => Some(req),
_ => {
Expand All @@ -212,7 +212,7 @@ impl<T: Config> Pallet<T> {

/// Gets the response from the offchain storage
pub fn response(commitment: H256) -> Option<Response> {
let pos = ResponseCommitments::<T>::get(commitment)?.mmr.pos;
let pos = ResponseCommitments::<T>::get(commitment)?.offchain.pos;
match T::OffchainDB::leaf(pos) {
Ok(Some(Leaf::Response(res))) => Some(res),
_ => {
Expand Down
4 changes: 2 additions & 2 deletions modules/pallets/mmr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ where
.map(|commitment| {
let val = child_trie::RequestCommitments::<T>::get(commitment)
.ok_or_else(|| sp_mmr_primitives::Error::LeafNotFound)?
.mmr;
.offchain;
Ok(val)
})
.collect::<Result<Vec<_>, _>>()?,
Expand All @@ -330,7 +330,7 @@ where
.map(|commitment| {
let val = child_trie::ResponseCommitments::<T>::get(commitment)
.ok_or_else(|| sp_mmr_primitives::Error::LeafNotFound)?
.mmr;
.offchain;
Ok(val)
})
.collect::<Result<Vec<_>, _>>()?,
Expand Down
2 changes: 1 addition & 1 deletion modules/pallets/state-coprocessor/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ where
pallet_ismp::child_trie::ResponseCommitments::<T>::insert(
commitment,
RequestMetadata {
mmr: LeafIndexAndPos {
offchain: LeafIndexAndPos {
leaf_index: leaf_index_and_pos.index,
pos: leaf_index_and_pos.position,
},
Expand Down
12 changes: 6 additions & 6 deletions modules/pallets/testsuite/src/tests/pallet_ismp_relayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ fn test_withdrawal_proof() {
let request_receipt_key = RequestReceipts::<Test>::storage_key(*request);
let fee_metadata = FeeMetadata::<Test> { payer: [0; 32].into(), fee: 1000u128.into() };
let leaf_meta = RequestMetadata {
mmr: LeafIndexAndPos { leaf_index: 0, pos: 0 },
offchain: LeafIndexAndPos { leaf_index: 0, pos: 0 },
fee: fee_metadata,
claimed: false,
};
Expand All @@ -124,7 +124,7 @@ fn test_withdrawal_proof() {
let response_receipt_key = ResponseReceipts::<Test>::storage_key(*request);
let fee_metadata = FeeMetadata::<Test> { payer: [0; 32].into(), fee: 1000u128.into() };
let leaf_meta = RequestMetadata {
mmr: LeafIndexAndPos { leaf_index: 0, pos: 0 },
offchain: LeafIndexAndPos { leaf_index: 0, pos: 0 },
fee: fee_metadata,
claimed: false,
};
Expand Down Expand Up @@ -423,15 +423,15 @@ fn test_evm_accumulate_fees() {
match key {
Key::Request(req) => {
let leaf_meta = RequestMetadata {
mmr: LeafIndexAndPos { leaf_index: 0, pos: 0 },
offchain: LeafIndexAndPos { leaf_index: 0, pos: 0 },
fee: FeeMetadata::<Test> { payer: [0; 32].into(), fee: 1000u128.into() },
claimed: false,
};
RequestCommitments::<Test>::insert(req, leaf_meta)
},
Key::Response { response_commitment, .. } => {
let leaf_meta = RequestMetadata {
mmr: LeafIndexAndPos { leaf_index: 0, pos: 0 },
offchain: LeafIndexAndPos { leaf_index: 0, pos: 0 },
fee: FeeMetadata::<Test> { payer: [0; 32].into(), fee: 1000u128.into() },
claimed: false,
};
Expand Down Expand Up @@ -628,15 +628,15 @@ fn setup_host_for_accumulate_fees() -> WithdrawalProof {
match key {
Key::Request(req) => {
let leaf_meta = RequestMetadata {
mmr: LeafIndexAndPos { leaf_index: 0, pos: 0 },
offchain: LeafIndexAndPos { leaf_index: 0, pos: 0 },
fee: FeeMetadata::<Test> { payer: [0; 32].into(), fee: 1000u128.into() },
claimed: false,
};
RequestCommitments::<Test>::insert(req, leaf_meta)
},
Key::Response { response_commitment, .. } => {
let leaf_meta = RequestMetadata {
mmr: LeafIndexAndPos { leaf_index: 0, pos: 0 },
offchain: LeafIndexAndPos { leaf_index: 0, pos: 0 },
fee: FeeMetadata::<Test> { payer: [0; 32].into(), fee: 1000u128.into() },
claimed: false,
};
Expand Down

0 comments on commit 73cf0dd

Please sign in to comment.