Skip to content

Conversation

@mindrunner
Copy link
Owner

No description provided.

@mindrunner mindrunner force-pushed the feature/c4-migration branch from 6ca4756 to 773f339 Compare January 21, 2026 14:13
- Update deps: @solana/kit, solana-kite, @staratlas/dev-sage
- Remove: @solana/web3.js, @coral-xyz/anchor, @staratlas/sage
- Rewrite: connection, wallet, tx sending with Kit patterns
- Delete: anchor.ts, programs.ts (no longer needed)
- Add: C4 migration plan in docs/
- Add account-registry.ts with discriminator-based decoding
- Add account-fetcher.ts with fetchAllAccounts/fetchAccount utils
- Add types.ts with AccountWithKey and C4 type re-exports
- Rewrite user-account.ts with Profile/Character/KeyPairSigner
- Rewrite game.ts to use account-fetcher
- Rewrite fleet-state types for __kind discriminators
- Update coordinates.ts to use bigint (no more BN)
- Update transform-sector/time for bigint
- Delete obsolete type-guard files (replaced by __kind)
Rewrote core fleet actions using dev-sage instruction functions:
- dock/undock: getIdleToDockedInstruction, getDockedToIdleInstruction
- move/end-move/stop-subwarp: getWarpToCoordinateInstruction, getStartSubwarpInstruction, getTheOneFleetStateHandlerInstruction, getStopSubwarpInstruction
- mine/end-mine: getStartMiningAsteroidInstruction, getStopMiningAsteroidInstruction
- cargo: getTransferCargoToFleetInstruction with cargoId-based transfers

Deleted ix/ folder (23 files) - inlined into act layer
Removed non-core act files (create-fleet, deposit-cargo, etc.)

Patterns: AccountWithKey<T>, KeyPairSigner, Address, fleet.state.__kind
Error reduction: 588 -> 392 (33%)
- Rewrite fleet-cargo.ts: cargo now on Fleet struct directly
- Rewrite user-fleets.ts: use fetchAllAccounts pattern
- Delete cargo-types.ts, cargo-stats-definition.ts, get-fleet-ships.ts: obsolete in C4
- Rewrite starbases.ts: starbase now embedded in StarSystem
- Rewrite starbase-by-*.ts: use StarSystem with starbase field
- Rewrite starbase-player.ts: use findStarbasePlayerPda pattern
- Rewrite planets*.ts: Planet -> CelestialBody
- Rewrite resources.ts, mine-items.ts: resource data embedded in CelestialBody
- Rewrite world-map.ts: new WorldMap structure for C4
- Stub profile.ts, pod-cleanup.ts, get-random-fleet.ts: TODO for C4
- Fix ships.ts: remove legacy imports
- Update util.ts, show-fleet-*.ts, settle-fleet.ts: use C4 types

Error count: 433 -> 317 (~27% reduction)
- Migrate all FSM files to C4 types (kind, Docked, coordinates)
- Update strategy files: Game → AccountWithKey<Game>
- Fix resource refs: game.data.mints → resource config
- Remove legacy R4 code: src/lib/, fleetbot/, airdrop/, service/fleet, service/gm
- Fix priority fee types: IInstruction → Instruction
- Clean compile with 0 errors
- Rewrite airdrop.ts using Kit types (Address, KeyPairSigner)
- Use superagent directly for airdrop requests
- Integrate with C4 player context for profile checking
Remove deleted fleetbot entry from tsup.config.ts, package.json
script, and docker/bin/fleetbot.sh to fix CI/CD build failures.
@mindrunner mindrunner force-pushed the feature/c4-migration branch from 7a8500c to a0d9bb9 Compare January 21, 2026 14:16
C4 stores coordinates as fixed-point with 56 fractional bits.
Use .toNumber() and Math.round() for display/matching.
Add .toRawTuple() for on-chain instructions.
- Add pre-flight validation for move/dock/undock (state, fuel, cooldown)
- Wrap transactions in try-catch, return success/failure instead of throwing
- Don't retry TransactionFailedError - on-chain failures won't succeed
- Fix fuel level reading from fleet.fuelTank instead of cargoHold
- Use character.playerProfile consistently for SAGE instructions
- Fix dynamic ship ID lookup in getRandomFleet
- implement tx simulation for compute unit estimation
- batch ship deposits to stay under 1232 byte tx limit
- handle C4 state struct changes (from/to, duration)
- reduce max fleet size 145→100 for safety margin
- skip sending txs that fail simulation with program error
…ort pairing

- Strategy now uses actual fleet locations to assign mining/transport pairs
- Added recovery logic for fleets stuck at incompatible (wrong faction) starbases
- Transports deliver to their paired miner's actual location
- Added findNearestCompatibleStarbase for recovery to faction-owned starbases
- Self-destruct fallback when no compatible starbase is reachable
- Fixed cargo availability checks before attempting refuel operations
- Improved logging for stuck fleets with location context
- Fixed lint/prettier issues with negated conditions
…System

The disband was failing with "System mismatch" because it passed
player.homeSystem but the fleet could be docked at a different nearby
starbase (within fuzzy match radius). Now uses the actual
fleetInfo.fleetState.data.system.
When starbase has insufficient crew for fleet creation, automatically
add crew using devAddCrew instruction (available on dev/test networks).
This allows the bot to create fleets without manually depositing crew.
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.

2 participants