Skip to content

Commit 4727416

Browse files
Merge branch 'main' into feat/role-management-extended-tests
2 parents 46896b2 + 50e2047 commit 4727416

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+8262
-6930
lines changed

PR-d.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
### Description
2+
Implements a query function to retrieve pool details by pool ID with proper error handling and gas-optimized storage access.
3+
4+
### Changes Made
5+
6+
**Data Structures:**
7+
- Added `Pool` struct containing `pool_id`, `name`, `total_liquidity`, `token_a`, `token_b`, `fee_rate`, `is_active`, `status`, and `end_time` fields
8+
- Added `DataKey` enum for type-safe storage key management
9+
- Added `Error` enum with `PoolNotFound` error variant using `#[contracterror]` macro
10+
11+
**Functions:**
12+
- `get_pool(pool_id: u64)` - Returns `Result<Pool, Error>` for pool retrieval
13+
- Uses persistent storage for data access
14+
- Returns `PoolNotFound` error for non-existent pools
15+
- Single storage lookup for gas efficiency
16+
- `create_pool()` - Helper function for creating pools (used in tests)
17+
18+
**Tests:**
19+
- `test_get_pool()` - Verifies successful pool retrieval with all fields
20+
- `test_get_pool_not_found()` - Validates error handling for invalid pool IDs
21+
22+
### Gas Optimization
23+
- Direct storage access with `.get()` and `.ok_or()` combinator
24+
- Single lookup operation per query
25+
- No unnecessary iterations or computations
26+
27+
### Acceptance Criteria
28+
- Returns complete pool data structure
29+
- Handles invalid pool IDs with appropriate errors
30+
- Gas-optimized implementation
31+
- All tests passing
32+
```

contract/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ target
44
# Local settings
55
.soroban
66
.stellar
7+
8+
# Test snapshots
9+
test_snapshots
10+

0 commit comments

Comments
 (0)