diff --git a/bacon.toml b/bacon.toml
deleted file mode 100644
index 22fbf444a..000000000
--- a/bacon.toml
+++ /dev/null
@@ -1,101 +0,0 @@
-# This is a configuration file for the bacon tool
-#
-# Bacon repository: https://github.com/Canop/bacon
-# Complete help on configuration: https://dystroy.org/bacon/config/
-# You can also check bacon's own bacon.toml file
-# as an example: https://github.com/Canop/bacon/blob/main/bacon.toml
-
-default_job = "check"
-
-[jobs.check]
-command = ["cargo", "check", "--profile=test", "--workspace", "--color", "always"]
-need_stdout = false
-
-[jobs.check-all]
-command = ["cargo", "check", "--all-targets", "--color", "always"]
-need_stdout = false
-
-# Run clippy on the default target
-[jobs.clippy]
-command = [
- "cargo", "clippy",
- "--color", "always",
-]
-need_stdout = false
-
-# Run clippy on all targets
-# To disable some lints, you may change the job this way:
-# [jobs.clippy-all]
-# command = [
-# "cargo", "clippy",
-# "--all-targets",
-# "--color", "always",
-# "--",
-# "-A", "clippy::bool_to_int_with_if",
-# "-A", "clippy::collapsible_if",
-# "-A", "clippy::derive_partial_eq_without_eq",
-# ]
-# need_stdout = false
-[jobs.clippy-all]
-command = [
- "cargo", "clippy",
- "--all-targets",
- "--color", "always",
-]
-need_stdout = false
-
-# This job lets you run
-# - all tests: bacon test
-# - a specific test: bacon test -- config::test_default_files
-# - the tests of a package: bacon test -- -- -p config
-[jobs.test]
-command = [
- "cargo", "test", "--color", "always",
- "--", "--color", "always", # see https://github.com/Canop/bacon/issues/124
-]
-need_stdout = true
-
-[jobs.doc]
-command = ["cargo", "doc", "--color", "always", "--no-deps"]
-need_stdout = false
-
-# If the doc compiles, then it opens in your browser and bacon switches
-# to the previous job
-[jobs.doc-open]
-command = ["cargo", "doc", "--color", "always", "--no-deps", "--open"]
-need_stdout = false
-on_success = "back" # so that we don't open the browser at each change
-
-# You can run your application and have the result displayed in bacon,
-# *if* it makes sense for this crate.
-# Don't forget the `--color always` part or the errors won't be
-# properly parsed.
-# If your program never stops (eg a server), you may set `background`
-# to false to have the cargo run output immediately displayed instead
-# of waiting for program's end.
-[jobs.run]
-command = [
- "cargo", "run",
- "--color", "always",
- # put launch parameters for your program behind a `--` separator
-]
-need_stdout = true
-allow_warnings = true
-background = true
-
-# This parameterized job runs the example of your choice, as soon
-# as the code compiles.
-# Call it as
-# bacon ex -- my-example
-[jobs.ex]
-command = ["cargo", "run", "--color", "always", "--example"]
-need_stdout = true
-allow_warnings = true
-
-# You may define here keybindings that would be specific to
-# a project, for example a shortcut to launch a specific job.
-# Shortcuts to internal functions (scrolling, toggling, etc.)
-# should go in your personal global prefs.toml file instead.
-[keybindings]
-# alt-m = "job:my-job"
-c = "job:clippy-all" # comment this to have 'c' run clippy on only the default target
diff --git a/integration-tests/src/tests/oracle.rs b/integration-tests/src/tests/oracle.rs
index 337d761f7..15c6617fd 100644
--- a/integration-tests/src/tests/oracle.rs
+++ b/integration-tests/src/tests/oracle.rs
@@ -15,23 +15,27 @@
// along with this program. If not, see .
use crate::*;
+use pallet_funding::AcceptedFundingAsset;
/// Tests for the oracle pallet integration.
/// Alice, Bob, Charlie are members of the OracleProvidersMembers.
/// Only members should be able to feed data into the oracle.
use parity_scale_codec::alloc::collections::HashMap;
+use polimec_common::PLMC_FOREIGN_ID;
use polimec_runtime::{Oracle, RuntimeOrigin};
use sp_runtime::{bounded_vec, BoundedVec, FixedU128};
use tests::defaults::*;
+use AcceptedFundingAsset::{DOT, USDC, USDT, WETH};
fn values(
- values: [f64; 4],
+ values: [f64; 5],
) -> BoundedVec<(u32, FixedU128), >::MaxFeedValues> {
- let [dot, usdc, usdt, plmc] = values;
+ let [dot, usdc, usdt, weth, plmc] = values;
bounded_vec![
- (10u32, FixedU128::from_float(dot)),
- (1337u32, FixedU128::from_float(usdc)),
- (1984u32, FixedU128::from_float(usdt)),
- (3344u32, FixedU128::from_float(plmc))
+ (DOT.id(), FixedU128::from_float(dot)),
+ (USDC.id(), FixedU128::from_float(usdc)),
+ (USDT.id(), FixedU128::from_float(usdt)),
+ (WETH.id(), FixedU128::from_float(weth)),
+ (PLMC_FOREIGN_ID, FixedU128::from_float(plmc))
]
}
@@ -43,19 +47,20 @@ fn members_can_feed_data() {
// pallet_funding genesis builder already inputs prices, so we need to advance one block to feed new values.
inst.advance_time(1u32);
let alice = PolimecNet::account_id_of(ALICE);
- assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([4.84, 1.0, 1.0, 0.4])));
+ assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([4.84, 1.0, 1.0, 2500.0, 0.4])));
let bob = PolimecNet::account_id_of(BOB);
- assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(bob.clone()), values([4.84, 1.0, 1.0, 0.4])));
+ assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(bob.clone()), values([4.84, 1.0, 1.0, 2500.0, 0.4])));
let charlie = PolimecNet::account_id_of(CHARLIE);
- assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone()), values([4.84, 1.0, 1.0, 0.4])));
+ assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone()), values([4.84, 1.0, 1.0, 2500.0, 0.4])));
let expected_values = HashMap::from([
- (10u32, FixedU128::from_float(4.84)),
- (1337u32, FixedU128::from_float(1.0)),
- (1984u32, FixedU128::from_float(1.0)),
- (3344u32, FixedU128::from_float(0.4)),
+ (DOT.id(), FixedU128::from_float(4.84)),
+ (USDC.id(), FixedU128::from_float(1.0)),
+ (USDT.id(), FixedU128::from_float(1.0)),
+ (WETH.id(), FixedU128::from_float(2500.0)),
+ (PLMC_FOREIGN_ID, FixedU128::from_float(0.4)),
]);
for (key, value) in Oracle::get_all_values() {
@@ -70,7 +75,7 @@ fn non_members_cannot_feed_data() {
PolimecNet::execute_with(|| {
let dave = PolimecNet::account_id_of(DAVE);
assert_noop!(
- Oracle::feed_values(RuntimeOrigin::signed(dave.clone()), values([4.84, 1.0, 1.0, 0.4])),
+ Oracle::feed_values(RuntimeOrigin::signed(dave.clone()), values([4.84, 1.0, 1.0, 2500.0, 0.4])),
orml_oracle::Error::::NoPermission
);
});
@@ -84,20 +89,24 @@ fn data_is_correctly_combined() {
inst.advance_time(1u32);
let alice = PolimecNet::account_id_of(ALICE);
- assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([1.0, 1.5, 1.1, 0.11111])));
+ assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([1.0, 1.5, 1.1, 2500.0, 0.11111])));
let bob = PolimecNet::account_id_of(BOB);
- assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(bob.clone()), values([2.0, 1.0, 1.2, 0.22222])));
+ assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(bob.clone()), values([2.0, 1.0, 1.2, 2500.0, 0.22222])));
let charlie = PolimecNet::account_id_of(CHARLIE);
- assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone()), values([3.0, 0.8, 1.1, 0.33333])));
+ assert_ok!(Oracle::feed_values(
+ RuntimeOrigin::signed(charlie.clone()),
+ values([3.0, 0.8, 1.1, 2500.0, 0.33333])
+ ));
// Default CombineData implementation is the median value
let expected_values = HashMap::from([
- (10u32, FixedU128::from_float(2.0)),
- (1337u32, FixedU128::from_float(1.0)),
- (1984u32, FixedU128::from_float(1.1)),
- (3344u32, FixedU128::from_float(0.22222)),
+ (DOT.id(), FixedU128::from_float(2.0)),
+ (USDC.id(), FixedU128::from_float(1.0)),
+ (USDT.id(), FixedU128::from_float(1.1)),
+ (WETH.id(), FixedU128::from_float(2500.0)),
+ (PLMC_FOREIGN_ID, FixedU128::from_float(0.22222)),
]);
for (key, value) in Oracle::get_all_values() {
@@ -116,13 +125,13 @@ fn pallet_funding_works() {
inst.advance_time(1u32);
let alice = PolimecNet::account_id_of(ALICE);
- assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([4.84, 1.0, 1.0, 0.4])));
+ assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(alice.clone()), values([4.84, 1.0, 1.0, 2500.0, 0.4])));
let bob = PolimecNet::account_id_of(BOB);
- assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(bob.clone()), values([4.84, 1.0, 1.0, 0.4])));
+ assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(bob.clone()), values([4.84, 1.0, 1.0, 2500.0, 0.4])));
let charlie = PolimecNet::account_id_of(CHARLIE);
- assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone()), values([4.84, 1.0, 1.0, 0.4])));
+ assert_ok!(Oracle::feed_values(RuntimeOrigin::signed(charlie.clone()), values([4.84, 1.0, 1.0, 2500.0, 0.4])));
let _project_id = inst.create_finished_project(
default_project_metadata(ISSUER.into()),
diff --git a/nodes/parachain/src/chain_spec/common.rs b/nodes/parachain/src/chain_spec/common.rs
index a1b5c383e..440e97373 100644
--- a/nodes/parachain/src/chain_spec/common.rs
+++ b/nodes/parachain/src/chain_spec/common.rs
@@ -13,6 +13,7 @@ use polimec_runtime::{
ExistentialDeposit, FeeRecipient, OracleProvidersMembershipConfig, Runtime, TreasuryAccount, PLMC,
};
use sp_core::{crypto::UncheckedInto, sr25519};
+use sp_core::crypto::Ss58AddressFormat;
use sp_runtime::{traits::AccountIdConversion, Perbill, Percent};
pub type ChainSpec = sc_service::GenericChainSpec;
@@ -65,6 +66,11 @@ pub fn eve() -> polimec_runtime::AccountId {
get_account_id_from_seed::("Eve")
}
+pub fn acc_from_ss58(string: &str) -> polimec_runtime::AccountId {
+ use sp_core::crypto::Ss58Codec;
+ sp_core::sr25519::Public::from_ss58check(string).unwrap().into()
+}
+
pub struct GenesisConfigParams {
pub stakers: Vec,
pub council_members: Vec,
diff --git a/nodes/parachain/src/chain_spec/polimec_paseo.rs b/nodes/parachain/src/chain_spec/polimec_paseo.rs
index 7266468a3..5dba26109 100644
--- a/nodes/parachain/src/chain_spec/polimec_paseo.rs
+++ b/nodes/parachain/src/chain_spec/polimec_paseo.rs
@@ -25,16 +25,29 @@ use crate::chain_spec::{
get_properties, Extensions, GenericChainSpec, DEFAULT_PARA_ID,
};
use polimec_runtime::{AccountId, MinCandidateStk};
+use crate::chain_spec::common::{acc_from_ss58};
pub fn get_local_chain_spec() -> GenericChainSpec {
- let endowed_accounts = vec![alice(), bob(), charlie(), dave()];
+ let endowed_accounts = vec![
+ alice(),
+ bob(),
+ charlie(),
+ dave(),
+ acc_from_ss58("5Do5UoayFvDrHroGS1YMqxTVUysSkrhNwVMzmj1foVb3vzzb"),
+ acc_from_ss58("5E5E37FNZD9KVHyGgSHt8pc2kq8e3VUS5rf8GmrxCa7ySs8s"),
+ acc_from_ss58("5ELLzYckeuomgTnv4Pf1aT4itxu35cn1KWNCGcftzv5N2x7o"),
+ ];
let endowed_accounts =
endowed_accounts.iter().map(|x| (x.clone(), MinCandidateStk::get() * 20)).collect::>();
let genesis_config_params = GenesisConfigParams {
stakers: vec![alice(), bob()],
council_members: vec![alice()],
technical_committee_members: vec![alice()],
- oracle_members: vec![alice(), bob(), charlie()],
+ oracle_members: vec![
+ acc_from_ss58("5Do5UoayFvDrHroGS1YMqxTVUysSkrhNwVMzmj1foVb3vzzb"),
+ acc_from_ss58("5E5E37FNZD9KVHyGgSHt8pc2kq8e3VUS5rf8GmrxCa7ySs8s"),
+ acc_from_ss58("5ELLzYckeuomgTnv4Pf1aT4itxu35cn1KWNCGcftzv5N2x7o"),
+ ],
endowed_accounts,
funding_assets_owner: eve(),
id: DEFAULT_PARA_ID,
diff --git a/pallets/oracle-ocw/src/tests.rs b/pallets/oracle-ocw/src/tests.rs
index 344be32f0..9fa2e860b 100644
--- a/pallets/oracle-ocw/src/tests.rs
+++ b/pallets/oracle-ocw/src/tests.rs
@@ -37,23 +37,26 @@ fn call_offchain_worker() {
assert_eq!(tx.signature.unwrap().0, 0);
match tx.call {
- RuntimeCall::Oracle(orml_oracle::Call::feed_values { values }) =>
+ RuntimeCall::Oracle(orml_oracle::Call::feed_values { values }) => {
+ dbg!(&values);
for (asset, price) in values {
match asset {
10 => assert_close_enough(price, FixedU128::from_float(6.138485575453039783)),
1984 => assert_close_enough(price, FixedU128::from_float(1.000154206100002620)),
1337 => assert_close_enough(price, FixedU128::from_float(1.000093378020633965)),
3344 => assert_close_enough(price, FixedU128::from_float(0.414564170729477207)),
+ 10_000 => assert_close_enough(price, FixedU128::from_float(1260.00)),
_ => panic!("Unexpected asset"),
}
- },
+ }
+ },
_ => panic!("Unexpected call"),
}
});
}
fn test_fetcher_against_real_api() {
- for asset in [AssetName::DOT, AssetName::USDC, AssetName::USDT, AssetName::PLMC] {
+ for asset in [AssetName::DOT, AssetName::USDC, AssetName::USDT, AssetName::PLMC, AssetName::WETH] {
let url = F::get_url(asset);
if url.is_empty() {
continue;
diff --git a/pallets/oracle-ocw/src/types.rs b/pallets/oracle-ocw/src/types.rs
index ec70c9377..2f958d497 100644
--- a/pallets/oracle-ocw/src/types.rs
+++ b/pallets/oracle-ocw/src/types.rs
@@ -132,7 +132,7 @@ impl FetchPrice for KrakenFetcher {
AssetName::DOT => "https://api.kraken.com/0/public/OHLC?pair=DOTUSD&interval=1",
AssetName::USDC => "https://api.kraken.com/0/public/OHLC?pair=USDCUSD&interval=1",
AssetName::PLMC => "",
- AssetName::WETH => "",
+ AssetName::WETH => "https://api.kraken.com/0/public/OHLC?pair=ETHUSD&interval=1",
}
}
}
@@ -160,6 +160,7 @@ impl FetchPrice for BitFinexFetcher {
AssetName::USDT => "https://api-pub.bitfinex.com/v2/candles/trade%3A1m%3AtUSTUSD/hist?limit=15",
AssetName::DOT => "https://api-pub.bitfinex.com/v2/candles/trade%3A1m%3AtDOTUSD/hist?limit=15",
AssetName::USDC => "https://api-pub.bitfinex.com/v2/candles/trade%3A1m%3AtUDCUSD/hist?limit=15",
+ AssetName::WETH => "https://api-pub.bitfinex.com/v2/candles/trade%3A1m%3AtETHUSD/hist?limit=15",
_ => "",
}
}
@@ -226,7 +227,7 @@ impl FetchPrice for BitStampFetcher {
AssetName::DOT => "https://www.bitstamp.net/api/v2/ohlc/dotusd/?step=60&limit=15",
AssetName::USDC => "https://www.bitstamp.net/api/v2/ohlc/usdcusd/?step=60&limit=15",
AssetName::PLMC => "",
- AssetName::WETH => "",
+ AssetName::WETH => "https://www.bitstamp.net/api/v2/ohlc/ethusd/?step=60&limit=15",
}
}
}
@@ -257,6 +258,7 @@ impl FetchPrice for CoinbaseFetcher {
match name {
AssetName::USDT => "https://api.exchange.coinbase.com/products/USDT-USD/candles?granularity=60",
AssetName::DOT => "https://api.exchange.coinbase.com/products/DOT-USD/candles?granularity=60",
+ AssetName::WETH => "https://api.exchange.coinbase.com/products/ETH-USD/candles?granularity=60",
_ => "",
}
}
diff --git a/scripts/zombienet/polimec-paseo-local.toml b/scripts/zombienet/polimec-paseo-local.toml
index 4ba85965c..cbe3a6e0e 100644
--- a/scripts/zombienet/polimec-paseo-local.toml
+++ b/scripts/zombienet/polimec-paseo-local.toml
@@ -25,20 +25,20 @@ chain = "polimec-paseo-local"
[[parachains.collators]]
name = "collator1"
command = "./target/release/polimec-node"
- args = ["--offchain-worker when-authority"]
+ args = ["--offchain-worker=always --enable-offchain-indexing=true"]
# ss58 key: 5Do5UoayFvDrHroGS1YMqxTVUysSkrhNwVMzmj1foVb3vzzb
keystore_key_types = ["aura", "plmc_sr"]
[[parachains.collators]]
name = "collator2"
command = "./target/release/polimec-node"
- args = ["--offchain-worker when-authority"]
+ args = ["--offchain-worker=always --enable-offchain-indexing=true"]
# ss58 key: 5E5E37FNZD9KVHyGgSHt8pc2kq8e3VUS5rf8GmrxCa7ySs8s
keystore_key_types = ["aura", "plmc_sr"]
[[parachains.collators]]
name = "collator3"
command = "./target/release/polimec-node"
- args = ["--offchain-worker when-authority"]
+ args = ["--offchain-worker=always --enable-offchain-indexing=true"]
# ss58 key: 5ELLzYckeuomgTnv4Pf1aT4itxu35cn1KWNCGcftzv5N2x7o
keystore_key_types = ["aura", "plmc_sr"]
\ No newline at end of file