diff --git a/packages/store/ts/config/v2/store.test.ts b/packages/store/ts/config/v2/store.test.ts index b8458e1ccc..93c83c32a7 100644 --- a/packages/store/ts/config/v2/store.test.ts +++ b/packages/store/ts/config/v2/store.test.ts @@ -13,7 +13,7 @@ describe("resolveStoreConfig", () => { Name: { tableId: resourceToHex({ type: "table", namespace: "", name: "Name" }), schema: { - key: { + id: { type: "bytes32", internalType: "bytes32", }, @@ -23,7 +23,7 @@ describe("resolveStoreConfig", () => { }, }, keySchema: { - key: { + id: { type: "bytes32", internalType: "bytes32", }, @@ -34,7 +34,7 @@ describe("resolveStoreConfig", () => { internalType: "address", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "Name", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, @@ -60,7 +60,7 @@ describe("resolveStoreConfig", () => { Name: { tableId: resourceToHex({ type: "table", namespace: "", name: "Name" }), schema: { - key: { + id: { type: "bytes32", internalType: "bytes32", }, @@ -70,7 +70,7 @@ describe("resolveStoreConfig", () => { }, }, keySchema: { - key: { + id: { type: "bytes32", internalType: "bytes32", }, @@ -81,7 +81,7 @@ describe("resolveStoreConfig", () => { internalType: "CustomType", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "Name", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, @@ -97,14 +97,14 @@ describe("resolveStoreConfig", () => { attest(config).equals(expected); }); - it("given a schema with a key field with static ABI type, it should use `key` as single key", () => { - const config = resolveStoreConfig({ tables: { Example: { key: "address", name: "string", age: "uint256" } } }); + it("given a schema with a key field with static ABI type, it should use `id` as single key", () => { + const config = resolveStoreConfig({ tables: { Example: { id: "address", name: "string", age: "uint256" } } }); const expected = { tables: { Example: { tableId: resourceToHex({ type: "table", namespace: "", name: "Example" }), schema: { - key: { + id: { type: "address", internalType: "address", }, @@ -118,7 +118,7 @@ describe("resolveStoreConfig", () => { }, }, keySchema: { - key: { + id: { type: "address", internalType: "address", }, @@ -133,7 +133,7 @@ describe("resolveStoreConfig", () => { internalType: "uint256", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "Example", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, @@ -149,14 +149,14 @@ describe("resolveStoreConfig", () => { attest(config).equals(expected); }); - it("given a schema with a key field with static custom type, it should use `key` as single key", () => { - const config = resolveStoreConfig({ tables: { Example: { key: "address", name: "string", age: "uint256" } } }); + it("given a schema with a key field with static custom type, it should use `id` as single key", () => { + const config = resolveStoreConfig({ tables: { Example: { id: "address", name: "string", age: "uint256" } } }); const expected = { tables: { Example: { tableId: resourceToHex({ type: "table", namespace: "", name: "Example" }), schema: { - key: { + id: { type: "address", internalType: "address", }, @@ -170,7 +170,7 @@ describe("resolveStoreConfig", () => { }, }, keySchema: { - key: { + id: { type: "address", internalType: "address", }, @@ -185,7 +185,7 @@ describe("resolveStoreConfig", () => { internalType: "uint256", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "Example", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, @@ -205,7 +205,7 @@ describe("resolveStoreConfig", () => { attest(() => resolveStoreConfig({ tables: { - // @ts-expect-error Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option. + // @ts-expect-error Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option. Example: { name: "string", age: "uint256", @@ -213,31 +213,31 @@ describe("resolveStoreConfig", () => { }, }), ).throwsAndHasTypeError( - "Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option.", + "Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option.", ); }); it("throw an error if the shorthand config includes a non-static key field", () => { attest(() => - // @ts-expect-error Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option. - resolveStoreConfig({ tables: { Example: { key: "string", name: "string", age: "uint256" } } }), + // @ts-expect-error Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option. + resolveStoreConfig({ tables: { Example: { id: "string", name: "string", age: "uint256" } } }), ).throwsAndHasTypeError( - "Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option.", + "Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option.", ); }); it("throw an error if the shorthand config includes a non-static user type as key field", () => { attest(() => resolveStoreConfig({ - // @ts-expect-error Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option. - tables: { Example: { key: "dynamic", name: "string", age: "uint256" } }, + // @ts-expect-error Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option. + tables: { Example: { id: "dynamic", name: "string", age: "uint256" } }, userTypes: { dynamic: { type: "string", filePath: "path/to/file" }, static: { type: "address", filePath: "path/to/file" }, }, }), ).throwsAndHasTypeError( - "Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option.", + "Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option.", ); }); @@ -245,7 +245,7 @@ describe("resolveStoreConfig", () => { const config = resolveStoreConfig({ tables: { Example: { - schema: { key: "address", name: "string", age: "uint256" }, + schema: { id: "address", name: "string", age: "uint256" }, primaryKey: ["age"], }, }, @@ -255,7 +255,7 @@ describe("resolveStoreConfig", () => { Example: { tableId: resourceToHex({ type: "table", namespace: "", name: "Example" }), schema: { - key: { + id: { type: "address", internalType: "address", }, @@ -275,7 +275,7 @@ describe("resolveStoreConfig", () => { }, }, valueSchema: { - key: { + id: { type: "address", internalType: "address", }, @@ -304,7 +304,7 @@ describe("resolveStoreConfig", () => { const config = resolveStoreConfig({ tables: { Example: { - schema: { key: "dynamic", name: "string", age: "static" }, + schema: { id: "dynamic", name: "string", age: "static" }, primaryKey: ["age"], }, }, @@ -318,7 +318,7 @@ describe("resolveStoreConfig", () => { Example: { tableId: resourceToHex({ type: "table", namespace: "", name: "Example" }), schema: { - key: { + id: { type: "string", internalType: "dynamic", }, @@ -338,7 +338,7 @@ describe("resolveStoreConfig", () => { }, }, valueSchema: { - key: { + id: { type: "string", internalType: "dynamic", }, @@ -369,8 +369,8 @@ describe("resolveStoreConfig", () => { const config = resolveStoreConfig({ tables: { Example: { - schema: { key: "address", name: "string", age: "uint256" }, - primaryKey: ["age", "key"], + schema: { id: "address", name: "string", age: "uint256" }, + primaryKey: ["age", "id"], }, }, }); @@ -379,7 +379,7 @@ describe("resolveStoreConfig", () => { Example: { tableId: resourceToHex({ type: "table", namespace: "", name: "Example" }), schema: { - key: { + id: { type: "address", internalType: "address", }, @@ -397,7 +397,7 @@ describe("resolveStoreConfig", () => { type: "uint256", internalType: "uint256", }, - key: { + id: { type: "address", internalType: "address", }, @@ -408,7 +408,7 @@ describe("resolveStoreConfig", () => { internalType: "string", }, }, - primaryKey: ["age", "key"], + primaryKey: ["age", "id"], name: "Example", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, @@ -658,15 +658,15 @@ describe("resolveStoreConfig", () => { resolveStoreConfig({ tables: { Example: { - schema: { key: "address", name: "string", age: "uint256" }, - // @ts-expect-error Type '"name"' is not assignable to type '"key" | "age"'. + schema: { id: "address", name: "string", age: "uint256" }, + // @ts-expect-error Type '"name"' is not assignable to type '"id" | "age"'. primaryKey: ["name"], }, }, }), ) - .throws('Invalid primary key. Expected `("key" | "age")[]`, received `["name"]`') - .type.errors(`Type '"name"' is not assignable to type '"key" | "age"'`); + .throws('Invalid primary key. Expected `("id" | "age")[]`, received `["name"]`') + .type.errors(`Type '"name"' is not assignable to type '"id" | "age"'`); }); it("should throw an error if the provided key is not a static field with user types", () => { @@ -674,8 +674,8 @@ describe("resolveStoreConfig", () => { resolveStoreConfig({ tables: { Example: { - schema: { key: "address", name: "Dynamic", age: "uint256" }, - // @ts-expect-error Type '"name"' is not assignable to type '"key" | "age"'. + schema: { id: "address", name: "Dynamic", age: "uint256" }, + // @ts-expect-error Type '"name"' is not assignable to type '"id" | "age"'. primaryKey: ["name"], }, }, @@ -684,15 +684,15 @@ describe("resolveStoreConfig", () => { }, }), ) - .throws('Invalid primary key. Expected `("key" | "age")[]`, received `["name"]`') - .type.errors(`Type '"name"' is not assignable to type '"key" | "age"'`); + .throws('Invalid primary key. Expected `("id" | "age")[]`, received `["name"]`') + .type.errors(`Type '"name"' is not assignable to type '"id" | "age"'`); }); it("should return the full config given a full config with enums and user types", () => { const config = resolveStoreConfig({ tables: { Example: { - schema: { key: "dynamic", name: "ValidNames", age: "static" }, + schema: { id: "dynamic", name: "ValidNames", age: "static" }, primaryKey: ["name"], }, }, @@ -709,7 +709,7 @@ describe("resolveStoreConfig", () => { Example: { tableId: resourceToHex({ type: "table", namespace: "", name: "Example" }), schema: { - key: { + id: { type: "string", internalType: "dynamic", }, @@ -733,7 +733,7 @@ describe("resolveStoreConfig", () => { type: "address", internalType: "static", }, - key: { + id: { type: "string", internalType: "dynamic", }, @@ -784,7 +784,7 @@ describe("resolveStoreConfig", () => { namespace: "namespace", tables: { Example: { - schema: { key: "address", name: "string", age: "uint256" }, + schema: { id: "address", name: "string", age: "uint256" }, primaryKey: ["age"], }, }, diff --git a/packages/store/ts/config/v2/table.test.ts b/packages/store/ts/config/v2/table.test.ts index 54851be0af..cd3adb2a34 100644 --- a/packages/store/ts/config/v2/table.test.ts +++ b/packages/store/ts/config/v2/table.test.ts @@ -12,7 +12,7 @@ describe("resolveTableConfig", () => { const expected = { tableId: "0x" as Hex, schema: { - key: { + id: { type: "bytes32", internalType: "bytes32", }, @@ -22,7 +22,7 @@ describe("resolveTableConfig", () => { }, }, keySchema: { - key: { + id: { type: "bytes32", internalType: "bytes32", }, @@ -33,7 +33,7 @@ describe("resolveTableConfig", () => { internalType: "address", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, @@ -49,7 +49,7 @@ describe("resolveTableConfig", () => { const expected = { tableId: "0x" as Hex, schema: { - key: { + id: { type: "bytes32", internalType: "bytes32", }, @@ -59,7 +59,7 @@ describe("resolveTableConfig", () => { }, }, keySchema: { - key: { + id: { type: "bytes32", internalType: "bytes32", }, @@ -70,7 +70,7 @@ describe("resolveTableConfig", () => { internalType: "CustomType", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, @@ -80,12 +80,12 @@ describe("resolveTableConfig", () => { attest(table).equals(expected); }); - it("should use `key` as single key if it has a static ABI type", () => { - const table = resolveTableConfig({ key: "address", name: "string", age: "uint256" }); + it("should use `id` as single key if it has a static ABI type", () => { + const table = resolveTableConfig({ id: "address", name: "string", age: "uint256" }); const expected = { tableId: "0x" as Hex, schema: { - key: { + id: { type: "address", internalType: "address", }, @@ -99,7 +99,7 @@ describe("resolveTableConfig", () => { }, }, keySchema: { - key: { + id: { type: "address", internalType: "address", }, @@ -114,7 +114,7 @@ describe("resolveTableConfig", () => { internalType: "uint256", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, @@ -124,13 +124,13 @@ describe("resolveTableConfig", () => { attest(table).equals(expected); }); - it("should use `key` as single key if it has a static custom type", () => { + it("should use `id` as single key if it has a static custom type", () => { const scope = extendScope(AbiTypeScope, { CustomType: "uint256" }); - const table = resolveTableConfig({ key: "CustomType", name: "string", age: "uint256" }, scope); + const table = resolveTableConfig({ id: "CustomType", name: "string", age: "uint256" }, scope); const expected = { tableId: "0x" as Hex, schema: { - key: { + id: { type: "uint256", internalType: "CustomType", }, @@ -144,7 +144,7 @@ describe("resolveTableConfig", () => { }, }, keySchema: { - key: { + id: { type: "uint256", internalType: "CustomType", }, @@ -159,7 +159,7 @@ describe("resolveTableConfig", () => { internalType: "uint256", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, @@ -170,17 +170,17 @@ describe("resolveTableConfig", () => { }); it("should throw if the shorthand key is a dynamic ABI type", () => { - // @ts-expect-error Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option. - attest(() => resolveTableConfig({ key: "string", name: "string", age: "uint256" })).throwsAndHasTypeError( - "Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option.", + // @ts-expect-error Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option. + attest(() => resolveTableConfig({ id: "string", name: "string", age: "uint256" })).throwsAndHasTypeError( + "Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option.", ); }); it("should throw if the shorthand key is a dyamic custom type", () => { const scope = extendScope(AbiTypeScope, { CustomType: "bytes" }); - // @ts-expect-error Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option. - attest(() => resolveTableConfig({ key: "CustomType" }, scope)).throwsAndHasTypeError( - "Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option.", + // @ts-expect-error Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option. + attest(() => resolveTableConfig({ id: "CustomType" }, scope)).throwsAndHasTypeError( + "Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option.", ); }); @@ -192,21 +192,21 @@ describe("resolveTableConfig", () => { }); it("should throw if the shorthand doesn't include a key field", () => { - // @ts-expect-error Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option. + // @ts-expect-error Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option. attest(() => resolveTableConfig({ name: "string", age: "uint256" })).throwsAndHasTypeError( - "Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option.", + "Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option.", ); }); it("should return the full config given a full config with one key", () => { const table = resolveTableConfig({ - schema: { key: "address", name: "string", age: "uint256" }, + schema: { id: "address", name: "string", age: "uint256" }, primaryKey: ["age"], }); const expected = { tableId: "0x" as Hex, schema: { - key: { type: "address", internalType: "address" }, + id: { type: "address", internalType: "address" }, name: { type: "string", internalType: "string" }, age: { type: "uint256", internalType: "uint256" }, }, @@ -214,7 +214,7 @@ describe("resolveTableConfig", () => { age: { type: "uint256", internalType: "uint256" }, }, valueSchema: { - key: { type: "address", internalType: "address" }, + id: { type: "address", internalType: "address" }, name: { type: "string", internalType: "string" }, }, primaryKey: ["age"], @@ -229,24 +229,24 @@ describe("resolveTableConfig", () => { it("should return the full config given a full config with two primaryKey", () => { const table = resolveTableConfig({ - schema: { key: "address", name: "string", age: "uint256" }, - primaryKey: ["age", "key"], + schema: { id: "address", name: "string", age: "uint256" }, + primaryKey: ["age", "id"], }); const expected = { tableId: "0x" as Hex, schema: { - key: { type: "address", internalType: "address" }, + id: { type: "address", internalType: "address" }, name: { type: "string", internalType: "string" }, age: { type: "uint256", internalType: "uint256" }, }, keySchema: { age: { type: "uint256", internalType: "uint256" }, - key: { type: "address", internalType: "address" }, + id: { type: "address", internalType: "address" }, }, valueSchema: { name: { type: "string", internalType: "string" }, }, - primaryKey: ["age", "key"], + primaryKey: ["age", "id"], name: "", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, @@ -258,11 +258,11 @@ describe("resolveTableConfig", () => { it("should return the full config given a config with custom types as values", () => { const scope = extendScope(AbiTypeScope, { CustomString: "string", CustomNumber: "uint256" }); - const table = resolveTableConfig({ key: "address", name: "CustomString", age: "CustomNumber" }, scope); + const table = resolveTableConfig({ id: "address", name: "CustomString", age: "CustomNumber" }, scope); const expected = { tableId: "0x" as Hex, schema: { - key: { + id: { type: "address", internalType: "address", }, @@ -276,7 +276,7 @@ describe("resolveTableConfig", () => { }, }, keySchema: { - key: { + id: { type: "address", internalType: "address", }, @@ -291,7 +291,7 @@ describe("resolveTableConfig", () => { internalType: "CustomNumber", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, @@ -303,11 +303,11 @@ describe("resolveTableConfig", () => { it("should return the full config given a config with custom type as key", () => { const scope = extendScope(AbiTypeScope, { CustomString: "string", CustomNumber: "uint256" }); - const table = resolveTableConfig({ key: "CustomNumber", name: "CustomString", age: "CustomNumber" }, scope); + const table = resolveTableConfig({ id: "CustomNumber", name: "CustomString", age: "CustomNumber" }, scope); const expected = { tableId: "0x" as Hex, schema: { - key: { + id: { type: "uint256", internalType: "CustomNumber", }, @@ -321,7 +321,7 @@ describe("resolveTableConfig", () => { }, }, keySchema: { - key: { + id: { type: "uint256", internalType: "CustomNumber", }, @@ -336,7 +336,7 @@ describe("resolveTableConfig", () => { internalType: "CustomNumber", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, @@ -349,13 +349,13 @@ describe("resolveTableConfig", () => { it("should throw if the provided key is a dynamic ABI type", () => { attest(() => resolveTableConfig({ - schema: { key: "address", name: "string", age: "uint256" }, - // @ts-expect-error Type '"name"' is not assignable to type '"key" | "age"' + schema: { id: "address", name: "string", age: "uint256" }, + // @ts-expect-error Type '"name"' is not assignable to type '"id" | "age"' primaryKey: ["name"], }), ) - .throws('Invalid primary key. Expected `("key" | "age")[]`, received `["name"]`') - .type.errors(`Type '"name"' is not assignable to type '"key" | "age"'`); + .throws('Invalid primary key. Expected `("id" | "age")[]`, received `["name"]`') + .type.errors(`Type '"name"' is not assignable to type '"id" | "age"'`); }); it("should throw if the provided key is a dynamic ABI type if user types are provided", () => { @@ -363,15 +363,15 @@ describe("resolveTableConfig", () => { attest(() => resolveTableConfig( { - schema: { key: "address", name: "string", age: "uint256" }, - // @ts-expect-error Type '"name"' is not assignable to type '"key" | "age"' + schema: { id: "address", name: "string", age: "uint256" }, + // @ts-expect-error Type '"name"' is not assignable to type '"id" | "age"' primaryKey: ["name"], }, scope, ), ) - .throws('Invalid primary key. Expected `("key" | "age")[]`, received `["name"]`') - .type.errors(`Type '"name"' is not assignable to type '"key" | "age"'`); + .throws('Invalid primary key. Expected `("id" | "age")[]`, received `["name"]`') + .type.errors(`Type '"name"' is not assignable to type '"id" | "age"'`); }); it("should throw if the provided key is a dynamic custom type", () => { @@ -379,15 +379,15 @@ describe("resolveTableConfig", () => { attest(() => resolveTableConfig( { - schema: { key: "CustomType", name: "string", age: "uint256" }, - // @ts-expect-error Type '"key"' is not assignable to type '"age"' - primaryKey: ["key"], + schema: { id: "CustomType", name: "string", age: "uint256" }, + // @ts-expect-error Type '"id"' is not assignable to type '"age"' + primaryKey: ["id"], }, scope, ), ) - .throws('Invalid primary key. Expected `("age")[]`, received `["key"]`') - .type.errors(`Type '"key"' is not assignable to type '"age"'`); + .throws('Invalid primary key. Expected `("age")[]`, received `["id"]`') + .type.errors(`Type '"id"' is not assignable to type '"age"'`); }); it("should throw if the provided key is neither a custom nor ABI type", () => { @@ -395,20 +395,20 @@ describe("resolveTableConfig", () => { attest(() => resolveTableConfig( { - schema: { key: "address", name: "string", age: "uint256" }, - // @ts-expect-error Type '"NotAKey"' is not assignable to type '"key" | "age"' + schema: { id: "address", name: "string", age: "uint256" }, + // @ts-expect-error Type '"NotAKey"' is not assignable to type '"id" | "age"' primaryKey: ["NotAKey"], }, scope, ), ) - .throws('Invalid primary key. Expected `("key" | "age")[]`, received `["NotAKey"]`') - .type.errors(`Type '"NotAKey"' is not assignable to type '"key" | "age"'`); + .throws('Invalid primary key. Expected `("id" | "age")[]`, received `["NotAKey"]`') + .type.errors(`Type '"NotAKey"' is not assignable to type '"id" | "age"'`); }); it("should extend the output Table type", () => { const scope = extendScope(AbiTypeScope, { CustomString: "string", CustomNumber: "uint256" }); - const table = resolveTableConfig({ key: "CustomNumber", name: "CustomString", age: "CustomNumber" }, scope); + const table = resolveTableConfig({ id: "CustomNumber", name: "CustomString", age: "CustomNumber" }, scope); attest(); }); }); diff --git a/packages/store/ts/config/v2/table.ts b/packages/store/ts/config/v2/table.ts index 1c6ec46a16..e27426d4b8 100644 --- a/packages/store/ts/config/v2/table.ts +++ b/packages/store/ts/config/v2/table.ts @@ -1,4 +1,4 @@ -import { ErrorMessage, evaluate } from "@arktype/util"; +import { evaluate } from "@arktype/util"; import { SchemaInput } from "./schema"; import { AbiTypeScope } from "./scope"; import { @@ -17,9 +17,6 @@ import { } from "./tableFull"; import { CONFIG_DEFAULTS } from "./defaults"; -export type NoStaticKeyFieldError = - ErrorMessage<"Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option.">; - export type TableInput< schema extends SchemaInput = SchemaInput, scope extends AbiTypeScope = AbiTypeScope, @@ -61,9 +58,9 @@ export type resolveTableConfig< /** * If a shorthand table config is passed we expand it with sane defaults: - * - A single ABI type is turned into { schema: { key: "bytes32", value: INPUT }, key: ["key"] }. - * - A schema with a `key` field with static ABI type is turned into { schema: INPUT, key: ["key"] }. - * - A schema without a `key` field is invalid. + * - A single ABI type is turned into { schema: { id: "bytes32", value: INPUT }, primaryKey: ["id"] }. + * - A schema with a `id` field with static ABI type is turned into { schema: INPUT, primaryKey: ["id"] }. + * - A schema without a `id` field is invalid. */ export function resolveTableConfig< input, diff --git a/packages/store/ts/config/v2/tableShorthand.test.ts b/packages/store/ts/config/v2/tableShorthand.test.ts index b5a4112673..2443fe30b7 100644 --- a/packages/store/ts/config/v2/tableShorthand.test.ts +++ b/packages/store/ts/config/v2/tableShorthand.test.ts @@ -4,40 +4,40 @@ import { AbiTypeScope, extendScope } from "./scope"; import { resolveTableShorthand } from "./tableShorthand"; describe("resolveTableShorthand", () => { - it("should expand a single ABI type into a key/value schema", () => { + it("should expand a single ABI type into a id/value schema", () => { const table = resolveTableShorthand("address"); attest<{ schema: { - key: "bytes32"; + id: "bytes32"; value: "address"; }; - primaryKey: ["key"]; + primaryKey: ["id"]; }>(table).equals({ schema: { - key: "bytes32", + id: "bytes32", value: "address", }, - primaryKey: ["key"], + primaryKey: ["id"], }); }); - it("should expand a single custom type into a key/value schema", () => { + it("should expand a single custom type into a id/value schema", () => { const scope = extendScope(AbiTypeScope, { CustomType: "uint256" }); const table = resolveTableShorthand("CustomType", scope); attest<{ schema: { - key: "bytes32"; + id: "bytes32"; value: "CustomType"; }; - primaryKey: ["key"]; + primaryKey: ["id"]; }>(table).equals({ schema: { - key: "bytes32", + id: "bytes32", value: "CustomType", }, - primaryKey: ["key"], + primaryKey: ["id"], }); }); @@ -63,73 +63,73 @@ describe("resolveTableShorthand", () => { ); }); - it("should use `key` as single key if it has a static ABI type", () => { - const table = resolveTableShorthand({ key: "address", name: "string", age: "uint256" }); + it("should use `id` as single key if it has a static ABI type", () => { + const table = resolveTableShorthand({ id: "address", name: "string", age: "uint256" }); attest<{ schema: { - key: "address"; + id: "address"; name: "string"; age: "uint256"; }; - primaryKey: ["key"]; + primaryKey: ["id"]; }>(table).equals({ schema: { - key: "address", + id: "address", name: "string", age: "uint256", }, - primaryKey: ["key"], + primaryKey: ["id"], }); }); - it("should throw an error if the shorthand doesn't include a key field", () => { + it("should throw an error if the shorthand doesn't include an `id` field", () => { attest(() => - // @ts-expect-error Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option. + // @ts-expect-error Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option. resolveTableShorthand({ name: "string", age: "uint256" }), ).throwsAndHasTypeError( - "Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option.", + "Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option.", ); }); - it("should throw an error if the shorthand config includes a non-static key field", () => { + it("should throw an error if the shorthand config includes a non-static `id` field", () => { attest(() => - // @ts-expect-error Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option. - resolveTableShorthand({ key: "string", name: "string", age: "uint256" }), + // @ts-expect-error Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option. + resolveTableShorthand({ id: "string", name: "string", age: "uint256" }), ).throwsAndHasTypeError( - "Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option.", + "Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option.", ); }); it("should throw an error if an invalid type is passed in", () => { attest(() => // @ts-expect-error Type '"NotACustomType"' is not assignable to type 'AbiType'. - resolveTableShorthand({ key: "uint256", name: "NotACustomType" }), + resolveTableShorthand({ id: "uint256", name: "NotACustomType" }), ) .throws("Invalid schema. Are you using invalid types or missing types in your scope?") .type.errors(`Type '"NotACustomType"' is not assignable to type 'AbiType'.`); }); - it("should use `key` as single key if it has a static custom type", () => { + it("should use `id` as single key if it has a static custom type", () => { const scope = extendScope(AbiTypeScope, { CustomType: "uint256" }); - const table = resolveTableShorthand({ key: "CustomType", name: "string", age: "uint256" }, scope); + const table = resolveTableShorthand({ id: "CustomType", name: "string", age: "uint256" }, scope); attest<{ - schema: { key: "CustomType"; name: "string"; age: "uint256" }; - primaryKey: ["key"]; + schema: { id: "CustomType"; name: "string"; age: "uint256" }; + primaryKey: ["id"]; }>(table).equals({ - schema: { key: "CustomType", name: "string", age: "uint256" }, - primaryKey: ["key"], + schema: { id: "CustomType", name: "string", age: "uint256" }, + primaryKey: ["id"], }); }); - it("should throw an error if `key` is not a custom static type", () => { + it("should throw an error if `id` is not a custom static type", () => { const scope = extendScope(AbiTypeScope, { CustomType: "bytes" }); attest(() => - // @ts-expect-error "Error: Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option." - resolveTableShorthand({ key: "CustomType", name: "string", age: "uint256" }, scope), + // @ts-expect-error "Error: Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option." + resolveTableShorthand({ id: "CustomType", name: "string", age: "uint256" }, scope), ).throwsAndHasTypeError( - "Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option.", + "Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option.", ); }); }); diff --git a/packages/store/ts/config/v2/tableShorthand.ts b/packages/store/ts/config/v2/tableShorthand.ts index 1817f0dabd..1d445587eb 100644 --- a/packages/store/ts/config/v2/tableShorthand.ts +++ b/packages/store/ts/config/v2/tableShorthand.ts @@ -1,11 +1,13 @@ -import { evaluate } from "@arktype/util"; +import { ErrorMessage, evaluate } from "@arktype/util"; import { isStaticAbiType } from "@latticexyz/schema-type"; import { hasOwnKey } from "./generics"; import { SchemaInput, isSchemaInput } from "./schema"; import { AbiTypeScope, getStaticAbiTypeKeys } from "./scope"; -import { NoStaticKeyFieldError } from "./table"; import { TableFullInput } from "./tableFull"; +export type NoStaticKeyFieldError = + ErrorMessage<"Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option.">; + export type TableShorthandInput = SchemaInput | keyof scope["types"]; export function isTableShorthandInput( @@ -18,8 +20,8 @@ export function isTableShorthandInput // We don't use `conform` here because the restrictions we're imposing here are not native to typescript export type validateTableShorthand = input extends SchemaInput - ? // If a shorthand schema is provided, require it to have a static key field - "key" extends getStaticAbiTypeKeys + ? // If a shorthand schema is provided, require it to have a static `id` field + "id" extends getStaticAbiTypeKeys ? input : NoStaticKeyFieldError : input extends keyof scope["types"] @@ -40,11 +42,11 @@ export function validateTableShorthand = input extends keyof scope["types"] ? evaluate< TableFullInput< - { key: "bytes32"; value: input }, + { id: "bytes32"; value: input }, scope, - ["key" & getStaticAbiTypeKeys<{ key: "bytes32"; value: input }, scope>] + ["id" & getStaticAbiTypeKeys<{ id: "bytes32"; value: input }, scope>] > > : input extends SchemaInput - ? "key" extends getStaticAbiTypeKeys - ? // If the shorthand includes a static field called `key`, use it as key - evaluate> + ? "id" extends getStaticAbiTypeKeys + ? // If the shorthand includes a static field called `id`, use it as `primaryKey` + evaluate> : never : never; @@ -76,15 +78,15 @@ export function resolveTableShorthand; } return { schema: { - key: "bytes32", + id: "bytes32", value: input, }, - primaryKey: ["key"], + primaryKey: ["id"], } as resolveTableShorthand; } diff --git a/packages/world/ts/config/v2/world.test.ts b/packages/world/ts/config/v2/world.test.ts index 71f43c85cd..b9e94f7626 100644 --- a/packages/world/ts/config/v2/world.test.ts +++ b/packages/world/ts/config/v2/world.test.ts @@ -13,11 +13,11 @@ describe("resolveWorldConfig", () => { tables: { ExampleTable: { schema: { - key: "address", + id: "address", value: "uint256", dynamic: "string", }, - primaryKey: ["key"], + primaryKey: ["id"], }, }, }, @@ -29,7 +29,7 @@ describe("resolveWorldConfig", () => { ExampleNamespace__ExampleTable: { tableId: resourceToHex({ type: "table", namespace: "ExampleNamespace", name: "ExampleTable" }), schema: { - key: { + id: { type: "address", internalType: "address", }, @@ -43,7 +43,7 @@ describe("resolveWorldConfig", () => { }, }, keySchema: { - key: { + id: { type: "address", internalType: "address", }, @@ -58,7 +58,7 @@ describe("resolveWorldConfig", () => { internalType: "string", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "ExampleTable", namespace: "ExampleNamespace", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, @@ -71,7 +71,7 @@ describe("resolveWorldConfig", () => { ExampleTable: { tableId: resourceToHex({ type: "table", namespace: "ExampleNamespace", name: "ExampleTable" }), schema: { - key: { + id: { type: "address", internalType: "address", }, @@ -85,7 +85,7 @@ describe("resolveWorldConfig", () => { }, }, keySchema: { - key: { + id: { type: "address", internalType: "address", }, @@ -100,7 +100,7 @@ describe("resolveWorldConfig", () => { internalType: "string", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "ExampleTable", namespace: "ExampleNamespace", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, @@ -125,11 +125,11 @@ describe("resolveWorldConfig", () => { tables: { ExampleTable: { schema: { - key: "Static", + id: "Static", value: "MyEnum", dynamic: "Dynamic", }, - primaryKey: ["key"], + primaryKey: ["id"], }, }, }, @@ -148,7 +148,7 @@ describe("resolveWorldConfig", () => { ExampleNamespace__ExampleTable: { tableId: resourceToHex({ type: "table", namespace: "ExampleNamespace", name: "ExampleTable" }), schema: { - key: { + id: { type: "address", internalType: "Static", }, @@ -162,7 +162,7 @@ describe("resolveWorldConfig", () => { }, }, keySchema: { - key: { + id: { type: "address", internalType: "Static", }, @@ -177,7 +177,7 @@ describe("resolveWorldConfig", () => { internalType: "Dynamic", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "ExampleTable", namespace: "ExampleNamespace", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, @@ -190,7 +190,7 @@ describe("resolveWorldConfig", () => { ExampleTable: { tableId: resourceToHex({ type: "table", namespace: "ExampleNamespace", name: "ExampleTable" }), schema: { - key: { + id: { type: "address", internalType: "Static", }, @@ -204,7 +204,7 @@ describe("resolveWorldConfig", () => { }, }, keySchema: { - key: { + id: { type: "address", internalType: "Static", }, @@ -219,7 +219,7 @@ describe("resolveWorldConfig", () => { internalType: "Dynamic", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "ExampleTable", namespace: "ExampleNamespace", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, @@ -249,11 +249,11 @@ describe("resolveWorldConfig", () => { tables: { ExampleTable: { schema: { - key: "Static", + id: "Static", value: "MyEnum", dynamic: "Dynamic", }, - primaryKey: ["key"], + primaryKey: ["id"], }, }, }, @@ -277,7 +277,7 @@ describe("resolveWorldConfig", () => { AnotherOne: { tables: { Example: { - schema: { key: "address", name: "string", age: "uint256" }, + schema: { id: "address", name: "string", age: "uint256" }, primaryKey: ["age"], }, }, @@ -300,7 +300,7 @@ describe("resolveWorldConfig", () => { Name: { tableId: resourceToHex({ type: "table", namespace: "", name: "Name" }), schema: { - key: { + id: { type: "bytes32", internalType: "bytes32", }, @@ -310,7 +310,7 @@ describe("resolveWorldConfig", () => { }, }, keySchema: { - key: { + id: { type: "bytes32", internalType: "bytes32", }, @@ -321,7 +321,7 @@ describe("resolveWorldConfig", () => { internalType: "address", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "Name", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, @@ -349,7 +349,7 @@ describe("resolveWorldConfig", () => { Name: { tableId: resourceToHex({ type: "table", namespace: "", name: "Name" }), schema: { - key: { + id: { type: "bytes32", internalType: "bytes32", }, @@ -359,7 +359,7 @@ describe("resolveWorldConfig", () => { }, }, keySchema: { - key: { + id: { type: "bytes32", internalType: "bytes32", }, @@ -370,7 +370,7 @@ describe("resolveWorldConfig", () => { internalType: "CustomType", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "Name", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, @@ -387,14 +387,14 @@ describe("resolveWorldConfig", () => { attest(config).equals(expected); }); - it("given a schema with a key field with static ABI type, it should use `key` as single key", () => { - const config = resolveWorldConfig({ tables: { Example: { key: "address", name: "string", age: "uint256" } } }); + it("given a schema with a key field with static ABI type, it should use `id` as single key", () => { + const config = resolveWorldConfig({ tables: { Example: { id: "address", name: "string", age: "uint256" } } }); const expected = { tables: { Example: { tableId: resourceToHex({ type: "table", namespace: "", name: "Example" }), schema: { - key: { + id: { type: "address", internalType: "address", }, @@ -408,7 +408,7 @@ describe("resolveWorldConfig", () => { }, }, keySchema: { - key: { + id: { type: "address", internalType: "address", }, @@ -423,7 +423,7 @@ describe("resolveWorldConfig", () => { internalType: "uint256", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "Example", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, @@ -440,14 +440,14 @@ describe("resolveWorldConfig", () => { attest(config).equals(expected); }); - it("given a schema with a key field with static custom type, it should use `key` as single key", () => { - const config = resolveWorldConfig({ tables: { Example: { key: "address", name: "string", age: "uint256" } } }); + it("given a schema with a key field with static custom type, it should use `id` as single key", () => { + const config = resolveWorldConfig({ tables: { Example: { id: "address", name: "string", age: "uint256" } } }); const expected = { tables: { Example: { tableId: resourceToHex({ type: "table", namespace: "", name: "Example" }), schema: { - key: { + id: { type: "address", internalType: "address", }, @@ -461,7 +461,7 @@ describe("resolveWorldConfig", () => { }, }, keySchema: { - key: { + id: { type: "address", internalType: "address", }, @@ -476,7 +476,7 @@ describe("resolveWorldConfig", () => { internalType: "uint256", }, }, - primaryKey: ["key"], + primaryKey: ["id"], name: "Example", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, @@ -497,7 +497,7 @@ describe("resolveWorldConfig", () => { attest(() => resolveWorldConfig({ tables: { - // @ts-expect-error Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option. + // @ts-expect-error Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option. Example: { name: "string", age: "uint256", @@ -505,31 +505,31 @@ describe("resolveWorldConfig", () => { }, }), ).throwsAndHasTypeError( - "Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option.", + "Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option.", ); }); it("throw an error if the shorthand config includes a non-static key field", () => { attest(() => - // @ts-expect-error Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option. - resolveWorldConfig({ tables: { Example: { key: "string", name: "string", age: "uint256" } } }), + // @ts-expect-error Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option. + resolveWorldConfig({ tables: { Example: { id: "string", name: "string", age: "uint256" } } }), ).throwsAndHasTypeError( - "Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option.", + "Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option.", ); }); it("throw an error if the shorthand config includes a non-static user type as key field", () => { attest(() => resolveWorldConfig({ - // @ts-expect-error Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option. - tables: { Example: { key: "dynamic", name: "string", age: "uint256" } }, + // @ts-expect-error Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option. + tables: { Example: { id: "dynamic", name: "string", age: "uint256" } }, userTypes: { dynamic: { type: "string", filePath: "path/to/file" }, static: { type: "address", filePath: "path/to/file" }, }, }), ).throwsAndHasTypeError( - "Invalid schema. Expected a `key` field with a static ABI type or an explicit `primaryKey` option.", + "Invalid schema. Expected an `id` field with a static ABI type or an explicit `primaryKey` option.", ); }); @@ -537,7 +537,7 @@ describe("resolveWorldConfig", () => { const config = resolveWorldConfig({ tables: { Example: { - schema: { key: "address", name: "string", age: "uint256" }, + schema: { id: "address", name: "string", age: "uint256" }, primaryKey: ["age"], }, }, @@ -547,7 +547,7 @@ describe("resolveWorldConfig", () => { Example: { tableId: resourceToHex({ type: "table", namespace: "", name: "Example" }), schema: { - key: { + id: { type: "address", internalType: "address", }, @@ -567,7 +567,7 @@ describe("resolveWorldConfig", () => { }, }, valueSchema: { - key: { + id: { type: "address", internalType: "address", }, @@ -597,7 +597,7 @@ describe("resolveWorldConfig", () => { const config = resolveWorldConfig({ tables: { Example: { - schema: { key: "dynamic", name: "string", age: "static" }, + schema: { id: "dynamic", name: "string", age: "static" }, primaryKey: ["age"], }, }, @@ -611,7 +611,7 @@ describe("resolveWorldConfig", () => { Example: { tableId: resourceToHex({ type: "table", namespace: "", name: "Example" }), schema: { - key: { + id: { type: "string", internalType: "dynamic", }, @@ -631,7 +631,7 @@ describe("resolveWorldConfig", () => { }, }, valueSchema: { - key: { + id: { type: "string", internalType: "dynamic", }, @@ -663,8 +663,8 @@ describe("resolveWorldConfig", () => { const config = resolveWorldConfig({ tables: { Example: { - schema: { key: "address", name: "string", age: "uint256" }, - primaryKey: ["age", "key"], + schema: { id: "address", name: "string", age: "uint256" }, + primaryKey: ["age", "id"], }, }, }); @@ -673,7 +673,7 @@ describe("resolveWorldConfig", () => { Example: { tableId: resourceToHex({ type: "table", namespace: "", name: "Example" }), schema: { - key: { + id: { type: "address", internalType: "address", }, @@ -691,7 +691,7 @@ describe("resolveWorldConfig", () => { type: "uint256", internalType: "uint256", }, - key: { + id: { type: "address", internalType: "address", }, @@ -702,7 +702,7 @@ describe("resolveWorldConfig", () => { internalType: "string", }, }, - primaryKey: ["age", "key"], + primaryKey: ["age", "id"], name: "Example", namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, @@ -955,15 +955,15 @@ describe("resolveWorldConfig", () => { resolveWorldConfig({ tables: { Example: { - schema: { key: "address", name: "string", age: "uint256" }, - // @ts-expect-error Type '"name"' is not assignable to type '"key" | "age"'. + schema: { id: "address", name: "string", age: "uint256" }, + // @ts-expect-error Type '"name"' is not assignable to type '"id" | "age"'. primaryKey: ["name"], }, }, }), ) - .throws('Invalid primary key. Expected `("key" | "age")[]`, received `["name"]`') - .type.errors(`Type '"name"' is not assignable to type '"key" | "age"'`); + .throws('Invalid primary key. Expected `("id" | "age")[]`, received `["name"]`') + .type.errors(`Type '"name"' is not assignable to type '"id" | "age"'`); }); it("should throw an error if the provided key is not a static field with user types", () => { @@ -971,8 +971,8 @@ describe("resolveWorldConfig", () => { resolveWorldConfig({ tables: { Example: { - schema: { key: "address", name: "Dynamic", age: "uint256" }, - // @ts-expect-error Type '"name"' is not assignable to type '"key" | "age"'. + schema: { id: "address", name: "Dynamic", age: "uint256" }, + // @ts-expect-error Type '"name"' is not assignable to type '"id" | "age"'. primaryKey: ["name"], }, }, @@ -981,15 +981,15 @@ describe("resolveWorldConfig", () => { }, }), ) - .throws('Invalid primary key. Expected `("key" | "age")[]`, received `["name"]`') - .type.errors(`Type '"name"' is not assignable to type '"key" | "age"'`); + .throws('Invalid primary key. Expected `("id" | "age")[]`, received `["name"]`') + .type.errors(`Type '"name"' is not assignable to type '"id" | "age"'`); }); it("should return the full config given a full config with enums and user types", () => { const config = resolveWorldConfig({ tables: { Example: { - schema: { key: "dynamic", name: "ValidNames", age: "static" }, + schema: { id: "dynamic", name: "ValidNames", age: "static" }, primaryKey: ["name"], }, }, @@ -1006,7 +1006,7 @@ describe("resolveWorldConfig", () => { Example: { tableId: resourceToHex({ type: "table", namespace: "", name: "Example" }), schema: { - key: { + id: { type: "string", internalType: "dynamic", }, @@ -1030,7 +1030,7 @@ describe("resolveWorldConfig", () => { type: "address", internalType: "static", }, - key: { + id: { type: "string", internalType: "dynamic", }, @@ -1082,7 +1082,7 @@ describe("resolveWorldConfig", () => { namespace: "namespace", tables: { Example: { - schema: { key: "address", name: "string", age: "uint256" }, + schema: { id: "address", name: "string", age: "uint256" }, primaryKey: ["age"], }, }, diff --git a/packages/world/ts/config/v2/world.ts b/packages/world/ts/config/v2/world.ts index 3ec7cd3c55..c2444b7eec 100644 --- a/packages/world/ts/config/v2/world.ts +++ b/packages/world/ts/config/v2/world.ts @@ -30,7 +30,7 @@ export type WorldConfigInput; -export type NamespacesInput = { [key: string]: NamespaceInput }; +export type NamespacesInput = { [namespace: string]: NamespaceInput }; export type NamespaceInput = Pick;