import { KeyedAccountInfo, PublicKey } from '@solana/web3.js'; import { BN } from '@staratlas/anchor'; import { Account, AsyncSigner, DecodedAccountData, InstructionReturn } from '@staratlas/data-source'; import { SageIDL, SageIDLProgram, SectorAccount } from './constants'; /** * Calculate the distance between two coordinates * @param coordinates1 - the 1st set of coordinates * @param coordinates2 - the 2nd set of coordinates * @returns distance */ export declare const calculateDistance: (coordinates1: [BN, BN], coordinates2: [BN, BN]) => number; /** * Check if two `SectorAccount` instances are equal * @param sector1 - first SectorAccount * @param sector2 - second SectorAccount * @returns a boolean */ export declare function sectorDataEquals(sector1: SectorAccount, sector2: SectorAccount): boolean; export type SectorConnection = { connectionSector: PublicKey; subCoordinates: [BN, BN]; flags: number; }; /** * Check if two `SectorConnection` instances are equal * @param sectorConnection1 - first SectorConnection * @param sectorConnection2 - second SectorConnection * @returns a boolean */ export declare function sectorConnectionEquals(sectorConnection1: SectorConnection, sectorConnection2: SectorConnection): boolean; export declare const SECTOR_CONNECTION_MIN_DATA_SIZE: number; export type ConnectionFlags = { isJumpPoint: boolean; }; /** * Check if two `ConnectionFlags` instances are equal * @param connectionFlags1 - first ConnectionFlags * @param connectionFlags2 - second ConnectionFlags * @returns a boolean */ export declare function connectionFlagsEquals(connectionFlags1: ConnectionFlags, connectionFlags2: ConnectionFlags): boolean; /** * Convert a connection flag to a byte * @param connectionFlags - the connection flag * @returns a byte */ export declare function connectionFlagsToByte(connectionFlags: ConnectionFlags): number; /** * Convert a byte to a connection flag * @param flags - a byte * @returns a ConnectionFlags instance */ export declare function connectionFlagsFromByte(flags: number): ConnectionFlags; export declare class Sector implements Account { private _data; private _key; private _connections; static readonly ACCOUNT_NAME: NonNullable[number]['name']; static readonly MIN_DATA_SIZE: number; constructor(_data: SectorAccount, _key: PublicKey, _connections: SectorConnection[]); get data(): Readonly; get key(): PublicKey; get connections(): Readonly; /** * Finds the Sector PDA * @param program - The SAGE Program IDL * @param gameId - The Game PublicKey * @param coordinates - The Sector Coordinates * @returns - The PDA address and bump respectively */ static findAddress(program: SageIDLProgram, gameId: PublicKey, coordinates: [BN, BN]): [PublicKey, number]; static decodeData(account: KeyedAccountInfo, program: SageIDLProgram): DecodedAccountData; /** * Register a Sector with SAGE * @param program - The SAGE program IDL * @param key - The key authorized for this instruction * @param profile - The Profile with required Permissions * @param discoverer - The `discoverer` of this sector * @param gameId - The Game PublicKey * @param coordinates - The coordinates for the sector * @param name - Name of the sector * @param keyIndex - The Index of the `key` in the permission list * @returns Returns an object with 2 fields: sectorKey and instructions. sectorKey is the PDA for the registered Sector. */ static registerSector(program: SageIDLProgram, key: AsyncSigner, profile: PublicKey, discoverer: PublicKey, gameId: PublicKey, coordinates: [BN, BN], name: string, keyIndex: number): { sectorKey: [PublicKey, number]; instructions: InstructionReturn; }; /** * Discover a Sector * This is meant to be called by players and results in the creation of un-discovered sectors * @param program - The SAGE program IDL * @param key - the key authorized to run this instruction * @param playerProfile - the profile with the required permissions for the instruction * @param profileFaction - the profile's faction * @param fleet - the fleet * @param gameId - The Game PublicKey * @param gameState - the game state * @param coordinates - The coordinates for the sector * @param keyIndex - The Index of the `key` in the permission list * @returns Returns an object with 2 fields: sectorKey and instructions. sectorKey is the PDA for the registered Sector. */ static discoverSector(program: SageIDLProgram, key: AsyncSigner, playerProfile: PublicKey, profileFaction: PublicKey, fleet: PublicKey, gameId: PublicKey, gameState: PublicKey, coordinates: [BN, BN], keyIndex: number): { sectorKey: [PublicKey, number]; instructions: InstructionReturn; }; /** * Add connection between 2 sectors for warping * @param program - The SAGE IDL program * @param key - The key authorized to use this instruction * @param profile - The Profile with permissions required * @param sector1 - The first sector * @param sector2 - The second sector * @param gameId - The Game PublicKey * @param subCoordinates1 - The sub coordinate for warp gate within sector 1 * @param flags1 - The flags for warp gate 1. * @see {@link ConnectionFlags} for more details on flags * @param subCoordinates2 - The sub coordinate for warp gate within sector 2 * @param flags2 - The flags for warp gate 2 * @see {@link ConnectionFlags} for more details on flags * @param keyIndex - The Index of the `key` in the permission list * @returns InstructionReturn */ static addConnection(program: SageIDLProgram, key: AsyncSigner, profile: PublicKey, sector1: PublicKey, sector2: PublicKey, gameId: PublicKey, subCoordinates1: [BN, BN], flags1: ConnectionFlags, subCoordinates2: [BN, BN], flags2: ConnectionFlags, keyIndex: number): InstructionReturn; /** * Remove an existing connection between 2 sectors for warping * @param program - The SAGE IDL program * @param key - The key authorized to use this instruction * @param profile - The Profile with permissions required * @param fundsTo - Account where rent fees go * @param sector1 - The first sector * @param sector2 - The second sector * @param keyIndex - The Index of the `key` in the permission list * @param gameId - The Game PublicKey * @returns InstructionReturn */ static removeConnection(program: SageIDLProgram, key: AsyncSigner, profile: PublicKey, fundsTo: PublicKey | 'funder', sector1: Sector, sector2: Sector, keyIndex: number, gameId: PublicKey): InstructionReturn; } //# sourceMappingURL=sector.d.ts.map