import { Hex } from 'viem'; import { StaticAbiType, DynamicAbiType } from '@latticexyz/schema-type/internal'; export { DynamicAbiType, StaticAbiType } from '@latticexyz/schema-type/internal'; import { ResourceType } from '@latticexyz/common'; import { satisfy } from '@ark/util'; /** * Common output types of a MUD config. We use these types as inputs for libraries. */ type AbiType = StaticAbiType | DynamicAbiType; type Schema = { readonly [fieldName: string]: { /** the Solidity primitive ABI type */ readonly type: AbiType; /** the user defined type or Solidity primitive ABI type */ readonly internalType: string; }; }; type Table = { /** * Human-readable label for this table. Used as config keys, library names, and filenames. * Labels are not length constrained like resource names, but special characters should be avoided to be compatible with the filesystem, Solidity compiler, etc. */ readonly label: string; /** * Human-readable label for this table's namespace. Used for namespace config keys and directory names. */ readonly namespaceLabel: string; /** * Table type used in table's resource ID and determines how storage and events are used by this table. */ readonly type: satisfy; /** * Table namespace used in table's resource ID and determines access control. */ readonly namespace: string; /** * Table name used in table's resource ID. */ readonly name: string; /** * Table's resource ID. */ readonly tableId: Hex; /** * Schema definition for this table's records. */ readonly schema: Schema; /** * Primary key for records of this table. An array of zero or more schema field names. * Using an empty array acts like a singleton, where only one record can exist for this table. */ readonly key: readonly string[]; }; type Tables = { readonly [label: string]: Table; }; export type { AbiType, Schema, Table, Tables };