From ce7496e3e6157355363b88721b621bdaffcf76ca Mon Sep 17 00:00:00 2001 From: Jemimah Suleiman Date: Sat, 22 Aug 2026 15:07:40 +0000 Subject: [PATCH] fix(marketx): restore orphaned safety tests and harden CI --- .github/workflows/ci.yml | 10 +- contracts/marketx/src/errors.rs | 10 + contracts/marketx/src/escrow.rs | 7 + contracts/marketx/src/fees.rs | 32 ++ contracts/marketx/src/lib.rs | 4 + contracts/marketx/src/test_integer_safety.rs | 113 +++-- contracts/marketx/src/test_volume.rs | 137 +++--- contracts/marketx/src/types.rs | 61 +++ contracts/marketx/src/utilities.rs | 53 ++- .../test/admin_can_pause_and_unpause.1.json | 129 ++++++ .../test/buyer_can_fund_escrow.1.json | 129 ++++++ .../test/buyer_can_release_escrow.1.json | 132 ++++++ .../escrow_actions_blocked_when_paused.1.json | 129 ++++++ .../test/escrow_counter_overflow_fails.1.json | 129 ++++++ .../escrow_ids_increment_sequentially.1.json | 129 ++++++ .../fund_fails_for_nonexistent_escrow.1.json | 129 ++++++ ...s_if_buyer_has_insufficient_balance.1.json | 129 ++++++ .../test/fund_fails_if_not_pending.1.json | 129 ++++++ .../test/no_escrow_id_collision.1.json | 129 ++++++ ...elease_fails_for_nonexistent_escrow.1.json | 129 ++++++ .../test/release_fails_if_not_pending.1.json | 129 ++++++ .../test/test_analytics_aggregation.1.json | 129 ++++++ ...arbiter_can_refund_buyer_on_dispute.1.json | 134 +++++- .../test_arbiter_can_resolve_dispute.1.json | 132 ++++++ ..._bump_escrow_extends_ttl_to_maximum.1.json | 129 ++++++ ..._bump_escrow_rejects_missing_escrow.1.json | 129 ++++++ ...create_escrow_emits_indexable_event.1.json | 129 ++++++ .../test_create_escrow_stores_arbiter.1.json | 129 ++++++ ..._escrow_without_arbiter_stores_none.1.json | 129 ++++++ .../test/test_distinct_escrows_allowed.1.json | 129 ++++++ .../test_duplicate_escrow_rejected.1.json | 129 ++++++ ...duplicate_escrow_with_none_metadata.1.json | 129 ++++++ .../test_escrow_hash_stored_correctly.1.json | 129 ++++++ ...row_metadata_for_nonexistent_escrow.1.json | 129 ++++++ .../test_metadata_at_max_size_accepted.1.json | 129 ++++++ ...t_metadata_none_stored_successfully.1.json | 129 ++++++ .../test_metadata_stored_successfully.1.json | 129 ++++++ .../test_oversized_metadata_rejected.1.json | 129 ++++++ ...mits_funds_and_status_change_events.1.json | 132 ++++++ ...pute_emits_status_change_with_actor.1.json | 129 ++++++ ...ispute_fails_for_nonexistent_escrow.1.json | 129 ++++++ ...solve_dispute_fails_if_not_disputed.1.json | 129 ++++++ package-lock.json | 2 +- scripts/check_rust_modules.py | 58 +++ tools/tarpaulin.rs | 407 ------------------ 45 files changed, 4626 insertions(+), 539 deletions(-) create mode 100644 scripts/check_rust_modules.py delete mode 100644 tools/tarpaulin.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51b19db..c183c1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -94,7 +94,15 @@ jobs: - name: Install tarpaulin run: cargo install cargo-tarpaulin - name: Run coverage - run: cargo tarpaulin --all-features --workspace --timeout 120 --out Stdout + run: cargo tarpaulin --all-features --workspace --timeout 120 --out Stdout --fail-under 70 + + module-reachability: + name: Rust Module Reachability + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Check Rust module reachability + run: python3 scripts/check_rust_modules.py sdk-parity: name: SDK Error Code Parity diff --git a/contracts/marketx/src/errors.rs b/contracts/marketx/src/errors.rs index a1398fc..ac82cff 100644 --- a/contracts/marketx/src/errors.rs +++ b/contracts/marketx/src/errors.rs @@ -6,7 +6,9 @@ use soroban_sdk::contracterror; pub enum ContractError { NotAdmin = 1, Unauthorized = 2, + /// Caller is not the proposed administrator. NotProposedAdmin = 3, + /// Caller is not the configured oracle. NotOracle = 4, EscrowNotFound = 10, InvalidEscrowState = 11, @@ -22,13 +24,21 @@ pub enum ContractError { ItemAmountInvalid = 83, EscrowNotExpired = 90, EscrowAlreadyFunded = 91, + /// The requested milestone does not exist. MilestoneNotFound = 100, + /// The requested milestone was already completed. MilestoneAlreadyCompleted = 101, + /// The escrow timelock has not been reached. TimeLockNotReached = 110, + /// Timelock release is not enabled for this escrow. TimeLockNotEnabled = 111, + /// The group buy has not received enough funding. GroupBuyNotFunded = 120, + /// The group buy has already been funded. GroupBuyAlreadyFunded = 121, + /// The group buy deadline has passed. GroupBuyDeadlinePassed = 122, + /// The group buy amount is invalid. InvalidGroupBuyAmount = 123, // ── Dispute Resolution V2 (#201-204) ───────────────────────────────────── diff --git a/contracts/marketx/src/escrow.rs b/contracts/marketx/src/escrow.rs index 3b6c87a..2bee339 100644 --- a/contracts/marketx/src/escrow.rs +++ b/contracts/marketx/src/escrow.rs @@ -57,6 +57,13 @@ impl Contract { env.storage() .persistent() .set(&DataKey::TotalFeesCollected, &0i128); + env.storage().persistent().set( + &DataKey::VolumeTiers, + &VolumeTierConfig { + reset_ledger: env.ledger().sequence(), + ..VolumeTierConfig::default() + }, + ); Ok(()) } diff --git a/contracts/marketx/src/fees.rs b/contracts/marketx/src/fees.rs index ae731f4..0afcf35 100644 --- a/contracts/marketx/src/fees.rs +++ b/contracts/marketx/src/fees.rs @@ -154,6 +154,38 @@ impl Contract { .unwrap_or(0) } + pub fn get_total_fees_collected(env: Env) -> i128 { + env.storage() + .persistent() + .get(&DataKey::TotalFeesCollected) + .unwrap_or(0) + } + + pub fn get_buyer_volume(env: Env, buyer: Address) -> i128 { + let config: VolumeTierConfig = env + .storage() + .persistent() + .get(&DataKey::VolumeTiers) + .unwrap_or_default(); + Self::buyer_volume_internal(&env, &buyer, &config) + } + + pub fn get_buyer_tier(env: Env, buyer: Address) -> u32 { + let config: VolumeTierConfig = env + .storage() + .persistent() + .get(&DataKey::VolumeTiers) + .unwrap_or_default(); + config.tier(Self::buyer_volume_internal(&env, &buyer, &config)) + } + + pub fn get_volume_tiers(env: Env) -> VolumeTierConfig { + env.storage() + .persistent() + .get(&DataKey::VolumeTiers) + .unwrap_or_default() + } + /// Add an address to the fee exemption whitelist. Admin only. pub fn add_fee_whitelist(env: Env, address: Address) -> Result<(), ContractError> { let admin = Self::assert_admin(&env)?; diff --git a/contracts/marketx/src/lib.rs b/contracts/marketx/src/lib.rs index a440082..0b1b9bd 100644 --- a/contracts/marketx/src/lib.rs +++ b/contracts/marketx/src/lib.rs @@ -30,6 +30,10 @@ pub use types::*; #[cfg(test)] mod test; +#[cfg(test)] +mod test_integer_safety; +#[cfg(test)] +mod test_volume; /// The MarketX escrow contract. /// diff --git a/contracts/marketx/src/test_integer_safety.rs b/contracts/marketx/src/test_integer_safety.rs index 379aa5d..ef01c5e 100644 --- a/contracts/marketx/src/test_integer_safety.rs +++ b/contracts/marketx/src/test_integer_safety.rs @@ -1,7 +1,7 @@ //! Integer Safety Tests for Fee Basis Points Calculations -//! +//! //! Tests to verify overflow-safe fee calculations -//! +//! //! Test Cases: //! - Zero amount returns zero fee //! - Amount less than 10,000 returns 0 (rounds down) @@ -12,81 +12,74 @@ #![cfg(test)] mod integer_safety_tests { - use soroban_sdk::{testutils::Address as _, token::Client as TokenClient, Address, Env, IntoVal}; - use crate::{Client, Contract}; + use crate::{Contract, ContractClient}; + use soroban_sdk::{ + testutils::Address as _, token::Client as TokenClient, token::StellarAssetClient, Address, + Env, + }; const FEE_BPS: u32 = 500; // 5% - fn setup() -> (Env, Address, Address, TokenClient, Address, Client) { + fn setup<'a>() -> ( + Env, + Address, + Address, + TokenClient<'a>, + Address, + ContractClient<'a>, + ) { let env = Env::default(); env.mock_all_auths(); - - let admin = Address::random(&env); - let buyer = Address::random(&env); - + + let admin = Address::generate(&env); + let buyer = Address::generate(&env); + let sac = env.register_stellar_asset_contract_v2(admin.clone()); - let token = TokenClient::new(&env, &sac); + let token = TokenClient::new(&env, &sac.address()); + let token_admin = StellarAssetClient::new(&env, &sac.address()); let token_id = sac.address(); - let contract_id = env.register_contract(None, Contract); - let client = Client::new(&env, &contract_id); + let contract_id = env.register(Contract, ()); + let client = ContractClient::new(&env, &contract_id); client.initialize(&admin, &admin, &FEE_BPS, &0i128, &0i128); - token.approve(&admin, &contract_id, &i128::MAX); + token_admin.mint(&buyer, &2_000_000_000); + token.approve(&buyer, &contract_id, &i128::MAX, &1000); (env, buyer, admin, token, token_id, client) } #[test] fn test_zero_amount_returns_zero_fee() { - let (env, buyer, seller, _token, token_id, client) = setup(); - - // Create and release escrow with 0 amount - should not panic - let escrow_id = client.create_escrow( - &buyer, - &seller, - &token_id, - &0i128, - &None, - &None, - &None, - ); + let (_env, buyer, seller, _token, token_id, client) = setup(); - client.fund_escrow(&escrow_id); - let result = client.try_release_escrow(&escrow_id); - - // Should handle gracefully (either success or appropriate error) - assert!(result.is_ok() || result.is_err()); + let result = client.try_create_escrow( + &buyer, &seller, &token_id, &0i128, &None, &None, &None, &None, + ); + assert_eq!(result, Err(Ok(crate::ContractError::InvalidEscrowAmount))); } #[test] fn test_small_amount_rounds_down() { - let (env, buyer, seller, _token, token_id, client) = setup(); - - // Amount 9,999 should give 0 fee with 500 bps - // (9999 * 500) / 10000 = 499.95 -> rounds to 0 + let (_env, buyer, seller, _token, token_id, client) = setup(); + + // Amount 9,999 floors to a 499 fee with 500 bps. let escrow_id = client.create_escrow( - &buyer, - &seller, - &token_id, - &9_999i128, - &None, - &None, - &None, + &buyer, &seller, &token_id, &9_999i128, &None, &None, &None, &None, ); client.fund_escrow(&escrow_id); client.release_escrow(&escrow_id); - // Get total fees collected - should be 0 (rounded down) + // Get total fees collected. let total_fees = client.get_total_fees_collected(); - assert_eq!(total_fees, 0); + assert_eq!(total_fees, 499); } #[test] fn test_exact_division() { - let (env, buyer, seller, _token, token_id, client) = setup(); - + let (_env, buyer, seller, _token, token_id, client) = setup(); + // Amount 10,000 with 500 bps = 500 fee exactly let escrow_id = client.create_escrow( &buyer, @@ -96,6 +89,7 @@ mod integer_safety_tests { &None, &None, &None, + &None, ); client.fund_escrow(&escrow_id); @@ -108,8 +102,8 @@ mod integer_safety_tests { #[test] fn test_remainder_handled_correctly() { - let (env, buyer, seller, _token, token_id, client) = setup(); - + let (_env, buyer, seller, _token, token_id, client) = setup(); + // Amount 10,001 with 500 bps // Fee = (10001 * 500) / 10000 = 500.05 -> floors to 500 let escrow_id = client.create_escrow( @@ -120,6 +114,7 @@ mod integer_safety_tests { &None, &None, &None, + &None, ); client.fund_escrow(&escrow_id); @@ -132,11 +127,11 @@ mod integer_safety_tests { #[test] fn test_large_amount_no_overflow() { - let (env, buyer, seller, _token, token_id, client) = setup(); - + let (_env, buyer, seller, _token, token_id, client) = setup(); + // Very large amount - should not cause overflow let large_amount = 1_000_000_000i128; // 100 XLM - + let escrow_id = client.create_escrow( &buyer, &seller, @@ -145,10 +140,11 @@ mod integer_safety_tests { &None, &None, &None, + &None, ); client.fund_escrow(&escrow_id); - + // This should not panic let result = client.try_release_escrow(&escrow_id); assert!(result.is_ok()); @@ -157,14 +153,15 @@ mod integer_safety_tests { #[test] fn test_multiple_escrows_accumulate_safely() { let (env, buyer, seller, _token, token_id, client) = setup(); - + // Create multiple escrows - for amount in [1000i128, 2000, 3000, 4000, 5000] { + for (index, amount) in [1000i128, 2000, 3000, 4000, 5000].into_iter().enumerate() { let escrow_id = client.create_escrow( &buyer, &seller, &token_id, &amount, + &Some(soroban_sdk::Bytes::from_slice(&env, &[index as u8])), &None, &None, &None, @@ -181,10 +178,11 @@ mod integer_safety_tests { #[test] fn test_zero_fee_bps_returns_zero() { - let (env, admin, buyer, seller, _token, token_id, client) = setup(); - + let (env, buyer, _admin, _token, token_id, client) = setup(); + let seller = Address::generate(&env); + // Set zero fee bps - client.set_fee_percentage(&admin, &0); + client.set_fee_percentage(&0); let escrow_id = client.create_escrow( &buyer, @@ -194,6 +192,7 @@ mod integer_safety_tests { &None, &None, &None, + &None, ); client.fund_escrow(&escrow_id); @@ -203,4 +202,4 @@ mod integer_safety_tests { let total_fees = client.get_total_fees_collected(); assert_eq!(total_fees, 0); } -} \ No newline at end of file +} diff --git a/contracts/marketx/src/test_volume.rs b/contracts/marketx/src/test_volume.rs index 2bb1032..c8b847d 100644 --- a/contracts/marketx/src/test_volume.rs +++ b/contracts/marketx/src/test_volume.rs @@ -1,9 +1,9 @@ //! Volume Discount Tests for MarketX Contract -//! +//! //! Tests for verifying volume-based fee discount functionality -//! +//! //! ## Test Coverage -//! +//! //! 1. Volume updates after escrow release //! 2. Tier calculation based on volume //! 3. Whitelist overrides volume discount @@ -12,61 +12,62 @@ #![cfg(test)] mod volume_tests { + use crate::{Contract, ContractClient}; use soroban_sdk::{ testutils::Address as _, - token::Client as TokenClient, + token::{Client as TokenClient, StellarAssetClient}, Address, Env, }; - use crate::{Client, Contract}; const FEE_BPS: u32 = 500; // 5% const MIN_FEE: i128 = 0; const MAX_FEE: i128 = 0; - fn setup() -> (Env, Address, Address, Address, TokenClient, Address, Client) { + fn setup<'a>() -> ( + Env, + Address, + Address, + Address, + TokenClient<'a>, + Address, + ContractClient<'a>, + ) { let env = Env::default(); env.mock_all_auths(); - let admin = Address::random(&env); - let buyer = Address::random(&env); - let seller = Address::random(&env); - + let admin = Address::generate(&env); + let buyer = Address::generate(&env); + let seller = Address::generate(&env); + let sac = env.register_stellar_asset_contract_v2(admin.clone()); - let token = TokenClient::new(&env, &sac); + let token = TokenClient::new(&env, &sac.address()); + let token_admin = StellarAssetClient::new(&env, &sac.address()); let token_id = sac.address(); - let contract_id = env.register_contract(None, Contract); - let client = Client::new(&env, &contract_id); + let contract_id = env.register(Contract, ()); + let client = ContractClient::new(&env, &contract_id); client.initialize(&admin, &admin, &FEE_BPS, &MIN_FEE, &MAX_FEE); - token.approve(&admin, &contract_id, &i128::MAX); + token_admin.mint(&buyer, &20_000_000); + token.approve(&buyer, &contract_id, &i128::MAX, &1000); (env, admin, buyer, seller, token, token_id, client) } #[test] fn test_volume_updated_after_escrow_release() { - let (env, _admin, buyer, seller, _token, token_id, client) = setup(); + let (_env, _admin, buyer, seller, _token, token_id, client) = setup(); let escrow_id = client.create_escrow( - &buyer, - &seller, - &token_id, - &100_000, - &None, - &None, - &None, + &buyer, &seller, &token_id, &100_000, &None, &None, &None, &None, ); client.fund_escrow(&escrow_id); client.release_escrow(&escrow_id); // Verify volume was updated - #[cfg(feature = "testutils")] - { - let volume = client.get_buyer_volume(&buyer); - assert_eq!(volume, 100_000, "Volume should be 100,000 after release"); - } + let volume = client.get_buyer_volume(&buyer); + assert_eq!(volume, 100_000); } #[test] @@ -74,12 +75,13 @@ mod volume_tests { let (env, _admin, buyer, seller, _token, token_id, client) = setup(); // Create escrows to reach tier 1 (100,000+) - for _ in 0..2 { + for index in 0..2 { let escrow_id = client.create_escrow( &buyer, &seller, &token_id, &100_000, + &Some(soroban_sdk::Bytes::from_slice(&env, &[index as u8])), &None, &None, &None, @@ -89,32 +91,23 @@ mod volume_tests { } // Total volume = 200,000 should be tier 1 - #[cfg(feature = "testutils")] - { - let tier = client.get_buyer_tier(&buyer); - assert_eq!(tier, 1, "200,000 volume should be tier 1 (10% discount)"); - } + let tier = client.get_buyer_tier(&buyer); + assert_eq!(tier, 1); } #[test] fn test_whitelist_prevents_fee() { - let (env, admin, buyer, seller, _token, token_id, client) = setup(); + let (_env, _admin, buyer, seller, _token, token_id, client) = setup(); // Add buyer to whitelist client.add_fee_whitelist(&buyer); let escrow_id = client.create_escrow( - &buyer, - &seller, - &token_id, - &1_000_000, - &None, - &None, - &None, + &buyer, &seller, &token_id, &1_000_000, &None, &None, &None, &None, ); client.fund_escrow(&escrow_id); - + // Release should succeed - whitelist gives 100% discount let result = client.try_release_escrow(&escrow_id); assert!(result.is_ok()); @@ -124,25 +117,22 @@ mod volume_tests { fn test_default_tiers_set_on_initialize() { let env = Env::default(); env.mock_all_auths(); - - let admin = Address::random(&env); - let contract_id = env.register_contract(None, Contract); - let client = Client::new(&env, &contract_id); + let admin = Address::generate(&env); + + let contract_id = env.register(Contract, ()); + let client = ContractClient::new(&env, &contract_id); client.initialize(&admin, &admin, &FEE_BPS, &MIN_FEE, &MAX_FEE); // Check default tiers exist - #[cfg(feature = "testutils")] - { - let tiers = client.get_volume_tiers(); - assert_eq!(tiers.tier_1_threshold, 100_000); - assert_eq!(tiers.tier_2_threshold, 1_000_000); - assert_eq!(tiers.tier_3_threshold, 10_000_000); - assert_eq!(tiers.tier_1_discount_bps, 100); // 10% - assert_eq!(tiers.tier_2_discount_bps, 250); // 25% - assert_eq!(tiers.tier_3_discount_bps, 500); // 50% max - } + let tiers = client.get_volume_tiers(); + assert_eq!(tiers.tier_1_threshold, 100_000); + assert_eq!(tiers.tier_2_threshold, 1_000_000); + assert_eq!(tiers.tier_3_threshold, 10_000_000); + assert_eq!(tiers.tier_1_discount_bps, 100); + assert_eq!(tiers.tier_2_discount_bps, 250); + assert_eq!(tiers.tier_3_discount_bps, 500); } #[test] @@ -150,33 +140,41 @@ mod volume_tests { let (env, _admin, buyer, seller, _token, token_id, client) = setup(); // First escrow - let id1 = client.create_escrow(&buyer, &seller, &token_id, &100_000, &None, &None, &None); + let id1 = client.create_escrow( + &buyer, &seller, &token_id, &100_000, &None, &None, &None, &None, + ); client.fund_escrow(&id1); client.release_escrow(&id1); // Second escrow - let id2 = client.create_escrow(&buyer, &seller, &token_id, &50_000, &None, &None, &None); + let id2 = client.create_escrow( + &buyer, + &seller, + &token_id, + &50_000, + &Some(soroban_sdk::Bytes::from_slice(&env, &[2u8])), + &None, + &None, + &None, + ); client.fund_escrow(&id2); client.release_escrow(&id2); - #[cfg(feature = "testutils")] - { - let volume = client.get_buyer_volume(&buyer); - assert_eq!(volume, 150_000, "Volume should accumulate to 150,000"); - } + let volume = client.get_buyer_volume(&buyer); + assert_eq!(volume, 150_000); } #[test] fn test_high_volume_tier_3() { let (env, _admin, buyer, seller, _token, token_id, client) = setup(); - // Create many escrows to reach tier 3 - for _ in 0..10 { + for index in 0..10 { let escrow_id = client.create_escrow( &buyer, &seller, &token_id, &1_000_000, // 0.1 XLM each + &Some(soroban_sdk::Bytes::from_slice(&env, &[index as u8])), &None, &None, &None, @@ -186,10 +184,7 @@ mod volume_tests { } // 10M+ should be tier 3 - #[cfg(feature = "testutils")] - { - let tier = client.get_buyer_tier(&buyer); - assert!(tier >= 3, "10M+ volume should be tier 3"); - } + let tier = client.get_buyer_tier(&buyer); + assert!(tier >= 3); } -} \ No newline at end of file +} diff --git a/contracts/marketx/src/types.rs b/contracts/marketx/src/types.rs index 9049407..ee9af70 100644 --- a/contracts/marketx/src/types.rs +++ b/contracts/marketx/src/types.rs @@ -77,6 +77,8 @@ pub enum DataKey { TotalReleasedAmount, PendingFee(Address, Address), FeeWhitelist(Address), + BuyerVolume(Address), + VolumeTiers, Oracle, MilestoneEscrow(u64), TimeLockEscrow(u64), @@ -150,6 +152,65 @@ pub const MAX_EVIDENCE_HASH_SIZE: u32 = 128; /// Maximum number of items per escrow pub const MAX_ITEMS_PER_ESCROW: u32 = 50; +pub const VOLUME_RESET_INTERVAL: u32 = 1_576_800; + +#[contracttype] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct VolumeTierConfig { + pub tier_1_threshold: i128, + pub tier_2_threshold: i128, + pub tier_3_threshold: i128, + pub tier_1_discount_bps: u32, + pub tier_2_discount_bps: u32, + pub tier_3_discount_bps: u32, + pub reset_ledger: u32, +} + +impl Default for VolumeTierConfig { + fn default() -> Self { + Self { + tier_1_threshold: 100_000, + tier_2_threshold: 1_000_000, + tier_3_threshold: 10_000_000, + tier_1_discount_bps: 100, + tier_2_discount_bps: 250, + tier_3_discount_bps: 500, + reset_ledger: 0, + } + } +} + +impl VolumeTierConfig { + pub fn tier(&self, volume: i128) -> u32 { + if volume >= self.tier_3_threshold { + 3 + } else if volume >= self.tier_2_threshold { + 2 + } else if volume >= self.tier_1_threshold { + 1 + } else { + 0 + } + } + + pub fn discount_bps(&self, tier: u32) -> u32 { + match tier { + 1 => self.tier_1_discount_bps, + 2 => self.tier_2_discount_bps, + 3 => self.tier_3_discount_bps, + _ => 0, + } + } +} + +#[contractevent(topics = ["volume_updated"], data_format = "vec")] +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct VolumeUpdatedEvent { + pub buyer: Address, + pub added_amount: i128, + pub new_volume: i128, +} + /// Maximum number of escrows that may be processed in a single /// `batch_collect_fees` call (#259). pub const MAX_ESCROWS_PER_BATCH: u32 = 50; diff --git a/contracts/marketx/src/utilities.rs b/contracts/marketx/src/utilities.rs index 6a9f60a..7c6c634 100644 --- a/contracts/marketx/src/utilities.rs +++ b/contracts/marketx/src/utilities.rs @@ -110,7 +110,22 @@ impl Contract { return 0; } - let mut fee: i128 = amount * (fee_bps as i128) / 10_000; + let volume_config: VolumeTierConfig = env + .storage() + .persistent() + .get(&DataKey::VolumeTiers) + .unwrap_or_default(); + let volume = Self::buyer_volume_internal(env, buyer, &volume_config); + let discount = volume_config + .discount_bps(volume_config.tier(volume)) + .min(500); + let effective_fee_bps = fee_bps.saturating_sub(discount); + + let whole = amount / 10_000; + let remainder = amount % 10_000; + let mut fee: i128 = whole + .saturating_mul(effective_fee_bps as i128) + .saturating_add(remainder.saturating_mul(effective_fee_bps as i128) / 10_000); // Rounding protection: if bps > 0 and amount > 0, fee must be at least 1 if fee == 0 && amount > 0 { @@ -174,9 +189,45 @@ impl Contract { .publish(env); } + Self::update_buyer_volume(env, buyer, amount); + Ok(fee) } + pub(crate) fn buyer_volume_internal( + env: &Env, + buyer: &Address, + config: &VolumeTierConfig, + ) -> i128 { + if env.ledger().sequence().saturating_sub(config.reset_ledger) >= VOLUME_RESET_INTERVAL { + 0 + } else { + env.storage() + .persistent() + .get(&DataKey::BuyerVolume(buyer.clone())) + .unwrap_or(0) + } + } + + pub(crate) fn update_buyer_volume(env: &Env, buyer: &Address, amount: i128) { + let mut config: VolumeTierConfig = env + .storage() + .persistent() + .get(&DataKey::VolumeTiers) + .unwrap_or_default(); + let current = Self::buyer_volume_internal(env, buyer, &config); + if env.ledger().sequence().saturating_sub(config.reset_ledger) >= VOLUME_RESET_INTERVAL { + config.reset_ledger = env.ledger().sequence(); + env.storage() + .persistent() + .set(&DataKey::VolumeTiers, &config); + } + let new_volume = current.saturating_add(amount); + env.storage() + .persistent() + .set(&DataKey::BuyerVolume(buyer.clone()), &new_volume); + } + pub(crate) fn validate_bytes_size(data: &Bytes, max: u32) -> Result<(), ContractError> { if data.len() > max { return Err(ContractError::MetadataTooLarge); diff --git a/contracts/marketx/test_snapshots/test/admin_can_pause_and_unpause.1.json b/contracts/marketx/test_snapshots/test/admin_can_pause_and_unpause.1.json index 886200b..fb14af8 100644 --- a/contracts/marketx/test_snapshots/test/admin_can_pause_and_unpause.1.json +++ b/contracts/marketx/test_snapshots/test/admin_can_pause_and_unpause.1.json @@ -273,6 +273,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -417,6 +441,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -441,6 +489,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/buyer_can_fund_escrow.1.json b/contracts/marketx/test_snapshots/test/buyer_can_fund_escrow.1.json index e21f7e7..244801a 100644 --- a/contracts/marketx/test_snapshots/test/buyer_can_fund_escrow.1.json +++ b/contracts/marketx/test_snapshots/test/buyer_can_fund_escrow.1.json @@ -561,6 +561,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -705,6 +729,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -729,6 +777,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/buyer_can_release_escrow.1.json b/contracts/marketx/test_snapshots/test/buyer_can_release_escrow.1.json index 91daac3..00a2363 100644 --- a/contracts/marketx/test_snapshots/test/buyer_can_release_escrow.1.json +++ b/contracts/marketx/test_snapshots/test/buyer_can_release_escrow.1.json @@ -247,6 +247,33 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "BuyerVolume" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "1000" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -578,6 +605,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -770,6 +821,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/escrow_actions_blocked_when_paused.1.json b/contracts/marketx/test_snapshots/test/escrow_actions_blocked_when_paused.1.json index d10017f..79d57be 100644 --- a/contracts/marketx/test_snapshots/test/escrow_actions_blocked_when_paused.1.json +++ b/contracts/marketx/test_snapshots/test/escrow_actions_blocked_when_paused.1.json @@ -256,6 +256,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -400,6 +424,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -424,6 +472,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/escrow_counter_overflow_fails.1.json b/contracts/marketx/test_snapshots/test/escrow_counter_overflow_fails.1.json index 491b664..b42ea68 100644 --- a/contracts/marketx/test_snapshots/test/escrow_counter_overflow_fails.1.json +++ b/contracts/marketx/test_snapshots/test/escrow_counter_overflow_fails.1.json @@ -242,6 +242,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -386,6 +410,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -410,6 +458,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/escrow_ids_increment_sequentially.1.json b/contracts/marketx/test_snapshots/test/escrow_ids_increment_sequentially.1.json index 362189d..39d7f0d 100644 --- a/contracts/marketx/test_snapshots/test/escrow_ids_increment_sequentially.1.json +++ b/contracts/marketx/test_snapshots/test/escrow_ids_increment_sequentially.1.json @@ -825,6 +825,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -969,6 +993,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -993,6 +1041,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/fund_fails_for_nonexistent_escrow.1.json b/contracts/marketx/test_snapshots/test/fund_fails_for_nonexistent_escrow.1.json index 745a9f8..3fe273f 100644 --- a/contracts/marketx/test_snapshots/test/fund_fails_for_nonexistent_escrow.1.json +++ b/contracts/marketx/test_snapshots/test/fund_fails_for_nonexistent_escrow.1.json @@ -241,6 +241,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -385,6 +409,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -409,6 +457,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/fund_fails_if_buyer_has_insufficient_balance.1.json b/contracts/marketx/test_snapshots/test/fund_fails_if_buyer_has_insufficient_balance.1.json index df328a2..6f911f7 100644 --- a/contracts/marketx/test_snapshots/test/fund_fails_if_buyer_has_insufficient_balance.1.json +++ b/contracts/marketx/test_snapshots/test/fund_fails_if_buyer_has_insufficient_balance.1.json @@ -496,6 +496,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -640,6 +664,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -664,6 +712,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/fund_fails_if_not_pending.1.json b/contracts/marketx/test_snapshots/test/fund_fails_if_not_pending.1.json index 1439e49..6a75b70 100644 --- a/contracts/marketx/test_snapshots/test/fund_fails_if_not_pending.1.json +++ b/contracts/marketx/test_snapshots/test/fund_fails_if_not_pending.1.json @@ -519,6 +519,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -663,6 +687,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -687,6 +735,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/no_escrow_id_collision.1.json b/contracts/marketx/test_snapshots/test/no_escrow_id_collision.1.json index 1f5ee5a..b81b06d 100644 --- a/contracts/marketx/test_snapshots/test/no_escrow_id_collision.1.json +++ b/contracts/marketx/test_snapshots/test/no_escrow_id_collision.1.json @@ -2190,6 +2190,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -2334,6 +2358,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -2358,6 +2406,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/release_fails_for_nonexistent_escrow.1.json b/contracts/marketx/test_snapshots/test/release_fails_for_nonexistent_escrow.1.json index 745a9f8..3fe273f 100644 --- a/contracts/marketx/test_snapshots/test/release_fails_for_nonexistent_escrow.1.json +++ b/contracts/marketx/test_snapshots/test/release_fails_for_nonexistent_escrow.1.json @@ -241,6 +241,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -385,6 +409,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -409,6 +457,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/release_fails_if_not_pending.1.json b/contracts/marketx/test_snapshots/test/release_fails_if_not_pending.1.json index 879bd9f..9003a65 100644 --- a/contracts/marketx/test_snapshots/test/release_fails_if_not_pending.1.json +++ b/contracts/marketx/test_snapshots/test/release_fails_if_not_pending.1.json @@ -437,6 +437,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -581,6 +605,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -605,6 +653,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_analytics_aggregation.1.json b/contracts/marketx/test_snapshots/test/test_analytics_aggregation.1.json index d3bc393..75cf5bc 100644 --- a/contracts/marketx/test_snapshots/test/test_analytics_aggregation.1.json +++ b/contracts/marketx/test_snapshots/test/test_analytics_aggregation.1.json @@ -837,6 +837,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -981,6 +1005,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -1005,6 +1053,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_arbiter_can_refund_buyer_on_dispute.1.json b/contracts/marketx/test_snapshots/test/test_arbiter_can_refund_buyer_on_dispute.1.json index 0563d42..5686ac3 100644 --- a/contracts/marketx/test_snapshots/test/test_arbiter_can_refund_buyer_on_dispute.1.json +++ b/contracts/marketx/test_snapshots/test/test_arbiter_can_refund_buyer_on_dispute.1.json @@ -177,6 +177,9 @@ ], [], [], + [], + [], + [], [] ], "ledger": { @@ -671,6 +674,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -693,7 +720,7 @@ }, "ext": "v0" }, - "live_until": 4095 + "live_until": 21376 }, { "entry": { @@ -815,6 +842,30 @@ }, "live_until": 21376 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -839,6 +890,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_arbiter_can_resolve_dispute.1.json b/contracts/marketx/test_snapshots/test/test_arbiter_can_resolve_dispute.1.json index 1f35b76..9d973fc 100644 --- a/contracts/marketx/test_snapshots/test/test_arbiter_can_resolve_dispute.1.json +++ b/contracts/marketx/test_snapshots/test/test_arbiter_can_resolve_dispute.1.json @@ -338,6 +338,33 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "BuyerVolume" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "1000" + } + } + }, + "ext": "v0" + }, + "live_until": 21376 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -671,6 +698,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -863,6 +914,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 21376 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_bump_escrow_extends_ttl_to_maximum.1.json b/contracts/marketx/test_snapshots/test/test_bump_escrow_extends_ttl_to_maximum.1.json index b3213ee..3a2457f 100644 --- a/contracts/marketx/test_snapshots/test/test_bump_escrow_extends_ttl_to_maximum.1.json +++ b/contracts/marketx/test_snapshots/test/test_bump_escrow_extends_ttl_to_maximum.1.json @@ -442,6 +442,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -586,6 +610,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -610,6 +658,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_bump_escrow_rejects_missing_escrow.1.json b/contracts/marketx/test_snapshots/test/test_bump_escrow_rejects_missing_escrow.1.json index 1b6f4f7..48718b7 100644 --- a/contracts/marketx/test_snapshots/test/test_bump_escrow_rejects_missing_escrow.1.json +++ b/contracts/marketx/test_snapshots/test/test_bump_escrow_rejects_missing_escrow.1.json @@ -241,6 +241,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -385,6 +409,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -409,6 +457,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_create_escrow_emits_indexable_event.1.json b/contracts/marketx/test_snapshots/test/test_create_escrow_emits_indexable_event.1.json index 853e122..7c7118f 100644 --- a/contracts/marketx/test_snapshots/test/test_create_escrow_emits_indexable_event.1.json +++ b/contracts/marketx/test_snapshots/test/test_create_escrow_emits_indexable_event.1.json @@ -443,6 +443,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -587,6 +611,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -611,6 +659,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_create_escrow_stores_arbiter.1.json b/contracts/marketx/test_snapshots/test/test_create_escrow_stores_arbiter.1.json index 7b0b858..0c1698a 100644 --- a/contracts/marketx/test_snapshots/test/test_create_escrow_stores_arbiter.1.json +++ b/contracts/marketx/test_snapshots/test/test_create_escrow_stores_arbiter.1.json @@ -440,6 +440,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -584,6 +608,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -608,6 +656,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_create_escrow_without_arbiter_stores_none.1.json b/contracts/marketx/test_snapshots/test/test_create_escrow_without_arbiter_stores_none.1.json index d167cd4..c0d4dd0 100644 --- a/contracts/marketx/test_snapshots/test/test_create_escrow_without_arbiter_stores_none.1.json +++ b/contracts/marketx/test_snapshots/test/test_create_escrow_without_arbiter_stores_none.1.json @@ -436,6 +436,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -580,6 +604,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -604,6 +652,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_distinct_escrows_allowed.1.json b/contracts/marketx/test_snapshots/test/test_distinct_escrows_allowed.1.json index 0a36f5f..457f63c 100644 --- a/contracts/marketx/test_snapshots/test/test_distinct_escrows_allowed.1.json +++ b/contracts/marketx/test_snapshots/test/test_distinct_escrows_allowed.1.json @@ -1231,6 +1231,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -1375,6 +1399,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -1399,6 +1447,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_duplicate_escrow_rejected.1.json b/contracts/marketx/test_snapshots/test/test_duplicate_escrow_rejected.1.json index 08ed819..8ca7885 100644 --- a/contracts/marketx/test_snapshots/test/test_duplicate_escrow_rejected.1.json +++ b/contracts/marketx/test_snapshots/test/test_duplicate_escrow_rejected.1.json @@ -440,6 +440,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -584,6 +608,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -608,6 +656,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_duplicate_escrow_with_none_metadata.1.json b/contracts/marketx/test_snapshots/test/test_duplicate_escrow_with_none_metadata.1.json index d167cd4..c0d4dd0 100644 --- a/contracts/marketx/test_snapshots/test/test_duplicate_escrow_with_none_metadata.1.json +++ b/contracts/marketx/test_snapshots/test/test_duplicate_escrow_with_none_metadata.1.json @@ -436,6 +436,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -580,6 +604,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -604,6 +652,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_escrow_hash_stored_correctly.1.json b/contracts/marketx/test_snapshots/test/test_escrow_hash_stored_correctly.1.json index 586a490..09c03f2 100644 --- a/contracts/marketx/test_snapshots/test/test_escrow_hash_stored_correctly.1.json +++ b/contracts/marketx/test_snapshots/test/test_escrow_hash_stored_correctly.1.json @@ -440,6 +440,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -584,6 +608,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -608,6 +656,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_get_escrow_metadata_for_nonexistent_escrow.1.json b/contracts/marketx/test_snapshots/test/test_get_escrow_metadata_for_nonexistent_escrow.1.json index 1b6f4f7..48718b7 100644 --- a/contracts/marketx/test_snapshots/test/test_get_escrow_metadata_for_nonexistent_escrow.1.json +++ b/contracts/marketx/test_snapshots/test/test_get_escrow_metadata_for_nonexistent_escrow.1.json @@ -241,6 +241,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -385,6 +409,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -409,6 +457,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_metadata_at_max_size_accepted.1.json b/contracts/marketx/test_snapshots/test/test_metadata_at_max_size_accepted.1.json index 4656677..122eb31 100644 --- a/contracts/marketx/test_snapshots/test/test_metadata_at_max_size_accepted.1.json +++ b/contracts/marketx/test_snapshots/test/test_metadata_at_max_size_accepted.1.json @@ -440,6 +440,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -584,6 +608,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -608,6 +656,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_metadata_none_stored_successfully.1.json b/contracts/marketx/test_snapshots/test/test_metadata_none_stored_successfully.1.json index d680756..ec77181 100644 --- a/contracts/marketx/test_snapshots/test/test_metadata_none_stored_successfully.1.json +++ b/contracts/marketx/test_snapshots/test/test_metadata_none_stored_successfully.1.json @@ -437,6 +437,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -581,6 +605,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -605,6 +653,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_metadata_stored_successfully.1.json b/contracts/marketx/test_snapshots/test/test_metadata_stored_successfully.1.json index b01a4b0..cbedfe0 100644 --- a/contracts/marketx/test_snapshots/test/test_metadata_stored_successfully.1.json +++ b/contracts/marketx/test_snapshots/test/test_metadata_stored_successfully.1.json @@ -441,6 +441,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -585,6 +609,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -609,6 +657,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_oversized_metadata_rejected.1.json b/contracts/marketx/test_snapshots/test/test_oversized_metadata_rejected.1.json index 56a03d5..e909d83 100644 --- a/contracts/marketx/test_snapshots/test/test_oversized_metadata_rejected.1.json +++ b/contracts/marketx/test_snapshots/test/test_oversized_metadata_rejected.1.json @@ -241,6 +241,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -385,6 +409,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -409,6 +457,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_release_emits_funds_and_status_change_events.1.json b/contracts/marketx/test_snapshots/test/test_release_emits_funds_and_status_change_events.1.json index d6e92ba..90019be 100644 --- a/contracts/marketx/test_snapshots/test/test_release_emits_funds_and_status_change_events.1.json +++ b/contracts/marketx/test_snapshots/test/test_release_emits_funds_and_status_change_events.1.json @@ -245,6 +245,33 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "BuyerVolume" + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "1000" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -576,6 +603,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -768,6 +819,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_resolve_dispute_emits_status_change_with_actor.1.json b/contracts/marketx/test_snapshots/test/test_resolve_dispute_emits_status_change_with_actor.1.json index ab3f5a1..9fdc849 100644 --- a/contracts/marketx/test_snapshots/test/test_resolve_dispute_emits_status_change_with_actor.1.json +++ b/contracts/marketx/test_snapshots/test/test_resolve_dispute_emits_status_change_with_actor.1.json @@ -695,6 +695,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -839,6 +863,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -863,6 +911,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_resolve_dispute_fails_for_nonexistent_escrow.1.json b/contracts/marketx/test_snapshots/test/test_resolve_dispute_fails_for_nonexistent_escrow.1.json index 745a9f8..3fe273f 100644 --- a/contracts/marketx/test_snapshots/test/test_resolve_dispute_fails_for_nonexistent_escrow.1.json +++ b/contracts/marketx/test_snapshots/test/test_resolve_dispute_fails_for_nonexistent_escrow.1.json @@ -241,6 +241,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -385,6 +409,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -409,6 +457,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/contracts/marketx/test_snapshots/test/test_resolve_dispute_fails_if_not_disputed.1.json b/contracts/marketx/test_snapshots/test/test_resolve_dispute_fails_if_not_disputed.1.json index 07f0661..eef936f 100644 --- a/contracts/marketx/test_snapshots/test/test_resolve_dispute_fails_if_not_disputed.1.json +++ b/contracts/marketx/test_snapshots/test/test_resolve_dispute_fails_if_not_disputed.1.json @@ -440,6 +440,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalCancelledAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -584,6 +608,30 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "TotalReleasedAmount" + } + ] + }, + "durability": "persistent", + "val": { + "i128": "0" + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, @@ -608,6 +656,87 @@ }, "live_until": 4095 }, + { + "entry": { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "VolumeTiers" + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "reset_ledger" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "tier_1_discount_bps" + }, + "val": { + "u32": 100 + } + }, + { + "key": { + "symbol": "tier_1_threshold" + }, + "val": { + "i128": "100000" + } + }, + { + "key": { + "symbol": "tier_2_discount_bps" + }, + "val": { + "u32": 250 + } + }, + { + "key": { + "symbol": "tier_2_threshold" + }, + "val": { + "i128": "1000000" + } + }, + { + "key": { + "symbol": "tier_3_discount_bps" + }, + "val": { + "u32": 500 + } + }, + { + "key": { + "symbol": "tier_3_threshold" + }, + "val": { + "i128": "10000000" + } + } + ] + } + } + }, + "ext": "v0" + }, + "live_until": 4095 + }, { "entry": { "last_modified_ledger_seq": 0, diff --git a/package-lock.json b/package-lock.json index 0a0061c..a1f7504 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "MarketX-contract--fork", + "name": "MarketX-contract", "lockfileVersion": 3, "requires": true, "packages": {} diff --git a/scripts/check_rust_modules.py b/scripts/check_rust_modules.py new file mode 100644 index 0000000..5d77dae --- /dev/null +++ b/scripts/check_rust_modules.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python3 +"""Fail when a Rust source file under a crate's src directory is unreachable.""" + +from pathlib import Path +import re +import sys + + +MODULE_RE = re.compile(r"^\s*(?:pub\s+)?mod\s+([A-Za-z_][A-Za-z0-9_]*)\s*;") +PATH_RE = re.compile(r"^\s*#\s*\[path\s*=\s*[\"']([^\"']+)[\"']\s*\]") + + +def reachable(crate_src: Path) -> set[Path]: + roots = [path for path in (crate_src / "lib.rs", crate_src / "main.rs") if path.exists()] + seen: set[Path] = set() + pending = list(roots) + + while pending: + current = pending.pop().resolve() + if current in seen: + continue + seen.add(current) + pending_path: Path | None = None + for line in current.read_text(encoding="utf-8").splitlines(): + if path_match := PATH_RE.match(line): + pending_path = (current.parent / path_match.group(1)).resolve() + continue + if module_match := MODULE_RE.match(line): + if pending_path is not None: + target = pending_path + pending_path = None + else: + module = module_match.group(1) + target = current.parent / module / "mod.rs" + if not target.exists(): + target = current.parent / f"{module}.rs" + if target.exists(): + pending.append(target) + return {path for path in seen if path.suffix == ".rs"} + + +def main() -> int: + orphaned: list[Path] = [] + for crate_src in sorted(Path("contracts").glob("*/src")): + files = {path.resolve() for path in crate_src.rglob("*.rs")} + missing = files - reachable(crate_src) + orphaned.extend(sorted(path.relative_to(Path.cwd()) for path in missing)) + + if orphaned: + for path in orphaned: + print(f"Unreachable Rust source: {path}") + return 1 + print("Rust module reachability check passed.") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) \ No newline at end of file diff --git a/tools/tarpaulin.rs b/tools/tarpaulin.rs deleted file mode 100644 index 8838457..0000000 --- a/tools/tarpaulin.rs +++ /dev/null @@ -1,407 +0,0 @@ -use soroban_sdk::contracterror; - -/// Errors that can be returned by the MarketX contract. -/// -/// Each error variant represents a specific failure condition that can occur -/// during contract execution. The error codes are organized by category -/// for easier maintenance and debugging. -#[contracterror] -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub enum ContractError { - // ========================= - // AUTHENTICATION ERRORS (1-9) - // ========================= - /// Caller is not the contract admin. - /// - /// This error is returned when a function requires admin privileges - /// but the caller is not the configured admin address. - /// - /// **Used in:** `assert_admin()`, `set_fee_percentage()` - NotAdmin = 1, - - /// Caller is not authorized to perform the requested action. - /// - /// This error is returned when a user attempts to perform an action - /// they are not authorized for (e.g., non-buyer trying to refund). - /// - /// **Used in:** `refund_escrow()` - Unauthorized = 2, - NotProposedAdmin = 3, - - // ========================= - // ESCROW ERRORS (10-19) - // ========================= - /// The specified escrow does not exist. - /// - /// This error is returned when attempting to operate on an escrow - /// ID that was never created or has been deleted. - /// - /// **Used in:** `fund_escrow()`, `release_escrow()`, `release_item()`, - /// `refund_escrow()`, `bump_escrow()`, `resolve_dispute()` - EscrowNotFound = 10, - - /// Escrow is not in the required state for the operation. - /// - /// This error is returned when the current escrow state does not - /// allow the requested operation (e.g., releasing an already released escrow). - /// - /// **Used in:** `fund_escrow()`, `release_escrow()`, `release_item()`, - /// `refund_escrow()`, `resolve_dispute()` - InvalidEscrowState = 11, - - /// The escrow amount is invalid. - /// - /// This error is returned when the escrow amount is zero or negative, - /// or when a refund amount exceeds the escrow amount. - /// - /// **Used in:** `create_escrow()`, `refund_escrow()` - InvalidEscrowAmount = 13, - - // ========================= - // SECURITY ERRORS (30-39) - // ========================= - /// Contract is currently paused. - /// - /// This error is returned when attempting to perform operations - /// while the contract is in a paused state. - /// - /// **Used in:** `assert_not_paused()` - ContractPaused = 31, - - // ========================= - // COUNTER ERRORS (40-49) - // ========================= - /// Escrow ID would overflow u64. - /// - /// This error is returned when the contract has already created - /// the maximum number of escrows (2^64 - 1). - /// - /// **Used in:** `next_escrow_id()`, `next_refund_id()` - EscrowIdOverflow = 40, - - // ========================= - // FEE ERRORS (50-59) - // ========================= - /// Fee configuration is invalid. - /// - /// This error is returned when the fee configuration is malformed - /// or missing required components (e.g., no fee collector set). - /// - /// **Used in:** `release_escrow()`, `set_fee_percentage()` - InvalidFeeConfig = 50, - - // ========================= - // METADATA ERRORS (60-69) - // ========================= - /// Metadata exceeds maximum allowed size. - /// - /// This error is returned when the provided metadata is larger - /// than `MAX_METADATA_SIZE` (1KB). - /// - /// **Used in:** `validate_metadata()` - MetadataTooLarge = 60, - - // ========================= - // DUPLICATION ERRORS (70-79) - // ========================= - /// Duplicate escrow detected. - /// - /// This error is returned when attempting to create an escrow with - /// the same buyer, seller, and metadata as an existing one. - /// - /// **Used in:** `check_duplicate_escrow()` - DuplicateEscrow = 70, - - // ========================= - // ITEM ERRORS (80-89) - // ========================= - /// Item not found in escrow. - /// - /// This error is returned when attempting to access an item - /// with an invalid index in the escrow's items array. - /// - /// **Used in:** `release_item()` - ItemNotFound = 80, - - /// Item has already been released. - /// - /// This error is returned when attempting to release an item - /// that has already been released to the seller. - /// - /// **Used in:** `release_item()` - ItemAlreadyReleased = 81, - - /// Too many items in escrow. - /// - /// This error is returned when attempting to create an escrow - /// with more items than `MAX_ITEMS_PER_ESCROW` (50). - /// - /// **Used in:** `create_escrow()` - TooManyItems = 82, - - /// Item amounts don't sum to total escrow amount. - /// - /// This error is returned when the sum of all item amounts - /// does not equal the total escrow amount. - /// - /// **Used in:** `create_escrow()` - ItemAmountInvalid = 83, - - // ========================= - // EXPIRY ERRORS (90-99) - // ========================= - /// Escrow has not yet passed the unfunded expiry window. - /// - /// This error is returned when `cancel_unfunded` is called before - /// the escrow has been pending long enough to be considered expired. - /// - /// **Used in:** `cancel_unfunded()` - EscrowNotExpired = 90, - - /// Escrow has already been funded and cannot be cancelled as unfunded. - /// - /// **Used in:** `cancel_unfunded()` - EscrowAlreadyFunded = 91, -} -use soroban_sdk::{contractevent, contracttype, Address, Bytes, BytesN, Vec}; - -#[cfg(test)] -use soroban_sdk::Env; - -/// Returns the contract address for the native XLM token (Stellar Asset Contract). -/// -/// # Example -/// ```ignore -/// use soroban_sdk::Env; -/// use crate::types::native_xlm_address; -/// -/// fn example(env: &Env) { -/// let xlm_address = native_xlm_address(env); -/// // Use xlm_address for creating escrows with native XLM -/// } -/// ``` -/// -/// # Note -/// The native XLM token uses the Stellar Asset Contract (SAC) which implements -/// the SEP-41 Token Interface. This means it can be used interchangeably with -/// custom tokens in all escrow operations. -#[cfg(test)] -pub fn native_xlm_address(env: &Env) -> Address { - // In test environments, register the native XLM Stellar Asset Contract - let sac = env.register_stellar_asset_contract_v2(env.current_contract_address()); - sac.address() -} - -#[contracttype] -#[derive(Clone)] -pub enum DataKey { - Escrow(u64), - - // Escrow Counter - EscrowCounter, - FeeCollector, - FeeBps, - MinFee, - ReentrancyLock, - Admin, - ProposedAdmin, - Paused, - RefundRequest(u64), - RefundCount, - EscrowRefunds(u64), - RefundHistory(u64), - GlobalRefundHistory, - InitialValue, - EscrowHash(BytesN<32>), - TotalFundedAmount, - - TotalRefundedAmount, - TotalDisputedCount, - TotalFeesCollected, - EscrowIds, - - TotalReleasedAmount, -} - -pub const MAX_METADATA_SIZE: u32 = 1024; - -/// Maximum number of items per escrow -pub const MAX_ITEMS_PER_ESCROW: u32 = 50; - -/// Represents a single item/milestone within an escrow -#[contracttype] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct EscrowItem { - /// The amount allocated to this item - pub amount: i128, - /// Whether this item has been released - pub released: bool, - /// Optional description/metadata for this item (e.g., product ID) - pub description: Option, -} - -#[contracttype] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct Escrow { - pub buyer: Address, - pub seller: Address, - pub token: Address, - pub amount: i128, - pub status: EscrowStatus, - pub metadata: Option, - pub arbiter: Option
, - /// Party that proposed mutual cancellation, if any. - pub cancellation_proposer: Option
, - /// Individual items/milestones within this escrow - /// If empty, the entire escrow is treated as a single item - pub items: Vec, - /// Ledger sequence number at which this escrow was created. - /// Used to enforce the unfunded expiry window. - pub created_at: u32, -} - -/// Number of ledgers after creation within which an escrow must be funded. -/// After this window, anyone may call `cancel_unfunded` to remove it. -/// ~7 days at ~5s per ledger: 7 * 24 * 3600 / 5 = 120_960 ledgers. -pub const UNFUNDED_EXPIRY_LEDGERS: u32 = 120_960; - -#[contractevent(topics = ["escrow_expired"], data_format = "vec")] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct EscrowExpiredEvent { - #[topic] - pub escrow_id: u64, - pub buyer: Address, - pub seller: Address, -} - -#[contracttype] -#[derive(Clone, Debug, Eq, PartialEq)] -pub enum EscrowStatus { - Pending, - Released, - Refunded, - Disputed, -} - -#[contractevent(topics = ["escrow_created"], data_format = "vec")] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct EscrowCreatedEvent { - #[topic] - pub escrow_id: u64, - pub buyer: Address, - pub seller: Address, - pub token: Address, - pub amount: i128, - pub status: EscrowStatus, - pub arbiter: Option
, -} - -#[contractevent(topics = ["funds_released"], data_format = "vec")] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct FundsReleasedEvent { - #[topic] - pub escrow_id: u64, - pub amount: i128, - pub fee: i128, -} - -#[contractevent(topics = ["fee_collected"], data_format = "vec")] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct FeeCollectedEvent { - #[topic] - pub escrow_id: u64, - pub fee_collector: Address, - pub fee: i128, -} - -#[contractevent(topics = ["status_change"], data_format = "vec")] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct StatusChangeEvent { - #[topic] - pub escrow_id: u64, - pub from_status: EscrowStatus, - pub to_status: EscrowStatus, - pub actor: Address, -} - -#[contractevent(topics = ["cancellation_proposed"], data_format = "vec")] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct CancellationProposedEvent { - #[topic] - pub escrow_id: u64, - pub actor: Address, -} - -#[contractevent(topics = ["fee_changed"], data_format = "vec")] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct FeeChangedEvent { - pub old_fee_bps: u32, - pub new_fee_bps: u32, - pub actor: Address, -} - -#[contractevent(topics = ["admin_transferred"], data_format = "vec")] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct AdminTransferredEvent { - pub old_admin: Address, - pub new_admin: Address, -} - -#[contracttype] -#[derive(Clone, Debug, Eq, PartialEq)] -pub enum RefundReason { - ProductNotReceived, - ProductDefective, - WrongProduct, - ChangedMind, - Other, -} - -#[contracttype] -#[derive(Clone, Debug, Eq, PartialEq)] -pub enum RefundStatus { - Pending, - Approved, - Rejected, -} - -#[contracttype] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct RefundRequest { - pub request_id: u64, - pub escrow_id: u64, - pub requester: Address, - pub amount: i128, - pub reason: RefundReason, - pub status: RefundStatus, - pub created_at: u64, - pub evidence_hash: Option, - pub counter_evidence_hash: Option, -} - -#[contracttype] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct RefundHistoryEntry { - pub refund_id: u64, - pub escrow_id: u64, - pub amount: i128, - pub refunded_at: u64, -} - -#[contractevent(topics = ["refund_requested"], data_format = "vec")] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct RefundRequestedEvent { - pub request_id: u64, - pub escrow_id: u64, - pub requester: Address, - pub evidence_hash: Option, -} - -#[contractevent(topics = ["counter_evidence"], data_format = "vec")] -#[derive(Clone, Debug, Eq, PartialEq)] -pub struct CounterEvidenceSubmittedEvent { - pub request_id: u64, - pub escrow_id: u64, - pub responder: Address, - pub counter_evidence_hash: Option, -}