Draft
Conversation
6ca4756 to
773f339
Compare
- 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.
7a8500c to
a0d9bb9
Compare
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.
- Recognize R4 mint addresses (fuel, ammo, food, tool) in resolveCargoId - Skip move to exact coordinates if distance is negligible (< 0.01) - Handle already-docked fleets gracefully in fsmDock - Revert devAddCrew attempt (requires admin key)
Add preciseDistanceFrom method to Coordinates that uses full raw coordinate precision instead of integer-rounded values. This fixes the "Not within range" error when a fleet is close to (but not exactly at) starbase coordinates - the integer distance appeared < 1 unit but the precise distance was ~0.4 units.
Treat "Status mismatch - expected X actual Y" errors as success when the fleet is already in the target state (Docked for dock, Idle for undock). This handles race conditions where the fleet state changed between fetching and transaction execution.
- Add game-resources.ts to derive R4 mints from game.cargoDefinitions - Use known cargo IDs (fuel/ammo from fleet, food=4, tool=5) - Remove dependency on FUEL_MINT, AMMO_MINT, FOOD_MINT, TOOL_MINT config - Update strategies to use getR4MintSet(game) instead of config mints - Simplify resource.ts (only keep atlas mint) This fixes the "R4 cargo IDs empty" error when config mints don't match the game's cargo definitions (e.g., atlasnet vs mainnet).
- Remove FUEL_MINT, AMMO_MINT, FOOD_MINT, TOOL_MINT, ATLAS_MINT from config - Delete resource.ts (R4 mints now come from game data) - R4 resources obtained via getR4MintSet() from game.cargoDefinitions
- Get R4 resources (fuel, ammo, food, tool) from game.resources - Catch all SimulationProgramError gracefully (Status mismatch, Insufficient amount, UnbalancedInstruction) - Catch TransactionFailedError for on-chain failures - Remove verbose error/debug logging for expected failures - Return false/failure instead of throwing exceptions - Add clear warnings when fleets waiting for resources
C4 has no self-destruct instruction. Fleets stuck at incompatible starbases will remain stuck until: 1. Starbase is conquered by player's faction 2. Fleet is destroyed in combat Updated warnings to clearly explain the situation instead of calling a non-existent function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.