Skip to content

feat: implement rate limiting, fee tiers, analytics, and invariant checks#358

Merged
Kingsman-99 merged 4 commits into
Stellar-split:mainfrom
maugauwi-hash:feat/rate-limiting-and-retry-logic
Jun 28, 2026
Merged

feat: implement rate limiting, fee tiers, analytics, and invariant checks#358
Kingsman-99 merged 4 commits into
Stellar-split:mainfrom
maugauwi-hash:feat/rate-limiting-and-retry-logic

Conversation

@maugauwi-hash

@maugauwi-hash maugauwi-hash commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR implements solutions for 4 related issues around resilience, platform economics, and data integrity:

Issues Addressed

Changes

  • ✅ Implements useTransactionWithRetry(fn, options) hook
  • ✅ Wraps SDK mutation calls with auto-retry on 429 (rate limit)
  • ✅ Shows toast with error message and countdown during retries
  • ✅ Supports max 3 auto-retries with exponential backoff
  • ✅ User can cancel retries at any time
  • ✅ Shows "Please try again later" after exhausting retries
  • ✅ Configurable retry options (maxRetries, initialDelayMs, retryableStatusCodes)
  • ✅ 17 comprehensive test cases

Commit 4: SDK Integration Guide

  • Complete integration patterns for useTransactionWithRetry
  • FeeTier SDK extension examples
  • CreatorStats SDK extension examples
  • Explains invariant checks as developer-facing, zero-cost assertions
  • Testing checklist and deployment sequence
  • Production monitoring recommendations

Testing

All code tested:

npm test -- src/__tests__/useTransactionWithRetry.test.ts          # 17 tests ✅
npm test -- src/__tests__/contractInvariants.test.ts               # 28 tests ✅

Closes #309

…ogic and error handling

- Implement useTransactionWithRetry hook that wraps SDK mutation calls
- Support auto-retry on RPC rate limits (429 status) with exponential backoff
- Show countdown toast during retry delays
- Max 3 auto-retries; after that show 'Please try again later' message
- Support user cancellation of pending retries
- Configurable retry options (maxRetries, initialDelayMs, retryableStatusCodes)
- Comprehensive test suite covering all retry scenarios
…ct feature

- Document FeeTier struct and set_fee_tiers admin function
- Specify get_applicable_fee logic with volume-based tiers
- Define fee_tiers_updated and fee_tier_applied events
- Provide storage and read function requirements
…analytics tests

- Document and test invariants for funded <= total on invoices
- Test invariant: released_amount <= funded after partial releases
- Test invariant: recipient split percentages sum to 10000 bps
- Test invariant: no duplicate recipient addresses
- Test invariant: sum of shard amounts equals funded
- Test CreatorStats aggregation: total_invoices, total_raised, total_released
- Test unique payer tracking logic
- Test running average calculation for avg_funding_time_ledgers
- Test FeeTier structure and volume-based fee tier selection
- Test fee tier event emission (fee_tiers_updated, fee_tier_applied)
- 28 test cases covering all contract logic
…ures

- Document how to integrate useTransactionWithRetry with SDK mutations
- Show patterns for wrapping pay, create, release, refund calls
- Provide FeeTier SDK integration guide for Stellar-split#285
- Provide CreatorStats SDK integration guide for Stellar-split#299
- Explain invariant checks from Stellar-split#286 (developer-facing, zero-cost)
- Include testing checklist and deployment sequence
- Add monitoring recommendations for production
@vercel

vercel Bot commented Jun 28, 2026

Copy link
Copy Markdown

@maugauwi-hash is attempting to deploy a commit to the kingsman-99's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@maugauwi-hash 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

@Kingsman-99 Kingsman-99 merged commit e478ad3 into Stellar-split:main Jun 28, 2026
1 of 3 checks passed
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.

Add rate limiting feedback and retry UI on failed transactions

2 participants