import { Account as TokenAccount } from '@solana/spl-token'; import { Connection, PublicKey } from '@solana/web3.js'; import { BN } from '@staratlas/anchor'; import { CargoIDLProgram, CargoPod, CargoType } from '@staratlas/cargo'; import { AsyncSigner, InstructionReturn } from '@staratlas/data-source'; import { SageIDLProgram } from './constants'; import { StarbasePlayer } from './starbasePlayer'; export declare const SAGE_CARGO_STAT_VALUE_INDEX = 0; /** * Gets the used up cargo space in the cargo pod * @param pod - the Cargo Pod account * @returns cargo space used in the cargo pod */ export declare const getUsedCargoSpace: (pod: CargoPod) => BN; /** * Gets the used up cargo space for a given token amount for the given cargo type * @param cargoType - the Cargo Type account * @param tokenAmount - the token amount * @returns cargo space used by the token amount */ export declare const getCargoSpaceUsedByTokenAmount: (cargoType: CargoType, tokenAmount: BN) => BN; /** * Gets the token amount required to reach a target cargo pod stat value * * You can use this to get how much tokens are required to fill up the pod capacity * or to determine how many tokens will take a given amount of cargo space * @param cargoType - the Cargo Type account * @param targetCargoSpace - the target cargo space amount (aka target cargo stat) * @returns amount of tokens needed to ge to `targetCargoSpace` */ export declare const getTokenAmountToReachTargetStat: (cargoType: CargoType, targetCargoSpace: BN) => BN; /** * Get StarbasePlayer accounts owned by the provided PlayerProfile * @param connection - Solana connection * @param sageProgram - the SAGE program * @param playerProfile - the player profile * @param gameId - the SAGE game id * @returns array of Starbase players */ export declare const getStarbasePlayersByProfile: (connection: Connection, sageProgram: SageIDLProgram, playerProfile: PublicKey, gameId: PublicKey) => Promise[]>; /** * Get CargoPod accounts owned by the provided authority * @param connection - Solana connection * @param cargoProgram - the SAGE program * @param authority - the authority * @returns array of Cargo Pods */ export declare const getCargoPodsByAuthority: (connection: Connection, cargoProgram: CargoIDLProgram, authority: PublicKey) => Promise[]>; /** * @deprecated use `getPodCleanupInstructions` instead * * Clean up Starbase cargo pods for the provided StarbasePlayer account * * Removes any extra StarbasePlayer-owned cargo pods by transferring all the cargo to the main cargo pod at a Starbase. * @param connection - Solana connection * @param sageProgram - the SAGE program * @param cargoProgram - the Cargo program * @param starbasePlayer - the StarbasePlayer * @param starbase - the Starbase associated with the `starbasePlayer` * @param playerProfile - the player profile * @param profileFaction - the player profile's faction * @param cargoStatsDefinition - the cargo stats definition * @param gameId - the SAGE game id * @param gameState - the game state account associated with `gameId` * @param key - the key authorized to run this instruction, should have at least `ADD_REMOVE_CARGO` SAGE permissions * @param keyIndex - the index of the `key` in the `playerProfile` permissions * @returns InstructionReturn[] * */ export declare const cleanCargoPodsByStarbasePlayer: (connection: Connection, sageProgram: SageIDLProgram, cargoProgram: CargoIDLProgram, starbasePlayer: PublicKey, starbase: PublicKey, playerProfile: PublicKey, profileFaction: PublicKey, cargoStatsDefinition: PublicKey, gameId: PublicKey, gameState: PublicKey, key: AsyncSigner, keyIndex: number) => Promise; interface PodCleanup { mainPod: PublicKey; podsAndTokensToClean: [PublicKey, TokenAccount[]][]; cargoSeqId: number; } /** * Returns the accounts that would be needed to clean up cargo pods at a Starbase * @param connection - SOlana connection object * @param cargoProgram - the Cargo program * @param starbasePlayer - the StarbasePlayer * @returns the accounts needed for cleanup as `PodCleanup` */ export declare const getCleanPodsByStarbasePlayerAccounts: (connection: Connection, cargoProgram: CargoIDLProgram, starbasePlayer: PublicKey) => Promise; /** * Get instructions for cleaning up cargo pods associated with a `starbasePlayer` account * @param podCleanup - pod cleanup accounts from `getCleanPodsByStarbasePlayerAccounts` * @param sageProgram - the SAGE program * @param cargoProgram - the Cargo program * @param starbasePlayer - the StarbasePlayer * @param starbase - the Starbase associated with the `starbasePlayer` * @param playerProfile - the player profile * @param profileFaction - the player profile's faction * @param cargoStatsDefinition - the cargo stats definition * @param gameId - the SAGE game id * @param gameState - the game state account associated with `gameId` * @param key - the key authorized to run this instruction, should have at least `ADD_REMOVE_CARGO` SAGE permissions * @param keyIndex - the index of the `key` in the `playerProfile` permissions * @returns InstructionReturn[] */ export declare const getPodCleanupInstructions: (podCleanup: PodCleanup, sageProgram: SageIDLProgram, cargoProgram: CargoIDLProgram, starbasePlayer: PublicKey, starbase: PublicKey, playerProfile: PublicKey, profileFaction: PublicKey, cargoStatsDefinition: PublicKey, gameId: PublicKey, gameState: PublicKey, key: AsyncSigner, keyIndex: number) => InstructionReturn[]; /** * Clean up Starbase cargo pods * * Checks if a PlayerProfile owns more than one cargo pod at the same Starbase and if so, removes * the extra cargo pods by transferring all the cargo to the main cargo pod at a Starbase. * @param connection - Solana connection * @param sageProgram - the SAGE program * @param cargoProgram - the Cargo program * @param playerProfile - the player profile * @param profileFaction - the player profile's faction * @param cargoStatsDefinition - the cargo stats definition * @param gameId - the SAGE game id * @param gameState - the game state account associated with `gameId` * @param key - the key authorized to run this instruction, should have at least `ADD_REMOVE_CARGO` SAGE permissions * @param keyIndex - the index of the `key` in the `playerProfile` permissions * @returns InstructionReturn[] */ export declare const cleanUpStarbaseCargoPods: (connection: Connection, sageProgram: SageIDLProgram, cargoProgram: CargoIDLProgram, playerProfile: PublicKey, profileFaction: PublicKey, cargoStatsDefinition: PublicKey, gameId: PublicKey, gameState: PublicKey, key: AsyncSigner, keyIndex: number) => Promise; /** * Find the certificate mint address * This mint represents cargo at a specific location (the starbase) * @param program - SAGE program * @param starbase - the Starbase * @param cargoMint - the cargo mint address * @param starbaseSeqId - the Starbase sequence id * @returns The PDA and bump respectively */ export declare const findCertificateMintAddress: (program: SageIDLProgram, starbase: PublicKey, cargoMint: PublicKey, starbaseSeqId: number) => [PublicKey, number]; /** * Find the local market account meta list address * * The account meta list is used to store all extra required * accounts needed when transferring tokens of mints that use the * Token 2022 program's transfer hook extension. * @param transferHookProgram - the transfer hook program * @param mint - the cargo mint * @returns The PDA and bump respectively */ export declare const findExtraAccountMetaListAddress: (transferHookProgram: PublicKey, mint: PublicKey) => [PublicKey, number]; /** * Ensures that the return is a PublicKey instance * @param input - the input to normalize * @returns the PublicKey */ export declare const normalizePublicKey: (input: number[] | PublicKey) => PublicKey; /** * The divideIntoParts function divides a number n into p parts, ensuring that the sum of * the parts equals n. If n cannot be divided equally, the remainder is distributed across * the parts. The result is returned as an array of length p, where each element represents * a part of n. * @param n - The number to be divided. This represents the total sum that needs to be distributed. * @param p - The number of parts into which n should be divided. * @returns An array of length p containing the parts of n. The elements of the array will sum up to n. */ export declare function divideIntoParts(n: number, p: number): number[]; export {}; //# sourceMappingURL=utils.d.ts.map