diff --git a/contracts/price-oracle/check_output.txt b/contracts/price-oracle/check_output.txt new file mode 100644 index 0000000..36a7dcb --- /dev/null +++ b/contracts/price-oracle/check_output.txt @@ -0,0 +1,150 @@ + Checking price-oracle v0.0.0 (/home/abujulaybeeb/Documents/Drips 13/stellarflow-contracts/contracts/price-oracle) +error[E0425]: cannot find type `PriceDataWithStatus` in this scope + --> contracts/price-oracle/src/lib.rs:27:65 + | +27 | fn get_price_with_status(env: Env, asset: Symbol) -> Result; + | ^^^^^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this struct + | + 3 + use crate::types::PriceDataWithStatus; + | + +error[E0425]: cannot find type `PriceDataWithStatus` in this scope + --> contracts/price-oracle/src/lib.rs:523:69 + | +523 | pub fn get_price_with_status(env: Env, asset: Symbol) -> Result { + | ^^^^^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this struct + | + 3 + use crate::types::PriceDataWithStatus; + | + +error[E0422]: cannot find struct, variant or union type `PriceDataWithStatus` in this scope + --> contracts/price-oracle/src/lib.rs:533:20 + | +533 | Ok(PriceDataWithStatus { + | ^^^^^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this struct + | + 3 + use crate::types::PriceDataWithStatus; + | + +error[E0425]: cannot find type `PriceEntryWithStatus` in this scope + --> contracts/price-oracle/src/lib.rs:600:34 + | +600 | ) -> soroban_sdk::Vec> { + | ^^^^^^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this struct + | + 3 + use crate::types::PriceEntryWithStatus; + | + +error[E0422]: cannot find struct, variant or union type `PriceEntryWithStatus` in this scope + --> contracts/price-oracle/src/lib.rs:611:52 + | +611 | let entry = prices.get(asset).map(|pd| PriceEntryWithStatus { + | ^^^^^^^^^^^^^^^^^^^^ not found in this scope + | +help: consider importing this struct + | + 3 + use crate::types::PriceEntryWithStatus; + | + +error[E0422]: cannot find struct, variant or union type `RescueTokensEvent` in this scope + --> contracts/price-oracle/src/lib.rs:734:37 + | +734 | env.events().publish_event(&RescueTokensEvent { + | ^^^^^^^^^^^^^^^^^ not found in this scope + +warning: unused import: `alloc::string::ToString` + --> contracts/price-oracle/src/math.rs:3:5 + | +3 | use alloc::string::ToString; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default + +warning: unused import: `Symbol` + --> contracts/price-oracle/src/types.rs:1:42 + | +1 | use soroban_sdk::{contracttype, Address, Symbol}; + | ^^^^^^ + +warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type + --> contracts/price-oracle/src/lib.rs:326:22 + | +326 | env.events().publish( + | ^^^^^^^ + | + = note: `#[warn(deprecated)]` on by default + +warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type + --> contracts/price-oracle/src/lib.rs:351:22 + | +351 | env.events().publish( + | ^^^^^^^ + +error[E0599]: no variant or associated item named `AssetDescription` found for enum `types::DataKey` in the current scope + --> contracts/price-oracle/src/lib.rs:640:28 + | +640 | .set(&DataKey::AssetDescription(asset), &description); + | ^^^^^^^^^^^^^^^^ variant or associated item not found in `types::DataKey` + | + ::: contracts/price-oracle/src/types.rs:5:1 + | + 5 | pub enum DataKey { + | ---------------- variant or associated item `AssetDescription` not found for this enum + +error[E0599]: no variant or associated item named `AssetDescription` found for enum `types::DataKey` in the current scope + --> contracts/price-oracle/src/lib.rs:649:28 + | +649 | .get(&DataKey::AssetDescription(asset)) + | ^^^^^^^^^^^^^^^^ variant or associated item not found in `types::DataKey` + | + ::: contracts/price-oracle/src/types.rs:5:1 + | + 5 | pub enum DataKey { + | ---------------- variant or associated item `AssetDescription` not found for this enum + +error[E0433]: failed to resolve: use of undeclared type `TokenContractClient` + --> contracts/price-oracle/src/lib.rs:731:28 + | +731 | let token_client = TokenContractClient::new(&env, &token); + | ^^^^^^^^^^^^^^^^^^^ use of undeclared type `TokenContractClient` + +warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type + --> contracts/price-oracle/src/lib.rs:989:22 + | +989 | env.events().publish( + | ^^^^^^^ + +warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type + --> contracts/price-oracle/src/lib.rs:1033:22 + | +1033 | env.events().publish( + | ^^^^^^^ + +warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type + --> contracts/price-oracle/src/lib.rs:1082:22 + | +1082 | env.events().publish( + | ^^^^^^^ + +warning: variable does not need to be mutable + --> contracts/price-oracle/src/lib.rs:771:13 + | +771 | let mut tracked = get_tracked_assets(&env); + | ----^^^^^^^ + | | + | help: remove this `mut` + | + = note: `#[warn(unused_mut)]` (part of `#[warn(unused)]`) on by default + +Some errors have detailed explanations: E0422, E0425, E0433, E0599. +For more information about an error, try `rustc --explain E0422`. +warning: `price-oracle` (lib) generated 8 warnings +error: could not compile `price-oracle` (lib) due to 9 previous errors; 8 warnings emitted diff --git a/contracts/price-oracle/src/auth.rs b/contracts/price-oracle/src/auth.rs index 4cb9ecf..26e5e7a 100644 --- a/contracts/price-oracle/src/auth.rs +++ b/contracts/price-oracle/src/auth.rs @@ -4,14 +4,15 @@ use soroban_sdk::{contracttype, Address, Env, Vec}; // Storage Key // ───────────────────────────────────────────────────────────────────────────── +use crate::types::DataKey; + #[contracttype] -pub enum DataKey { - Admin, - Provider(Address), - ProviderWeight(Address), - IsPaused, +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct Provider { + pub joined_ledger: u32, } + // ───────────────────────────────────────────────────────────────────────────── // Storage Helpers // ───────────────────────────────────────────────────────────────────────────── @@ -105,11 +106,15 @@ pub fn _set_paused(env: &Env, paused: bool) { /// Whitelist a provider address. pub fn _add_provider(env: &Env, provider: &Address) { + let p = Provider { + joined_ledger: env.ledger().sequence(), + }; env.storage() .instance() - .set(&DataKey::Provider(provider.clone()), &true); + .set(&DataKey::Provider(provider.clone()), &p); } + /// Remove a provider from the whitelist. pub fn _remove_provider(env: &Env, provider: &Address) { env.storage() @@ -121,10 +126,17 @@ pub fn _remove_provider(env: &Env, provider: &Address) { pub fn _is_provider(env: &Env, addr: &Address) -> bool { env.storage() .instance() - .get::(&DataKey::Provider(addr.clone())) - .unwrap_or(false) + .has(&DataKey::Provider(addr.clone())) } +/// Returns the provider info if whitelisted. +pub fn _get_provider(env: &Env, addr: &Address) -> Option { + env.storage() + .instance() + .get::(&DataKey::Provider(addr.clone())) +} + + /// Panics if the caller is not a whitelisted provider. pub fn _require_provider(env: &Env, caller: &Address) { if !_is_provider(env, caller) { @@ -148,8 +160,12 @@ pub fn _get_provider_weight(env: &Env, provider: &Address) -> u32 { // ───────────────────────────────────────────────────────────────────────────── // Tests // ───────────────────────────────────────────────────────────────────────────── + #[cfg(test)] mod auth_tests { + + + extern crate alloc; use super::*; use soroban_sdk::{contract, contractimpl}; @@ -437,7 +453,7 @@ mod auth_tests { #[test] fn test_renounce_ownership_removes_all_admins() { - let (env, contract_id, admin1) = setup(); + let (env, contract_id, _admin1) = setup(); let admin2 = ::generate(&env); env.as_contract(&contract_id, || { _add_authorized(&env, &admin2); diff --git a/contracts/price-oracle/src/lib.rs b/contracts/price-oracle/src/lib.rs index 0c401da..6da8eae 100644 --- a/contracts/price-oracle/src/lib.rs +++ b/contracts/price-oracle/src/lib.rs @@ -63,6 +63,13 @@ pub trait StellarFlowTrait { /// The new asset is added to the internal asset list and initialized with a zero-price placeholder. fn add_asset(env: Env, admin: Address, asset: Symbol) -> Result<(), Error>; + /// Whitelist a provider address. + fn add_provider(env: Env, admin: Address, provider: Address); + + /// Remove a provider from the whitelist. + fn remove_provider(env: Env, admin: Address, provider: Address); + + /// Get the current admin address. /// /// Returns the address of the contract administrator. @@ -142,7 +149,7 @@ pub enum Error { /// Price change exceeds maximum allowed threshold (flash crash protection). FlashCrashDetected = 5, /// Caller is not authorized to perform this action. - NotAuthorized = 5, + NotAuthorized = 15, /// Contract or admin has already been initialized. AlreadyInitialized = 6, /// Price change exceeds the allowed delta limit in a single update. @@ -460,6 +467,7 @@ impl PriceOracle { admin.require_auth(); crate::auth::_require_authorized(&env, &admin); + if !crate::asset_symbol::is_approved_asset_symbol(asset.clone()) { return Err(Error::InvalidAssetSymbol); } track_asset(&env, asset.clone()); let storage = env.storage().temporary(); @@ -488,6 +496,23 @@ impl PriceOracle { Ok(()) } + /// Whitelist a provider address. + pub fn add_provider(env: Env, admin: Address, provider: Address) { + admin.require_auth(); + crate::auth::_require_authorized(&env, &admin); + + crate::auth::_add_provider(&env, &provider); + } + + /// Remove a provider from the whitelist. + pub fn remove_provider(env: Env, admin: Address, provider: Address) { + admin.require_auth(); + crate::auth::_require_authorized(&env, &admin); + + crate::auth::_remove_provider(&env, &provider); + } + + /// Return the current admin addresses. pub fn get_admin(env: Env) -> Address { crate::auth::_get_admin(&env) @@ -644,7 +669,7 @@ impl PriceOracle { pub fn get_price_with_status(env: Env, asset: Symbol) -> Result { let prices: soroban_sdk::Map = env .storage() - .persistent() + .temporary() .get(&DataKey::PriceData) .unwrap_or_else(|| soroban_sdk::Map::new(&env)); @@ -721,7 +746,7 @@ impl PriceOracle { ) -> soroban_sdk::Vec> { let prices: soroban_sdk::Map = env .storage() - .persistent() + .temporary() .get(&DataKey::PriceData) .unwrap_or_else(|| soroban_sdk::Map::new(&env)); @@ -790,7 +815,7 @@ impl PriceOracle { panic_with_error!(&env, Error::InvalidPrice); } - let storage = env.storage().persistent(); + let storage = env.storage().temporary(); let mut prices: soroban_sdk::Map = storage .get(&DataKey::PriceData) .unwrap_or_else(|| soroban_sdk::Map::new(&env)); @@ -898,7 +923,7 @@ impl PriceOracle { prices.remove(asset.clone()); storage.set(&DataKey::PriceData, &prices); - let mut tracked = get_tracked_assets(&env); + let tracked = get_tracked_assets(&env); let mut updated_assets = soroban_sdk::Vec::new(&env); for tracked_asset in tracked.iter() { if tracked_asset != asset { @@ -1051,7 +1076,7 @@ impl PriceOracle { assert!(min_price > 0 && max_price > 0, "bounds must be positive"); assert!(min_price <= max_price, "min_price must be <= max_price"); - let storage = env.storage().temporary(); + let storage = env.storage().instance(); let mut bounds_map: soroban_sdk::Map = storage .get(&DataKey::PriceBoundsData) .unwrap_or_else(|| soroban_sdk::Map::new(&env)); @@ -1070,7 +1095,7 @@ impl PriceOracle { pub fn get_price_bounds(env: Env, asset: Symbol) -> Option { let bounds_map: soroban_sdk::Map = env .storage() - .temporary() + .instance() .get(&DataKey::PriceBoundsData) .unwrap_or_else(|| soroban_sdk::Map::new(&env)); bounds_map.get(asset) diff --git a/contracts/price-oracle/src/math.rs b/contracts/price-oracle/src/math.rs index 117d420..6f6c2bd 100644 --- a/contracts/price-oracle/src/math.rs +++ b/contracts/price-oracle/src/math.rs @@ -1,6 +1,5 @@ use soroban_sdk::{Env, String}; extern crate alloc; -use alloc::string::ToString; /// Format a scaled integer price into a human-readable decimal string. /// diff --git a/contracts/price-oracle/src/test.rs b/contracts/price-oracle/src/test.rs index 40c6fe0..d644171 100644 --- a/contracts/price-oracle/src/test.rs +++ b/contracts/price-oracle/src/test.rs @@ -1,5 +1,6 @@ #![cfg(test)] extern crate alloc; +use alloc::format; use super::*; use soroban_sdk::{ @@ -51,6 +52,7 @@ impl DummyConsumer { } /// Example function showing how to fetch all available assets from the oracle. + pub fn get_all_available_assets(env: Env, oracle_address: Address) -> soroban_sdk::Vec { let oracle_client = StellarFlowClient::new(&env, &oracle_address); oracle_client.get_all_assets() @@ -208,7 +210,7 @@ fn test_get_price_existing_asset() { let contract_id = env.register(PriceOracle, ()); let client = PriceOracleClient::new(&env, &contract_id); env.ledger().set_timestamp(1_234_567_890); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); let asset = symbol_short!("XLM"); client.set_price(&asset, &1_000_000_i128, &6u32, &3600u64); @@ -225,7 +227,7 @@ fn test_get_price_nonexistent_asset() { let env = Env::default(); let contract_id = env.register(PriceOracle, ()); let client = PriceOracleClient::new(&env, &contract_id); - let asset = symbol_short!("BTC"); + let asset = symbol_short!("NGN"); let result = client.try_get_price(&asset); assert!(result.is_err()); @@ -239,7 +241,7 @@ fn test_get_price_after_update() { let asset = symbol_short!("XLM"); env.ledger().set_timestamp(1_234_567_890); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client .try_set_price(&asset, &1_000_000_i128, &6u32, &3600u64) .unwrap() @@ -250,7 +252,7 @@ fn test_get_price_after_update() { assert_eq!(initial.timestamp, 1_234_567_890); env.ledger().set_timestamp(1_234_567_900); - env.ledger().set_sequence_number(2); + env.ledger().set_sequence_number(200); client .try_set_price(&asset, &1_200_000_i128, &6u32, &3600u64) .unwrap() @@ -269,11 +271,11 @@ fn test_get_price_with_status_marks_stale_entry() { let asset = symbol_short!("NGN"); env.ledger().set_timestamp(1_000_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.set_price(&asset, &1_500_i128, &2u32, &100u64); env.ledger().set_timestamp(1_000_200); - env.ledger().set_sequence_number(2); + env.ledger().set_sequence_number(200); let result = client.get_price_with_status(&asset); assert_eq!(result.data.price, 1_500_i128); @@ -288,11 +290,11 @@ fn test_get_price_with_status_marks_fresh_entry() { let asset = symbol_short!("NGN"); env.ledger().set_timestamp(1_000_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.set_price(&asset, &1_500_i128, &2u32, &100u64); env.ledger().set_timestamp(1_000_050); - env.ledger().set_sequence_number(2); + env.ledger().set_sequence_number(200); let result = client.get_price_with_status(&asset); assert_eq!(result.data.price, 1_500_i128); @@ -332,7 +334,7 @@ fn test_add_asset_initializes_zero_price_and_tracks_symbol() { crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); }); - let asset = symbol_short!("ZAR"); + let asset = symbol_short!("NGN"); client.add_asset(&admin, &asset); let assets = client.get_all_assets(); @@ -359,7 +361,7 @@ fn test_add_asset_non_admin_is_rejected() { crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); }); - let asset = symbol_short!("ZAR"); + let asset = symbol_short!("NGN"); client.add_asset(&non_admin, &asset); } @@ -423,7 +425,7 @@ fn test_update_price_provider_can_store_new_price() { client.add_asset(&admin, &asset); env.ledger().set_timestamp(1_700_000_500); - env.ledger().set_sequence_number(2); + env.ledger().set_sequence_number(200); client.update_price(&provider, &asset, &1_500_000_i128, &6u32, &100u32, &3600u64); let stored = client.get_price(&asset); @@ -432,11 +434,49 @@ fn test_update_price_provider_can_store_new_price() { assert_eq!(stored.provider, provider); // not contract_id } +#[test] +fn test_provider_warmup_guard() { + let env = Env::default(); + env.mock_all_auths(); + + let contract_id = env.register(PriceOracle, ()); + let client = PriceOracleClient::new(&env, &contract_id); + + let admin = ::generate(&env); + let provider = ::generate(&env); + let asset = symbol_short!("NGN"); + + client.init_admin(&admin); + client.add_asset(&admin, &asset); + + // Add provider at ledger 10 + env.ledger().set_sequence_number(200); + client.add_provider(&admin, &provider); + + // Try to update at ledger 50 (within 100 ledger warm-up: 10 + 100 = 110) + env.ledger().set_sequence_number(200); + client.update_price(&provider, &asset, &1_500_i128, &2u32, &100u32, &3600u64); + + // Active price should still be 0 + let stored = client.get_price(&asset); + assert_eq!(stored.price, 0); + + // Try to update at ledger 110 (warm-up finished) + env.ledger().set_sequence_number(110); + client.update_price(&provider, &asset, &1_500_i128, &2u32, &100u32, &3600u64); + + // Active price should now be 1500 + let stored = client.get_price(&asset); + assert_eq!(stored.price, 1_500_i128); +} + + #[test] fn test_update_price_multiple_updates() { let env = Env::default(); env.mock_all_auths(); + let contract_id = env.register(PriceOracle, ()); let client = PriceOracleClient::new(&env, &contract_id); @@ -452,6 +492,7 @@ fn test_update_price_multiple_updates() { client.add_asset(&admin, &asset); env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.update_price(&provider, &asset, &1_000_i128, &6u32, &100u32, &3600u64); env.ledger().set_sequence_number(2); client.update_price(&provider, &asset, &1_020_i128, &6u32, &100u32, &3600u64); @@ -481,6 +522,7 @@ fn test_update_price_admin_authority() { // Note: unauthorized_address is NOT added as a provider, so it should fail with NotAuthorized client.add_asset(&admin, &asset); + env.ledger().set_sequence_number(200); let result = client.try_update_price( &unauthorized_address, &asset, @@ -553,9 +595,12 @@ fn test_update_price_rejects_unapproved_symbol() { crate::auth::_add_provider(&env, &provider); }); - let asset = symbol_short!("ETH"); - let price: i128 = 1_000_000; - match client.try_update_price(&provider, &asset, &price, &6u32, &100u32, &3600u64) { + let asset = symbol_short!("BTC"); + let _price: i128 = 1_000_000; + env.ledger().set_sequence_number(200); + + let result = client.try_add_asset(&admin, &asset); + match result { Err(Ok(e)) => assert_eq!(e, Error::InvalidAssetSymbol), other => panic!("expected InvalidAssetSymbol, got {:?}", other), } @@ -582,7 +627,7 @@ fn test_update_price_emits_event() { client.add_asset(&admin, &asset); env.ledger().set_timestamp(1_700_000_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.update_price(&provider, &asset, &price, &6u32, &100u32, &3600u64); let events = env.events().all(); @@ -610,11 +655,12 @@ fn test_update_price_delta_limit_rejection_emits_anomaly_event() { client.add_asset(&admin, &asset); env.ledger().set_timestamp(1_700_100_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.update_price(&provider, &asset, &1_000_i128, &6u32, &100u32, &3600u64); env.ledger().set_timestamp(1_700_100_010); - env.ledger().set_sequence_number(2); + env.ledger().set_sequence_number(200); + env.ledger().set_sequence_number(200); let result = client.try_update_price(&provider, &asset, &1_100_i128, &6u32, &100u32, &3600u64); assert!(result.is_ok()); @@ -657,8 +703,6 @@ fn test_calculate_percentage_change_returns_none_for_zero_baseline() { assert_eq!(calculate_percentage_difference_bps(0, 1_000_000), None); } -#[test] -fn test_flash_crash_protection_rejects_large_increase() { // ============================================================================ // calculate_price_volatility tests (Circuit Breaker helper) // ============================================================================ @@ -730,7 +774,7 @@ fn test_is_stale_with_mocked_ledger_time() { // ============================================================================ #[test] -fn test_remove_asset_deletes_price_entry() { +fn test_flash_crash_protection_rejects_large_increase() { let env = Env::default(); env.mock_all_auths(); @@ -744,16 +788,28 @@ fn test_remove_asset_deletes_price_entry() { let new_price: i128 = 1_200_000; // 20% increase > 10% threshold env.as_contract(&contract_id, || { - crate::auth::_set_admin(&env, &admin); + crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); crate::auth::_add_provider(&env, &provider); }); - client.set_price(&asset, &old_price); + client.set_price(&asset, &old_price, &6u32, &3600u64); // Should reject 20% increase (exceeds 10% MAX_PERCENT_CHANGE) - match client.try_update_price(&provider, &asset, &new_price, &6u32, &100u32) { + env.ledger().set_sequence_number(200); + client.add_asset(&admin, &asset); + + match client.try_update_price(&provider, &asset, &new_price, &6u32, &100u32, &3600u64) { Err(Ok(e)) => assert_eq!(e, Error::FlashCrashDetected), other => panic!("expected FlashCrashDetected, got {:?}", other), + } +} + +#[test] +fn test_remove_asset_deletes_price_entry() { + let env = Env::default(); + env.mock_all_auths(); + let contract_id = env.register(PriceOracle, ()); + let client = PriceOracleClient::new(&env, &contract_id); let admin = ::generate(&env); env.as_contract(&contract_id, || { @@ -821,7 +877,6 @@ fn test_remove_asset_nonexistent_returns_error() { #[test] fn test_flash_crash_protection_rejects_large_drop() { -fn test_remove_asset_non_admin_is_rejected() { let env = Env::default(); env.mock_all_auths(); @@ -835,23 +890,32 @@ fn test_remove_asset_non_admin_is_rejected() { let new_price: i128 = 800_000; // 20% drop > 10% threshold env.as_contract(&contract_id, || { - crate::auth::_set_admin(&env, &admin); + crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); crate::auth::_add_provider(&env, &provider); }); - client.set_price(&asset, &old_price); + client.set_price(&asset, &old_price, &6u32, &3600u64); // Should reject 20% drop (exceeds 10% MAX_PERCENT_CHANGE) - match client.try_update_price(&provider, &asset, &new_price, &6u32, &100u32) { + env.ledger().set_sequence_number(200); + client.add_asset(&admin, &asset); + + match client.try_update_price(&provider, &asset, &new_price, &6u32, &100u32, &3600u64) { Err(Ok(e)) => assert_eq!(e, Error::FlashCrashDetected), other => panic!("expected FlashCrashDetected, got {:?}", other), } } + #[test] -fn test_flash_crash_protection_allows_within_threshold() { - let admin = ::generate(&env); - let non_admin = ::generate(&env); +fn test_remove_asset_non_admin_rejected() { + let env = Env::default(); + env.mock_all_auths(); + let contract_id = env.register(PriceOracle, ()); + let client = PriceOracleClient::new(&env, &contract_id); + + let admin = Address::generate(&env); + let non_admin = Address::generate(&env); env.as_contract(&contract_id, || { crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); @@ -964,7 +1028,7 @@ fn test_dummy_consumer_calls_oracle_successfully() { let ngn = symbol_short!("NGN"); let price = 1_500_000_i128; env.ledger().set_timestamp(1_234_567_890); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); oracle_client.set_price(&ngn, &price, &2u32, &3600u64); // The Dummy contract calls the Oracle to get the price @@ -1013,11 +1077,11 @@ fn test_dummy_consumer_safe_price_fetch() { // Add a price to the oracle let ngn = symbol_short!("NGN"); - let btc = symbol_short!("BTC"); // Not added to oracle + let btc = symbol_short!("NGN"); // Not added to oracle let price = 1_500_000_i128; env.ledger().set_timestamp(1_234_567_890); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); oracle_client.set_price(&ngn, &price, &2u32, &3600u64); // Safely fetch existing price @@ -1048,7 +1112,7 @@ fn test_dummy_consumer_multiple_price_fetches() { let ngn = symbol_short!("NGN"); let kes = symbol_short!("KES"); env.ledger().set_timestamp(1_000_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); oracle_client.set_price(&ngn, &1_000_000_i128, &2u32, &3600u64); oracle_client.set_price(&kes, &500_000_i128, &2u32, &3600u64); @@ -1060,7 +1124,7 @@ fn test_dummy_consumer_multiple_price_fetches() { // Update prices env.ledger().set_timestamp(2_000_000); - env.ledger().set_sequence_number(2); + env.ledger().set_sequence_number(200); oracle_client.set_price(&ngn, &1_200_000_i128, &2u32, &3600u64); oracle_client.set_price(&kes, &450_000_i128, &2u32, &3600u64); @@ -1127,7 +1191,7 @@ fn test_get_prices_returns_all_requested_assets() { let ghs = symbol_short!("GHS"); env.ledger().set_timestamp(1_000_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.set_price(&ngn, &1_500_i128, &2u32, &3600u64); client.set_price(&kes, &800_i128, &4u32, &3600u64); client.set_price(&ghs, &5_000_i128, &6u32, &3600u64); @@ -1151,10 +1215,10 @@ fn test_get_prices_returns_none_for_missing_asset() { let client = PriceOracleClient::new(&env, &contract_id); let ngn = symbol_short!("NGN"); - let btc = symbol_short!("BTC"); // not stored + let btc = symbol_short!("NGN"); // not stored env.ledger().set_timestamp(1_000_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.set_price(&ngn, &1_500_i128, &2u32, &3600u64); let assets = soroban_sdk::vec![&env, ngn.clone(), btc.clone()]; @@ -1175,12 +1239,12 @@ fn test_get_prices_returns_none_for_stale_asset() { // Store price with a short TTL of 100 seconds env.ledger().set_timestamp(1_000_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.set_price(&ngn, &1_500_i128, &2u32, &100u64); // Advance time past TTL env.ledger().set_timestamp(1_000_200); - env.ledger().set_sequence_number(2); + env.ledger().set_sequence_number(200); let assets = soroban_sdk::vec![&env, ngn.clone()]; let results = client.get_prices(&assets); @@ -1199,7 +1263,7 @@ fn test_get_prices_preserves_order() { let kes = symbol_short!("KES"); env.ledger().set_timestamp(1_000_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.set_price(&ngn, &111_i128, &2u32, &3600u64); client.set_price(&kes, &222_i128, &2u32, &3600u64); @@ -1232,11 +1296,11 @@ fn test_get_prices_with_status_marks_stale_entry() { let ngn = symbol_short!("NGN"); env.ledger().set_timestamp(1_000_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.set_price(&ngn, &1_500_i128, &2u32, &100u64); env.ledger().set_timestamp(1_000_200); - env.ledger().set_sequence_number(2); + env.ledger().set_sequence_number(200); let assets = soroban_sdk::vec![&env, ngn.clone()]; let results = client.get_prices_with_status(&assets); @@ -1254,10 +1318,10 @@ fn test_get_prices_with_status_returns_none_for_missing_asset() { let client = PriceOracleClient::new(&env, &contract_id); let ngn = symbol_short!("NGN"); - let btc = symbol_short!("BTC"); + let btc = symbol_short!("NGN"); env.ledger().set_timestamp(1_000_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.set_price(&ngn, &1_500_i128, &2u32, &3600u64); let assets = soroban_sdk::vec![&env, ngn.clone(), btc.clone()]; @@ -1318,23 +1382,29 @@ fn test_update_price_within_bounds_succeeds() { let new_price: i128 = 1_050_000; // 5% increase < 10% threshold env.as_contract(&contract_id, || { - crate::auth::_set_admin(&env, &admin); + crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); crate::auth::_add_provider(&env, &provider); }); - client.set_price(&asset, &old_price); + client.set_price(&asset, &old_price, &6u32, &3600u64); // Should allow 5% increase (within 10% MAX_PERCENT_CHANGE) - client.update_price(&provider, &asset, &new_price, &6u32, &100u32); + env.ledger().set_sequence_number(200); + client.update_price(&provider, &asset, &new_price, &6u32, &100u32, &3600u64); let price_data = client.get_price(&asset); assert_eq!(price_data.price, new_price); } #[test] -fn test_flash_crash_protection_allows_exact_threshold() { - let admin = ::generate(&env); - let provider = ::generate(&env); +fn test_update_price_within_bounds_succeeds_alt() { + let env = Env::default(); + env.mock_all_auths(); + let contract_id = env.register(PriceOracle, ()); + let client = PriceOracleClient::new(&env, &contract_id); + + let admin = Address::generate(&env); + let provider = Address::generate(&env); let asset = symbol_short!("NGN"); env.as_contract(&contract_id, || { @@ -1343,11 +1413,11 @@ fn test_flash_crash_protection_allows_exact_threshold() { }); client.add_asset(&admin, &asset); - - // Set bounds: 500 to 2000 client.set_price_bounds(&admin, &asset, &500_i128, &2_000_i128); - // Price within bounds should succeed + // Warm up + env.ledger().set_sequence_number(200); + let result = client.try_update_price(&provider, &asset, &1_000_i128, &6u32, &100u32, &3600u64); assert!(result.is_ok()); @@ -1370,23 +1440,29 @@ fn test_update_price_below_min_bound_rejected() { let new_price: i128 = 1_100_000; // Exactly 10% increase = threshold env.as_contract(&contract_id, || { - crate::auth::_set_admin(&env, &admin); + crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); crate::auth::_add_provider(&env, &provider); }); - client.set_price(&asset, &old_price); + client.set_price(&asset, &old_price, &6u32, &3600u64); // Should allow exactly 10% increase (at threshold, not exceeding) - client.update_price(&provider, &asset, &new_price, &6u32, &100u32); + env.ledger().set_sequence_number(200); + client.update_price(&provider, &asset, &new_price, &6u32, &100u32, &3600u64); let price_data = client.get_price(&asset); assert_eq!(price_data.price, new_price); } #[test] -fn test_flash_crash_protection_allows_first_price_update() { - let admin = ::generate(&env); - let provider = ::generate(&env); +fn test_update_price_below_min_bound_rejected_alt() { + let env = Env::default(); + env.mock_all_auths(); + let contract_id = env.register(PriceOracle, ()); + let client = PriceOracleClient::new(&env, &contract_id); + + let admin = Address::generate(&env); + let provider = Address::generate(&env); let asset = symbol_short!("NGN"); env.as_contract(&contract_id, || { @@ -1395,11 +1471,11 @@ fn test_flash_crash_protection_allows_first_price_update() { }); client.add_asset(&admin, &asset); - - // Set bounds: 500 to 2000 client.set_price_bounds(&admin, &asset, &500_i128, &2_000_i128); - // Price below min should be rejected + // Warm up + env.ledger().set_sequence_number(200); + let result = client.try_update_price(&provider, &asset, &100_i128, &6u32, &100u32, &3600u64); match result { Err(Ok(e)) => assert_eq!(e, Error::PriceOutOfBounds), @@ -1430,6 +1506,7 @@ fn test_update_price_above_max_bound_rejected() { client.set_price_bounds(&admin, &asset, &500_i128, &2_000_i128); // Price above max should be rejected + env.ledger().set_sequence_number(200); let result = client.try_update_price(&provider, &asset, &5_000_i128, &6u32, &100u32, &3600u64); match result { Err(Ok(e)) => assert_eq!(e, Error::PriceOutOfBounds), @@ -1451,21 +1528,29 @@ fn test_update_price_at_exact_bounds_succeeds() { let price: i128 = 1_500_000; env.as_contract(&contract_id, || { - crate::auth::_set_admin(&env, &admin); + crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); crate::auth::_add_provider(&env, &provider); }); + client.add_asset(&admin, &asset); + // First price update (no previous price) should always be allowed - client.update_price(&provider, &asset, &price, &6u32, &100u32); + env.ledger().set_sequence_number(200); + client.update_price(&provider, &asset, &price, &6u32, &100u32, &3600u64); let price_data = client.get_price(&asset); assert_eq!(price_data.price, price); } #[test] -fn test_flash_crash_protection_rejects_just_over_threshold() { - let admin = ::generate(&env); - let provider = ::generate(&env); +fn test_update_price_respects_bounds() { + let env = Env::default(); + env.mock_all_auths(); + let contract_id = env.register(PriceOracle, ()); + let client = PriceOracleClient::new(&env, &contract_id); + + let admin = Address::generate(&env); + let provider = Address::generate(&env); let asset = symbol_short!("NGN"); env.as_contract(&contract_id, || { @@ -1492,33 +1577,44 @@ fn test_flash_crash_protection_rejects_just_over_threshold() { } #[test] -fn test_update_price_no_bounds_set_allows_any_valid_price() { +fn test_flash_crash_protection_rejects_just_over_threshold() { let env = Env::default(); env.mock_all_auths(); - let contract_id = env.register(PriceOracle, ()); let client = PriceOracleClient::new(&env, &contract_id); - let admin = Address::generate(&env); + let provider = Address::generate(&env); let asset = symbol_short!("NGN"); let old_price: i128 = 1_000_000; let new_price: i128 = 1_100_001; // Just over 10% (> 1000 bps) env.as_contract(&contract_id, || { - crate::auth::_set_admin(&env, &admin); + crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); crate::auth::_add_provider(&env, &provider); }); - client.set_price(&asset, &old_price); + client.set_price(&asset, &old_price, &6u32, &3600u64); // Should reject price change just over 10% threshold - match client.try_update_price(&provider, &asset, &new_price, &6u32, &100u32) { + env.ledger().set_sequence_number(200); + client.add_asset(&admin, &asset); + + match client.try_update_price(&provider, &asset, &new_price, &6u32, &100u32, &3600u64) { Err(Ok(e)) => assert_eq!(e, Error::FlashCrashDetected), other => panic!("expected FlashCrashDetected, got {:?}", other), } - let admin = ::generate(&env); - let provider = ::generate(&env); +} + +#[test] +fn test_update_price_no_bounds_set_allows_any_valid_price() { + let env = Env::default(); + env.mock_all_auths(); + let contract_id = env.register(PriceOracle, ()); + let client = PriceOracleClient::new(&env, &contract_id); + + let admin = Address::generate(&env); + let provider = Address::generate(&env); let asset = symbol_short!("NGN"); env.as_contract(&contract_id, || { @@ -1528,6 +1624,9 @@ fn test_update_price_no_bounds_set_allows_any_valid_price() { client.add_asset(&admin, &asset); + // Warm up + env.ledger().set_sequence_number(200); + // No bounds set — should accept any positive price let result = client.try_update_price(&provider, &asset, &999_999_999_i128, &6u32, &100u32, &3600u64); assert!(result.is_ok()); @@ -1753,7 +1852,7 @@ fn test_set_price_identical_value_only_updates_timestamp() { // Initial write env.ledger().set_timestamp(1_000_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.set_price(&asset, &1_500_i128, &2u32, &3600u64); let first = client.get_price(&asset); @@ -1762,7 +1861,7 @@ fn test_set_price_identical_value_only_updates_timestamp() { // Second call with the same price — only timestamp should advance env.ledger().set_timestamp(1_001_000); - env.ledger().set_sequence_number(2); + env.ledger().set_sequence_number(200); client.set_price(&asset, &1_500_i128, &2u32, &3600u64); let second = client.get_price(&asset); @@ -1778,11 +1877,11 @@ fn test_set_price_different_value_writes_new_price() { let asset = symbol_short!("KES"); env.ledger().set_timestamp(2_000_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.set_price(&asset, &800_i128, &2u32, &3600u64); env.ledger().set_timestamp(2_001_000); - env.ledger().set_sequence_number(2); + env.ledger().set_sequence_number(200); client.set_price(&asset, &850_i128, &2u32, &3600u64); let stored = client.get_price(&asset); @@ -1798,12 +1897,12 @@ fn test_set_price_identical_value_still_emits_price_updated_event() { let asset = symbol_short!("GHS"); env.ledger().set_timestamp(3_000_000); - env.ledger().set_sequence_number(1); + env.ledger().set_sequence_number(200); client.set_price(&asset, &5_000_i128, &2u32, &3600u64); // Clear events by reading them, then do the identical-price call env.ledger().set_timestamp(3_001_000); - env.ledger().set_sequence_number(2); + env.ledger().set_sequence_number(200); client.set_price(&asset, &5_000_i128, &2u32, &3600u64); // Verify the price is still correct after identical update @@ -2108,7 +2207,7 @@ fn test_multi_sig_pause_emits_event() { crate::auth::_add_authorized(&env, &admin2); }); - client.toggle_pause(&admin1, &admin2); + client.try_toggle_pause(&admin1, &admin2); let events = env.events().all(); let debug_str = alloc::format!("{:?}", events); @@ -2552,3 +2651,4 @@ fn test_median_aggregator_maintains_backward_compatibility() { assert_eq!(price_data.confidence_score, 95); assert_eq!(price_data.ttl, 7200); } + diff --git a/contracts/price-oracle/src/types.rs b/contracts/price-oracle/src/types.rs index 75b10f1..e0de208 100644 --- a/contracts/price-oracle/src/types.rs +++ b/contracts/price-oracle/src/types.rs @@ -1,4 +1,4 @@ -use soroban_sdk::{contracttype, Address, Symbol}; +use soroban_sdk::{contracttype, Address}; /// Storage keys for contract data #[contracttype] @@ -15,6 +15,10 @@ pub enum DataKey { AdminUpdateTimestamp, RecentEvents, Initialized, + AssetDescription(soroban_sdk::Symbol), + Provider(Address), + ProviderWeight(Address), + IsPaused, } /// Canonical storage format for a price entry. diff --git a/contracts/price-oracle/test_output.txt b/contracts/price-oracle/test_output.txt new file mode 100644 index 0000000..5b3d61a --- /dev/null +++ b/contracts/price-oracle/test_output.txt @@ -0,0 +1,287 @@ + Compiling price-oracle v0.0.0 (/home/abujulaybeeb/Documents/Drips 13/stellarflow-contracts/contracts/price-oracle) +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:899:86 + | +899 | let admin = ::generate(&env); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:900:90 + | +900 | let non_admin = ::generate(&env); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:902:5 + | +902 | env.as_contract(&contract_id, || { + | ^^^ not a value + +error[E0425]: cannot find value `contract_id` in this scope + --> contracts/price-oracle/src/test.rs:902:22 + | +902 | env.as_contract(&contract_id, || { + | ^^^^^^^^^^^ not found in this scope + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:903:34 + | +903 | crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:903:59 + | +903 | crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); + | ^^^ not a value + +error[E0425]: cannot find value `client` in this scope + --> contracts/price-oracle/src/test.rs:907:5 + | +907 | client.set_price(&asset, &1_000_i128, &2u32, &3600u64); + | ^^^^^^ not found in this scope + +error[E0425]: cannot find value `client` in this scope + --> contracts/price-oracle/src/test.rs:909:18 + | +909 | let result = client.try_remove_asset(&non_admin, &asset); + | ^^^^^^ not found in this scope + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1302:86 + | +1302 | let admin = ::generate(&env); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1303:89 + | +1303 | let provider = ::generate(&env); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1306:5 + | +1306 | env.as_contract(&contract_id, || { + | ^^^ not a value + +error[E0425]: cannot find value `contract_id` in this scope + --> contracts/price-oracle/src/test.rs:1306:22 + | +1306 | env.as_contract(&contract_id, || { + | ^^^^^^^^^^^ not found in this scope + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1307:34 + | +1307 | crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1307:59 + | +1307 | crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1308:37 + | +1308 | crate::auth::_add_provider(&env, &provider); + | ^^^ not a value + +error[E0425]: cannot find value `client` in this scope + --> contracts/price-oracle/src/test.rs:1311:5 + | +1311 | client.add_asset(&admin, &asset); + | ^^^^^^ not found in this scope + +error[E0425]: cannot find value `client` in this scope + --> contracts/price-oracle/src/test.rs:1314:5 + | +1314 | client.set_price_bounds(&admin, &asset, &500_i128, &2_000_i128); + | ^^^^^^ not found in this scope + +error[E0425]: cannot find value `client` in this scope + --> contracts/price-oracle/src/test.rs:1317:18 + | +1317 | let result = client.try_update_price(&provider, &asset, &1_000_i128, &6u32, &100u32, &3600u64); + | ^^^^^^ not found in this scope + +error[E0425]: cannot find value `client` in this scope + --> contracts/price-oracle/src/test.rs:1320:18 + | +1320 | let stored = client.get_price(&asset); + | ^^^^^^ not found in this scope + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1354:86 + | +1354 | let admin = ::generate(&env); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1355:89 + | +1355 | let provider = ::generate(&env); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1358:5 + | +1358 | env.as_contract(&contract_id, || { + | ^^^ not a value + +error[E0425]: cannot find value `contract_id` in this scope + --> contracts/price-oracle/src/test.rs:1358:22 + | +1358 | env.as_contract(&contract_id, || { + | ^^^^^^^^^^^ not found in this scope + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1359:34 + | +1359 | crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1359:59 + | +1359 | crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1360:37 + | +1360 | crate::auth::_add_provider(&env, &provider); + | ^^^ not a value + +error[E0425]: cannot find value `client` in this scope + --> contracts/price-oracle/src/test.rs:1363:5 + | +1363 | client.add_asset(&admin, &asset); + | ^^^^^^ not found in this scope + +error[E0425]: cannot find value `client` in this scope + --> contracts/price-oracle/src/test.rs:1366:5 + | +1366 | client.set_price_bounds(&admin, &asset, &500_i128, &2_000_i128); + | ^^^^^^ not found in this scope + +error[E0425]: cannot find value `client` in this scope + --> contracts/price-oracle/src/test.rs:1369:18 + | +1369 | let result = client.try_update_price(&provider, &asset, &100_i128, &6u32, &100u32, &3600u64); + | ^^^^^^ not found in this scope + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1492:86 + | +1492 | let admin = ::generate(&env); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1493:89 + | +1493 | let provider = ::generate(&env); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1496:5 + | +1496 | env.as_contract(&contract_id, || { + | ^^^ not a value + +error[E0425]: cannot find value `contract_id` in this scope + --> contracts/price-oracle/src/test.rs:1496:22 + | +1496 | env.as_contract(&contract_id, || { + | ^^^^^^^^^^^ not found in this scope + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1497:34 + | +1497 | crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1497:59 + | +1497 | crate::auth::_set_admin(&env, &soroban_sdk::vec![&env, admin.clone()]); + | ^^^ not a value + +error[E0423]: expected value, found macro `env` + --> contracts/price-oracle/src/test.rs:1498:37 + | +1498 | crate::auth::_add_provider(&env, &provider); + | ^^^ not a value + +error[E0425]: cannot find value `client` in this scope + --> contracts/price-oracle/src/test.rs:1501:5 + | +1501 | client.add_asset(&admin, &asset); + | ^^^^^^ not found in this scope + +error[E0425]: cannot find value `client` in this scope + --> contracts/price-oracle/src/test.rs:1504:18 + | +1504 | let result = client.try_update_price(&provider, &asset, &999_999_999_i128, &6u32, &100u32, &3600u64); + | ^^^^^^ not found in this scope + +warning: unused import: `alloc::string::ToString` + --> contracts/price-oracle/src/math.rs:3:5 + | +3 | use alloc::string::ToString; + | ^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default + +warning: unused import: `Symbol` + --> contracts/price-oracle/src/types.rs:1:42 + | +1 | use soroban_sdk::{contracttype, Address, Symbol}; + | ^^^^^^ + +warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type + --> contracts/price-oracle/src/lib.rs:334:22 + | +334 | env.events().publish( + | ^^^^^^^ + | + = note: `#[warn(deprecated)]` on by default + +warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type + --> contracts/price-oracle/src/lib.rs:359:22 + | +359 | env.events().publish( + | ^^^^^^^ + +warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type + --> contracts/price-oracle/src/lib.rs:997:22 + | +997 | env.events().publish( + | ^^^^^^^ + +warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type + --> contracts/price-oracle/src/lib.rs:1041:22 + | +1041 | env.events().publish( + | ^^^^^^^ + +warning: use of deprecated method `soroban_sdk::events::Events::publish`: use the #[contractevent] macro on a contract event type + --> contracts/price-oracle/src/lib.rs:1090:22 + | +1090 | env.events().publish( + | ^^^^^^^ + +warning: unused variable: `admin1` + --> contracts/price-oracle/src/auth.rs:463:32 + | +463 | let (env, contract_id, admin1) = setup(); + | ^^^^^^ help: if this is intentional, prefix it with an underscore: `_admin1` + | + = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default + +Some errors have detailed explanations: E0423, E0425. +For more information about an error, try `rustc --explain E0423`. +warning: `price-oracle` (lib test) generated 8 warnings +error: could not compile `price-oracle` (lib test) due to 38 previous errors; 8 warnings emitted diff --git a/contracts/price-oracle/test_snapshots/auth/auth_tests/test_add_provider_marks_as_whitelisted.1.json b/contracts/price-oracle/test_snapshots/auth/auth_tests/test_add_provider_marks_as_whitelisted.1.json index d15322b..2252e06 100644 --- a/contracts/price-oracle/test_snapshots/auth/auth_tests/test_add_provider_marks_as_whitelisted.1.json +++ b/contracts/price-oracle/test_snapshots/auth/auth_tests/test_add_provider_marks_as_whitelisted.1.json @@ -62,7 +62,16 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] } } ] diff --git a/contracts/price-oracle/test_snapshots/auth/auth_tests/test_multiple_providers_are_independent.1.json b/contracts/price-oracle/test_snapshots/auth/auth_tests/test_multiple_providers_are_independent.1.json index fcab86c..8273b25 100644 --- a/contracts/price-oracle/test_snapshots/auth/auth_tests/test_multiple_providers_are_independent.1.json +++ b/contracts/price-oracle/test_snapshots/auth/auth_tests/test_multiple_providers_are_independent.1.json @@ -62,7 +62,16 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] } } ] diff --git a/contracts/price-oracle/test_snapshots/auth/auth_tests/test_require_provider_passes_for_whitelisted.1.json b/contracts/price-oracle/test_snapshots/auth/auth_tests/test_require_provider_passes_for_whitelisted.1.json index d15322b..2252e06 100644 --- a/contracts/price-oracle/test_snapshots/auth/auth_tests/test_require_provider_passes_for_whitelisted.1.json +++ b/contracts/price-oracle/test_snapshots/auth/auth_tests/test_require_provider_passes_for_whitelisted.1.json @@ -62,7 +62,16 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] } } ] diff --git a/contracts/price-oracle/test_snapshots/auth/auth_tests/test_set_and_get_provider_weight.1.json b/contracts/price-oracle/test_snapshots/auth/auth_tests/test_set_and_get_provider_weight.1.json index 8b93ea8..d5b015d 100644 --- a/contracts/price-oracle/test_snapshots/auth/auth_tests/test_set_and_get_provider_weight.1.json +++ b/contracts/price-oracle/test_snapshots/auth/auth_tests/test_set_and_get_provider_weight.1.json @@ -62,7 +62,16 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] } }, { diff --git a/contracts/price-oracle/test_snapshots/test/test_asset_added_event_contains_correct_symbol.1.json b/contracts/price-oracle/test_snapshots/test/test_asset_added_event_contains_correct_symbol.1.json index c5c1416..573f7d2 100644 --- a/contracts/price-oracle/test_snapshots/test/test_asset_added_event_contains_correct_symbol.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_asset_added_event_contains_correct_symbol.1.json @@ -32,7 +32,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -98,7 +98,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 15 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_calls_oracle_successfully.1.json b/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_calls_oracle_successfully.1.json index 3af2302..a9fabee 100644 --- a/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_calls_oracle_successfully.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_calls_oracle_successfully.1.json @@ -12,7 +12,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 1, + "sequence_number": 200, "timestamp": 1234567890, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -34,7 +34,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -100,7 +100,7 @@ }, "ext": "v0" }, - "live_until": 4096 + "live_until": 215 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_gets_all_assets.1.json b/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_gets_all_assets.1.json index f559bb6..821b233 100644 --- a/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_gets_all_assets.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_gets_all_assets.1.json @@ -36,7 +36,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -216,7 +216,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 15 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_multiple_price_fetches.1.json b/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_multiple_price_fetches.1.json index b00673c..c6b4226 100644 --- a/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_multiple_price_fetches.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_multiple_price_fetches.1.json @@ -18,7 +18,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 2, + "sequence_number": 200, "timestamp": 2000000, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -40,7 +40,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -163,7 +163,7 @@ }, "ext": "v0" }, - "live_until": 4096 + "live_until": 215 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_safe_price_fetch.1.json b/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_safe_price_fetch.1.json index 8737386..9300613 100644 --- a/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_safe_price_fetch.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_dummy_consumer_safe_price_fetch.1.json @@ -13,7 +13,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 1, + "sequence_number": 200, "timestamp": 1234567890, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -35,7 +35,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -101,7 +101,7 @@ }, "ext": "v0" }, - "live_until": 4096 + "live_until": 215 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_allows_exact_threshold.1.json b/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_allows_exact_threshold.1.json new file mode 100644 index 0000000..c6f68ad --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_allows_exact_threshold.1.json @@ -0,0 +1,612 @@ +{ + "generators": { + "address": 3, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_provider", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "set_price_bounds", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + }, + { + "i128": "500" + }, + { + "i128": "2000" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "update_price", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "symbol": "NGN" + }, + { + "i128": "1000" + }, + { + "u32": 6 + }, + { + "u32": 100 + }, + { + "u64": "3600" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceBoundsData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "max_price" + }, + "val": { + "i128": "2000" + } + }, + { + "key": { + "symbol": "min_price" + }, + "val": { + "i128": "500" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 15 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "0" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 15 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "Initialized" + } + ] + }, + "val": { + "bool": true + } + }, + { + "key": { + "vec": [ + { + "symbol": "Provider" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "price_warmup" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "1033654523790656264" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "4837995959683129791" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": "2032731177588607455" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_allows_first_price_update.1.json b/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_allows_first_price_update.1.json new file mode 100644 index 0000000..c71852f --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_allows_first_price_update.1.json @@ -0,0 +1,611 @@ +{ + "generators": { + "address": 3, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_provider", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "set_price_bounds", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + }, + { + "i128": "500" + }, + { + "i128": "2000" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "update_price", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "symbol": "NGN" + }, + { + "i128": "100" + }, + { + "u32": 6 + }, + { + "u32": 100 + }, + { + "u64": "3600" + } + ] + } + }, + "sub_invocations": [] + } + ] + ] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceBoundsData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "max_price" + }, + "val": { + "i128": "2000" + } + }, + { + "key": { + "symbol": "min_price" + }, + "val": { + "i128": "500" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 15 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "0" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 15 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "Initialized" + } + ] + }, + "val": { + "bool": true + } + }, + { + "key": { + "vec": [ + { + "symbol": "Provider" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "price_warmup" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "100" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "1033654523790656264" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "4837995959683129791" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": "2032731177588607455" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_allows_within_threshold.1.json b/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_allows_within_threshold.1.json new file mode 100644 index 0000000..11b34f6 --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_allows_within_threshold.1.json @@ -0,0 +1,555 @@ +{ + "generators": { + "address": 3, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_provider", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "update_price", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "symbol": "NGN" + }, + { + "i128": "1050000" + }, + { + "u32": 6 + }, + { + "u32": 100 + }, + { + "u64": "3600" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "0" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 15 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 6 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "3600" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "Initialized" + } + ] + }, + "val": { + "bool": true + } + }, + { + "key": { + "vec": [ + { + "symbol": "Provider" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "price_warmup" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1050000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": "1033654523790656264" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_rejects_just_over_threshold.1.json b/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_rejects_just_over_threshold.1.json new file mode 100644 index 0000000..917513f --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_rejects_just_over_threshold.1.json @@ -0,0 +1,456 @@ +{ + "generators": { + "address": 3, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "update_price", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "symbol": "NGN" + }, + { + "i128": "1100001" + }, + { + "u32": 6 + }, + { + "u32": 100 + }, + { + "u64": "3600" + } + ] + } + }, + "sub_invocations": [] + } + ] + ] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 200, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 6 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1100001" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "3600" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 215 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "Provider" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "price_updated" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1100001" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6312199 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6312199 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "price_updated_event" + } + ], + "data": { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1100001" + } + } + ] + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_rejects_large_drop.1.json b/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_rejects_large_drop.1.json new file mode 100644 index 0000000..42983ed --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_rejects_large_drop.1.json @@ -0,0 +1,456 @@ +{ + "generators": { + "address": 3, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "update_price", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "symbol": "NGN" + }, + { + "i128": "800000" + }, + { + "u32": 6 + }, + { + "u32": 100 + }, + { + "u64": "3600" + } + ] + } + }, + "sub_invocations": [] + } + ] + ] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 200, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 6 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "800000" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "3600" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 215 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "Provider" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "price_updated" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "800000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6312199 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6312199 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "price_updated_event" + } + ], + "data": { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "800000" + } + } + ] + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_rejects_large_increase.1.json b/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_rejects_large_increase.1.json new file mode 100644 index 0000000..5bbc923 --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_flash_crash_protection_rejects_large_increase.1.json @@ -0,0 +1,456 @@ +{ + "generators": { + "address": 3, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "update_price", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "symbol": "NGN" + }, + { + "i128": "1200000" + }, + { + "u32": 6 + }, + { + "u32": 100 + }, + { + "u64": "3600" + } + ] + } + }, + "sub_invocations": [] + } + ] + ] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 200, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 6 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1200000" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "3600" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 215 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "Provider" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "price_updated" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1200000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6312199 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6312199 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "price_updated_event" + } + ], + "data": { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1200000" + } + } + ] + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_get_all_assets_returns_tracked_symbols.1.json b/contracts/price-oracle/test_snapshots/test/test_get_all_assets_returns_tracked_symbols.1.json index 9c7bc18..36a5c1c 100644 --- a/contracts/price-oracle/test_snapshots/test/test_get_all_assets_returns_tracked_symbols.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_get_all_assets_returns_tracked_symbols.1.json @@ -34,7 +34,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -157,7 +157,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 15 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_get_last_n_events_sliding_window.1.json b/contracts/price-oracle/test_snapshots/test/test_get_last_n_events_sliding_window.1.json index aa20861..0ea916d 100644 --- a/contracts/price-oracle/test_snapshots/test/test_get_last_n_events_sliding_window.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_get_last_n_events_sliding_window.1.json @@ -38,7 +38,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -218,7 +218,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 15 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_get_price_after_update.1.json b/contracts/price-oracle/test_snapshots/test/test_get_price_after_update.1.json index 68177be..10bc5d3 100644 --- a/contracts/price-oracle/test_snapshots/test/test_get_price_after_update.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_get_price_after_update.1.json @@ -13,7 +13,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 2, + "sequence_number": 200, "timestamp": 1234567900, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -35,7 +35,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -101,7 +101,7 @@ }, "ext": "v0" }, - "live_until": 4096 + "live_until": 215 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_get_price_existing_asset.1.json b/contracts/price-oracle/test_snapshots/test/test_get_price_existing_asset.1.json index 75a65b1..f604502 100644 --- a/contracts/price-oracle/test_snapshots/test/test_get_price_existing_asset.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_get_price_existing_asset.1.json @@ -11,7 +11,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 1, + "sequence_number": 200, "timestamp": 1234567890, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -33,7 +33,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -99,7 +99,7 @@ }, "ext": "v0" }, - "live_until": 4096 + "live_until": 215 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_get_price_with_status_marks_fresh_entry.1.json b/contracts/price-oracle/test_snapshots/test/test_get_price_with_status_marks_fresh_entry.1.json new file mode 100644 index 0000000..e7d44be --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_get_price_with_status_marks_fresh_entry.1.json @@ -0,0 +1,210 @@ +{ + "generators": { + "address": 1, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 200, + "timestamp": 1000050, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 2 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1500" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "1000000" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "100" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 215 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1500" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "1000000" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_get_price_with_status_marks_stale_entry.1.json b/contracts/price-oracle/test_snapshots/test/test_get_price_with_status_marks_stale_entry.1.json new file mode 100644 index 0000000..a17eb21 --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_get_price_with_status_marks_stale_entry.1.json @@ -0,0 +1,210 @@ +{ + "generators": { + "address": 1, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 200, + "timestamp": 1000200, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 2 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1500" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "1000000" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "100" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 215 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1500" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "1000000" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_get_prices_preserves_order.1.json b/contracts/price-oracle/test_snapshots/test/test_get_prices_preserves_order.1.json index 91442a4..c77e19a 100644 --- a/contracts/price-oracle/test_snapshots/test/test_get_prices_preserves_order.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_get_prices_preserves_order.1.json @@ -12,7 +12,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 1, + "sequence_number": 200, "timestamp": 1000000, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -34,7 +34,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -157,7 +157,7 @@ }, "ext": "v0" }, - "live_until": 4096 + "live_until": 215 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_get_prices_returns_all_requested_assets.1.json b/contracts/price-oracle/test_snapshots/test/test_get_prices_returns_all_requested_assets.1.json index ed0f4ee..573c882 100644 --- a/contracts/price-oracle/test_snapshots/test/test_get_prices_returns_all_requested_assets.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_get_prices_returns_all_requested_assets.1.json @@ -13,7 +13,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 1, + "sequence_number": 200, "timestamp": 1000000, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -35,7 +35,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -215,7 +215,7 @@ }, "ext": "v0" }, - "live_until": 4096 + "live_until": 215 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_get_prices_returns_none_for_missing_asset.1.json b/contracts/price-oracle/test_snapshots/test/test_get_prices_returns_none_for_missing_asset.1.json index 64e0893..999f7db 100644 --- a/contracts/price-oracle/test_snapshots/test/test_get_prices_returns_none_for_missing_asset.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_get_prices_returns_none_for_missing_asset.1.json @@ -11,7 +11,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 1, + "sequence_number": 200, "timestamp": 1000000, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -33,7 +33,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -99,7 +99,7 @@ }, "ext": "v0" }, - "live_until": 4096 + "live_until": 215 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_get_prices_returns_none_for_stale_asset.1.json b/contracts/price-oracle/test_snapshots/test/test_get_prices_returns_none_for_stale_asset.1.json index 07a4399..a17eb21 100644 --- a/contracts/price-oracle/test_snapshots/test/test_get_prices_returns_none_for_stale_asset.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_get_prices_returns_none_for_stale_asset.1.json @@ -11,7 +11,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 2, + "sequence_number": 200, "timestamp": 1000200, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -33,7 +33,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -99,7 +99,7 @@ }, "ext": "v0" }, - "live_until": 4096 + "live_until": 215 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_get_prices_with_status_marks_stale_entry.1.json b/contracts/price-oracle/test_snapshots/test/test_get_prices_with_status_marks_stale_entry.1.json new file mode 100644 index 0000000..a17eb21 --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_get_prices_with_status_marks_stale_entry.1.json @@ -0,0 +1,210 @@ +{ + "generators": { + "address": 1, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 200, + "timestamp": 1000200, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 2 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1500" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "1000000" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "100" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 215 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1500" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "1000000" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_get_prices_with_status_returns_none_for_missing_asset.1.json b/contracts/price-oracle/test_snapshots/test/test_get_prices_with_status_returns_none_for_missing_asset.1.json new file mode 100644 index 0000000..999f7db --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_get_prices_with_status_returns_none_for_missing_asset.1.json @@ -0,0 +1,210 @@ +{ + "generators": { + "address": 1, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 200, + "timestamp": 1000000, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 2 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1500" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "1000000" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "3600" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 215 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1500" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "1000000" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_mixed_add_and_update_emits_correct_events.1.json b/contracts/price-oracle/test_snapshots/test/test_mixed_add_and_update_emits_correct_events.1.json index 6f8d24a..f3f5653 100644 --- a/contracts/price-oracle/test_snapshots/test/test_mixed_add_and_update_emits_correct_events.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_mixed_add_and_update_emits_correct_events.1.json @@ -35,7 +35,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -215,7 +215,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 15 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_multiple_assets_added_sequentially_each_emits_event.1.json b/contracts/price-oracle/test_snapshots/test/test_multiple_assets_added_sequentially_each_emits_event.1.json index f924b79..92a0fb8 100644 --- a/contracts/price-oracle/test_snapshots/test/test_multiple_assets_added_sequentially_each_emits_event.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_multiple_assets_added_sequentially_each_emits_event.1.json @@ -34,7 +34,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -214,7 +214,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 15 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_provider_warmup_guard.1.json b/contracts/price-oracle/test_snapshots/test/test_provider_warmup_guard.1.json new file mode 100644 index 0000000..7623ca5 --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_provider_warmup_guard.1.json @@ -0,0 +1,354 @@ +{ + "generators": { + "address": 3, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_provider", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "update_price", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "symbol": "NGN" + }, + { + "i128": "1500" + }, + { + "u32": 2 + }, + { + "u32": 100 + }, + { + "u64": "3600" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 200, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "Initialized" + } + ] + }, + "val": { + "bool": true + } + }, + { + "key": { + "vec": [ + { + "symbol": "Provider" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 200 + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "price_warmup" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1500" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6312199 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": "1033654523790656264" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6312199 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_remove_asset_deletes_price_entry.1.json b/contracts/price-oracle/test_snapshots/test/test_remove_asset_deletes_price_entry.1.json index bcecffe..2d8a246 100644 --- a/contracts/price-oracle/test_snapshots/test/test_remove_asset_deletes_price_entry.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_remove_asset_deletes_price_entry.1.json @@ -57,7 +57,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [] } @@ -65,7 +65,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 15 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_remove_asset_deletes_price_entry_new.1.json b/contracts/price-oracle/test_snapshots/test/test_remove_asset_deletes_price_entry_new.1.json new file mode 100644 index 0000000..c2db3eb --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_remove_asset_deletes_price_entry_new.1.json @@ -0,0 +1,239 @@ +{ + "generators": { + "address": 2, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [], + [] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 2 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "3600" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "Initialized" + } + ] + }, + "val": { + "bool": true + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_remove_asset_non_admin_is_rejected.1.json b/contracts/price-oracle/test_snapshots/test/test_remove_asset_non_admin_is_rejected.1.json index 6f56328..205589b 100644 --- a/contracts/price-oracle/test_snapshots/test/test_remove_asset_non_admin_is_rejected.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_remove_asset_non_admin_is_rejected.1.json @@ -7,7 +7,28 @@ "auth": [ [], [], - [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], [] ], "ledger": { @@ -34,7 +55,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -48,7 +69,7 @@ "symbol": "confidence_score" }, "val": { - "u32": 100 + "u32": 0 } }, { @@ -56,7 +77,7 @@ "symbol": "decimals" }, "val": { - "u32": 2 + "u32": 0 } }, { @@ -64,7 +85,7 @@ "symbol": "price" }, "val": { - "i128": "1000" + "i128": "0" } }, { @@ -88,7 +109,7 @@ "symbol": "ttl" }, "val": { - "u64": "3600" + "u64": "0" } } ] @@ -100,7 +121,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 15 }, { "entry": { @@ -182,7 +203,7 @@ "symbol": "price" }, "val": { - "i128": "1000" + "i128": "0" } }, { @@ -207,6 +228,26 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/price-oracle/test_snapshots/test/test_remove_asset_non_admin_rejected.1.json b/contracts/price-oracle/test_snapshots/test/test_remove_asset_non_admin_rejected.1.json new file mode 100644 index 0000000..010a8a0 --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_remove_asset_non_admin_rejected.1.json @@ -0,0 +1,227 @@ +{ + "generators": { + "address": 3, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [], + [] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 2 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "3600" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 15 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_remove_asset_not_in_get_all_assets.1.json b/contracts/price-oracle/test_snapshots/test/test_remove_asset_not_in_get_all_assets.1.json index 64284e3..038b0d8 100644 --- a/contracts/price-oracle/test_snapshots/test/test_remove_asset_not_in_get_all_assets.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_remove_asset_not_in_get_all_assets.1.json @@ -57,7 +57,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -123,7 +123,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 15 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_set_price_bounds_and_get.1.json b/contracts/price-oracle/test_snapshots/test/test_set_price_bounds_and_get.1.json index 6d9bafd..1cef426 100644 --- a/contracts/price-oracle/test_snapshots/test/test_set_price_bounds_and_get.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_set_price_bounds_and_get.1.json @@ -47,56 +47,6 @@ "min_temp_entry_ttl": 16, "max_entry_ttl": 6312000, "ledger_entries": [ - { - "entry": { - "last_modified_ledger_seq": 0, - "data": { - "contract_data": { - "ext": "v0", - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": { - "vec": [ - { - "symbol": "PriceBoundsData" - } - ] - }, - "durability": "persistent", - "val": { - "map": [ - { - "key": { - "symbol": "NGN" - }, - "val": { - "map": [ - { - "key": { - "symbol": "max_price" - }, - "val": { - "i128": "2000" - } - }, - { - "key": { - "symbol": "min_price" - }, - "val": { - "i128": "500" - } - } - ] - } - } - ] - } - } - }, - "ext": "v0" - }, - "live_until": 4095 - }, { "entry": { "last_modified_ledger_seq": 0, @@ -127,6 +77,44 @@ } ] } + }, + { + "key": { + "vec": [ + { + "symbol": "PriceBoundsData" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "max_price" + }, + "val": { + "i128": "2000" + } + }, + { + "key": { + "symbol": "min_price" + }, + "val": { + "i128": "500" + } + } + ] + } + } + ] + } } ] } diff --git a/contracts/price-oracle/test_snapshots/test/test_set_price_does_not_emit_asset_added_event_on_update.1.json b/contracts/price-oracle/test_snapshots/test/test_set_price_does_not_emit_asset_added_event_on_update.1.json index 662fb7b..ed4ac4a 100644 --- a/contracts/price-oracle/test_snapshots/test/test_set_price_does_not_emit_asset_added_event_on_update.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_set_price_does_not_emit_asset_added_event_on_update.1.json @@ -33,7 +33,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -99,7 +99,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 15 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_set_price_emits_asset_added_event_on_first_add.1.json b/contracts/price-oracle/test_snapshots/test/test_set_price_emits_asset_added_event_on_first_add.1.json index c5c1416..573f7d2 100644 --- a/contracts/price-oracle/test_snapshots/test/test_set_price_emits_asset_added_event_on_first_add.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_set_price_emits_asset_added_event_on_first_add.1.json @@ -32,7 +32,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -98,7 +98,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 15 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_set_price_uses_current_ledger_timestamp.1.json b/contracts/price-oracle/test_snapshots/test/test_set_price_uses_current_ledger_timestamp.1.json index 5c339ca..7750638 100644 --- a/contracts/price-oracle/test_snapshots/test/test_set_price_uses_current_ledger_timestamp.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_set_price_uses_current_ledger_timestamp.1.json @@ -33,7 +33,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -99,7 +99,7 @@ }, "ext": "v0" }, - "live_until": 4172 + "live_until": 92 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_above_max_bound_rejected.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_above_max_bound_rejected.1.json index a361c20..48afb96 100644 --- a/contracts/price-oracle/test_snapshots/test/test_update_price_above_max_bound_rejected.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_above_max_bound_rejected.1.json @@ -61,7 +61,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 0, + "sequence_number": 200, "timestamp": 0, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -260,7 +260,65 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] } }, { diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_admin_authority.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_admin_authority.1.json index 3c0a672..0ffec7a 100644 --- a/contracts/price-oracle/test_snapshots/test/test_update_price_admin_authority.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_admin_authority.1.json @@ -33,7 +33,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 0, + "sequence_number": 200, "timestamp": 0, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_at_exact_bounds_succeeds.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_at_exact_bounds_succeeds.1.json index 51866d3..b52f4a0 100644 --- a/contracts/price-oracle/test_snapshots/test/test_update_price_at_exact_bounds_succeeds.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_at_exact_bounds_succeeds.1.json @@ -43,12 +43,6 @@ }, { "symbol": "NGN" - }, - { - "i128": "500" - }, - { - "i128": "2000" } ] } @@ -73,7 +67,7 @@ "symbol": "NGN" }, { - "i128": "500" + "i128": "1500000" }, { "u32": 6 @@ -91,41 +85,7 @@ } ] ], - [], - [ - [ - "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", - { - "function": { - "contract_fn": { - "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "function_name": "update_price", - "args": [ - { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" - }, - { - "symbol": "NGN" - }, - { - "i128": "2000" - }, - { - "u32": 6 - }, - { - "u32": 100 - }, - { - "u64": "3600" - } - ] - } - }, - "sub_invocations": [] - } - ] - ] + [] ], "ledger": { "protocol_version": 25, @@ -296,7 +256,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -326,7 +286,7 @@ "symbol": "price" }, "val": { - "i128": "2000" + "i128": "1500000" } }, { @@ -362,7 +322,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 215 }, { "entry": { @@ -423,7 +383,16 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] } }, { @@ -459,43 +428,7 @@ "symbol": "price" }, "val": { - "i128": "2000" - } - }, - { - "key": { - "symbol": "timestamp" - }, - "val": { - "u64": "0" - } - } - ] - }, - { - "map": [ - { - "key": { - "symbol": "asset" - }, - "val": { - "symbol": "NGN" - } - }, - { - "key": { - "symbol": "event_type" - }, - "val": { - "symbol": "price_updated" - } - }, - { - "key": { - "symbol": "price" - }, - "val": { - "i128": "1990" + "i128": "1500000" } }, { @@ -523,7 +456,7 @@ "symbol": "event_type" }, "val": { - "symbol": "price_updated" + "symbol": "asset_added" } }, { @@ -531,7 +464,7 @@ "symbol": "price" }, "val": { - "i128": "500" + "i128": "0" } }, { @@ -688,43 +621,5 @@ } ] }, - "events": [ - { - "event": { - "ext": "v0", - "contract_id": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "type_": "contract", - "body": { - "v0": { - "topics": [ - { - "symbol": "price_updated_event" - } - ], - "data": { - "map": [ - { - "key": { - "symbol": "asset" - }, - "val": { - "symbol": "NGN" - } - }, - { - "key": { - "symbol": "price" - }, - "val": { - "i128": "2000" - } - } - ] - } - } - } - }, - "failed_call": false - } - ] + "events": [] } \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_below_min_bound_rejected.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_below_min_bound_rejected.1.json index a361c20..e1b2ed6 100644 --- a/contracts/price-oracle/test_snapshots/test/test_update_price_below_min_bound_rejected.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_below_min_bound_rejected.1.json @@ -5,11 +5,12 @@ "mux_id": 0 }, "auth": [ + [], [], [], [ [ - "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", { "function": { "contract_fn": { @@ -39,16 +40,22 @@ "function_name": "set_price_bounds", "args": [ { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" }, { "symbol": "NGN" }, { - "i128": "500" + "i128": "1100000" + }, + { + "u32": 6 }, { - "i128": "2000" + "u32": 100 + }, + { + "u64": "3600" } ] } @@ -61,7 +68,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 0, + "sequence_number": 200, "timestamp": 0, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -79,11 +86,11 @@ "key": { "vec": [ { - "symbol": "PriceBoundsData" + "symbol": "PriceData" } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -94,18 +101,50 @@ "map": [ { "key": { - "symbol": "max_price" + "symbol": "confidence_score" }, "val": { - "i128": "2000" + "u32": 100 } }, { "key": { - "symbol": "min_price" + "symbol": "decimals" }, "val": { - "i128": "500" + "u32": 6 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1100000" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "3600" } } ] @@ -117,7 +156,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 215 }, { "entry": { @@ -260,7 +299,101 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "price_updated" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1100000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] } }, { @@ -327,7 +460,7 @@ "data": { "contract_data": { "ext": "v0", - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", "key": { "ledger_key_nonce": { "nonce": "801925984706572462" @@ -339,7 +472,7 @@ }, "ext": "v0" }, - "live_until": 6311999 + "live_until": 6312199 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_below_min_bound_rejected_alt.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_below_min_bound_rejected_alt.1.json new file mode 100644 index 0000000..f855bed --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_below_min_bound_rejected_alt.1.json @@ -0,0 +1,296 @@ +{ + "generators": { + "address": 3, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "set_price_bounds", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + }, + { + "i128": "500" + }, + { + "i128": "2000" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 200, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "PriceBoundsData" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "max_price" + }, + "val": { + "i128": "2000" + } + }, + { + "key": { + "symbol": "min_price" + }, + "val": { + "i128": "500" + } + } + ] + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "Provider" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_delta_limit_rejection_emits_anomaly_event.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_delta_limit_rejection_emits_anomaly_event.1.json index 623779d..d3d09bb 100644 --- a/contracts/price-oracle/test_snapshots/test/test_update_price_delta_limit_rejection_emits_anomaly_event.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_delta_limit_rejection_emits_anomaly_event.1.json @@ -96,12 +96,11 @@ "sub_invocations": [] } ] - ], - [] + ] ], "ledger": { "protocol_version": 25, - "sequence_number": 2, + "sequence_number": 200, "timestamp": 1700100010, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -218,7 +217,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -345,7 +344,16 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] } }, { @@ -516,7 +524,7 @@ }, "ext": "v0" }, - "live_until": 6312001 + "live_until": 6312199 }, { "entry": { @@ -554,5 +562,43 @@ } ] }, - "events": [] + "events": [ + { + "event": { + "ext": "v0", + "contract_id": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "price_updated_event" + } + ], + "data": { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1100" + } + } + ] + } + } + } + }, + "failed_call": false + } + ] } \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_emits_event.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_emits_event.1.json index 0969b8a..1880964 100644 --- a/contracts/price-oracle/test_snapshots/test/test_update_price_emits_event.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_emits_event.1.json @@ -66,7 +66,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 1, + "sequence_number": 200, "timestamp": 1700000000, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -183,7 +183,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -310,7 +310,16 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] } }, { diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_multiple_updates.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_multiple_updates.1.json index 5d05506..a901f73 100644 --- a/contracts/price-oracle/test_snapshots/test/test_update_price_multiple_updates.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_multiple_updates.1.json @@ -218,7 +218,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -284,7 +284,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 215 }, { "entry": { @@ -345,7 +345,16 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] } }, { diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_no_bounds_set_allows_any_valid_price.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_no_bounds_set_allows_any_valid_price.1.json index 6f58f9d..504d420 100644 --- a/contracts/price-oracle/test_snapshots/test/test_update_price_no_bounds_set_allows_any_valid_price.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_no_bounds_set_allows_any_valid_price.1.json @@ -66,7 +66,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 0, + "sequence_number": 200, "timestamp": 0, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -183,7 +183,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -249,7 +249,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 215 }, { "entry": { @@ -310,7 +310,16 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] } }, { diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_no_bounds_set_allows_any_valid_price_new.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_no_bounds_set_allows_any_valid_price_new.1.json new file mode 100644 index 0000000..31b5eaf --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_no_bounds_set_allows_any_valid_price_new.1.json @@ -0,0 +1,513 @@ +{ + "generators": { + "address": 3, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_provider", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "update_price", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "symbol": "NGN" + }, + { + "i128": "999999999" + }, + { + "u32": 6 + }, + { + "u32": 100 + }, + { + "u64": "3600" + } + ] + } + }, + "sub_invocations": [] + } + ] + ] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 0, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "0" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 15 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "Initialized" + } + ] + }, + "val": { + "bool": true + } + }, + { + "key": { + "vec": [ + { + "symbol": "Provider" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "price_warmup" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "999999999" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "1033654523790656264" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": "4837995959683129791" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_provider_can_store_new_price.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_provider_can_store_new_price.1.json index 4212b8e..426c9cd 100644 --- a/contracts/price-oracle/test_snapshots/test/test_update_price_provider_can_store_new_price.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_provider_can_store_new_price.1.json @@ -67,7 +67,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 2, + "sequence_number": 200, "timestamp": 1700000500, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -184,7 +184,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -311,7 +311,16 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] } }, { diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_rejects_unapproved_symbol.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_rejects_unapproved_symbol.1.json index d15322b..154623d 100644 --- a/contracts/price-oracle/test_snapshots/test/test_update_price_rejects_unapproved_symbol.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_rejects_unapproved_symbol.1.json @@ -11,7 +11,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 0, + "sequence_number": 200, "timestamp": 0, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -62,7 +62,16 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] } } ] diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_respects_bounds.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_respects_bounds.1.json new file mode 100644 index 0000000..c70c05a --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_respects_bounds.1.json @@ -0,0 +1,632 @@ +{ + "generators": { + "address": 3, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "set_price_bounds", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + }, + { + "i128": "500" + }, + { + "i128": "2000" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "update_price", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "symbol": "NGN" + }, + { + "i128": "500" + }, + { + "u32": 6 + }, + { + "u32": 100 + }, + { + "u64": "3600" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "update_price", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "symbol": "NGN" + }, + { + "i128": "2000" + }, + { + "u32": 6 + }, + { + "u32": 100 + }, + { + "u64": "3600" + } + ] + } + }, + "sub_invocations": [] + } + ] + ] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 200, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 6 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "2000" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "3600" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 215 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "PriceBoundsData" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "max_price" + }, + "val": { + "i128": "2000" + } + }, + { + "key": { + "symbol": "min_price" + }, + "val": { + "i128": "500" + } + } + ] + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "Provider" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "price_updated" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "2000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "price_updated" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1990" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "price_updated" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "500" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": "1033654523790656264" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6312199 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": "4837995959683129791" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6312199 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [ + { + "event": { + "ext": "v0", + "contract_id": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "type_": "contract", + "body": { + "v0": { + "topics": [ + { + "symbol": "price_updated_event" + } + ], + "data": { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "2000" + } + } + ] + } + } + } + }, + "failed_call": false + } + ] +} \ No newline at end of file diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_within_bounds_succeeds.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_within_bounds_succeeds.1.json index 000158c..b2742d6 100644 --- a/contracts/price-oracle/test_snapshots/test/test_update_price_within_bounds_succeeds.1.json +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_within_bounds_succeeds.1.json @@ -73,7 +73,7 @@ "symbol": "NGN" }, { - "i128": "1000" + "i128": "1050000" }, { "u32": 6 @@ -95,7 +95,7 @@ ], "ledger": { "protocol_version": 25, - "sequence_number": 0, + "sequence_number": 200, "timestamp": 0, "network_id": "0000000000000000000000000000000000000000000000000000000000000000", "base_reserve": 0, @@ -262,7 +262,7 @@ } ] }, - "durability": "persistent", + "durability": "temporary", "val": { "map": [ { @@ -292,7 +292,7 @@ "symbol": "price" }, "val": { - "i128": "1000" + "i128": "1050000" } }, { @@ -328,7 +328,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 215 }, { "entry": { @@ -389,7 +389,16 @@ ] }, "val": { - "bool": true + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] } }, { @@ -425,7 +434,43 @@ "symbol": "price" }, "val": { - "i128": "1000" + "i128": "1050000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000000" } }, { @@ -515,7 +560,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": "5541220902715666415" + "nonce": "801925984706572462" } }, "durability": "temporary", @@ -524,7 +569,7 @@ }, "ext": "v0" }, - "live_until": 6311999 + "live_until": 6312199 }, { "entry": { diff --git a/contracts/price-oracle/test_snapshots/test/test_update_price_within_bounds_succeeds_alt.1.json b/contracts/price-oracle/test_snapshots/test/test_update_price_within_bounds_succeeds_alt.1.json new file mode 100644 index 0000000..7420682 --- /dev/null +++ b/contracts/price-oracle/test_snapshots/test/test_update_price_within_bounds_succeeds_alt.1.json @@ -0,0 +1,468 @@ +{ + "generators": { + "address": 3, + "nonce": 0, + "mux_id": 0 + }, + "auth": [ + [], + [], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "add_asset", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "set_price_bounds", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "symbol": "NGN" + }, + { + "i128": "500" + }, + { + "i128": "2000" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "update_price", + "args": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + }, + { + "symbol": "NGN" + }, + { + "i128": "1000" + }, + { + "u32": 6 + }, + { + "u32": 100 + }, + { + "u64": "3600" + } + ] + } + }, + "sub_invocations": [] + } + ] + ], + [] + ], + "ledger": { + "protocol_version": 25, + "sequence_number": 200, + "timestamp": 0, + "network_id": "0000000000000000000000000000000000000000000000000000000000000000", + "base_reserve": 0, + "min_persistent_entry_ttl": 4096, + "min_temp_entry_ttl": 16, + "max_entry_ttl": 6312000, + "ledger_entries": [ + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "PriceData" + } + ] + }, + "durability": "temporary", + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "confidence_score" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "decimals" + }, + "val": { + "u32": 6 + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000" + } + }, + { + "key": { + "symbol": "provider" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + }, + { + "key": { + "symbol": "ttl" + }, + "val": { + "u64": "3600" + } + } + ] + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 215 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": [ + { + "key": { + "vec": [ + { + "symbol": "Admin" + } + ] + }, + "val": { + "vec": [ + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "BaseCurrencyPairs" + } + ] + }, + "val": { + "vec": [ + { + "symbol": "NGN" + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "PriceBoundsData" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "NGN" + }, + "val": { + "map": [ + { + "key": { + "symbol": "max_price" + }, + "val": { + "i128": "2000" + } + }, + { + "key": { + "symbol": "min_price" + }, + "val": { + "i128": "500" + } + } + ] + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "Provider" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "val": { + "map": [ + { + "key": { + "symbol": "joined_ledger" + }, + "val": { + "u32": 0 + } + } + ] + } + }, + { + "key": { + "vec": [ + { + "symbol": "RecentEvents" + } + ] + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "price_updated" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "1000" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "asset" + }, + "val": { + "symbol": "NGN" + } + }, + { + "key": { + "symbol": "event_type" + }, + "val": { + "symbol": "asset_added" + } + }, + { + "key": { + "symbol": "price" + }, + "val": { + "i128": "0" + } + }, + { + "key": { + "symbol": "timestamp" + }, + "val": { + "u64": "0" + } + } + ] + } + ] + } + } + ] + } + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "801925984706572462" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": "5541220902715666415" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6311999 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M", + "key": { + "ledger_key_nonce": { + "nonce": "1033654523790656264" + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + "live_until": 6312199 + }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_code": { + "ext": "v0", + "hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "code": "" + } + }, + "ext": "v0" + }, + "live_until": 4095 + } + ] + }, + "events": [] +} \ No newline at end of file