Is union airdrop claim soon? (Link below 👇)
This files are essentially Union’s airdrop claim state machine,
written in TypeScript with heavy use of the effect functional library for state, events, concurrency, and error handling
Here’s the breakdown of what it does:
1. Purpose
It coordinates the full lifecycle of an airdrop claim:
1. Switch to the correct block chain (switchChain).
2. Connect a Cosmos wallet.
3. Have the user sign a specific message:
"I'm signing this message to claim my Union airdrop rewards."
4. Submit the claim to Union’s backend.
5. Poll & verify until completion (or fail with retry strategies).
It wraps this process in a resilient, event-driven state machine that can:
Recover from errors.
Retry with exponential/linear backoff.
Track confidence and entropy of state.
Record a transition history for observability.
2. Key Concepts in the File
States (AirdropClaimState)
These represent every possible stage:
Initializing → prepping
SwitchChain → changing blockchain network
WalletConnecting → trying to connect a wallet
Signing → signing the airdrop claim message
Claiming → sending the claim transaction
Verifying → checking if claim is processed
Completed → success
Failed → error, with retry info
Events (AirdropEvent)
Triggers that move between states, e.g.:
Start
WalletConnected
MessageSigned
ClaimSubmitted
ClaimVerified
Failed variants
Retry / Reset
Error Handling
AirdropClaimError wraps:
Cause
Operation (switchChain, sign, claim, verify, connect)
Severity (recoverable, critical, temporary)
Context (extra debug info)
3. Services
The state machine depends on 3 injectable services:
WalletOracle → detects wallets, predicts best wallet, checks wallet health.
ClaimOrchestrator → handles claim submission, polling, and verification.
StateCoherence → keeps state consistent, calculates entropy, decides if “decoherence” (reset) is needed.
4. The State Machine Class
QuantumAirdropStateMachine:
Stores current state (Ref).
Receives events via an event queue.
Runs processTransition to compute the new state based on the old state event.
Records history of transitions with timestamps.
Calculates “confidence” in current state (goes down after failures, up after successes).
Can return metrics like:
Current state tag
Confidence
Entropy
Failure rate
5. Factory & Example
createQuantumAirdropStateMachine → makes a machine in Initializing state.
QuantumAirdropLayer → merges the live service implementations.
runQuantumAirdropClaim(chain) → example usage: start machine, send Start event, log metrics.
✅ In plain terms:
This is a fault-tolerant, metrics aware workflow for claiming Union airdrops that moves step-by-step from “not started” to “done,” handling every possible success/failure in between.
github.com/unionlabs/union/b…