Skip to content

Commit

Permalink
HOTFIX: OB RPC - OffchainDBExt (#889)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gauthamastro authored Dec 6, 2023
2 parents f140059 + 390523c commit 9f4b280
Show file tree
Hide file tree
Showing 15 changed files with 158 additions and 232 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/clients/orderbook/keystore-*
/clients/thea/keystore-*

/fullnode
# Generated by Cargo
# will have compiled files and executables
**/target/
Expand Down
4 changes: 1 addition & 3 deletions Cargo.lock

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

3 changes: 0 additions & 3 deletions pallets/ocex/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ serde_json = { workspace = true, default-features = true }
polkadex-primitives = { workspace = true }
sc-rpc-api = { workspace = true, default-features = true }
sc-rpc = { workspace = true, default-features = true }
sp-std = { workspace = true, default-features = false }
sp-offchain = { workspace = true, default-features = true }
parking_lot = { workspace = true }
hash-db = { workspace = true }
trie-db = { workspace = true }
sp-trie = { workspace = true }
rust_decimal = { workspace = true, features = ["scale-codec"], default-features = false }
pallet-ocex-lmp = { path = "../../ocex" }
14 changes: 9 additions & 5 deletions pallets/ocex/rpc/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@

#![cfg_attr(not(feature = "std"), no_std)]

use parity_scale_codec::{Codec, Decode};
use orderbook_primitives::ObCheckpointRaw;
use parity_scale_codec::Codec;
use polkadex_primitives::AssetId;
use rust_decimal::Decimal;
use sp_std::{collections::btree_map::BTreeMap, vec::Vec};

sp_api::decl_runtime_apis! {
pub trait PolkadexOcexRuntimeApi<AccountId, Hash> where AccountId: Codec, Hash : Codec, BTreeMap<AccountId,Vec<AccountId>>: Decode {
// Returns all on-chain registered main accounts and it's proxies
fn get_main_accounts() -> BTreeMap<AccountId,Vec<AccountId>>;
pub trait PolkadexOcexRuntimeApi<AccountId, Hash> where AccountId: Codec, Hash : Codec {
fn get_ob_recover_state() -> Result<Vec<u8>, sp_runtime::DispatchError>;
// gets balance from given account of given asset
fn get_balance(from: AccountId, of: AssetId) -> Result<Decimal, sp_runtime::DispatchError>;
// gets the latest checkpoint from the offchain State
fn fetch_checkpoint() -> Result<ObCheckpointRaw, sp_runtime::DispatchError>;
// Returns the asset inventory deviation in the offchain State
fn calculate_inventory_deviation(offchain_inventory: BTreeMap<AssetId,Decimal>, last_processed_block: u32) -> Result<BTreeMap<AssetId,Decimal>, sp_runtime::DispatchError>;
fn calculate_inventory_deviation() -> Result<BTreeMap<AssetId,Decimal>, sp_runtime::DispatchError>;
}
}
Loading

0 comments on commit 9f4b280

Please sign in to comment.