Skip to content

feat: Add account sponsorship, per-endpoint rate limiter, and client config validation (#213, #214, #137) - #302

Merged
k-deejah merged 2 commits into
Sorokit:mainfrom
sublime247:feat/sponsorship-ratelimit-validation
Jul 26, 2026
Merged

feat: Add account sponsorship, per-endpoint rate limiter, and client config validation (#213, #214, #137)#302
k-deejah merged 2 commits into
Sorokit:mainfrom
sublime247:feat/sponsorship-ratelimit-validation

Conversation

@sublime247

@sublime247 sublime247 commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #213
Closes #214
Closes #137
This PR implements the solution for issues #213, #214, and #137:

1. Account Sponsorship Utilities (#213)

  • Added setSponsor(account, sponsor) and removeSponsor(account) functions in src/account/sponsorship.ts.
  • Validates account and sponsor public key format using isValidPublicKey.
  • Prevents self-sponsorship.
  • Constructs operation sequence (beginSponsoringFutureReserves + endSponsoringFutureReserves or revokeAccountSponsorship) and tracks required signers.
  • Exposed methods on client.account and public SDK entry points.

2. Advanced Rate Limiter with Per-Endpoint Quotas (#214)

  • Extended TokenBucketRateLimiter in src/shared/utils.ts to support per-endpoint quotas.
  • Provided sensible default limits per endpoint category (contract.simulate: 5 req/s, account.get: 20 req/s, etc.).
  • Added setEndpointLimit() for runtime overrides and handleResponseHeaders() for X-Rate-Limit-* header parsing.

3. Client Configuration Validation on Startup (#137)

  • Added validateClientConfig() in src/client/createSorokitClient.ts.
  • Checks required network parameter, well-formed URLs (horizonUrl, rpcUrl), and interface methods on cache and logger.
  • Returns detailed validation errors with typed SorokitErrorCode.INVALID_CONFIG or INVALID_NETWORK.

Verification

  • Added comprehensive unit tests in sponsorship.test.ts, client.test.ts, and shared.test.ts.
  • Verified clean build via npm run build and tests via npm test.

@drips-wave

drips-wave Bot commented Jul 26, 2026

Copy link
Copy Markdown

@sublime247 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@k-deejah
k-deejah merged commit 334fc6c into Sorokit:main Jul 26, 2026
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.

Implement advanced rate limiter with per-endpoint quotas Add account sponsorship utilities Add client configuration validation on startup

2 participants