-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/c4 migration #672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
mindrunner
wants to merge
25
commits into
main
Choose a base branch
from
feature/c4-migration
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Feature/c4 migration #672
+9,363
−9,738
Conversation
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
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.
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.