cargo/actions
Interfaces
Section titled “Interfaces”PlanAuthorization
Section titled “PlanAuthorization”Defined in: packages/sage/src/internal/planning/authorization-adapter.ts:100
Address-only authorization retained by planning before execution binds signers.
Example
Section titled “Example”declare const profile: Address;declare const authority: Address;const authorization: PlanAuthorization = { profile, authority, keyIndex: 0,};Properties
Section titled “Properties”authority
Section titled “authority”readonly authority: Address;Defined in: packages/sage/src/internal/planning/authorization-adapter.ts:102
certificate?
Section titled “certificate?”readonly optional certificate?: Address;Defined in: packages/sage/src/internal/planning/authorization-adapter.ts:104
keyIndex
Section titled “keyIndex”readonly keyIndex: number;Defined in: packages/sage/src/internal/planning/authorization-adapter.ts:103
profile
Section titled “profile”readonly profile: Address;Defined in: packages/sage/src/internal/planning/authorization-adapter.ts:101
PlanDepositCargoToGameOptions
Section titled “PlanDepositCargoToGameOptions”Defined in: packages/sage/src/cargo/actions/deposit.ts:42
Exact wallet token units to deposit into an existing player-local Starbase. The owner is the source token owner, independently of the Profile authority. The default source is the owner’s standard associated token account; an explicit existing original Token account may be supplied instead.
Example
Section titled “Example”declare const authorization: PlanAuthorization;declare const owner: Address;const options: PlanDepositCargoToGameOptions = { cargoId: 1, amount: 10n, owner, authorization };Properties
Section titled “Properties”amount
Section titled “amount”readonly amount: bigint;Defined in: packages/sage/src/cargo/actions/deposit.ts:44
authorization
Section titled “authorization”readonly authorization: PlanAuthorization;Defined in: packages/sage/src/cargo/actions/deposit.ts:45
cargoId
Section titled “cargoId”readonly cargoId: number;Defined in: packages/sage/src/cargo/actions/deposit.ts:43
readonly owner: Address;Defined in: packages/sage/src/cargo/actions/deposit.ts:46
source?
Section titled “source?”readonly optional source?: Address;Defined in: packages/sage/src/cargo/actions/deposit.ts:47
PlanFleetTransferCargoAtStarbaseOptions
Section titled “PlanFleetTransferCargoAtStarbaseOptions”Defined in: packages/sage/src/cargo/actions/index.ts:66
Inputs for one explicit Fleet/player-Starbase cargo transfer.
Every quantity is a positive raw on-chain bigint. Ammo and fuel are bounded
by signed i64 because direction is encoded by sign; cargo-hold quantities use
unsigned u64 and cargo ids use unsigned u16.
Example
Section titled “Example”declare const authorization: PlanAuthorization;const options: PlanFleetTransferCargoAtStarbaseOptions = { authorization, direction: 'toFleet', amounts: { ammo: 25n, cargoHold: [{ cargoId: 3, amount: 2n }], },};Properties
Section titled “Properties”amounts
Section titled “amounts”readonly amounts: { ammo?: bigint; cargoHold?: readonly { amount: bigint; cargoId: number; }[]; fuel?: bigint;};Defined in: packages/sage/src/cargo/actions/index.ts:69
readonly optional ammo?: bigint;cargoHold?
Section titled “cargoHold?”readonly optional cargoHold?: readonly { amount: bigint; cargoId: number;}[];readonly optional fuel?: bigint;authorization
Section titled “authorization”readonly authorization: PlanAuthorization;Defined in: packages/sage/src/cargo/actions/index.ts:67
direction
Section titled “direction”readonly direction: "toFleet" | "toStarbase";Defined in: packages/sage/src/cargo/actions/index.ts:68
PlanFleetTransferCargoWithinFleetOptions
Section titled “PlanFleetTransferCargoWithinFleetOptions”Defined in: packages/sage/src/cargo/actions/index.ts:97
Inputs for moving one exact cargo quantity between two pods in one Fleet.
The amount is a positive raw on-chain unsigned-u64 bigint; the cargo id is
an unsigned-u16 integer. Pod names select the Fleet snapshot’s nested ammo,
fuel, or cargo-hold inventory without accepting CargoPod account addresses.
Example
Section titled “Example”declare const authorization: PlanAuthorization;const options: PlanFleetTransferCargoWithinFleetOptions = { amount: 5n, authorization, cargoId: 2, from: 'ammo', to: 'cargoHold',};Properties
Section titled “Properties”amount
Section titled “amount”readonly amount: bigint;Defined in: packages/sage/src/cargo/actions/index.ts:102
authorization
Section titled “authorization”readonly authorization: PlanAuthorization;Defined in: packages/sage/src/cargo/actions/index.ts:98
cargoId
Section titled “cargoId”readonly cargoId: number;Defined in: packages/sage/src/cargo/actions/index.ts:101
readonly from: "cargoHold" | "ammo" | "fuel";Defined in: packages/sage/src/cargo/actions/index.ts:99
readonly to: "cargoHold" | "ammo" | "fuel";Defined in: packages/sage/src/cargo/actions/index.ts:100
PlanWithdrawCargoFromGameOptions
Section titled “PlanWithdrawCargoFromGameOptions”Defined in: packages/sage/src/cargo/actions/withdrawal.ts:39
An exact withdrawal to an explicit receiving wallet, independently of Profile authority.
destinationAccount permits creating only a missing canonical ATA. An existing
destination needs no extra payer signature; custom destinations must exist.
Example
Section titled “Example”declare const authorization: PlanAuthorization;declare const recipient: Address;const options: PlanWithdrawCargoFromGameOptions = {cargoId:3,amount:10n,authorization,recipient};Properties
Section titled “Properties”amount
Section titled “amount”readonly amount: bigint;Defined in: packages/sage/src/cargo/actions/withdrawal.ts:41
authorization
Section titled “authorization”readonly authorization: PlanAuthorization;Defined in: packages/sage/src/cargo/actions/withdrawal.ts:42
cargoId
Section titled “cargoId”readonly cargoId: number;Defined in: packages/sage/src/cargo/actions/withdrawal.ts:40
destination?
Section titled “destination?”readonly optional destination?: Address;Defined in: packages/sage/src/cargo/actions/withdrawal.ts:44
destinationAccount?
Section titled “destinationAccount?”readonly optional destinationAccount?: { mode: "create-if-missing"; payer: Address;};Defined in: packages/sage/src/cargo/actions/withdrawal.ts:45
readonly mode: "create-if-missing";readonly payer: Address;recipient
Section titled “recipient”readonly recipient: Address;Defined in: packages/sage/src/cargo/actions/withdrawal.ts:43
Type Aliases
Section titled “Type Aliases”FleetCargoTransferDebitBounds
Section titled “FleetCargoTransferDebitBounds”type FleetCargoTransferDebitBounds = | { reason: FleetCargoTransferDebitBoundsUnavailableReason; status: "unavailable"; toJSON: unknown;} | { authority: Address; character: Address; direction: "toFleet" | "toStarbase"; fleet: Address; game: Address; keyIndex: number; maximumCharacterAtlasDebitRaw: 0n; maximumCharacterRenownDebit: 0n; profile: Address; profileStorage: "separate"; starbasePlayer: Address; status: "available"; system: Address; transactionFees: "excluded"; toJSON: unknown;};Defined in: packages/sage/src/cargo/actions/transfer-bounds.ts:41
Gross Character debit bounds of one Fleet/Starbase cargo transfer.
The program never spends the Character’s ATLAS or Renown in this transfer, in either direction and for any cargo, so an available bound is zero. Profile storage funding is a separate Profile lamport debit, reported by the Plan’s storage guard and not netted here; transaction fees are excluded.
Union Members
Section titled “Union Members”Type Literal
Section titled “Type Literal”{ reason: FleetCargoTransferDebitBoundsUnavailableReason; status: "unavailable"; toJSON: unknown;}Type Literal
Section titled “Type Literal”{ authority: Address; character: Address; direction: "toFleet" | "toStarbase"; fleet: Address; game: Address; keyIndex: number; maximumCharacterAtlasDebitRaw: 0n; maximumCharacterRenownDebit: 0n; profile: Address; profileStorage: "separate"; starbasePlayer: Address; status: "available"; system: Address; transactionFees: "excluded"; toJSON: unknown;}authority
Section titled “authority”readonly authority: Address;character
Section titled “character”readonly character: Address;direction
Section titled “direction”readonly direction: "toFleet" | "toStarbase";readonly fleet: Address;readonly game: Address;keyIndex
Section titled “keyIndex”readonly keyIndex: number;maximumCharacterAtlasDebitRaw
Section titled “maximumCharacterAtlasDebitRaw”readonly maximumCharacterAtlasDebitRaw: 0n;Raw ATLAS units; always 0n for this transfer.
maximumCharacterRenownDebit
Section titled “maximumCharacterRenownDebit”readonly maximumCharacterRenownDebit: 0n;Renown points; always 0n for this transfer.
profile
Section titled “profile”readonly profile: Address;profileStorage
Section titled “profileStorage”readonly profileStorage: "separate";starbasePlayer
Section titled “starbasePlayer”readonly starbasePlayer: Address;status
Section titled “status”readonly status: "available";system
Section titled “system”readonly system: Address;transactionFees
Section titled “transactionFees”readonly transactionFees: "excluded";toJSON()
Section titled “toJSON()”toJSON(): unknown;Returns
Section titled “Returns”unknown
Example
Section titled “Example”declare const bounds: FleetCargoTransferDebitBounds;if (bounds.status === 'available') console.log(bounds.maximumCharacterAtlasDebitRaw); // 0nFleetCargoTransferDebitBoundsUnavailableReason
Section titled “FleetCargoTransferDebitBoundsUnavailableReason”type FleetCargoTransferDebitBoundsUnavailableReason = | "not-fleet-cargo-transfer" | "within-fleet-transfer" | "multiple-fleet-cargo-transfers" | "combined-plan" | "unsupported-instruction" | "missing-pre-sign-guard" | "unqualified-deployment";Defined in: packages/sage/src/cargo/actions/transfer-bounds.ts:18
Why a Plan has no Character debit bound. Unavailable never implies zero.
Example
Section titled “Example”const reason: FleetCargoTransferDebitBoundsUnavailableReason = 'combined-plan';Functions
Section titled “Functions”getFleetCargoTransferDebitBounds()
Section titled “getFleetCargoTransferDebitBounds()”function getFleetCargoTransferDebitBounds(plan): FleetCargoTransferDebitBounds;Defined in: packages/sage/src/cargo/actions/transfer-bounds.ts:151
Reads the Character debit bounds of a Fleet/Starbase cargo transfer Plan without network I/O.
The bounds are read from the instruction the Plan will sign, so they are
recomputed on every call: inspect again after hydrating or changing a Plan.
They are available only for a single-step Plan whose instruction, accounts
and pre-sign guards match what planFleetTransferCargoAtStarbase builds.
Execution still rechecks the Fleet, Starbase Player, the Character’s
canonical identity and cargo-category access, and the Profile storage
ceiling before signing; changes to the Character’s ATLAS, XP or Renown do
not block it, because the transfer never spends them.
The zero bound is the audited z.ink PTR deployment’s behaviour, not an
on-chain spending cap; a Plan for any other deployment is
unqualified-deployment. A Character behind the Game’s research or XP
definitions is brought up to date during the transfer, which can change its
rent against the Profile outside the storage ceiling but never its ATLAS
or Renown.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
plan | Plan |
Returns
Section titled “Returns”Example
Section titled “Example”declare const plan: Plan;const bounds = getFleetCargoTransferDebitBounds(plan);if (bounds.status === 'available') console.log(bounds.maximumCharacterAtlasDebitRaw, bounds.direction);else console.log(bounds.reason);planDepositCargoToGame()
Section titled “planDepositCargoToGame()”function planDepositCargoToGame( ctx, starbase,options): Promise<Plan>;Defined in: packages/sage/src/cargo/actions/deposit.ts:72
Plans a wallet-to-game cargo deposit without signing, sending, or creating accounts.
Amount is exact raw token units, independent of mint display decimals. Refresh
the loaded Starbase before planning; execution checks the retained guards.
Profile authority and token owner both sign when they are different addresses.
A cargo id new to the Starbase Player adds a cargo line whose storage the
program funds from the Profile vault; the Plan states that amount, and a
positive one needs Profile AUTH or drainSolVault.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ctx | SageContext |
starbase | StarbasePlayerIntent |
options | PlanDepositCargoToGameOptions |
Returns
Section titled “Returns”Promise<Plan>
Example
Section titled “Example”import { planDepositCargoToGame } from '@aephia/atlas-kit/cargo/actions';import type { SageContext, Address } from '@aephia/atlas-kit/client';import type { StarbasePlayerSnapshot } from '@aephia/atlas-kit/starbases';declare const ctx: SageContext;declare const starbase: StarbasePlayerSnapshot;declare const authorization: PlanAuthorization;declare const owner: Address;const plan = await planDepositCargoToGame(ctx, starbase, { cargoId: 1, amount: 10n, authorization, owner,});console.log(plan.summary);planFleetTransferCargoAtStarbase()
Section titled “planFleetTransferCargoAtStarbase()”function planFleetTransferCargoAtStarbase( ctx, fleet,input): Promise<Plan>;Defined in: packages/sage/src/cargo/actions/index.ts:546
Plans one bidirectional Fleet/player-Starbase cargo transfer without signing or RPC writes.
The caller supplies only gameplay direction and positive raw-unit quantities.
Planning directly re-reads the Fleet, canonical Character, and derived
StarbasePlayer; checks known source balances (aggregated by cargo id for the
shared Starbase inventory) and, when loading the Fleet, exact
ammo/fuel/cargo capacity; and returns one inspectable instruction. It also
reads the Profile and Rent sysvar to bound the storage the program funds from
the Profile vault for cargo lines the transfer adds, net of lines it empties
across the Fleet and Starbase Player; a positive amount needs Profile AUTH or
drainSolVault. It refuses a Fleet below its required crew, in either
direction. The transfer never spends the Character’s ATLAS, XP, Renown or
asset counts. The program reads the Character for cargo-category access, and only
a Character behind the Game’s current research or XP definitions is brought
up to date, with any rent change settled against the Profile outside the
quoted storage ceiling. The chain remains authoritative for state races, faction policy,
Profile permission bits including
MANAGE_FLEET_CARGO, and program arithmetic. Starbase destination capacity is not inferred because the
shipped StarbasePlayer read exposes no total-capacity field.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ctx | SageContext |
fleet | FleetSnapshot |
input | PlanFleetTransferCargoAtStarbaseOptions |
Returns
Section titled “Returns”Promise<Plan>
Example
Section titled “Example”declare const ctx: SageContext;declare const fleet: FleetSnapshot;declare const authorization: PlanAuthorization;const plan = await planFleetTransferCargoAtStarbase(ctx, fleet, { authorization, direction: 'toStarbase', amounts: { fuel: 10n },});console.log(plan.describe());planFleetTransferCargoWithinFleet()
Section titled “planFleetTransferCargoWithinFleet()”function planFleetTransferCargoWithinFleet( ctx, fleet,input): Promise<Plan>;Defined in: packages/sage/src/cargo/actions/index.ts:933
Plans one exact cargo transfer between two nested pods in one Fleet.
The caller supplies pod names, one unsigned-u16 cargo id, and one positive
raw unsigned-u64 amount. Planning uses only the supplied Fleet snapshot for
pod identities, resolved cargo ids, balances, and ammo/fuel/cargo-hold
capacity. It accepts idle, docked, and Claim Stake transfer states and
returns one signer-free, inspectable instruction. It reads the Fleet, Profile
and Rent sysvar to bound the storage the program funds from the Profile vault
when the transfer adds a cargo-hold line; a positive amount needs Profile AUTH
or drainSolVault. It refuses a Fleet below its required crew. The chain
remains authoritative for state races, Profile permission bits including
MANAGE_FLEET_CARGO, and program arithmetic.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ctx | SageContext |
fleet | FleetSnapshot |
input | PlanFleetTransferCargoWithinFleetOptions |
Returns
Section titled “Returns”Promise<Plan>
Example
Section titled “Example”declare const ctx: SageContext;declare const fleet: FleetSnapshot;declare const authorization: PlanAuthorization;const plan = await planFleetTransferCargoWithinFleet(ctx, fleet, { amount: 5n, authorization, cargoId: fleet.ammo.id, from: 'ammo', to: 'cargoHold',});console.log(plan.describe());planWithdrawCargoFromGame()
Section titled “planWithdrawCargoFromGame()”function planWithdrawCargoFromGame( ctx, starbase,options): Promise<Plan>;Defined in: packages/sage/src/cargo/actions/withdrawal.ts:69
Plans an exact game-to-wallet withdrawal without signing or submitting. Current verified game/token conversion is limited to zero-decimal cargo mints. The recipient never signs merely to receive tokens. ATA creation is explicit, with storage funding described separately from execution transaction fees. Permissions and the remaining epoch budget stay chain-authoritative.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
ctx | SageContext |
starbase | StarbasePlayerIntent |
options | PlanWithdrawCargoFromGameOptions |
Returns
Section titled “Returns”Promise<Plan>
Example
Section titled “Example”import {planWithdrawCargoFromGame} from '@aephia/atlas-kit/cargo/actions';import type {SageContext,Address} from '@aephia/atlas-kit/client';import type {StarbasePlayerSnapshot} from '@aephia/atlas-kit/starbases';declare const ctx:SageContext;declare const starbase:StarbasePlayerSnapshot;declare const authorization:PlanAuthorization;declare const recipient:Address;const plan=await planWithdrawCargoFromGame(ctx,starbase,{cargoId:3,amount:10n,authorization,recipient});console.log(plan.summary);