-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(store,world): move/rename v2 config output types (#2432)
- Loading branch information
Showing
20 changed files
with
111 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import { SchemaAbiType } from "@latticexyz/schema-type"; | ||
import { ResolvedTableConfig } from "@latticexyz/store/config/v2"; | ||
|
||
export type Schema = { readonly [key: string]: { readonly type: SchemaAbiType } }; | ||
import { Table, Schema } from "@latticexyz/store/config/v2"; | ||
|
||
export type schemaAbiTypes<schema extends Schema> = { | ||
[key in keyof schema]: schema[key]["type"]; | ||
}; | ||
|
||
export type TableRecord<table extends ResolvedTableConfig = ResolvedTableConfig> = { | ||
export type TableRecord<table extends Table = Table> = { | ||
readonly table: table; | ||
readonly fields: schemaAbiTypes<table["schema"]>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { DynamicAbiType, StaticAbiType } from "@latticexyz/schema-type"; | ||
import { Hex } from "viem"; | ||
|
||
// Although we could import `SchemaAbiType` from `@latticexyz/schema-type` here, we "redefine" this here | ||
// so that our downstream type errors give back `AbiType` instead of the union of all possible ABI types. | ||
// | ||
// This is a bit of a TS compiler hack and we should figure out a better long-term approach. | ||
export type AbiType = StaticAbiType | DynamicAbiType; | ||
|
||
export type UserTypes = { | ||
readonly [userTypeName: string]: AbiType; | ||
}; | ||
|
||
export type Enums = { | ||
readonly [enumName: string]: readonly [string, ...string[]]; | ||
}; | ||
|
||
export 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; | ||
}; | ||
}; | ||
|
||
export type KeySchema = { | ||
readonly [keyName: string]: { | ||
/** the Solidity primitive ABI type */ | ||
readonly type: StaticAbiType; | ||
/** the user defined type or Solidity primitive ABI type */ | ||
readonly internalType: string; | ||
}; | ||
}; | ||
|
||
export type Table = { | ||
readonly tableId: Hex; | ||
readonly primaryKey: readonly string[]; | ||
readonly schema: Schema; | ||
/** @deprecated Use `schema` and `primaryKey` */ | ||
readonly keySchema: KeySchema; | ||
/** @deprecated Use `schema` and `primaryKey` */ | ||
readonly valueSchema: Schema; | ||
}; | ||
|
||
export type Config = { | ||
readonly tables: { | ||
readonly [namespacedTableName: string]: Table; | ||
}; | ||
readonly userTypes: UserTypes; | ||
readonly enums: Enums; | ||
readonly namespace: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./world"; | ||
export * from "./output"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Config as StoreConfig, Table } from "@latticexyz/store/config/v2"; | ||
|
||
export type Config = StoreConfig & { | ||
readonly namespaces: { | ||
readonly [namespace: string]: { | ||
readonly tables: { | ||
readonly [tableName: string]: Table; | ||
}; | ||
}; | ||
}; | ||
}; |
Oops, something went wrong.