Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Get Tips (filtered for unclaimed and unlocked)
- ↓
- getAggregatedTipsByFid(fid: number)
- • Filters: status = 'pending'
- • Filters: tx_hash = null
- • Filters: claim_nonce = null
- • Filters: claim_started_at = null OR expired
- ↓
- 2. Lock Tips with Unique Nonce
- ↓
- lockTipsForClaiming(tips: Tip[])
- • Generates UUID for claim_nonce
- • Sets claim_started_at timestamp
- • Sets lock_timeout (15 minutes)
- • Updates all tips atomically
- ↓
- 3. Verify Lock Success
- ↓
- verifyTipsLock(tips: Tip[], claimNonce: string)
- • Checks all tips have our claim_nonce
- • Confirms tips are still pending
- • Ensures tx_hash is still null
- ↓
- 4. Send Transaction
- ↓
- sendTransaction(tokenAddress, to, amount, decimals, isNative)
- • Handles both native (ETH) and ERC20 tokens
- • Waits for transaction receipt
- • Returns success/failure with hash
- ↓
- 5. Update Tips with Transaction Hash
- ↓
- updateTipsStatus(tips, txHash, walletAddress, claimNonce)
- • Updates only if claim_nonce matches (atomic)
- • Sets tx_hash, status = 'success'
- • Records claimed_at timestamp
- • Clears claim_nonce and lock
- ↓
- 6. Release Lock if Anything Fails
- ↓
- releaseTipsLock(tips, claimNonce)
- • Clears claim_nonce
- • Clears claim_started_at
- • Only affects tips with matching nonce
Advertisement
Add Comment
Please, Sign In to add comment