Right now every on-chain button in the app is faked. Create stream does a setTimeout, withdraw and cancel just show toasts. We need to actually talk to the contracts.
Instead of wiring each button individually, let's build a proper contract service layer first. One place that handles the full lifecycle — build the transaction XDR, simulate it to catch errors before the user even sees Freighter, sign it, submit, and poll for confirmation.
This should cover all the contract functions we have: stream (create, withdraw, cancel, balance_of, get_stream), vesting (create, claim, revoke, vested_of, get_schedule), and distributor (distribute, distribute_custom).
Needs @stellar/stellar-sdk added as a dep. The service should be network-aware (testnet/mainnet from env config) and throw typed errors matching the contract's error codes (NotFound, Unauthorized, AlreadyCancelled etc) so the UI can show meaningful messages.
Done when:
- All contract functions callable through one service
- Simulation runs before Freighter pops up
- Contract errors get parsed into typed exceptions
- Works on testnet and mainnet
- Has unit tests for tx building and error parsing
Right now every on-chain button in the app is faked. Create stream does a setTimeout, withdraw and cancel just show toasts. We need to actually talk to the contracts.
Instead of wiring each button individually, let's build a proper contract service layer first. One place that handles the full lifecycle — build the transaction XDR, simulate it to catch errors before the user even sees Freighter, sign it, submit, and poll for confirmation.
This should cover all the contract functions we have: stream (create, withdraw, cancel, balance_of, get_stream), vesting (create, claim, revoke, vested_of, get_schedule), and distributor (distribute, distribute_custom).
Needs
@stellar/stellar-sdkadded as a dep. The service should be network-aware (testnet/mainnet from env config) and throw typed errors matching the contract's error codes (NotFound, Unauthorized, AlreadyCancelled etc) so the UI can show meaningful messages.Done when: