0x0x230x

Untitled

Jan 10th, 2025
33
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. getAggregatedTipsByFid(fid: number)
  3. • Filters: status = 'pending'
  4. • Filters: tx_hash = null
  5. • Filters: claim_nonce = null
  6. • Filters: claim_started_at = null OR expired
  7. 2. Lock Tips with Unique Nonce
  8. lockTipsForClaiming(tips: Tip[])
  9. • Generates UUID for claim_nonce
  10. • Sets claim_started_at timestamp
  11. • Sets lock_timeout (15 minutes)
  12. • Updates all tips atomically
  13. 3. Verify Lock Success
  14. verifyTipsLock(tips: Tip[], claimNonce: string)
  15. • Checks all tips have our claim_nonce
  16. • Confirms tips are still pending
  17. • Ensures tx_hash is still null
  18. 4. Send Transaction
  19. sendTransaction(tokenAddress, to, amount, decimals, isNative)
  20. • Handles both native (ETH) and ERC20 tokens
  21. • Waits for transaction receipt
  22. • Returns success/failure with hash
  23. 5. Update Tips with Transaction Hash
  24. updateTipsStatus(tips, txHash, walletAddress, claimNonce)
  25. • Updates only if claim_nonce matches (atomic)
  26. • Sets tx_hash, status = 'success'
  27. • Records claimed_at timestamp
  28. • Clears claim_nonce and lock
  29. 6. Release Lock if Anything Fails
  30. releaseTipsLock(tips, claimNonce)
  31. • Clears claim_nonce
  32. • Clears claim_started_at
  33. • Only affects tips with matching nonce
Advertisement
Add Comment
Please, Sign In to add comment