Commit 486cb93
committed
feat(sdk): add SolanaSpendingLimits class to TypeScript SDK
Add TypeScript SDK integration for interacting with the mpc-spending-limit
Solana program.
SolanaSpendingLimits class provides:
- initialize(): Create spending config on-chain
- getState(): Fetch current config state
- getRemaining(): Get remaining allowance across periods
- validateTransfer(): Check if transfer is allowed (throws on violation)
- canTransfer(): Boolean check without throwing
- updateLimits(): Modify spending limits
- togglePause(): Pause/unpause config
- setGuardian(): Set emergency guardian
- addToWhitelist()/removeFromWhitelist(): Manage whitelist
- recordSpending(): Record completed transfer
- validateAndRecord(): Atomic validation + recording
Also includes:
- PDA derivation helpers
- State parsing from account data
- Base58 encoding/decoding utilities
- Network presets (Mainnet, Devnet, Testnet)
- Typed error codes for all spending limit violations1 parent 8b23a0d commit 486cb93
3 files changed
Lines changed: 1471 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
78 | 81 | | |
79 | 82 | | |
80 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
0 commit comments