Skip to content

Commit

Permalink
Loans: Integration with OracleV2 (#1658)
Browse files Browse the repository at this point in the history
* loans using new oracle v2 system in runtimes

* remove old orml oracles from runtimes and integration tests

* simplify DataRegistry for benchmarking

* fix loan benchmarks

* fix loan benchmarks with runtimes

* update integration tests

* add new tests for updating oracle collections

* remove pallet-data-collector

* fix path
  • Loading branch information
lemunozm authored Dec 29, 2023
1 parent 1552ccf commit f8a7bbf
Show file tree
Hide file tree
Showing 25 changed files with 285 additions and 1,216 deletions.
48 changes: 0 additions & 48 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ members = [
"pallets/permissions",
"pallets/pool-system",
"pallets/pool-registry",
"pallets/data-collector",
"pallets/restricted-tokens",
"pallets/restricted-xtokens",
"pallets/transfer-allowlist",
Expand Down Expand Up @@ -255,7 +254,6 @@ pallet-claims = { path = "pallets/claims", default-features = false }
pallet-collator-allowlist = { path = "pallets/collator-allowlist", default-features = false }
pallet-crowdloan-claim = { path = "pallets/crowdloan-claim", default-features = false }
pallet-crowdloan-reward = { path = "pallets/crowdloan-reward", default-features = false }
pallet-data-collector = { path = "pallets/data-collector", default-features = false }
pallet-ethereum-transaction = { path = "pallets/ethereum-transaction", default-features = false }
pallet-fees = { path = "pallets/fees", default-features = false }
pallet-foreign-investments = { path = "pallets/foreign-investments", default-features = false }
Expand Down
27 changes: 8 additions & 19 deletions libs/mocks/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pub mod pallet {
use cfg_traits::data::{DataCollection, DataRegistry};
use frame_support::pallet_prelude::*;
use mock_builder::{execute_call, register_call};
use orml_traits::{DataFeeder, DataProvider};

#[pallet::config]
pub trait Config: frame_system::Config {
Expand All @@ -12,8 +11,6 @@ pub mod pallet {
type Collection: DataCollection<Self::DataId, Data = Self::Data>;
type Data;
type DataElem;
#[cfg(feature = "runtime-benchmarks")]
type MaxCollectionSize: Get<u32>;
}

#[pallet::pallet]
Expand Down Expand Up @@ -49,19 +46,11 @@ pub mod pallet {
) {
register_call!(move |(a, b)| f(a, b));
}

pub fn mock_feed_value(
f: impl Fn(Option<T::AccountId>, T::DataId, T::DataElem) -> DispatchResult + 'static,
) {
register_call!(move |(a, b, c)| f(a, b, c));
}
}

impl<T: Config> DataRegistry<T::DataId, T::CollectionId> for Pallet<T> {
type Collection = T::Collection;
type Data = T::Data;
#[cfg(feature = "runtime-benchmarks")]
type MaxCollectionSize = T::MaxCollectionSize;

fn get(a: &T::DataId, b: &T::CollectionId) -> Result<T::Data, DispatchError> {
execute_call!((a, b))
Expand All @@ -80,15 +69,15 @@ pub mod pallet {
}
}

impl<T: Config> DataProvider<T::DataId, T::DataElem> for Pallet<T> {
fn get(a: &T::DataId) -> Option<T::DataElem> {
execute_call!(a)
}
}
#[cfg(feature = "runtime-benchmarks")]
impl<T: Config> cfg_traits::ValueProvider<(u32, T::CollectionId), T::DataId> for Pallet<T> {
type Value = T::Data;

impl<T: Config> DataFeeder<T::DataId, T::DataElem, T::AccountId> for Pallet<T> {
fn feed_value(a: Option<T::AccountId>, b: T::DataId, c: T::DataElem) -> DispatchResult {
execute_call!((a, b, c))
fn get(
_: &(u32, T::CollectionId),
_: &T::DataId,
) -> Result<Option<Self::Value>, DispatchError> {
unimplemented!()
}
}

Expand Down
4 changes: 0 additions & 4 deletions libs/traits/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ pub trait DataRegistry<DataId, CollectionId> {
/// Represents a data
type Data;

/// Identify the max number a collection can reach.
#[cfg(feature = "runtime-benchmarks")]
type MaxCollectionSize: sp_runtime::traits::Get<u32>;

/// Return the last data value for a data id in a collection
fn get(data_id: &DataId, collection_id: &CollectionId) -> Result<Self::Data, DispatchError>;

Expand Down
1 change: 0 additions & 1 deletion libs/types/src/ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ pub const NFT_SALES_PALLET_ID: PalletId = PalletId(*b"pal/nfts");
pub const STAKE_POT_PALLET_ID: PalletId = PalletId(*b"PotStake");
pub const BLOCK_REWARDS_PALLET_ID: PalletId = PalletId(*b"cfg/blrw");
pub const LIQUIDITY_REWARDS_PALLET_ID: PalletId = PalletId(*b"cfg/lqrw");
pub const PRICE_ORACLE_PALLET_ID: PalletId = PalletId(*b"or/price");

// Other ids
pub const CHAIN_BRIDGE_HASH_ID: [u8; 13] = *b"cent_nft_hash";
Expand Down
63 changes: 0 additions & 63 deletions pallets/data-collector/Cargo.toml

This file was deleted.

Loading

0 comments on commit f8a7bbf

Please sign in to comment.