Skip to content

reservation: add SDK module with instruction builders and account parsers#275

Merged
martinsander00 merged 3 commits intomainfrom
ms/reservation-sdk
Mar 5, 2026
Merged

reservation: add SDK module with instruction builders and account parsers#275
martinsander00 merged 3 commits intomainfrom
ms/reservation-sdk

Conversation

@martinsander00
Copy link
Copy Markdown
Contributor

@martinsander00 martinsander00 commented Mar 2, 2026

Summary

  • Add reservation SDK with PDA helpers, instruction builders (InitializeClientSeat, InitializePaymentEscrow, ClosePaymentEscrow), and raw-byte parsers for ClientSeat, PaymentEscrow, DeviceHistory, and MetroHistory on-chain accounts

Lines of code

Added Removed
+577 -2

Related PRs

Part 1 of #274

@martinsander00 martinsander00 force-pushed the ms/reservation-sdk branch 3 times, most recently from 65255ab to 7af7ba9 Compare March 4, 2026 00:26
…sers

Add reservation SDK with PDA helpers, instruction builders
(InitializeClientSeat, InitializePaymentEscrow, ClosePaymentEscrow),
and raw-byte parsers for ClientSeat, PaymentEscrow, DeviceHistory,
and MetroHistory on-chain accounts.

Part 1 of #274
… and ClientSeat layout

- Add FundPaymentEscrowUsdc(u64) instruction variant with discriminator
- Add FundPaymentEscrowUsdcAccounts (10 accounts) for funding escrows
- Fix ClosePaymentEscrowAccounts: insert execution_controller at index 1 (now 8 accounts)
- Update ClientSeat parse offsets for new on-chain layout: flags at 48,
  funded_epoch at 56, active_epoch at 64, funding_index at 72
- parse_client_seat now returns (device_key, client_ip, tenure, funded_epoch, active_epoch)
@martinsander00 martinsander00 merged commit 7cc4444 into main Mar 5, 2026
@martinsander00 martinsander00 deleted the ms/reservation-sdk branch March 5, 2026 18:21
karl-dz pushed a commit that referenced this pull request Mar 6, 2026
#276)

## Summary of Changes
- Add `reservation` subcommand behind the `experimental` feature gate
with:
- `initialize-seat`: create a client seat and payment escrow for a
(device, client_ip) pair; skips seat creation if it already exists
- `fund`: deposit USDC into a per-seat payment escrow; validates
positive amount and checks on-chain minimum price
- `withdraw`: close a payment escrow and reclaim USDC; pre-flight check
for escrow existence
- `list`: show all client seats with optional device, client-ip, and
withdraw-authority filters
  - `price`: show current device pricing (metro base + device premium)
- Simplify `ClosePaymentEscrowAccounts` SDK constructor to accept
`Option<&Pubkey>` for refund account

## Diff Breakdown
| Category          | Files | Lines (+/-) | Net   |
|-------------------|-------|-------------|-------|
| CLI commands      |     7 | +798 / -0   | +798  |
| SDK (constructor) |     1 | +10 / -13   | -3    |
| Build / changelog |     2 | +5 / -0     | +5    |

~800 net lines — 5 new CLI commands, subcommand scaffold, and SDK
cleanup.

<details>
<summary>Key files (click to expand)</summary>

- `crates/solana-cli/src/command/reservation/mod.rs` — subcommand enum,
`DeviceArgs` (shared `--device` / `--device-code` resolution), feature
gate
- `crates/solana-cli/src/command/reservation/initialize_seat.rs` — sends
`InitializeClientSeat` + `InitializePaymentEscrow` in one transaction;
skips seat ix if already exists
- `crates/solana-cli/src/command/reservation/fund.rs` — sends
`FundPaymentEscrowUsdc`, derives exchange key from on-chain
DeviceHistory, validates amount against current price
- `crates/solana-cli/src/command/reservation/withdraw.rs` — sends
`ClosePaymentEscrow`, pre-flight escrow existence check
- `crates/solana-cli/src/command/reservation/price.rs` — read-only,
joins MetroHistory + DeviceHistory to show per-device pricing
- `crates/solana-cli/src/command/reservation/list.rs` — read-only,
fetches ClientSeat accounts with discriminator memcmp filter, supports
`--withdraw-authority` and `--client-ip` filters
- `crates/solana-cli/src/command/mod.rs` — wires `Reservation` variant
into top-level CLI
- `crates/solana-sdk/src/reservation/instruction/account.rs` — merged
`new` / `new_with_ata_refund` into single constructor

</details>

## Related PRs
- **#275 (SDK)**: merged — this PR builds on it
- **#277 (Mock + tests)**: depends on this — adds mock program and
integration tests

Part 2 of #274
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants