Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Make fee market instantiable #35

Merged
merged 9 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions modules/fee-market/rpc/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ decl_runtime_apis! {
where
Balance: Codec + MaybeDisplay + MaybeFromStr,
{
fn market_fee(
) -> Option<Fee<Balance>>;

fn in_process_orders() -> InProcessOrders;
fn market_fee(instance: u8) -> Option<Fee<Balance>>;
boundless-forest marked this conversation as resolved.
Show resolved Hide resolved
fn in_process_orders(instance: u8) -> InProcessOrders;
}
}
12 changes: 6 additions & 6 deletions modules/fee-market/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const RUNTIME_ERROR: i64 = -1;
#[rpc]
pub trait FeeMarketApi<Fee> {
#[rpc(name = "fee_marketFee")]
fn market_fee(&self) -> Result<Option<Fee>>;
fn market_fee(&self, instance: u8) -> Result<Option<Fee>>;
#[rpc(name = "fee_inProcessOrders")]
fn in_process_orders(&self) -> Result<InProcessOrders>;
fn in_process_orders(&self, instance: u8) -> Result<InProcessOrders>;
}

pub struct FeeMarket<Client, Block, Balance> {
Expand All @@ -64,24 +64,24 @@ where
Block: BlockT,
Balance: 'static + Sync + Send + Codec + MaybeDisplay + MaybeFromStr,
{
fn market_fee(&self) -> Result<Option<Fee<Balance>>> {
fn market_fee(&self, instance: u8) -> Result<Option<Fee<Balance>>> {
let api = self.client.runtime_api();
let best = self.client.info().best_hash;
let at = BlockId::hash(best);

api.market_fee(&at).map_err(|e| Error {
api.market_fee(&at, instance).map_err(|e| Error {
code: ErrorCode::ServerError(RUNTIME_ERROR),
message: "Unable to query market fee.".into(),
data: Some(format!("{:?}", e).into()),
})
}

fn in_process_orders(&self) -> Result<InProcessOrders> {
fn in_process_orders(&self, instance: u8) -> Result<InProcessOrders> {
let api = self.client.runtime_api();
let best = self.client.info().best_hash;
let at = BlockId::hash(best);

api.in_process_orders(&at).map_err(|e| Error {
api.in_process_orders(&at, instance).map_err(|e| Error {
code: ErrorCode::ServerError(RUNTIME_ERROR),
message: "Unable to query in process orders.".into(),
data: Some(format!("{:?}", e).into()),
Expand Down
Loading