UNPKG

@wuwei-labs/srsly

Version:
72 lines 2.29 kB
/** * Constants used for PDA derivation across SRSLY, SAGE, and Thread programs * @module pda/constants */ /** * Faction-specific coordinates for starbase derivation in SAGE * These coordinates are used to derive starbase PDAs */ export const FACTION_COORDINATES = { mud: { x: 0, y: -39 }, oni: { x: -40, y: 30 }, ustur: { x: 40, y: 30 }, }; /** * Mapping of numeric faction IDs to faction names */ export const FACTION_MAPPING = { 1: 'mud', 2: 'oni', 3: 'ustur', }; /** * Seed constants for SAGE program PDA derivation */ export const STARBASE_SEED = 'Starbase'; export const STARBASE_PLAYER_SEED = 'starbase_player'; export const SAGE_PLAYER_PROFILE_SEED = 'sage_player_profile'; export const PROFILE_FACTION_SEED = 'player_faction'; /** * Seed constants for SRSLY program PDA derivation */ export const CONTRACT_SEED = 'rental_contract'; export const RENTAL_SEED = 'rental_state'; export const RENTAL_AUTHORITY_SEED = 'rental_authority'; export const BORROWER_STATE_SEED = 'borrower_state'; export const CONFIG_SEED = 'config'; export const ACTIVE_RENTAL_SEED = 'active'; export const QUEUED_RENTAL_SEED = 'queued'; /** * Antegen program addresses and seed constants for PDA derivation */ export const ANTEGEN_THREAD_PROGRAM = 'AgTv5w1UvUb6zeqkThwMrztGu9hpepBu8YLghuR4dpSx'; export const ANTEGEN_FIBER_PROGRAM = 'AgFv5afjW9DmSPkiEvJ1er5bAAmRUqaBeTB6Cr8e1hKx'; export const THREAD_SEED = 'thread'; export const THREAD_FIBER_SEED = 'thread_fiber'; /** * Type guard to check if a value is a valid faction name */ export function isValidFactionName(faction) { return faction === 'mud' || faction === 'oni' || faction === 'ustur'; } /** * Get faction name from numeric faction ID */ export function getFactionName(factionId) { const name = FACTION_MAPPING[factionId]; if (!name) { throw new Error(`Invalid faction ID: ${factionId}. Expected 1 (mud), 2 (oni), or 3 (ustur)`); } return name; } /** * Get faction coordinates by name */ export function getFactionCoordinates(faction) { const coords = FACTION_COORDINATES[faction.toLowerCase()]; if (!coords) { throw new Error(`Invalid faction: ${faction}. Expected 'mud', 'oni', or 'ustur'`); } return coords; } //# sourceMappingURL=constants.js.map