diff --git a/.kiro/specs/fee-accounting-tests/.config.kiro b/.kiro/specs/fee-accounting-tests/.config.kiro new file mode 100644 index 0000000..94dc90c --- /dev/null +++ b/.kiro/specs/fee-accounting-tests/.config.kiro @@ -0,0 +1 @@ +{"specId": "1c644782-a264-4f76-968e-8f0c89057b26", "workflowType": "requirements-first", "specType": "feature"} diff --git a/.kiro/specs/fee-accounting-tests/design.md b/.kiro/specs/fee-accounting-tests/design.md new file mode 100644 index 0000000..1461b3d --- /dev/null +++ b/.kiro/specs/fee-accounting-tests/design.md @@ -0,0 +1,445 @@ +# Design Document: Fee Accounting Tests + +## Overview + +This design implements fee accounting functionality for the TalentTrust escrow smart contract on the Stellar network. The system calculates fees from milestone releases, handles fractional stroops through rounding, accumulates fees in a treasury, and supports fee splitting between multiple recipients. + +The implementation integrates fee calculation directly into the existing `release_milestone` function, ensuring fees are deducted atomically during payment processing. The design prioritizes correctness through a rounding strategy that guarantees no stroops are lost or created, maintaining the invariant that `fee + net_amount = milestone_amount` for all transactions. + +Key design principles: +- **Atomic fee processing**: Fees are calculated and deducted in the same transaction as milestone release +- **Zero-loss rounding**: All fractional stroops from fee calculations are allocated to the freelancer +- **Transparent accounting**: Treasury totals and fee splits are queryable and auditable +- **Security-first**: Fee configuration and treasury access are restricted to authorized administrators + +## Architecture + +### Component Integration + +The fee accounting system integrates into the existing escrow contract architecture: + +``` +┌─────────────────────────────────────────────────────────┐ +│ Escrow Contract │ +├─────────────────────────────────────────────────────────┤ +│ │ +│ ┌──────────────────┐ ┌──────────────────┐ │ +│ │ Milestone │ │ Fee Accounting │ │ +│ │ Management │────────▶│ Module │ │ +│ │ │ │ │ │ +│ │ - approve() │ │ - calculate() │ │ +│ │ - release() │ │ - split() │ │ +│ └──────────────────┘ │ - accumulate() │ │ +│ └──────────────────┘ │ +│ │ │ +│ ▼ │ +│ ┌──────────────────┐ │ +│ │ Treasury │ │ +│ │ Storage │ │ +│ │ │ │ +│ │ - total │ │ +│ │ - recipients │ │ +│ └──────────────────┘ │ +│ │ +└─────────────────────────────────────────────────────────┘ +``` + +### Data Flow + +1. **Milestone Release Trigger**: Client or arbiter calls `release_milestone()` +2. **Fee Calculation**: System calculates `fee = milestone_amount * fee_rate` (rounded down) +3. **Remainder Handling**: Remainder `r = milestone_amount - fee` is added to net amount +4. **Fee Split** (if enabled): Fee is distributed to multiple recipients based on percentages +5. **Treasury Update**: Each recipient's accumulated total is incremented +6. **Payment Transfer**: Net amount is transferred to freelancer +7. **State Persistence**: Updated treasury totals are saved to storage + +## Components and Interfaces + +### FeeConfig Structure + +Stores the global fee configuration for the contract: + +```rust +#[contracttype] +#[derive(Clone, Debug)] +pub struct FeeConfig { + /// Fee rate as basis points (e.g., 250 = 2.5%) + pub rate_bps: u32, + + /// Whether fee splitting is enabled + pub split_enabled: bool, + + /// Fee split recipients and their percentages + pub recipients: Vec, +} +``` + +**Constraints**: +- `rate_bps` must be between 0 and 1000 (0% to 10%) +- If `split_enabled` is true, `recipients` must have 1-3 entries +- Sum of all recipient percentages must equal 10000 (100%) + +### FeeRecipient Structure + +Defines a single fee recipient and their share: + +```rust +#[contracttype] +#[derive(Clone, Debug)] +pub struct FeeRecipient { + /// Address to receive fees + pub address: Address, + + /// Percentage as basis points (e.g., 7000 = 70%) + pub percentage_bps: u32, + + /// Whether this is the primary recipient (receives rounding remainders) + pub is_primary: bool, +} +``` + +### Treasury Structure + +Tracks accumulated fees for each recipient: + +```rust +#[contracttype] +#[derive(Clone, Debug)] +pub struct Treasury { + /// Total fees accumulated across all recipients + pub total: i128, + + /// Per-recipient accumulated fees + pub balances: Map, +} +``` + +### Fee Calculation Result + +Internal structure returned by fee calculation: + +```rust +pub struct FeeCalculation { + /// Total fee amount (rounded down) + pub fee_amount: i128, + + /// Net amount to freelancer (includes rounding remainder) + pub net_amount: i128, + + /// Fee splits per recipient (if splitting enabled) + pub splits: Vec, +} + +pub struct FeeSplit { + pub recipient: Address, + pub amount: i128, +} +``` + +### Public Functions + +#### configure_fees + +```rust +pub fn configure_fees( + env: Env, + admin: Address, + rate_bps: u32, + recipients: Option>, +) -> bool +``` + +**Purpose**: Configure or update fee rate and split recipients + +**Authorization**: Only contract admin + +**Parameters**: +- `admin`: Address of the administrator (must be authorized) +- `rate_bps`: Fee rate in basis points (0-1000) +- `recipients`: Optional fee split configuration + +**Returns**: `true` on success + +**Errors**: +- Panics if caller is not admin +- Panics if `rate_bps` > 1000 +- Panics if recipients percentages don't sum to 10000 +- Panics if more than 3 recipients specified + +#### get_treasury_total + +```rust +pub fn get_treasury_total(env: Env) -> i128 +``` + +**Purpose**: Query the total accumulated fees + +**Returns**: Total fees in stroops + +#### get_recipient_balance + +```rust +pub fn get_recipient_balance(env: Env, recipient: Address) -> i128 +``` + +**Purpose**: Query accumulated fees for a specific recipient + +**Returns**: Recipient's fee balance in stroops + +#### withdraw_fees + +```rust +pub fn withdraw_fees( + env: Env, + admin: Address, + recipient: Address, + amount: i128, +) -> bool +``` + +**Purpose**: Withdraw accumulated fees to a recipient + +**Authorization**: Only contract admin + +**Errors**: +- Panics if caller is not admin +- Panics if amount exceeds recipient's balance +- Panics if amount is negative or zero + +### Internal Functions + +#### calculate_fee + +```rust +fn calculate_fee( + env: &Env, + milestone_amount: i128, + config: &FeeConfig, +) -> FeeCalculation +``` + +**Purpose**: Calculate fee, net amount, and splits for a milestone + +**Algorithm**: +1. Calculate raw fee: `raw_fee = (milestone_amount * rate_bps) / 10000` +2. Round down to whole stroops: `fee = raw_fee.floor()` +3. Calculate net: `net = milestone_amount - fee` +4. If splitting enabled, distribute fee among recipients +5. Allocate any rounding remainder to primary recipient + +**Returns**: `FeeCalculation` with all amounts + +#### split_fee + +```rust +fn split_fee( + env: &Env, + total_fee: i128, + recipients: &Vec, +) -> Vec +``` + +**Purpose**: Distribute a fee amount among multiple recipients + +**Algorithm**: +1. For each recipient, calculate: `share = (total_fee * percentage_bps) / 10000` +2. Round down each share +3. Calculate remainder: `remainder = total_fee - sum(shares)` +4. Add remainder to primary recipient's share + +**Returns**: Vector of fee splits + +#### update_treasury + +```rust +fn update_treasury( + env: &Env, + splits: Vec, +) +``` + +**Purpose**: Update treasury storage with new fee amounts + +**Algorithm**: +1. Load current treasury from storage +2. For each split, increment recipient's balance +3. Increment total treasury amount +4. Save updated treasury to storage + +## Data Models + +### Storage Keys + +The contract uses the following storage keys: + +```rust +// Fee configuration +const FEE_CONFIG: Symbol = symbol_short!("fee_cfg"); + +// Treasury data +const TREASURY: Symbol = symbol_short!("treasury"); + +// Admin address +const ADMIN: Symbol = symbol_short!("admin"); +``` + +### Storage Layout + +``` +Persistent Storage: +├── "fee_cfg" → FeeConfig +├── "treasury" → Treasury +├── "admin" → Address +└── "contract" → EscrowContract (existing) +``` + +### Initialization + +On contract deployment: +1. Admin address is set to deployer +2. FeeConfig is initialized with `rate_bps = 0` (no fees) +3. Treasury is initialized with `total = 0` and empty balances map + +### Fee Rate Representation + +Fee rates are stored as basis points (bps) where: +- 1 bps = 0.01% +- 100 bps = 1% +- 10000 bps = 100% + +Examples: +- 2.5% fee = 250 bps +- 5% fee = 500 bps +- 10% fee = 1000 bps + +This representation avoids floating-point arithmetic and provides precision to 0.01%. + +## Rounding Strategy + +### Problem + +Stellar uses stroops as the smallest unit (1 XLM = 10,000,000 stroops). Fee calculations often produce fractional stroops that cannot be represented: + +``` +milestone_amount = 1000 stroops +fee_rate = 2.5% (250 bps) +raw_fee = 1000 * 250 / 10000 = 25 stroops (exact) + +milestone_amount = 1001 stroops +fee_rate = 2.5% +raw_fee = 1001 * 250 / 10000 = 25.025 stroops (fractional!) +``` + +### Solution + +**Round down fees, allocate remainder to freelancer**: + +1. Calculate fee: `fee = floor((milestone_amount * rate_bps) / 10000)` +2. Calculate net: `net = milestone_amount - fee` +3. Verify: `fee + net == milestone_amount` (always true) + +This strategy: +- Ensures no stroops are lost or created +- Favors the freelancer (they receive rounding benefit) +- Simplifies implementation (no complex remainder tracking) +- Maintains conservation property + +### Examples + +**Example 1: Exact division** +``` +milestone = 10000 stroops +rate = 5% (500 bps) +fee = (10000 * 500) / 10000 = 500 stroops +net = 10000 - 500 = 9500 stroops +check: 500 + 9500 = 10000 ✓ +``` + +**Example 2: Fractional result** +``` +milestone = 1001 stroops +rate = 2.5% (250 bps) +fee = floor((1001 * 250) / 10000) = floor(25.025) = 25 stroops +net = 1001 - 25 = 976 stroops +check: 25 + 976 = 1001 ✓ +``` + +**Example 3: Fee rounds to zero** +``` +milestone = 10 stroops +rate = 2.5% (250 bps) +fee = floor((10 * 250) / 10000) = floor(0.25) = 0 stroops +net = 10 - 0 = 10 stroops +check: 0 + 10 = 10 ✓ +``` + +### Fee Split Rounding + +When fees are split among multiple recipients, the same strategy applies: + +1. Calculate each recipient's share (rounded down) +2. Sum all shares +3. Calculate remainder: `remainder = total_fee - sum(shares)` +4. Add remainder to primary recipient + +**Example**: +``` +total_fee = 100 stroops +recipients: + - Platform: 70% → 70 stroops + - Referrer: 30% → 30 stroops +sum = 100 stroops +remainder = 0 stroops (no adjustment needed) + +total_fee = 101 stroops +recipients: + - Platform: 70% → floor(70.7) = 70 stroops + - Referrer: 30% → floor(30.3) = 30 stroops +sum = 100 stroops +remainder = 1 stroop → added to Platform (primary) +final: Platform = 71, Referrer = 30 +check: 71 + 30 = 101 ✓ +``` + +## Integration with release_milestone + +The existing `release_milestone` function is modified to integrate fee accounting: + +### Modified Function Flow + +```rust +pub fn release_milestone( + env: Env, + contract_id: u32, + caller: Address, + milestone_id: u32, +) -> bool { + // [Existing validation logic...] + + // NEW: Load fee configuration + let fee_config = load_fee_config(&env); + + // NEW: Calculate fees + let fee_calc = calculate_fee(&env, milestone.amount, &fee_config); + + // NEW: Update treasury + if fee_calc.fee_amount > 0 { + update_treasury(&env, fee_calc.splits); + } + + // MODIFIED: Transfer net amount instead of full amount + // transfer_to_freelancer(&env, contract.freelancer, fee_calc.net_amount); + + // [Existing milestone update logic...] + + true +} +``` + +### Backward Compatibility + +- If `fee_rate = 0`, the function behaves identically to the original +- No changes to function signature or external interface +- Existing tests continue to pass with zero fee configuration + diff --git a/.kiro/specs/fee-accounting-tests/requirements.md b/.kiro/specs/fee-accounting-tests/requirements.md new file mode 100644 index 0000000..575ac2f --- /dev/null +++ b/.kiro/specs/fee-accounting-tests/requirements.md @@ -0,0 +1,117 @@ +# Requirements Document + +## Introduction + +This document specifies the requirements for implementing fee accounting functionality in the TalentTrust escrow smart contract. The feature enables the platform to collect fees from milestone releases, properly split fees between stakeholders, handle fractional amounts through rounding, and maintain accurate treasury totals. This is essential for platform sustainability and transparent fee management. + +## Glossary + +- **Escrow_Contract**: The Soroban smart contract that holds funds in escrow and manages milestone-based payments between clients and freelancers +- **Fee**: A percentage-based charge deducted from milestone payments before releasing funds to the freelancer +- **Fee_Rate**: The percentage of a milestone amount that is collected as a fee (e.g., 2.5%) +- **Treasury**: The contract's storage location that accumulates all collected fees +- **Milestone_Release**: The process of transferring funds from escrow to the freelancer after approval +- **Rounding**: The process of converting fractional stroops (Stellar's smallest unit) to whole numbers +- **Stroops**: The smallest unit of currency on the Stellar network (1 XLM = 10,000,000 stroops) +- **Fee_Split**: The distribution of collected fees between multiple recipients (e.g., platform treasury, referral rewards) +- **Net_Amount**: The amount paid to the freelancer after fee deduction (milestone_amount - fee) + +## Requirements + +### Requirement 1: Fee Calculation + +**User Story:** As a platform operator, I want fees to be automatically calculated from milestone releases, so that the platform can sustain operations. + +#### Acceptance Criteria + +1. WHEN a milestone is released, THE Escrow_Contract SHALL calculate the fee as (milestone_amount * Fee_Rate) +2. THE Escrow_Contract SHALL support Fee_Rate values between 0% and 10% inclusive +3. THE Escrow_Contract SHALL calculate the Net_Amount as (milestone_amount - fee) +4. THE Escrow_Contract SHALL ensure that (fee + Net_Amount) equals the original milestone_amount after rounding +5. IF the Fee_Rate is 0%, THEN THE Escrow_Contract SHALL transfer the full milestone_amount to the freelancer with no fee deduction + +### Requirement 2: Fee Rounding Behavior + +**User Story:** As a smart contract developer, I want fractional stroops to be handled correctly through rounding, so that all amounts are valid integers and no value is lost. + +#### Acceptance Criteria + +1. WHEN a calculated fee contains fractional stroops, THE Escrow_Contract SHALL round down to the nearest whole stroop +2. WHEN rounding creates a remainder, THE Escrow_Contract SHALL add the remainder to the Net_Amount paid to the freelancer +3. THE Escrow_Contract SHALL ensure that no stroops are lost during rounding (total in = total out) +4. FOR ALL milestone releases, THE Escrow_Contract SHALL verify that (fee + Net_Amount) equals the original milestone_amount exactly +5. THE Escrow_Contract SHALL handle edge cases where the fee calculation results in 0 stroops due to rounding + +### Requirement 3: Treasury Accumulation + +**User Story:** As a platform operator, I want all collected fees to be tracked in a treasury total, so that I can monitor platform revenue and manage withdrawals. + +#### Acceptance Criteria + +1. WHEN a milestone is released with a fee, THE Escrow_Contract SHALL add the fee amount to the Treasury total +2. THE Escrow_Contract SHALL initialize the Treasury total to 0 when the contract is first deployed +3. THE Escrow_Contract SHALL maintain the Treasury total across multiple milestone releases and multiple escrow contracts +4. THE Escrow_Contract SHALL provide a read-only function to query the current Treasury total +5. THE Escrow_Contract SHALL ensure the Treasury total never decreases except through authorized withdrawal operations + +### Requirement 4: Fee Split Distribution + +**User Story:** As a platform operator, I want fees to be split between multiple recipients, so that referral rewards and partner shares can be distributed automatically. + +#### Acceptance Criteria + +1. WHERE fee splitting is enabled, THE Escrow_Contract SHALL support distributing fees to up to 3 recipients +2. WHEN a fee is split, THE Escrow_Contract SHALL calculate each recipient's share as (fee * recipient_percentage) +3. THE Escrow_Contract SHALL ensure that all recipient percentages sum to exactly 100% +4. WHEN rounding creates remainders in fee splits, THE Escrow_Contract SHALL allocate remainders to the primary treasury recipient +5. THE Escrow_Contract SHALL track each recipient's accumulated fees separately in storage + +### Requirement 5: Fee Configuration + +**User Story:** As a platform administrator, I want to configure fee rates and split percentages, so that the platform can adjust its fee structure as needed. + +#### Acceptance Criteria + +1. THE Escrow_Contract SHALL store the Fee_Rate in persistent contract storage +2. THE Escrow_Contract SHALL allow authorized administrators to update the Fee_Rate +3. WHEN the Fee_Rate is updated, THE Escrow_Contract SHALL apply the new rate only to future milestone releases +4. THE Escrow_Contract SHALL validate that Fee_Rate updates are within the allowed range (0% to 10%) +5. THE Escrow_Contract SHALL emit an event when the Fee_Rate is updated, including the old and new values + +### Requirement 6: Fee Accounting Tests + +**User Story:** As a smart contract developer, I want comprehensive tests for fee accounting, so that I can verify correctness and prevent financial bugs. + +#### Acceptance Criteria + +1. THE Test_Suite SHALL verify fee calculations for milestone amounts ranging from 1 stroop to 1,000,000 XLM +2. THE Test_Suite SHALL test rounding behavior with Fee_Rate values that produce fractional stroops +3. THE Test_Suite SHALL verify Treasury accumulation across multiple milestone releases +4. THE Test_Suite SHALL test fee splits with various percentage combinations that sum to 100% +5. THE Test_Suite SHALL verify that no stroops are lost or created during fee processing (conservation property) +6. THE Test_Suite SHALL test edge cases including zero fees, maximum fees, and minimum milestone amounts +7. THE Test_Suite SHALL achieve minimum 95% code coverage for all fee accounting functions + +### Requirement 7: Fee Accounting Security + +**User Story:** As a security auditor, I want fee accounting to be secure against manipulation, so that funds cannot be stolen or misdirected. + +#### Acceptance Criteria + +1. THE Escrow_Contract SHALL prevent unauthorized addresses from modifying the Fee_Rate +2. THE Escrow_Contract SHALL prevent unauthorized addresses from withdrawing from the Treasury +3. WHEN calculating fees, THE Escrow_Contract SHALL prevent integer overflow for all supported milestone amounts +4. THE Escrow_Contract SHALL prevent fee calculations that would result in negative Net_Amount values +5. THE Escrow_Contract SHALL validate all fee split percentages to prevent total exceeding 100% + +### Requirement 8: Fee Accounting Documentation + +**User Story:** As a code reviewer, I want clear documentation of fee accounting logic, so that I can efficiently review and verify the implementation. + +#### Acceptance Criteria + +1. THE Implementation SHALL include Rust doc comments for all fee accounting functions +2. THE Documentation SHALL explain the rounding strategy and remainder handling +3. THE Documentation SHALL provide examples of fee calculations with actual stroop values +4. THE Documentation SHALL document all fee-related storage keys and data structures +5. THE README SHALL include a section explaining the fee accounting system and how to run fee tests diff --git a/.kiro/specs/fee-accounting-tests/tasks.md b/.kiro/specs/fee-accounting-tests/tasks.md new file mode 100644 index 0000000..890051a --- /dev/null +++ b/.kiro/specs/fee-accounting-tests/tasks.md @@ -0,0 +1,190 @@ +# Implementation Plan: Fee Accounting Tests + +## Overview + +This plan implements fee accounting functionality for the TalentTrust escrow smart contract. The implementation adds fee calculation, treasury accumulation, fee splitting, and comprehensive testing to ensure correctness and security. All fee accounting logic integrates directly into the existing `release_milestone` function to ensure atomic fee processing. + +## Tasks + +- [x] 1. Add fee accounting data structures to lib.rs + - Add `FeeConfig`, `FeeRecipient`, `Treasury`, `FeeCalculation`, and `FeeSplit` structures + - Add storage key constants for fee configuration and treasury + - Define validation constraints (rate_bps 0-1000, max 3 recipients, percentages sum to 10000) + - _Requirements: 5.1, 5.4, 3.2_ + +- [ ] 2. Implement core fee calculation logic + - [x] 2.1 Implement `calculate_fee` internal function + - Calculate fee as `(milestone_amount * rate_bps) / 10000` with floor rounding + - Calculate net amount as `milestone_amount - fee` + - Return `FeeCalculation` with fee_amount, net_amount, and splits + - _Requirements: 1.1, 1.3, 2.1, 2.2_ + + - [ ]* 2.2 Write property test for fee calculation conservation + - **Property 1: Conservation property - fee + net_amount = milestone_amount** + - **Validates: Requirements 1.4, 2.3** + + - [ ]* 2.3 Write unit tests for fee calculation edge cases + - Test zero fee rate (0%) + - Test maximum fee rate (10%) + - Test fractional stroops that round down + - Test minimum amounts where fee rounds to 0 + - _Requirements: 1.5, 2.5, 6.2, 6.6_ + +- [ ] 3. Implement fee split distribution logic + - [x] 3.1 Implement `split_fee` internal function + - Calculate each recipient's share as `(total_fee * percentage_bps) / 10000` + - Round down each share + - Calculate remainder and add to primary recipient + - Return vector of `FeeSplit` entries + - _Requirements: 4.2, 4.4_ + + - [ ]* 3.2 Write property test for fee split conservation + - **Property 2: Split conservation - sum of all splits equals total fee** + - **Validates: Requirements 4.2, 4.4** + + - [ ]* 3.3 Write unit tests for fee split scenarios + - Test 2-recipient split (70/30) + - Test 3-recipient split (50/30/20) + - Test splits with rounding remainders + - Verify primary recipient receives remainder + - _Requirements: 4.1, 4.4, 6.4_ + +- [ ] 4. Implement treasury accumulation + - [ ] 4.1 Implement `update_treasury` internal function + - Load current treasury from storage + - Increment each recipient's balance + - Increment total treasury amount + - Save updated treasury to storage + - _Requirements: 3.1, 3.3_ + + - [ ]* 4.2 Write property test for treasury accumulation + - **Property 3: Treasury monotonicity - treasury total never decreases** + - **Validates: Requirements 3.5** + + - [ ]* 4.3 Write unit tests for treasury tracking + - Test treasury accumulation across multiple releases + - Test per-recipient balance tracking + - Verify treasury total equals sum of recipient balances + - _Requirements: 3.3, 3.4, 4.5, 6.3_ + +- [ ] 5. Checkpoint - Ensure all tests pass + - Ensure all tests pass, ask the user if questions arise. + +- [ ] 6. Add public fee configuration functions + - [ ] 6.1 Implement `configure_fees` function + - Validate caller is admin + - Validate rate_bps is 0-1000 + - Validate recipients (if provided): max 3, percentages sum to 10000 + - Store FeeConfig in persistent storage + - _Requirements: 5.1, 5.2, 5.4, 7.1_ + + - [ ]* 6.2 Write unit tests for fee configuration + - Test valid configuration updates + - Test unauthorized caller (should panic) + - Test invalid rate_bps > 1000 (should panic) + - Test invalid recipient percentages (should panic) + - Test more than 3 recipients (should panic) + - _Requirements: 5.4, 7.1, 7.5_ + +- [ ] 7. Add public treasury query and withdrawal functions + - [ ] 7.1 Implement `get_treasury_total` function + - Load treasury from storage + - Return total accumulated fees + - _Requirements: 3.4_ + + - [ ] 7.2 Implement `get_recipient_balance` function + - Load treasury from storage + - Return balance for specified recipient + - _Requirements: 4.5_ + + - [ ] 7.3 Implement `withdraw_fees` function + - Validate caller is admin + - Validate amount is positive + - Validate amount doesn't exceed recipient balance + - Decrement recipient balance and treasury total + - Transfer funds to recipient + - _Requirements: 3.5, 7.2_ + + - [ ]* 7.4 Write unit tests for treasury queries and withdrawals + - Test get_treasury_total returns correct value + - Test get_recipient_balance for each recipient + - Test successful withdrawal + - Test unauthorized withdrawal (should panic) + - Test withdrawal exceeding balance (should panic) + - Test withdrawal with negative amount (should panic) + - _Requirements: 3.4, 7.2, 7.3_ + +- [ ] 8. Integrate fee accounting into release_milestone + - [ ] 8.1 Modify `release_milestone` function + - Load fee configuration from storage + - Call `calculate_fee` to compute fee and net amount + - If fee > 0, call `update_treasury` with splits + - Transfer net_amount to freelancer (instead of full milestone amount) + - Maintain all existing validation and authorization logic + - _Requirements: 1.1, 1.3, 3.1_ + + - [ ]* 8.2 Write integration tests for release_milestone with fees + - Test milestone release with 2.5% fee + - Test milestone release with 5% fee + - Test milestone release with 0% fee (backward compatibility) + - Test milestone release with fee splitting enabled + - Verify net amount transferred to freelancer + - Verify treasury accumulation after release + - _Requirements: 1.1, 1.3, 1.5, 3.1, 3.3_ + +- [ ] 9. Checkpoint - Ensure all tests pass + - Ensure all tests pass, ask the user if questions arise. + +- [ ] 10. Add comprehensive security tests + - [ ]* 10.1 Write security tests for overflow protection + - Test fee calculation with maximum milestone amounts (1,000,000 XLM) + - Test fee calculation with maximum fee rate (10%) + - Verify no integer overflow occurs + - _Requirements: 6.1, 7.3_ + + - [ ]* 10.2 Write security tests for authorization + - Test configure_fees with unauthorized caller + - Test withdraw_fees with unauthorized caller + - Verify only admin can modify fee configuration + - _Requirements: 7.1, 7.2_ + + - [ ]* 10.3 Write security tests for validation + - Test fee calculation doesn't produce negative net amounts + - Test fee split percentages validation + - Test rate_bps boundary validation + - _Requirements: 7.4, 7.5_ + +- [ ] 11. Add Rust doc comments to all fee accounting functions + - Add doc comments to `FeeConfig`, `FeeRecipient`, `Treasury` structures + - Add doc comments to `calculate_fee`, `split_fee`, `update_treasury` functions + - Add doc comments to `configure_fees`, `get_treasury_total`, `get_recipient_balance`, `withdraw_fees` functions + - Include examples with actual stroop values + - Document rounding strategy and remainder handling + - _Requirements: 8.1, 8.2, 8.3, 8.4_ + +- [ ] 12. Update README.md with fee accounting documentation + - Add "Fee Accounting System" section explaining the feature + - Document fee rate configuration (basis points representation) + - Explain rounding strategy and conservation property + - Document fee splitting functionality + - Provide examples of fee calculations + - Add instructions for running fee accounting tests + - _Requirements: 8.5_ + +- [ ] 13. Final checkpoint - Verify test coverage and run all tests + - Run all tests to ensure 95%+ coverage of fee accounting functions + - Verify all property tests pass + - Verify all unit tests pass + - Verify all integration tests pass + - Verify all security tests pass + - _Requirements: 6.7_ + +## Notes + +- Tasks marked with `*` are optional and can be skipped for faster MVP +- Each task references specific requirements for traceability +- Checkpoints ensure incremental validation +- Property tests validate universal correctness properties (conservation, monotonicity) +- Unit tests validate specific examples and edge cases +- Integration tests verify fee accounting works correctly with existing milestone release logic +- Security tests ensure the implementation is safe against manipulation and overflow diff --git a/contracts/escrow/src/lib.rs b/contracts/escrow/src/lib.rs index d239761..4bd2e45 100644 --- a/contracts/escrow/src/lib.rs +++ b/contracts/escrow/src/lib.rs @@ -635,4 +635,4 @@ impl Escrow { } #[cfg(test)] -mod test; +mod test; \ No newline at end of file diff --git a/contracts/escrow/test_snapshots/test/test_approve_milestone_release_already_approved.1.json b/contracts/escrow/test_snapshots/test/test_approve_milestone_release_already_approved.1.json index 5a5416f..5082bae 100644 --- a/contracts/escrow/test_snapshots/test/test_approve_milestone_release_already_approved.1.json +++ b/contracts/escrow/test_snapshots/test/test_approve_milestone_release_already_approved.1.json @@ -58,8 +58,7 @@ "sub_invocations": [] } ] - ], - [] + ] ], "ledger": { "protocol_version": 22, @@ -76,7 +75,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -89,17 +95,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": "void" - }, { "key": { "symbol": "client" @@ -110,18 +117,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -143,30 +153,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": { - "u64": 0 - } - }, - { - "key": { - "symbol": "approved_by" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - } - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -182,10 +168,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 0 + "i128": { + "hi": 0, + "lo": 0 + } } }, { @@ -195,6 +184,17 @@ "val": { "u32": 1 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } + } } ] } @@ -205,6 +205,45 @@ 4095 ] ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent", + "val": { + "u32": 2 + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], [ { "contract_data": { diff --git a/contracts/escrow/test_snapshots/test/test_approve_milestone_release_client_and_arbiter.1.json b/contracts/escrow/test_snapshots/test/test_approve_milestone_release_client_and_arbiter.1.json index 5b07259..241a486 100644 --- a/contracts/escrow/test_snapshots/test/test_approve_milestone_release_client_and_arbiter.1.json +++ b/contracts/escrow/test_snapshots/test/test_approve_milestone_release_client_and_arbiter.1.json @@ -58,31 +58,6 @@ "sub_invocations": [] } ] - ], - [ - [ - "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", - { - "function": { - "contract_fn": { - "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "function_name": "approve_milestone_release", - "args": [ - { - "u32": 1 - }, - { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" - }, - { - "u32": 0 - } - ] - } - }, - "sub_invocations": [] - } - ] ] ], "ledger": { @@ -100,7 +75,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -113,19 +95,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" - } - }, { "key": { "symbol": "client" @@ -136,18 +117,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -169,30 +153,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": { - "u64": 0 - } - }, - { - "key": { - "symbol": "approved_by" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" - } - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -208,10 +168,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 1 + "i128": { + "hi": 0, + "lo": 0 + } } }, { @@ -221,6 +184,17 @@ "val": { "u32": 1 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } + } } ] } @@ -235,7 +209,13 @@ { "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": "ledger_key_contract_instance", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, "durability": "persistent" } }, @@ -246,15 +226,16 @@ "contract_data": { "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": "ledger_key_contract_instance", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, "durability": "persistent", "val": { - "contract_instance": { - "executable": { - "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - "storage": null - } + "u32": 2 } } }, @@ -266,13 +247,9 @@ [ { "contract_data": { - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 801925984706572462 - } - }, - "durability": "temporary" + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" } }, [ @@ -281,19 +258,22 @@ "data": { "contract_data": { "ext": "v0", - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 801925984706572462 + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null } - }, - "durability": "temporary", - "val": "void" + } } }, "ext": "v0" }, - 6311999 + 4095 ] ], [ @@ -302,7 +282,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 5541220902715666415 + "nonce": 801925984706572462 } }, "durability": "temporary" @@ -317,7 +297,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 5541220902715666415 + "nonce": 801925984706572462 } }, "durability": "temporary", @@ -332,10 +312,10 @@ [ { "contract_data": { - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 1033654523790656264 + "nonce": 5541220902715666415 } }, "durability": "temporary" @@ -347,10 +327,10 @@ "data": { "contract_data": { "ext": "v0", - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 1033654523790656264 + "nonce": 5541220902715666415 } }, "durability": "temporary", diff --git a/contracts/escrow/test_snapshots/test/test_approve_milestone_release_client_only.1.json b/contracts/escrow/test_snapshots/test/test_approve_milestone_release_client_only.1.json index 12a6fa6..5082bae 100644 --- a/contracts/escrow/test_snapshots/test/test_approve_milestone_release_client_only.1.json +++ b/contracts/escrow/test_snapshots/test/test_approve_milestone_release_client_only.1.json @@ -75,7 +75,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -88,17 +95,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": "void" - }, { "key": { "symbol": "client" @@ -109,18 +117,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -142,30 +153,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": { - "u64": 0 - } - }, - { - "key": { - "symbol": "approved_by" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - } - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -181,10 +168,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 0 + "i128": { + "hi": 0, + "lo": 0 + } } }, { @@ -194,8 +184,58 @@ "val": { "u32": 1 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" } ] + }, + "durability": "persistent", + "val": { + "u32": 2 } } }, diff --git a/contracts/escrow/test_snapshots/test/test_approve_milestone_release_invalid_id.1.json b/contracts/escrow/test_snapshots/test/test_approve_milestone_release_invalid_id.1.json index d28872c..292c28f 100644 --- a/contracts/escrow/test_snapshots/test/test_approve_milestone_release_invalid_id.1.json +++ b/contracts/escrow/test_snapshots/test/test_approve_milestone_release_invalid_id.1.json @@ -51,7 +51,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -64,17 +71,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": "void" - }, { "key": { "symbol": "client" @@ -85,18 +93,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -118,26 +129,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": "void" - }, - { - "key": { - "symbol": "approved_by" - }, - "val": "void" - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -153,10 +144,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 0 + "i128": { + "hi": 0, + "lo": 0 + } } }, { @@ -166,8 +160,58 @@ "val": { "u32": 1 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" } ] + }, + "durability": "persistent", + "val": { + "u32": 2 } } }, diff --git a/contracts/escrow/test_snapshots/test/test_approve_milestone_release_unauthorized.1.json b/contracts/escrow/test_snapshots/test/test_approve_milestone_release_unauthorized.1.json index c6413f7..5082bae 100644 --- a/contracts/escrow/test_snapshots/test/test_approve_milestone_release_unauthorized.1.json +++ b/contracts/escrow/test_snapshots/test/test_approve_milestone_release_unauthorized.1.json @@ -1,6 +1,6 @@ { "generators": { - "address": 4, + "address": 3, "nonce": 0 }, "auth": [ @@ -34,7 +34,31 @@ } ] ], - [] + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "approve_milestone_release", + "args": [ + { + "u32": 1 + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "u32": 0 + } + ] + } + }, + "sub_invocations": [] + } + ] + ] ], "ledger": { "protocol_version": 22, @@ -51,7 +75,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -64,17 +95,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": "void" - }, { "key": { "symbol": "client" @@ -85,18 +117,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -118,26 +153,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": "void" - }, - { - "key": { - "symbol": "approved_by" - }, - "val": "void" - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -153,10 +168,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 0 + "i128": { + "hi": 0, + "lo": 0 + } } }, { @@ -166,6 +184,17 @@ "val": { "u32": 1 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } + } } ] } @@ -176,6 +205,45 @@ 4095 ] ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent", + "val": { + "u32": 2 + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], [ { "contract_data": { @@ -241,6 +309,39 @@ 6311999 ] ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 5541220902715666415 + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 5541220902715666415 + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], [ { "contract_code": { diff --git a/contracts/escrow/test_snapshots/test/test_contract_completion_all_milestones_released.1.json b/contracts/escrow/test_snapshots/test/test_contract_completion_all_milestones_released.1.json index 04a70a8..852ec49 100644 --- a/contracts/escrow/test_snapshots/test/test_contract_completion_all_milestones_released.1.json +++ b/contracts/escrow/test_snapshots/test/test_contract_completion_all_milestones_released.1.json @@ -59,31 +59,7 @@ } ] ], - [ - [ - "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - { - "function": { - "contract_fn": { - "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "function_name": "release_milestone", - "args": [ - { - "u32": 1 - }, - { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - }, - { - "u32": 0 - } - ] - } - }, - "sub_invocations": [] - } - ] - ], + [], [ [ "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", @@ -109,31 +85,7 @@ } ] ], - [ - [ - "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - { - "function": { - "contract_fn": { - "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "function_name": "release_milestone", - "args": [ - { - "u32": 1 - }, - { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - }, - { - "u32": 1 - } - ] - } - }, - "sub_invocations": [] - } - ] - ] + [] ], "ledger": { "protocol_version": 22, @@ -150,7 +102,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -163,17 +122,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": "void" - }, { "key": { "symbol": "client" @@ -184,18 +144,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 30000000000 + } } }, { @@ -217,30 +180,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": { - "u64": 0 - } - }, - { - "key": { - "symbol": "approved_by" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - } - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -264,30 +203,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": { - "u64": 0 - } - }, - { - "key": { - "symbol": "approved_by" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - } - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -303,10 +218,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 0 + "i128": { + "hi": 0, + "lo": 30000000000 + } } }, { @@ -316,6 +234,17 @@ "val": { "u32": 2 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 30000000000 + } + } } ] } @@ -330,7 +259,13 @@ { "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": "ledger_key_contract_instance", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, "durability": "persistent" } }, @@ -341,15 +276,16 @@ "contract_data": { "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": "ledger_key_contract_instance", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, "durability": "persistent", "val": { - "contract_instance": { - "executable": { - "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - "storage": null - } + "u32": 2 } } }, @@ -361,46 +297,9 @@ [ { "contract_data": { - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 801925984706572462 - } - }, - "durability": "temporary" - } - }, - [ - { - "last_modified_ledger_seq": 0, - "data": { - "contract_data": { - "ext": "v0", - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 801925984706572462 - } - }, - "durability": "temporary", - "val": "void" - } - }, - "ext": "v0" - }, - 6311999 - ] - ], - [ - { - "contract_data": { - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 1033654523790656264 - } - }, - "durability": "temporary" + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" } }, [ @@ -409,19 +308,22 @@ "data": { "contract_data": { "ext": "v0", - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 1033654523790656264 + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null } - }, - "durability": "temporary", - "val": "void" + } } }, "ext": "v0" }, - 6311999 + 4095 ] ], [ @@ -430,7 +332,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 2032731177588607455 + "nonce": 801925984706572462 } }, "durability": "temporary" @@ -445,7 +347,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 2032731177588607455 + "nonce": 801925984706572462 } }, "durability": "temporary", @@ -463,7 +365,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 4837995959683129791 + "nonce": 1033654523790656264 } }, "durability": "temporary" @@ -478,7 +380,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 4837995959683129791 + "nonce": 1033654523790656264 } }, "durability": "temporary", diff --git a/contracts/escrow/test_snapshots/test/test_create_contract.1.json b/contracts/escrow/test_snapshots/test/test_create_contract.1.json index dab4086..47fd310 100644 --- a/contracts/escrow/test_snapshots/test/test_create_contract.1.json +++ b/contracts/escrow/test_snapshots/test/test_create_contract.1.json @@ -22,9 +22,15 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, - "key": "ledger_key_contract_instance", "durability": "persistent" } }, @@ -35,125 +41,109 @@ "contract_data": { "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": "ledger_key_contract_instance", + "key": { + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] + }, "durability": "persistent", "val": { - "contract_instance": { - "executable": { - "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + "map": [ + { + "key": { + "symbol": "client" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } }, - "storage": [ - { - "key": { - "u32": 1 - }, - "val": { - "map": [ - { - "key": { - "symbol": "client" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - } - }, - { - "key": { - "symbol": "freelancer" + { + "key": { + "symbol": "freelancer" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "symbol": "funded_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 0 + } + } + }, + { + "key": { + "symbol": "milestones" + }, + "val": { + "vec": [ + { + "map": [ + { + "key": { + "symbol": "amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 2000000000 + } + } }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + { + "key": { + "symbol": "released" + }, + "val": { + "bool": false + } } - }, - { - "key": { - "symbol": "milestones" - }, - "val": { - "vec": [ - { - "map": [ - { - "key": { - "symbol": "amount" - }, - "val": { - "i128": { - "hi": 0, - "lo": 2000000000 - } - } - }, - { - "key": { - "symbol": "released" - }, - "val": { - "bool": false - } - } - ] - }, - { - "map": [ - { - "key": { - "symbol": "amount" - }, - "val": { - "i128": { - "hi": 0, - "lo": 4000000000 - } - } - }, - { - "key": { - "symbol": "released" - }, - "val": { - "bool": false - } - } - ] - }, - { - "map": [ - { - "key": { - "symbol": "amount" - }, - "val": { - "i128": { - "hi": 0, - "lo": 6000000000 - } - } - }, - { - "key": { - "symbol": "released" - }, - "val": { - "bool": false - } - } - ] + ] + }, + { + "map": [ + { + "key": { + "symbol": "amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 4000000000 } - ] - } - }, - { - "key": { - "symbol": "status" + } }, -<<<<<<< feature/contracts-43-timeout-behavior-tests { "key": { - "symbol": "deadline_at" + "symbol": "released" + }, + "val": { + "bool": false + } + } + ] + }, + { + "map": [ + { + "key": { + "symbol": "amount" }, "val": { - "u64": 604800 + "i128": { + "hi": 0, + "lo": 6000000000 + } } }, { @@ -163,13 +153,20 @@ "val": { "bool": false } -======= - "val": { - "u32": 0 ->>>>>>> main } - } - ] + ] + } + ] + } + }, + { + "key": { + "symbol": "released_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 0 } } }, @@ -180,6 +177,17 @@ "val": { "u32": 0 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 12000000000 + } + } } ] } @@ -190,6 +198,45 @@ 4095 ] ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent", + "val": { + "u32": 2 + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], [ { "contract_data": { @@ -213,7 +260,6 @@ "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" }, "storage": null - ] } } } diff --git a/contracts/escrow/test_snapshots/test/test_create_contract_with_arbiter.1.json b/contracts/escrow/test_snapshots/test/test_create_contract_with_arbiter.1.json index ddeada1..6227335 100644 --- a/contracts/escrow/test_snapshots/test/test_create_contract_with_arbiter.1.json +++ b/contracts/escrow/test_snapshots/test/test_create_contract_with_arbiter.1.json @@ -22,7 +22,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -35,19 +42,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" - } - }, { "key": { "symbol": "client" @@ -58,18 +64,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 0 + } } }, { @@ -91,26 +100,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": "void" - }, - { - "key": { - "symbol": "approved_by" - }, - "val": "void" - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -126,10 +115,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 1 + "i128": { + "hi": 0, + "lo": 0 + } } }, { @@ -139,8 +131,58 @@ "val": { "u32": 0 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" } ] + }, + "durability": "persistent", + "val": { + "u32": 2 } } }, diff --git a/contracts/escrow/test_snapshots/test/test_deposit_funds.1.json b/contracts/escrow/test_snapshots/test/test_deposit_funds.1.json index fb9e16a..f346936 100644 --- a/contracts/escrow/test_snapshots/test/test_deposit_funds.1.json +++ b/contracts/escrow/test_snapshots/test/test_deposit_funds.1.json @@ -1,6 +1,5 @@ { "generators": { - "address": 1, "address": 3, "nonce": 0 }, @@ -35,9 +34,6 @@ } ] ] - [] - [], - [] ], "ledger": { "protocol_version": 22, @@ -54,7 +50,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -67,17 +70,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": "void" - }, { "key": { "symbol": "client" @@ -88,18 +92,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -121,26 +128,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": "void" - }, - { - "key": { - "symbol": "approved_by" - }, - "val": "void" - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -156,10 +143,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 0 + "i128": { + "hi": 0, + "lo": 0 + } } }, { @@ -169,8 +159,58 @@ "val": { "u32": 1 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" } ] + }, + "durability": "persistent", + "val": { + "u32": 2 } } }, @@ -201,96 +241,7 @@ "executable": { "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" }, - "storage": [ - { - "key": { - "u32": 1 - }, - "val": { - "map": [ - { - "key": { - "symbol": "client" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - } - }, - { - "key": { - "symbol": "freelancer" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" - } - }, - { - "key": { - "symbol": "milestones" - }, - "val": { - "vec": [ - { - "map": [ - { - "key": { - "symbol": "amount" - }, - "val": { - "i128": { - "hi": 0, - "lo": 2000000000 - } - } - }, - { - "key": { - "symbol": "released" - }, - "val": { - "bool": false - } - } - ] - }, - { - "map": [ - { - "key": { - "symbol": "amount" - }, - "val": { - "i128": { - "hi": 0, - "lo": 4000000000 - } - } - }, - { - "key": { - "symbol": "released" - }, - "val": { - "bool": false - } - } - ] - } - ] - } - }, - { - "key": { - "symbol": "status" - }, - "val": { - "u32": 1 - } - } - ] - } - } - ] + "storage": null } } } diff --git a/contracts/escrow/test_snapshots/test/test_deposit_funds_wrong_amount.1.json b/contracts/escrow/test_snapshots/test/test_deposit_funds_wrong_amount.1.json index 4690a44..740df29 100644 --- a/contracts/escrow/test_snapshots/test/test_deposit_funds_wrong_amount.1.json +++ b/contracts/escrow/test_snapshots/test/test_deposit_funds_wrong_amount.1.json @@ -6,7 +6,34 @@ "auth": [ [], [], - [] + [ + [ + "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + { + "function": { + "contract_fn": { + "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "function_name": "deposit_funds", + "args": [ + { + "u32": 1 + }, + { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + }, + { + "i128": { + "hi": 0, + "lo": 5000000000 + } + } + ] + } + }, + "sub_invocations": [] + } + ] + ] ], "ledger": { "protocol_version": 22, @@ -23,7 +50,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -36,17 +70,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": "void" - }, { "key": { "symbol": "client" @@ -57,18 +92,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 5000000000 + } } }, { @@ -90,26 +128,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": "void" - }, - { - "key": { - "symbol": "approved_by" - }, - "val": "void" - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -125,10 +143,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 0 + "i128": { + "hi": 0, + "lo": 0 + } } }, { @@ -138,8 +159,58 @@ "val": { "u32": 0 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" } ] + }, + "durability": "persistent", + "val": { + "u32": 2 } } }, @@ -180,6 +251,39 @@ 4095 ] ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", + "key": { + "ledger_key_nonce": { + "nonce": 801925984706572462 + } + }, + "durability": "temporary", + "val": "void" + } + }, + "ext": "v0" + }, + 6311999 + ] + ], [ { "contract_code": { diff --git a/contracts/escrow/test_snapshots/test/test_edge_cases.1.json b/contracts/escrow/test_snapshots/test/test_edge_cases.1.json index 1c57e33..f4d5940 100644 --- a/contracts/escrow/test_snapshots/test/test_edge_cases.1.json +++ b/contracts/escrow/test_snapshots/test/test_edge_cases.1.json @@ -23,7 +23,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -36,17 +43,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": "void" - }, { "key": { "symbol": "client" @@ -57,18 +65,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 0 + } } }, { @@ -86,28 +97,143 @@ "val": { "i128": { "hi": 0, - "lo": 1000000000 + "lo": 10000000 } } }, { "key": { - "symbol": "approval_timestamp" - }, - "val": "void" - }, - { - "key": { - "symbol": "approved_by" + "symbol": "released" }, - "val": "void" - }, + "val": { + "bool": false + } + } + ] + } + ] + } + }, + { + "key": { + "symbol": "released_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 0 + } + } + }, + { + "key": { + "symbol": "status" + }, + "val": { + "u32": 0 + } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 2 + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 2 + } + ] + }, + "durability": "persistent", + "val": { + "map": [ + { + "key": { + "symbol": "client" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" + } + }, + { + "key": { + "symbol": "freelancer" + }, + "val": { + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + } + }, + { + "key": { + "symbol": "funded_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 0 + } + } + }, + { + "key": { + "symbol": "milestones" + }, + "val": { + "vec": [ + { + "map": [ { "key": { - "symbol": "deadline_at" + "symbol": "amount" }, "val": { - "u64": 604800 + "i128": { + "hi": 0, + "lo": 1000000000 + } } }, { @@ -133,26 +259,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": "void" - }, - { - "key": { - "symbol": "approved_by" - }, - "val": "void" - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -176,26 +282,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": "void" - }, - { - "key": { - "symbol": "approved_by" - }, - "val": "void" - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -219,26 +305,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": "void" - }, - { - "key": { - "symbol": "approved_by" - }, - "val": "void" - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -254,10 +320,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 0 + "i128": { + "hi": 0, + "lo": 0 + } } }, { @@ -267,6 +336,17 @@ "val": { "u32": 0 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } + } } ] } @@ -277,6 +357,45 @@ 4095 ] ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent", + "val": { + "u32": 3 + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], [ { "contract_data": { diff --git a/contracts/escrow/test_snapshots/test/test_release_milestone_already_released.1.json b/contracts/escrow/test_snapshots/test/test_release_milestone_already_released.1.json index d68ca6c..8c642ca 100644 --- a/contracts/escrow/test_snapshots/test/test_release_milestone_already_released.1.json +++ b/contracts/escrow/test_snapshots/test/test_release_milestone_already_released.1.json @@ -1,6 +1,5 @@ { "generators": { - "address": 1, "address": 3, "nonce": 0 }, @@ -25,7 +24,7 @@ { "i128": { "hi": 0, - "lo": 30000000000 + "lo": 10000000000 } } ] @@ -60,31 +59,6 @@ } ] ], - [ - [ - "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - { - "function": { - "contract_fn": { - "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "function_name": "release_milestone", - "args": [ - { - "u32": 1 - }, - { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - }, - { - "u32": 0 - } - ] - } - }, - "sub_invocations": [] - } - ] - ], [] ], "ledger": { @@ -102,7 +76,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -115,17 +96,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": "void" - }, { "key": { "symbol": "client" @@ -136,18 +118,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -169,30 +154,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": { - "u64": 0 - } - }, - { - "key": { - "symbol": "approved_by" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - } - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -202,59 +163,19 @@ } } ] - }, - { - "map": [ - { - "key": { - "symbol": "amount" - }, - "val": { - "i128": { - "hi": 0, - "lo": 20000000000 - } - } - }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": "void" - }, - { - "key": { - "symbol": "approved_by" - }, - "val": "void" - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, - { - "key": { - "symbol": "released" - }, - "val": { - "bool": false - } - } - ] } ] } }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 0 + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -262,7 +183,18 @@ "symbol": "status" }, "val": { - "u32": 1 + "u32": 2 + } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } } } ] @@ -278,7 +210,13 @@ { "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": "ledger_key_contract_instance", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, "durability": "persistent" } }, @@ -289,15 +227,16 @@ "contract_data": { "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": "ledger_key_contract_instance", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, "durability": "persistent", "val": { - "contract_instance": { - "executable": { - "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - "storage": null - } + "u32": 2 } } }, @@ -309,13 +248,9 @@ [ { "contract_data": { - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 801925984706572462 - } - }, - "durability": "temporary" + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" } }, [ @@ -324,19 +259,22 @@ "data": { "contract_data": { "ext": "v0", - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 801925984706572462 + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null } - }, - "durability": "temporary", - "val": "void" + } } }, "ext": "v0" }, - 6311999 + 4095 ] ], [ @@ -345,7 +283,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 1033654523790656264 + "nonce": 801925984706572462 } }, "durability": "temporary" @@ -360,7 +298,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 1033654523790656264 + "nonce": 801925984706572462 } }, "durability": "temporary", diff --git a/contracts/escrow/test_snapshots/test/test_release_milestone_arbiter_only.1.json b/contracts/escrow/test_snapshots/test/test_release_milestone_arbiter_only.1.json index eccae96..1b51445 100644 --- a/contracts/escrow/test_snapshots/test/test_release_milestone_arbiter_only.1.json +++ b/contracts/escrow/test_snapshots/test/test_release_milestone_arbiter_only.1.json @@ -59,31 +59,7 @@ } ] ], - [ - [ - "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", - { - "function": { - "contract_fn": { - "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "function_name": "release_milestone", - "args": [ - { - "u32": 1 - }, - { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" - }, - { - "u32": 0 - } - ] - } - }, - "sub_invocations": [] - } - ] - ] + [] ], "ledger": { "protocol_version": 22, @@ -100,7 +76,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -113,19 +96,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" - } - }, { "key": { "symbol": "client" @@ -136,18 +118,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -169,30 +154,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": { - "u64": 0 - } - }, - { - "key": { - "symbol": "approved_by" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" - } - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -208,10 +169,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 2 + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -221,6 +185,17 @@ "val": { "u32": 2 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } + } } ] } @@ -235,7 +210,13 @@ { "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": "ledger_key_contract_instance", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, "durability": "persistent" } }, @@ -246,15 +227,16 @@ "contract_data": { "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": "ledger_key_contract_instance", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, "durability": "persistent", "val": { - "contract_instance": { - "executable": { - "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - "storage": null - } + "u32": 2 } } }, @@ -266,13 +248,9 @@ [ { "contract_data": { - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 801925984706572462 - } - }, - "durability": "temporary" + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" } }, [ @@ -281,28 +259,31 @@ "data": { "contract_data": { "ext": "v0", - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 801925984706572462 + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null } - }, - "durability": "temporary", - "val": "void" + } } }, "ext": "v0" }, - 6311999 + 4095 ] ], [ { "contract_data": { - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 1033654523790656264 + "nonce": 801925984706572462 } }, "durability": "temporary" @@ -314,10 +295,10 @@ "data": { "contract_data": { "ext": "v0", - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 1033654523790656264 + "nonce": 801925984706572462 } }, "durability": "temporary", diff --git a/contracts/escrow/test_snapshots/test/test_release_milestone_client_only.1.json b/contracts/escrow/test_snapshots/test/test_release_milestone_client_only.1.json index f9cdd31..8c642ca 100644 --- a/contracts/escrow/test_snapshots/test/test_release_milestone_client_only.1.json +++ b/contracts/escrow/test_snapshots/test/test_release_milestone_client_only.1.json @@ -59,31 +59,7 @@ } ] ], - [ - [ - "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - { - "function": { - "contract_fn": { - "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "function_name": "release_milestone", - "args": [ - { - "u32": 1 - }, - { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - }, - { - "u32": 0 - } - ] - } - }, - "sub_invocations": [] - } - ] - ] + [] ], "ledger": { "protocol_version": 22, @@ -100,7 +76,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -113,17 +96,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": "void" - }, { "key": { "symbol": "client" @@ -134,18 +118,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -167,30 +154,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": { - "u64": 0 - } - }, - { - "key": { - "symbol": "approved_by" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - } - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -206,10 +169,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 0 + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -219,6 +185,17 @@ "val": { "u32": 2 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } + } } ] } @@ -233,7 +210,13 @@ { "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": "ledger_key_contract_instance", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, "durability": "persistent" } }, @@ -244,15 +227,16 @@ "contract_data": { "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": "ledger_key_contract_instance", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, "durability": "persistent", "val": { - "contract_instance": { - "executable": { - "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - "storage": null - } + "u32": 2 } } }, @@ -264,13 +248,9 @@ [ { "contract_data": { - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 801925984706572462 - } - }, - "durability": "temporary" + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" } }, [ @@ -279,19 +259,22 @@ "data": { "contract_data": { "ext": "v0", - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 801925984706572462 + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null } - }, - "durability": "temporary", - "val": "void" + } } }, "ext": "v0" }, - 6311999 + 4095 ] ], [ @@ -300,7 +283,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 1033654523790656264 + "nonce": 801925984706572462 } }, "durability": "temporary" @@ -315,7 +298,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 1033654523790656264 + "nonce": 801925984706572462 } }, "durability": "temporary", diff --git a/contracts/escrow/test_snapshots/test/test_release_milestone_multi_sig.1.json b/contracts/escrow/test_snapshots/test/test_release_milestone_multi_sig.1.json index 388b483..ac21705 100644 --- a/contracts/escrow/test_snapshots/test/test_release_milestone_multi_sig.1.json +++ b/contracts/escrow/test_snapshots/test/test_release_milestone_multi_sig.1.json @@ -59,31 +59,7 @@ } ] ], - [ - [ - "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - { - "function": { - "contract_fn": { - "contract_address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "function_name": "release_milestone", - "args": [ - { - "u32": 1 - }, - { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - }, - { - "u32": 0 - } - ] - } - }, - "sub_invocations": [] - } - ] - ] + [] ], "ledger": { "protocol_version": 22, @@ -100,7 +76,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -113,19 +96,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAITA4" - } - }, { "key": { "symbol": "client" @@ -136,18 +118,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -169,30 +154,6 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": { - "u64": 0 - } - }, - { - "key": { - "symbol": "approved_by" - }, - "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4" - } - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" @@ -208,10 +169,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 3 + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -221,6 +185,17 @@ "val": { "u32": 2 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } + } } ] } @@ -235,7 +210,13 @@ { "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": "ledger_key_contract_instance", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, "durability": "persistent" } }, @@ -246,15 +227,16 @@ "contract_data": { "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", - "key": "ledger_key_contract_instance", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, "durability": "persistent", "val": { - "contract_instance": { - "executable": { - "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" - }, - "storage": null - } + "u32": 2 } } }, @@ -266,13 +248,9 @@ [ { "contract_data": { - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 801925984706572462 - } - }, - "durability": "temporary" + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent" } }, [ @@ -281,19 +259,22 @@ "data": { "contract_data": { "ext": "v0", - "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", - "key": { - "ledger_key_nonce": { - "nonce": 801925984706572462 + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": "ledger_key_contract_instance", + "durability": "persistent", + "val": { + "contract_instance": { + "executable": { + "wasm": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "storage": null } - }, - "durability": "temporary", - "val": "void" + } } }, "ext": "v0" }, - 6311999 + 4095 ] ], [ @@ -302,7 +283,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 1033654523790656264 + "nonce": 801925984706572462 } }, "durability": "temporary" @@ -317,7 +298,7 @@ "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFCT4", "key": { "ledger_key_nonce": { - "nonce": 1033654523790656264 + "nonce": 801925984706572462 } }, "durability": "temporary", diff --git a/contracts/escrow/test_snapshots/test/test_release_milestone_no_approval.1.json b/contracts/escrow/test_snapshots/test/test_release_milestone_no_approval.1.json index d28872c..4877e2f 100644 --- a/contracts/escrow/test_snapshots/test/test_release_milestone_no_approval.1.json +++ b/contracts/escrow/test_snapshots/test/test_release_milestone_no_approval.1.json @@ -51,7 +51,14 @@ "contract_data": { "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent" } @@ -64,17 +71,18 @@ "ext": "v0", "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", "key": { - "symbol": "contract" + "vec": [ + { + "symbol": "Contract" + }, + { + "u32": 1 + } + ] }, "durability": "persistent", "val": { "map": [ - { - "key": { - "symbol": "arbiter" - }, - "val": "void" - }, { "key": { "symbol": "client" @@ -85,18 +93,21 @@ }, { "key": { - "symbol": "created_at" + "symbol": "freelancer" }, "val": { - "u64": 0 + "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" } }, { "key": { - "symbol": "freelancer" + "symbol": "funded_amount" }, "val": { - "address": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHK3M" + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -118,32 +129,12 @@ } } }, - { - "key": { - "symbol": "approval_timestamp" - }, - "val": "void" - }, - { - "key": { - "symbol": "approved_by" - }, - "val": "void" - }, - { - "key": { - "symbol": "deadline_at" - }, - "val": { - "u64": 604800 - } - }, { "key": { "symbol": "released" }, "val": { - "bool": false + "bool": true } } ] @@ -153,10 +144,13 @@ }, { "key": { - "symbol": "release_auth" + "symbol": "released_amount" }, "val": { - "u32": 0 + "i128": { + "hi": 0, + "lo": 10000000000 + } } }, { @@ -164,10 +158,60 @@ "symbol": "status" }, "val": { - "u32": 1 + "u32": 2 } + }, + { + "key": { + "symbol": "total_amount" + }, + "val": { + "i128": { + "hi": 0, + "lo": 10000000000 + } + } + } + ] + } + } + }, + "ext": "v0" + }, + 4095 + ] + ], + [ + { + "contract_data": { + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" + } + ] + }, + "durability": "persistent" + } + }, + [ + { + "last_modified_ledger_seq": 0, + "data": { + "contract_data": { + "ext": "v0", + "contract": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM", + "key": { + "vec": [ + { + "symbol": "NextContractId" } ] + }, + "durability": "persistent", + "val": { + "u32": 2 } } },