Skip to content

Commit

Permalink
Remove explicit mailbox dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
breathx committed Dec 13, 2023
1 parent 9baedba commit 0e355c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
3 changes: 2 additions & 1 deletion pallets/gear-voucher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ pub mod pallet {
PrepaidCall::SendMessage { destination, .. } => {
Some(Self::voucher_id(who, destination))
}
PrepaidCall::SendReply { .. } => todo!("TODO (breathx): extract mailbox here"),
PrepaidCall::SendReply { reply_to_id, .. } => T::Mailbox::peek(who, reply_to_id)
.map(|stored_message| Self::voucher_id(who, &stored_message.source())),
}
}
}
Expand Down
7 changes: 3 additions & 4 deletions pallets/payment/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,9 @@ impl DelegateFee<RuntimeCall, AccountId> for DelegateFeeAccountBuilder {
RuntimeCall::GearVoucher(pallet_gear_voucher::Call::call {
call: pallet_gear_voucher::PrepaidCall::SendMessage { .. },
}) => Some(FEE_PAYER),
RuntimeCall::GearVoucher(pallet_gear_voucher::Call::call {
call: pallet_gear_voucher::PrepaidCall::SendReply { reply_to_id, .. },
}) => <MailboxOf<Test> as common::storage::Mailbox>::peek(who, reply_to_id)
.map(|stored_message| GearVoucher::voucher_id(who, &stored_message.source())),
RuntimeCall::GearVoucher(pallet_gear_voucher::Call::call { call }) => {
GearVoucher::sponsor_of(who, call)
}
_ => None,
}
}
Expand Down
12 changes: 4 additions & 8 deletions runtime/vara/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#[cfg(all(feature = "std", not(feature = "fuzz")))]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

use common::storage::{Mailbox, Messenger};
use common::storage::Messenger;
use frame_election_provider_support::{
onchain, ElectionDataProvider, NposSolution, SequentialPhragmen, VoteWeight,
};
Expand Down Expand Up @@ -1057,13 +1057,9 @@ pub struct DelegateFeeAccountBuilder;
impl DelegateFee<RuntimeCall, AccountId> for DelegateFeeAccountBuilder {
fn delegate_fee(call: &RuntimeCall, who: &AccountId) -> Option<AccountId> {
match call {
RuntimeCall::GearVoucher(pallet_gear_voucher::Call::call {
call: pallet_gear_voucher::PrepaidCall::SendMessage { destination, .. },
}) => Some(GearVoucher::voucher_id(who, destination)),
RuntimeCall::GearVoucher(pallet_gear_voucher::Call::call {
call: pallet_gear_voucher::PrepaidCall::SendReply { reply_to_id, .. },
}) => <<GearMessenger as Messenger>::Mailbox as Mailbox>::peek(who, reply_to_id)
.map(|stored_message| GearVoucher::voucher_id(who, &stored_message.source())),
RuntimeCall::GearVoucher(pallet_gear_voucher::Call::call { call }) => {
GearVoucher::sponsor_of(who, call)
}
_ => None,
}
}
Expand Down

0 comments on commit 0e355c4

Please sign in to comment.