/** * This code was AUTOGENERATED using the Codama library. * Please DO NOT EDIT THIS FILE, instead use visitors * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ import { combineCodec, getAddressDecoder, getAddressEncoder, getArrayDecoder, getArrayEncoder, getSetDecoder, getSetEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, type Address, type Codec, type Decoder, type Encoder, } from '@solana/kit'; import { getShipDecoder, getShipEncoder, getShipIdDecoder, getShipIdEncoder, type Ship, type ShipArgs, type ShipId, type ShipIdArgs, } from '.'; /** A collection of [`Ship`] definitions and their associated mints. This is stored in [`Game`](crate::state::Game::ship_definitions). */ export type ShipDefinitions = { /** The sequence id of this type */ seqId: number; /** Max weighted number of ships in a fleet, calculated with [`ShipCounts::get_fleet_size`] */ maxFleetSize: number; /** The map of mints to ship ids. This should be append-only, as old mints must be retained to allow withdrawal of removed ships. */ mintToId: { /** The total size of the unsized bytes in the list */ unsizedLen: number; /** The list of items containing offsets, and potentially extra metadata, for the start of each element in the unsized list */ offsetList: Array<{ offset: number; key: Address }>; /** The list of byte offsets for the start of each element in the unsized list */ unsizedList: Array>; }; /** The map of ship ids to ship definitions */ ships: { /** The total size of the unsized bytes in the list */ unsizedLen: number; /** The list of items containing offsets, and potentially extra metadata, for the start of each element in the unsized list */ offsetList: Array<{ offset: number; key: ShipId }>; /** The list of byte offsets for the start of each element in the unsized list */ unsizedList: Array; }; }; export type ShipDefinitionsArgs = { /** The sequence id of this type */ seqId: number; /** Max weighted number of ships in a fleet, calculated with [`ShipCounts::get_fleet_size`] */ maxFleetSize: number; /** The map of mints to ship ids. This should be append-only, as old mints must be retained to allow withdrawal of removed ships. */ mintToId: { /** The total size of the unsized bytes in the list */ unsizedLen: number; /** The list of items containing offsets, and potentially extra metadata, for the start of each element in the unsized list */ offsetList: Array<{ offset: number; key: Address }>; /** The list of byte offsets for the start of each element in the unsized list */ unsizedList: Array>; }; /** The map of ship ids to ship definitions */ ships: { /** The total size of the unsized bytes in the list */ unsizedLen: number; /** The list of items containing offsets, and potentially extra metadata, for the start of each element in the unsized list */ offsetList: Array<{ offset: number; key: ShipIdArgs }>; /** The list of byte offsets for the start of each element in the unsized list */ unsizedList: Array; }; }; export function getShipDefinitionsEncoder(): Encoder { return getStructEncoder([ ['seqId', getU32Encoder()], ['maxFleetSize', getU32Encoder()], [ 'mintToId', getStructEncoder([ ['unsizedLen', getU32Encoder()], [ 'offsetList', getArrayEncoder( getStructEncoder([ ['offset', getU32Encoder()], ['key', getAddressEncoder()], ]), ), ], ['unsizedList', getArrayEncoder(getSetEncoder(getShipIdEncoder()))], ]), ], [ 'ships', getStructEncoder([ ['unsizedLen', getU32Encoder()], [ 'offsetList', getArrayEncoder( getStructEncoder([ ['offset', getU32Encoder()], ['key', getShipIdEncoder()], ]), ), ], ['unsizedList', getArrayEncoder(getShipEncoder())], ]), ], ]); } export function getShipDefinitionsDecoder(): Decoder { return getStructDecoder([ ['seqId', getU32Decoder()], ['maxFleetSize', getU32Decoder()], [ 'mintToId', getStructDecoder([ ['unsizedLen', getU32Decoder()], [ 'offsetList', getArrayDecoder( getStructDecoder([ ['offset', getU32Decoder()], ['key', getAddressDecoder()], ]), ), ], ['unsizedList', getArrayDecoder(getSetDecoder(getShipIdDecoder()))], ]), ], [ 'ships', getStructDecoder([ ['unsizedLen', getU32Decoder()], [ 'offsetList', getArrayDecoder( getStructDecoder([ ['offset', getU32Decoder()], ['key', getShipIdDecoder()], ]), ), ], ['unsizedList', getArrayDecoder(getShipDecoder())], ]), ], ]); } export function getShipDefinitionsCodec(): Codec< ShipDefinitionsArgs, ShipDefinitions > { return combineCodec(getShipDefinitionsEncoder(), getShipDefinitionsDecoder()); }