0x0x230x

Untitled

Jan 10th, 2025
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. 1. Get Tips (filtered for unclaimed and unlocked)
  2. ↓
  3. getAggregatedTipsByFid(fid: number)
  4. • Filters: status = 'pending'
  5. • Filters: tx_hash = null
  6. • Filters: claim_nonce = null
  7. • Filters: claim_started_at = null OR expired
  8. ↓
  9. 2. Lock Tips with Unique Nonce
  10. ↓
  11. lockTipsForClaiming(tips: Tip[])
  12. • Generates UUID for claim_nonce
  13. • Sets claim_started_at timestamp
  14. • Sets lock_timeout (15 minutes)
  15. • Updates all tips atomically
  16. ↓
  17. 3. Verify Lock Success
  18. ↓
  19. verifyTipsLock(tips: Tip[], claimNonce: string)
  20. • Checks all tips have our claim_nonce
  21. • Confirms tips are still pending
  22. • Ensures tx_hash is still null
  23. ↓
  24. 4. Send Transaction
  25. ↓
  26. sendTransaction(tokenAddress, to, amount, decimals, isNative)
  27. • Handles both native (ETH) and ERC20 tokens
  28. • Waits for transaction receipt
  29. • Returns success/failure with hash
  30. ↓
  31. 5. Update Tips with Transaction Hash
  32. ↓
  33. updateTipsStatus(tips, txHash, walletAddress, claimNonce)
  34. • Updates only if claim_nonce matches (atomic)
  35. • Sets tx_hash, status = 'success'
  36. • Records claimed_at timestamp
  37. • Clears claim_nonce and lock
  38. ↓
  39. 6. Release Lock if Anything Fails
  40. ↓
  41. releaseTipsLock(tips, claimNonce)
  42. • Clears claim_nonce
  43. • Clears claim_started_at
  44. • Only affects tips with matching nonce
Advertisement
Add Comment
Please, Sign In to add comment