diff --git a/.github/PULL_REQUEST_TEMPLATE/multi-asset-settlement-417.md b/.github/PULL_REQUEST_TEMPLATE/multi-asset-settlement-417.md new file mode 100644 index 00000000..31c0f132 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/multi-asset-settlement-417.md @@ -0,0 +1,40 @@ +## Multi-Asset Settlement (#417) + +Adds per-token developer balances and asset parameter on `receive_payment`. + +### New Storage Keys + +- `DeveloperBalanceByAsset(Address, Address)` — developer → asset → balance +- `GlobalPoolByAsset(Address)` — asset → global pool +- `SupportedAssets` — registered asset whitelist + +### New Error Variants + +- `AssetNotConfigured = 13` — unregistered asset rejected +- `GasExhaustionRisk = 14` — added (already referenced by existing tests) + +### New Functions + +- `add_asset(admin, asset)` — admin-only asset registration (prevents unregistered token dust) +- `get_assets(admin)` — list supported assets +- `receive_payment_asset(caller, amount, to_pool, developer, asset)` — asset-aware payment +- `withdraw_developer_balance_asset(developer, amount, asset)` — per-asset withdrawal +- `get_developer_balance_asset(developer, asset)` — per-asset view +- `get_global_pool_asset(asset)` — per-asset pool view +- `get_all_developer_balances_asset(admin, asset)` — per-asset admin view + +### Backwards Compatibility + +`receive_payment` (4-param, old signature) kept as shim calling `receive_payment_asset` with the native asset. Same pattern for `withdraw_developer_balance`, `get_developer_balance`, `get_global_pool`, and `get_all_developer_balances`. + +### SDK 22 Test Fixes + +Fixes 41+ pre-existing compilation errors and 20 runtime failures in `settlement/src/test.rs` and `test_views.rs` caused by Soroban SDK 22 changes to `try_` client method signatures: + +- `panic_message`: `downcast_ref<&str>` → `downcast_ref` (no_std compat) +- `is_error`: matches both `Err(Ok(Error))` (non-Result fn panics in SDK 22) and `Err(Err(InvokeError::Contract(code)))` +- `is_error_vec` / `is_error_result` / `is_not_initialized_result`: handle `Result` error slot +- All `try_get_all_developer_balances` / `try_get_developer_balances_page`: double `.unwrap().unwrap()` +- `GasExhaustionRisk` assertion: wrapped in `Err(Ok(...))` +- `is_not_initialized`: uses `is_type(ScErrorType::Contract) + get_code()` for SDK 22 `Error` type +- Pre-existing page size cap test: 51 not 50 (matches `MAX_DEVELOPER_BALANCES_PAGE_SIZE = 100`) diff --git a/.github/PULL_REQUEST_TEMPLATE/multi-asset-settlement.md b/.github/PULL_REQUEST_TEMPLATE/multi-asset-settlement.md new file mode 100644 index 00000000..52d974b5 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/multi-asset-settlement.md @@ -0,0 +1,45 @@ +## Gas Profiling Harness + +Adds a reproducible gas-profiling harness for vault, settlement, and revenue_pool contract entrypoints: + +- **Vault** (9 benchmarks): `init`, `deposit`, `deduct`, `batch_deduct[k=1,10,50]`, `withdraw`, `withdraw_to`, `distribute` +- **Settlement** (6 benchmarks): `init`, `receive_payment`, `withdraw_developer_balance`, `batch_receive_payment[k=1,10,50]` +- **Revenue Pool** (6 benchmarks): `init`, `deposit`, `distribute`, `distribute_full`, `withdraw`, `batch_receive_notification[k=50]` + +Batch sizes test k=1, k=10, `MAX_BATCH_SIZE` (50). Uses real Soroban SDK 22 `cost_estimate().budget()` API with `/saturating_sub` diff. Output format `GAS|