From 5fc685743d742390c8ece41c95e57f9f4c8559bb Mon Sep 17 00:00:00 2001 From: alvrs Date: Thu, 14 Sep 2023 12:43:52 +0100 Subject: [PATCH 01/19] feat: use valueSchema every where --- e2e/packages/contracts/mud.config.ts | 8 ++-- e2e/packages/sync-test/data/encodeTestData.ts | 4 +- e2e/packages/sync-test/data/types.ts | 2 +- .../minimal/packages/contracts/mud.config.ts | 6 +-- packages/cli/scripts/generate-test-tables.ts | 13 +++--- packages/cli/src/utils/deploy.ts | 6 +-- .../protocol-parser/src/decodeRecord.test.ts | 12 +++--- packages/protocol-parser/src/decodeRecord.ts | 16 ++++---- .../protocol-parser/src/encodeRecord.test.ts | 14 +++---- packages/protocol-parser/src/encodeRecord.ts | 15 ++++--- packages/protocol-parser/src/encodeValue.ts | 2 +- .../protocol-parser/src/hexToPackedCounter.ts | 4 +- .../protocol-parser/src/keySchemaToHex.ts | 4 +- .../protocol-parser/src/valueSchemaToHex.ts | 6 +-- packages/store-sync/src/blockLogsToStorage.ts | 4 +- .../src/postgres/buildInternalTables.ts | 1 - packages/store-sync/src/schemaToDefaults.ts | 4 +- packages/store/mud.config.ts | 10 ++--- packages/store/src/IStore.sol | 4 +- packages/store/src/StoreRead.sol | 8 ++-- packages/store/test/StoreCore.t.sol | 4 +- packages/store/test/StoreCoreDynamic.t.sol | 2 +- packages/store/test/StoreCoreGas.t.sol | 22 +++++----- packages/store/test/tables/StoreHooks.t.sol | 2 +- packages/store/ts/codegen/renderTable.ts | 12 +++--- packages/store/ts/codegen/tableOptions.ts | 8 ++-- packages/store/ts/common.ts | 2 +- packages/store/ts/config/storeConfig.ts | 26 ++++++------ .../store/ts/register/mudConfig.test-d.ts | 8 ++-- packages/world/mud.config.ts | 40 +++++++++---------- .../StoreRegistrationSystem.sol | 4 +- .../modules/keysintable/getKeysInTable.sol | 13 +++--- packages/world/ts/register/index.test.ts | 2 +- .../phaser/packages/contracts/mud.config.ts | 2 +- .../threejs/packages/contracts/mud.config.ts | 2 +- .../vanilla/packages/contracts/mud.config.ts | 2 +- 36 files changed, 147 insertions(+), 147 deletions(-) diff --git a/e2e/packages/contracts/mud.config.ts b/e2e/packages/contracts/mud.config.ts index 762ce21584..c3da4297c5 100644 --- a/e2e/packages/contracts/mud.config.ts +++ b/e2e/packages/contracts/mud.config.ts @@ -6,7 +6,7 @@ export default mudConfig({ keySchema: { key: "uint32", }, - schema: { + valueSchema: { value: "uint32", }, }, @@ -14,14 +14,14 @@ export default mudConfig({ keySchema: { key: "uint32", }, - schema: { + valueSchema: { x: "int32", y: "int32", }, }, NumberList: { keySchema: {}, - schema: { + valueSchema: { value: "uint32[]", }, }, @@ -32,7 +32,7 @@ export default mudConfig({ c: "uint256", d: "int120", }, - schema: { + valueSchema: { num: "int256", value: "bool", }, diff --git a/e2e/packages/sync-test/data/encodeTestData.ts b/e2e/packages/sync-test/data/encodeTestData.ts index c0a6ab9dd5..a433626d61 100644 --- a/e2e/packages/sync-test/data/encodeTestData.ts +++ b/e2e/packages/sync-test/data/encodeTestData.ts @@ -18,9 +18,9 @@ export function encodeTestData(testData: Data) { return encodeAbiParameters([{ type: keyType }], [keyValue]); }); - const encodedValue = encodePacked(Object.values(config.tables[table].schema), Object.values(record.value)); + const encodedValue = encodePacked(Object.values(config.tables[table].valueSchema), Object.values(record.value)); - const encodedValueSchema = schemaToHex(abiTypesToSchema(Object.values(config.tables[table].schema))); + const encodedValueSchema = schemaToHex(abiTypesToSchema(Object.values(config.tables[table].valueSchema))); return { key: encodedKey, diff --git a/e2e/packages/sync-test/data/types.ts b/e2e/packages/sync-test/data/types.ts index 4ab5dab4ed..85abd2c90d 100644 --- a/e2e/packages/sync-test/data/types.ts +++ b/e2e/packages/sync-test/data/types.ts @@ -10,7 +10,7 @@ type Key = SchemaToPrimitive< (typeof config)["tables"][Table]["keySchema"] >; type Value
= SchemaToPrimitive< - (typeof config)["tables"][Table]["schema"] + (typeof config)["tables"][Table]["valueSchema"] >; export type Datum
= { diff --git a/examples/minimal/packages/contracts/mud.config.ts b/examples/minimal/packages/contracts/mud.config.ts index 70d98bb5d6..58cf475496 100644 --- a/examples/minimal/packages/contracts/mud.config.ts +++ b/examples/minimal/packages/contracts/mud.config.ts @@ -16,14 +16,14 @@ export default mudConfig({ tables: { CounterTable: { keySchema: {}, - schema: { + valueSchema: { value: "uint32", }, storeArgument: true, }, MessageTable: { keySchema: {}, - schema: { + valueSchema: { value: "string", }, ephemeral: true, @@ -34,7 +34,7 @@ export default mudConfig({ item: "uint32", itemVariant: "uint32", }, - schema: { amount: "uint32" }, + valueSchema: { amount: "uint32" }, }, }, // KeysWithValue doesn't seem to like singleton keys diff --git a/packages/cli/scripts/generate-test-tables.ts b/packages/cli/scripts/generate-test-tables.ts index ec8174f3ee..d7ca0db655 100644 --- a/packages/cli/scripts/generate-test-tables.ts +++ b/packages/cli/scripts/generate-test-tables.ts @@ -1,12 +1,11 @@ import path from "path"; -import { StoreConfig } from "@latticexyz/store"; import { tablegen } from "@latticexyz/store/codegen"; import { mudConfig } from "@latticexyz/world/register"; import { getSrcDirectory } from "@latticexyz/common/foundry"; import { logError } from "../src/utils/errors"; // This config is used only for tests. -// Aside from avoiding `mud.config.mts` in cli package (could cause issues), +// Aside from avoiding `mud.config.ts` in cli package (could cause issues), // this also tests that mudConfig and tablegen can work as standalone functions let config; try { @@ -22,7 +21,7 @@ try { k6: "Enum1", k7: "Enum2", }, - schema: { + valueSchema: { v1: "uint256", v2: "int32", v3: "bytes16", @@ -33,7 +32,7 @@ try { }, }, Dynamics1: { - schema: { + valueSchema: { staticB32: "bytes32[1]", staticI32: "int32[2]", staticU128: "uint128[3]", @@ -42,7 +41,7 @@ try { }, }, Dynamics2: { - schema: { + valueSchema: { u64: "uint64[]", str: "string", b: "bytes", @@ -50,7 +49,7 @@ try { }, Singleton: { keySchema: {}, - schema: { + valueSchema: { v1: "int256", v2: "uint32[2]", v3: "uint32[2]", @@ -59,7 +58,7 @@ try { dataStruct: false, }, Ephemeral: { - schema: "uint256", + valueSchema: "uint256", ephemeral: true, }, }, diff --git a/packages/cli/src/utils/deploy.ts b/packages/cli/src/utils/deploy.ts index e9079dfd39..5ac0bc5bf3 100644 --- a/packages/cli/src/utils/deploy.ts +++ b/packages/cli/src/utils/deploy.ts @@ -147,14 +147,14 @@ export async function deploy( const tableIds: { [tableName: string]: Uint8Array } = {}; promises = [ ...promises, - ...Object.entries(mudConfig.tables).map(async ([tableName, { name, schema, keySchema }]) => { + ...Object.entries(mudConfig.tables).map(async ([tableName, { name, valueSchema, keySchema }]) => { console.log(chalk.blue(`Registering table ${tableName} at ${namespace}/${name}`)); // Store the tableId for later use tableIds[tableName] = toResourceSelector(namespace, name); // Register table - const schemaTypes = Object.values(schema).map((abiOrUserType) => { + const schemaTypes = Object.values(valueSchema).map((abiOrUserType) => { const { schemaType } = resolveAbiOrUserType(abiOrUserType, mudConfig); return schemaType; }); @@ -179,7 +179,7 @@ export async function deploy( encodeSchema(keyTypes), encodeSchema(schemaTypes), Object.keys(keySchema), - Object.keys(schema), + Object.keys(valueSchema), ], confirmations ); diff --git a/packages/protocol-parser/src/decodeRecord.test.ts b/packages/protocol-parser/src/decodeRecord.test.ts index 390dcc6ade..87e357f599 100644 --- a/packages/protocol-parser/src/decodeRecord.test.ts +++ b/packages/protocol-parser/src/decodeRecord.test.ts @@ -3,17 +3,17 @@ import { decodeRecord } from "./decodeRecord"; describe("decodeRecord", () => { it("can decode hex to record values", () => { - const schema = { staticFields: ["uint32", "uint128"], dynamicFields: ["uint32[]", "string"] } as const; + const valueSchema = { staticFields: ["uint32", "uint128"], dynamicFields: ["uint32[]", "string"] } as const; const values = decodeRecord( - schema, + valueSchema, "0x0000000100000000000000000000000000000002000000000000000000000000000000000000000b0000000008000000000000130000000300000004736f6d6520737472696e67" ); expect(values).toStrictEqual([1, 2n, [3, 4], "some string"]); }); it("can decode an empty record", () => { - const schema = { staticFields: [], dynamicFields: ["string", "string"] } as const; - const values = decodeRecord(schema, "0x0000000000000000000000000000000000000000000000000000000000000000"); + const valueSchema = { staticFields: [], dynamicFields: ["string", "string"] } as const; + const values = decodeRecord(valueSchema, "0x0000000000000000000000000000000000000000000000000000000000000000"); expect(values).toMatchInlineSnapshot(` [ "", @@ -23,8 +23,8 @@ describe("decodeRecord", () => { }); it("can decode an out of bounds array", () => { - const schema = { staticFields: [], dynamicFields: ["uint32[]"] } as const; - const values = decodeRecord(schema, "0x0000000000000000000000000000000000000000000000000400000000000004"); + const valueSchema = { staticFields: [], dynamicFields: ["uint32[]"] } as const; + const values = decodeRecord(valueSchema, "0x0000000000000000000000000000000000000000000000000400000000000004"); expect(values).toMatchInlineSnapshot(` [ [ diff --git a/packages/protocol-parser/src/decodeRecord.ts b/packages/protocol-parser/src/decodeRecord.ts index 2f8536287d..c48dc0bd24 100644 --- a/packages/protocol-parser/src/decodeRecord.ts +++ b/packages/protocol-parser/src/decodeRecord.ts @@ -13,23 +13,23 @@ import { staticDataLength } from "./staticDataLength"; import { readHex } from "./readHex"; /** @deprecated use `decodeValue` instead */ -export function decodeRecord(schema: Schema, data: Hex): readonly (StaticPrimitiveType | DynamicPrimitiveType)[] { +export function decodeRecord(valueSchema: Schema, data: Hex): readonly (StaticPrimitiveType | DynamicPrimitiveType)[] { const values: (StaticPrimitiveType | DynamicPrimitiveType)[] = []; let bytesOffset = 0; - schema.staticFields.forEach((fieldType) => { + valueSchema.staticFields.forEach((fieldType) => { const fieldByteLength = staticAbiTypeToByteLength[fieldType]; const value = decodeStaticField(fieldType, readHex(data, bytesOffset, bytesOffset + fieldByteLength)); bytesOffset += fieldByteLength; values.push(value); }); - // Warn user if static data length doesn't match the schema, because data corruption might be possible. - const schemaStaticDataLength = staticDataLength(schema.staticFields); + // Warn user if static data length doesn't match the value schema, because data corruption might be possible. + const schemaStaticDataLength = staticDataLength(valueSchema.staticFields); const actualStaticDataLength = bytesOffset; if (actualStaticDataLength !== schemaStaticDataLength) { console.warn( - "Decoded static data length does not match schema's expected static data length. Data may get corrupted. Is `getStaticByteLength` outdated?", + "Decoded static data length does not match value schema's expected static data length. Data may get corrupted. Is `getStaticByteLength` outdated?", { expectedLength: schemaStaticDataLength, actualLength: actualStaticDataLength, @@ -38,11 +38,11 @@ export function decodeRecord(schema: Schema, data: Hex): readonly (StaticPrimiti ); } - if (schema.dynamicFields.length > 0) { + if (valueSchema.dynamicFields.length > 0) { const dataLayout = hexToPackedCounter(readHex(data, bytesOffset, bytesOffset + 32)); bytesOffset += 32; - schema.dynamicFields.forEach((fieldType, i) => { + valueSchema.dynamicFields.forEach((fieldType, i) => { const dataLength = dataLayout.fieldByteLengths[i]; if (dataLength > 0) { const value = decodeDynamicField(fieldType, readHex(data, bytesOffset, bytesOffset + dataLength)); @@ -53,7 +53,7 @@ export function decodeRecord(schema: Schema, data: Hex): readonly (StaticPrimiti } }); - // Warn user if dynamic data length doesn't match the schema, because data corruption might be possible. + // Warn user if dynamic data length doesn't match the dynamic data length, because data corruption might be possible. const actualDynamicDataLength = bytesOffset - 32 - actualStaticDataLength; // TODO: refactor this so we don't break for bytes offsets >UINT40 if (BigInt(actualDynamicDataLength) !== dataLayout.totalByteLength) { diff --git a/packages/protocol-parser/src/encodeRecord.test.ts b/packages/protocol-parser/src/encodeRecord.test.ts index fde765d9b6..29222756fa 100644 --- a/packages/protocol-parser/src/encodeRecord.test.ts +++ b/packages/protocol-parser/src/encodeRecord.test.ts @@ -2,23 +2,23 @@ import { describe, expect, it } from "vitest"; import { encodeRecord } from "./encodeRecord"; describe("encodeRecord", () => { - it("can encode a schema and record values to hex", () => { - const schema = { staticFields: ["uint32", "uint128"], dynamicFields: ["uint32[]", "string"] } as const; - const hex = encodeRecord(schema, [1, 2n, [3, 4], "some string"]); + it("can encode a value schema and record values to hex", () => { + const valueSchema = { staticFields: ["uint32", "uint128"], dynamicFields: ["uint32[]", "string"] } as const; + const hex = encodeRecord(valueSchema, [1, 2n, [3, 4], "some string"]); expect(hex).toBe( "0x0000000100000000000000000000000000000002000000000000000000000000000000000000000b0000000008000000000000130000000300000004736f6d6520737472696e67" ); }); it("should not include the packed dynamic lengths if there are no dynamic fields", () => { - const schema = { staticFields: ["uint32", "uint128"], dynamicFields: [] } as const; - const hex = encodeRecord(schema, [1, 2n]); + const valueSchema = { staticFields: ["uint32", "uint128"], dynamicFields: [] } as const; + const hex = encodeRecord(valueSchema, [1, 2n]); expect(hex).toBe("0x0000000100000000000000000000000000000002"); }); it("can encode an array to hex", () => { - const schema = { staticFields: [], dynamicFields: ["uint32[]"] } as const; - const hex = encodeRecord(schema, [[42]]); + const valueSchema = { staticFields: [], dynamicFields: ["uint32[]"] } as const; + const hex = encodeRecord(valueSchema, [[42]]); expect(hex).toBe("0x00000000000000000000000000000000000000000000000004000000000000040000002a"); }); }); diff --git a/packages/protocol-parser/src/encodeRecord.ts b/packages/protocol-parser/src/encodeRecord.ts index b224a6c532..b92287830c 100644 --- a/packages/protocol-parser/src/encodeRecord.ts +++ b/packages/protocol-parser/src/encodeRecord.ts @@ -4,18 +4,21 @@ import { encodeField } from "./encodeField"; import { Schema } from "./common"; /** @deprecated use `encodeValue` instead */ -export function encodeRecord(schema: Schema, values: readonly (StaticPrimitiveType | DynamicPrimitiveType)[]): Hex { - const staticValues = values.slice(0, schema.staticFields.length) as readonly StaticPrimitiveType[]; - const dynamicValues = values.slice(schema.staticFields.length) as readonly DynamicPrimitiveType[]; +export function encodeRecord( + valueSchema: Schema, + values: readonly (StaticPrimitiveType | DynamicPrimitiveType)[] +): Hex { + const staticValues = values.slice(0, valueSchema.staticFields.length) as readonly StaticPrimitiveType[]; + const dynamicValues = values.slice(valueSchema.staticFields.length) as readonly DynamicPrimitiveType[]; const staticData = staticValues - .map((value, i) => encodeField(schema.staticFields[i], value).replace(/^0x/, "")) + .map((value, i) => encodeField(valueSchema.staticFields[i], value).replace(/^0x/, "")) .join(""); - if (schema.dynamicFields.length === 0) return `0x${staticData}`; + if (valueSchema.dynamicFields.length === 0) return `0x${staticData}`; const dynamicDataItems = dynamicValues.map((value, i) => - encodeField(schema.dynamicFields[i], value).replace(/^0x/, "") + encodeField(valueSchema.dynamicFields[i], value).replace(/^0x/, "") ); const dynamicFieldByteLengths = dynamicDataItems.map((value) => value.length / 2).reverse(); diff --git a/packages/protocol-parser/src/encodeValue.ts b/packages/protocol-parser/src/encodeValue.ts index 6394f144b3..f953ccee21 100644 --- a/packages/protocol-parser/src/encodeValue.ts +++ b/packages/protocol-parser/src/encodeValue.ts @@ -13,6 +13,6 @@ export function encodeValue( // TODO: refactor and move all encodeRecord logic into this method so we can delete encodeRecord // This currently assumes fields/values are ordered by static, dynamic - // TODO: make sure we preserve ordering based on schema definition + // TODO: make sure we preserve ordering based on value schema definition return encodeRecord({ staticFields, dynamicFields }, Object.values(value)); } diff --git a/packages/protocol-parser/src/hexToPackedCounter.ts b/packages/protocol-parser/src/hexToPackedCounter.ts index 6ab5920bbd..c8816d15f7 100644 --- a/packages/protocol-parser/src/hexToPackedCounter.ts +++ b/packages/protocol-parser/src/hexToPackedCounter.ts @@ -9,7 +9,7 @@ import { readHex } from "./readHex"; // - Last 7 bytes (uint56) are used for the total byte length of the dynamic data // - The next 5 byte (uint40) sections are used for the byte length of each field, indexed from right to left -// We use byte lengths rather than item counts so that, on chain, we can slice without having to get the schema first (and thus the field lengths of each dynamic type) +// We use byte lengths rather than item counts so that, on chain, we can slice without having to get the value schema first (and thus the field lengths of each dynamic type) export function hexToPackedCounter(data: Hex): { totalByteLength: bigint; @@ -20,7 +20,7 @@ export function hexToPackedCounter(data: Hex): { } const totalByteLength = decodeStaticField("uint56", readHex(data, 32 - 7, 32)); - // TODO: use schema to make sure we only parse as many as we need (rather than zeroes at the end)? + // TODO: use value schema to make sure we only parse as many as we need (rather than zeroes at the end)? const reversedFieldByteLengths = decodeDynamicField("uint40[]", readHex(data, 0, 32 - 7)); // Reverse the lengths const fieldByteLengths = Object.freeze([...reversedFieldByteLengths].reverse()); diff --git a/packages/protocol-parser/src/keySchemaToHex.ts b/packages/protocol-parser/src/keySchemaToHex.ts index 0d5d3a697e..f2e9443153 100644 --- a/packages/protocol-parser/src/keySchemaToHex.ts +++ b/packages/protocol-parser/src/keySchemaToHex.ts @@ -3,6 +3,6 @@ import { Hex } from "viem"; import { KeySchema } from "./common"; import { schemaToHex } from "./schemaToHex"; -export function keySchemaToHex(schema: KeySchema): Hex { - return schemaToHex({ staticFields: Object.values(schema).filter(isStaticAbiType), dynamicFields: [] }); +export function keySchemaToHex(keySchema: KeySchema): Hex { + return schemaToHex({ staticFields: Object.values(keySchema).filter(isStaticAbiType), dynamicFields: [] }); } diff --git a/packages/protocol-parser/src/valueSchemaToHex.ts b/packages/protocol-parser/src/valueSchemaToHex.ts index b7e24b7f7a..205b8696ea 100644 --- a/packages/protocol-parser/src/valueSchemaToHex.ts +++ b/packages/protocol-parser/src/valueSchemaToHex.ts @@ -3,9 +3,9 @@ import { Hex } from "viem"; import { ValueSchema } from "./common"; import { schemaToHex } from "./schemaToHex"; -export function valueSchemaToHex(schema: ValueSchema): Hex { +export function valueSchemaToHex(valueSchema: ValueSchema): Hex { return schemaToHex({ - staticFields: Object.values(schema).filter(isStaticAbiType), - dynamicFields: Object.values(schema).filter(isDynamicAbiType), + staticFields: Object.values(valueSchema).filter(isStaticAbiType), + dynamicFields: Object.values(valueSchema).filter(isDynamicAbiType), }); } diff --git a/packages/store-sync/src/blockLogsToStorage.ts b/packages/store-sync/src/blockLogsToStorage.ts index 70f07276a6..f4af902b71 100644 --- a/packages/store-sync/src/blockLogsToStorage.ts +++ b/packages/store-sync/src/blockLogsToStorage.ts @@ -48,9 +48,9 @@ export function blockLogsToStorage({ const table = hexToTableId(tableId); - const valueTuple = decodeRecord(abiTypesToSchema(Object.values(schemasTable.schema)), log.args.data); + const valueTuple = decodeRecord(abiTypesToSchema(Object.values(schemasTable.valueSchema)), log.args.data); const value = Object.fromEntries( - Object.keys(schemasTable.schema).map((name, i) => [name, valueTuple[i]]) + Object.keys(schemasTable.valueSchema).map((name, i) => [name, valueTuple[i]]) ) as ConfigToValuePrimitives; const keySchema = hexToSchema(value.keySchema); diff --git a/packages/store-sync/src/postgres/buildInternalTables.ts b/packages/store-sync/src/postgres/buildInternalTables.ts index 889566db44..08a4fd8b80 100644 --- a/packages/store-sync/src/postgres/buildInternalTables.ts +++ b/packages/store-sync/src/postgres/buildInternalTables.ts @@ -1,5 +1,4 @@ import { integer, pgSchema, text } from "drizzle-orm/pg-core"; -import { DynamicAbiType, StaticAbiType } from "@latticexyz/schema-type"; import { transformSchemaName } from "./transformSchemaName"; import { asAddress, asBigInt, asJson, asNumber } from "./columnTypes"; import { KeySchema, ValueSchema } from "@latticexyz/protocol-parser"; diff --git a/packages/store-sync/src/schemaToDefaults.ts b/packages/store-sync/src/schemaToDefaults.ts index 36dab2b1ec..15be27c54c 100644 --- a/packages/store-sync/src/schemaToDefaults.ts +++ b/packages/store-sync/src/schemaToDefaults.ts @@ -1,8 +1,8 @@ import { schemaAbiTypeToDefaultValue } from "@latticexyz/schema-type"; import { ValueSchema, SchemaToPrimitives } from "@latticexyz/protocol-parser"; -export function schemaToDefaults(schema: TSchema): SchemaToPrimitives { +export function schemaToDefaults(valueSchema: TSchema): SchemaToPrimitives { return Object.fromEntries( - Object.entries(schema).map(([key, abiType]) => [key, schemaAbiTypeToDefaultValue[abiType]]) + Object.entries(valueSchema).map(([key, abiType]) => [key, schemaAbiTypeToDefaultValue[abiType]]) ) as SchemaToPrimitives; } diff --git a/packages/store/mud.config.ts b/packages/store/mud.config.ts index 8a99d085b3..814ab527b9 100644 --- a/packages/store/mud.config.ts +++ b/packages/store/mud.config.ts @@ -13,7 +13,7 @@ export default mudConfig({ keySchema: { tableId: "bytes32", }, - schema: { + valueSchema: { fieldLayout: "bytes32", keySchema: "bytes32", valueSchema: "bytes32", @@ -23,12 +23,12 @@ export default mudConfig({ }, // The Hooks table is a generic table used by the `filterFromList` util in `Hook.sol` Hooks: { - schema: "bytes21[]", + valueSchema: "bytes21[]", tableIdArgument: true, }, // TODO: move these test tables to a separate mud config Mixed: { - schema: { + valueSchema: { u32: "uint32", u128: "uint128", a32: "uint32[]", @@ -36,7 +36,7 @@ export default mudConfig({ }, }, Vector2: { - schema: { + valueSchema: { x: "uint32", y: "uint32", }, @@ -50,7 +50,7 @@ export default mudConfig({ k5: "bool", k6: "ExampleEnum", }, - schema: "bool", + valueSchema: "bool", }, }, }); diff --git a/packages/store/src/IStore.sol b/packages/store/src/IStore.sol index 2a939e8529..c2e48c9fb4 100644 --- a/packages/store/src/IStore.sol +++ b/packages/store/src/IStore.sol @@ -9,9 +9,9 @@ import { IStoreHook } from "./IStoreHook.sol"; interface IStoreRead { function getFieldLayout(bytes32 table) external view returns (FieldLayout fieldLayout); - function getValueSchema(bytes32 table) external view returns (Schema schema); + function getValueSchema(bytes32 table) external view returns (Schema valueSchema); - function getKeySchema(bytes32 table) external view returns (Schema schema); + function getKeySchema(bytes32 table) external view returns (Schema keySchema); // Get full record (including full array) function getRecord( diff --git a/packages/store/src/StoreRead.sol b/packages/store/src/StoreRead.sol index 28fc1ff91a..425d66aee0 100644 --- a/packages/store/src/StoreRead.sol +++ b/packages/store/src/StoreRead.sol @@ -11,12 +11,12 @@ contract StoreRead is IStoreRead { fieldLayout = StoreCore.getFieldLayout(table); } - function getValueSchema(bytes32 table) public view virtual returns (Schema schema) { - schema = StoreCore.getValueSchema(table); + function getValueSchema(bytes32 table) public view virtual returns (Schema valueSchema) { + valueSchema = StoreCore.getValueSchema(table); } - function getKeySchema(bytes32 table) public view virtual returns (Schema schema) { - schema = StoreCore.getKeySchema(table); + function getKeySchema(bytes32 table) public view virtual returns (Schema keySchema) { + keySchema = StoreCore.getKeySchema(table); } // Get full record (static and dynamic data) diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index 15892cb85c..f6e37eac36 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -92,7 +92,7 @@ contract StoreCoreTest is Test, StoreMock { keccak256("table"), FieldLayout.wrap(keccak256("random bytes as value field layout")), Schema.wrap(keccak256("random bytes as key schema")), - Schema.wrap(keccak256("random bytes as schema")), + Schema.wrap(keccak256("random bytes as value schema")), keyNames, fieldNames ); @@ -926,7 +926,7 @@ contract StoreCoreTest is Test, StoreMock { bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some key"); - // Register table's schema + // Register table's value schema FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 0); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128); IStore(this).registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](1)); diff --git a/packages/store/test/StoreCoreDynamic.t.sol b/packages/store/test/StoreCoreDynamic.t.sol index 19a08dd88c..a29d56eaa5 100644 --- a/packages/store/test/StoreCoreDynamic.t.sol +++ b/packages/store/test/StoreCoreDynamic.t.sol @@ -37,7 +37,7 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { } function setUp() public { - // Register table's schema + // Register table's value schema FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT256, diff --git a/packages/store/test/StoreCoreGas.t.sol b/packages/store/test/StoreCoreGas.t.sol index 97e2ec65a6..d09dc15539 100644 --- a/packages/store/test/StoreCoreGas.t.sol +++ b/packages/store/test/StoreCoreGas.t.sol @@ -60,7 +60,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { StoreCore.getFieldLayout(table); endGasReport(); - startGasReport("StoreCore: get schema (warm)"); + startGasReport("StoreCore: get value schema (warm)"); StoreCore.getValueSchema(table); endGasReport(); @@ -103,7 +103,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(1, 2, 4, 2); - // Register schema + // Register table StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](5)); // Create some key @@ -127,7 +127,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { } function testSetAndGetStaticData() public { - // Register table's schema + // Register table Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT8, SchemaType.UINT16, @@ -154,7 +154,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { } function testSetAndGetStaticDataSpanningWords() public { - // Register table's schema + // Register table Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT256); FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 32, 0); bytes32 table = keccak256("some.table"); @@ -182,7 +182,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { function testSetAndGetDynamicData() public { bytes32 table = keccak256("some.table"); - // Register table's schema + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, @@ -258,7 +258,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { function testSetAndGetField() public { bytes32 table = keccak256("some.table"); - // Register table's schema + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, @@ -348,7 +348,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { function testDeleteData() public { bytes32 table = keccak256("some.table"); - // Register table's schema + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, @@ -405,7 +405,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { function testPushToField() public { bytes32 table = keccak256("some.table"); - // Register table's schema + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT256, @@ -492,7 +492,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { TestUpdateInFieldData memory data = TestUpdateInFieldData("", "", "", "", "", "", ""); bytes32 table = keccak256("some.table"); - // Register table's schema + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT256, @@ -602,7 +602,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some key"); - // Register table's schema + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 0); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128); StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](1)); @@ -654,7 +654,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some key"); - // Register table's schema + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 1); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT32_ARRAY); StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); diff --git a/packages/store/test/tables/StoreHooks.t.sol b/packages/store/test/tables/StoreHooks.t.sol index ff347c9b86..5960dde364 100644 --- a/packages/store/test/tables/StoreHooks.t.sol +++ b/packages/store/test/tables/StoreHooks.t.sol @@ -8,7 +8,7 @@ import { StoreHooks } from "../../src/codegen/Tables.sol"; contract StoreHooksTest is Test, GasReporter, StoreMock { function testTable() public { - // StoreHooks schema is already registered by StoreCore + // StoreHooks table is already registered by StoreMock bytes32 key = keccak256("somekey"); bytes21[] memory hooks = new bytes21[](1); diff --git a/packages/store/ts/codegen/renderTable.ts b/packages/store/ts/codegen/renderTable.ts index cc19b244ef..8181133cfb 100644 --- a/packages/store/ts/codegen/renderTable.ts +++ b/packages/store/ts/codegen/renderTable.ts @@ -84,18 +84,18 @@ export function renderTable(options: RenderTableOptions) { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](${keyTuple.length}); - ${renderList(keyTuple, ({ enumName }, index) => `_schema[${index}] = SchemaType.${enumName};`)} + SchemaType[] memory _keySchema = new SchemaType[](${keyTuple.length}); + ${renderList(keyTuple, ({ enumName }, index) => `_keySchema[${index}] = SchemaType.${enumName};`)} - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](${fields.length}); - ${renderList(fields, ({ enumName }, index) => `_schema[${index}] = SchemaType.${enumName};`)} + SchemaType[] memory _valueSchema = new SchemaType[](${fields.length}); + ${renderList(fields, ({ enumName }, index) => `_valueSchema[${index}] = SchemaType.${enumName};`)} - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/store/ts/codegen/tableOptions.ts b/packages/store/ts/codegen/tableOptions.ts index 5dccb14aca..fa38785757 100644 --- a/packages/store/ts/codegen/tableOptions.ts +++ b/packages/store/ts/codegen/tableOptions.ts @@ -27,9 +27,9 @@ export function getTableOptions(config: StoreConfig): TableOptions[] { // struct adds methods to get/set all values at once const withStruct = tableData.dataStruct; // operate on all fields at once; for only 1 field keep them only if struct is also kept - const withRecordMethods = withStruct || Object.keys(tableData.schema).length > 1; + const withRecordMethods = withStruct || Object.keys(tableData.valueSchema).length > 1; // field methods can be simply get/set if there's only 1 field and no record methods - const noFieldMethodSuffix = !withRecordMethods && Object.keys(tableData.schema).length === 1; + const noFieldMethodSuffix = !withRecordMethods && Object.keys(tableData.valueSchema).length === 1; // list of any symbols that need to be imported const imports: RelativeImportDatum[] = []; @@ -50,8 +50,8 @@ export function getTableOptions(config: StoreConfig): TableOptions[] { return keyTuple; }); - const fields = Object.keys(tableData.schema).map((name) => { - const abiOrUserType = tableData.schema[name]; + const fields = Object.keys(tableData.valueSchema).map((name) => { + const abiOrUserType = tableData.valueSchema[name]; const { renderType, schemaType } = resolveAbiOrUserType(abiOrUserType, config); const importDatum = importForAbiOrUserType(abiOrUserType, tableData.directory, config); diff --git a/packages/store/ts/common.ts b/packages/store/ts/common.ts index 380709deec..5e6ce3e000 100644 --- a/packages/store/ts/common.ts +++ b/packages/store/ts/common.ts @@ -21,7 +21,7 @@ export type SchemaConfigToPrimitives = { export type ConfigToTablesPrimitives = { [key in keyof C["tables"]]: { key: SchemaConfigToPrimitives; - value: SchemaConfigToPrimitives; + value: SchemaConfigToPrimitives; }; }; diff --git a/packages/store/ts/config/storeConfig.ts b/packages/store/ts/config/storeConfig.ts index 6944b4f61b..bca792c804 100644 --- a/packages/store/ts/config/storeConfig.ts +++ b/packages/store/ts/config/storeConfig.ts @@ -87,17 +87,17 @@ export interface TableConfig< dataStruct?: boolean; /** Generate only `emitEphemeral` which emits an event without writing to storage. Default is false. */ ephemeral?: boolean; - /** Table's key schema names mapped to their types. Default is `{ key: "bytes32" }` */ + /** Table's key names mapped to their types. Default is `{ key: "bytes32" }` */ keySchema?: Record>; - /** Table's column names mapped to their types. Table name's 1st letter should be lowercase. */ - schema: SchemaConfig; + /** Table's field names mapped to their types. Table name's 1st letter should be lowercase. */ + valueSchema: SchemaConfig; } export type FullTableConfig< UserTypes extends StringForUnion = StringForUnion, StaticUserTypes extends StringForUnion = StringForUnion > = Required> & { - schema: FullSchemaConfig; + valueSchema: FullSchemaConfig; }; export interface ExpandTableConfig, TableName extends string> @@ -108,13 +108,13 @@ export interface ExpandTableConfig, TableN name: TableName; tableIdArgument: typeof TABLE_DEFAULTS.tableIdArgument; storeArgument: typeof TABLE_DEFAULTS.storeArgument; - // dataStruct isn't expanded, because its value is conditional on the number of schema fields + // dataStruct isn't expanded, because its value is conditional on the number of value schema fields dataStruct: boolean; keySchema: typeof TABLE_DEFAULTS.keySchema; ephemeral: typeof TABLE_DEFAULTS.ephemeral; } > { - schema: ExpandSchemaConfig; + valueSchema: ExpandSchemaConfig; } const zFullTableConfig = z @@ -125,12 +125,12 @@ const zFullTableConfig = z storeArgument: z.boolean().default(TABLE_DEFAULTS.storeArgument), dataStruct: z.boolean().optional(), keySchema: zKeySchema, - schema: zSchemaConfig, + valueSchema: zSchemaConfig, ephemeral: z.boolean().default(TABLE_DEFAULTS.ephemeral), }) .transform((arg) => { - // default dataStruct value depends on schema's length - if (Object.keys(arg.schema).length === 1) { + // default dataStruct value depends on value schema's length + if (Object.keys(arg.valueSchema).length === 1) { arg.dataStruct ??= false; } else { arg.dataStruct ??= true; @@ -140,7 +140,7 @@ const zFullTableConfig = z const zShorthandTableConfig = zFieldData.transform((fieldData) => { return zFullTableConfig.parse({ - schema: { + valueSchema: { value: fieldData, }, }); @@ -177,7 +177,7 @@ export type FullTablesConfig< export type ExpandTablesConfig> = { [TableName in keyof T]: T[TableName] extends FieldData - ? ExpandTableConfig<{ schema: { value: T[TableName] } }, TableName extends string ? TableName : never> + ? ExpandTableConfig<{ valueSchema: { value: T[TableName] } }, TableName extends string ? TableName : never> : T[TableName] extends TableConfig ? ExpandTableConfig : // Weakly typed values get a weakly typed expansion. @@ -290,7 +290,7 @@ function validateStoreConfig(config: z.output, ctx: // Local table variables must be unique within the table for (const table of Object.values(config.tables)) { const keySchemaNames = Object.keys(table.keySchema); - const fieldNames = Object.keys(table.schema); + const fieldNames = Object.keys(table.valueSchema); const duplicateVariableNames = getDuplicates([...keySchemaNames, ...fieldNames]); if (duplicateVariableNames.length > 0) { ctx.addIssue({ @@ -325,7 +325,7 @@ function validateStoreConfig(config: z.output, ctx: for (const keySchemaType of Object.values(table.keySchema)) { validateStaticAbiOrUserType(staticUserTypeNames, keySchemaType, ctx); } - for (const fieldType of Object.values(table.schema)) { + for (const fieldType of Object.values(table.valueSchema)) { validateAbiOrUserType(userTypeNames, staticUserTypeNames, fieldType, ctx); } } diff --git a/packages/store/ts/register/mudConfig.test-d.ts b/packages/store/ts/register/mudConfig.test-d.ts index 3e0c7c39a0..de08e2695b 100644 --- a/packages/store/ts/register/mudConfig.test-d.ts +++ b/packages/store/ts/register/mudConfig.test-d.ts @@ -12,12 +12,12 @@ describe("mudConfig", () => { keySchema: { a: "Enum1"; }; - schema: { + valueSchema: { b: "Enum2"; }; }; Table2: { - schema: { + valueSchema: { a: "uint32"; }; }; @@ -38,12 +38,12 @@ describe("mudConfig", () => { keySchema: { a: "Enum1"; }; - schema: { + valueSchema: { b: "Enum2"; }; }; Table2: { - schema: { + valueSchema: { a: "uint32"; }; }; diff --git a/packages/world/mud.config.ts b/packages/world/mud.config.ts index b23b1e0919..a043d644dd 100644 --- a/packages/world/mud.config.ts +++ b/packages/world/mud.config.ts @@ -15,7 +15,7 @@ export default mudConfig({ keySchema: { namespace: "bytes16", }, - schema: { + valueSchema: { owner: "address", }, }, @@ -24,7 +24,7 @@ export default mudConfig({ resourceSelector: "bytes32", caller: "address", }, - schema: { + valueSchema: { access: "bool", }, }, @@ -33,13 +33,13 @@ export default mudConfig({ moduleName: "bytes16", argumentsHash: "bytes32", // Hash of the params passed to the `install` function }, - schema: { + valueSchema: { moduleAddress: "address", }, // TODO: this is a workaround to use `getRecord` instead of `getField` in the autogen library, - // to allow using the table before it is registered. This is because `getRecord` passes the schema + // to allow using the table before it is registered. This is because `getRecord` passes the valueSchema // to store, while `getField` loads it from storage. Remove this once we have support for passing the - // schema in `getField` too. (See https://github.com/latticexyz/mud/issues/444) + // valueSchema in `getField` too. (See https://github.com/latticexyz/mud/issues/444) dataStruct: true, }, Delegations: { @@ -47,7 +47,7 @@ export default mudConfig({ delegator: "address", delegatee: "address", }, - schema: { + valueSchema: { delegationControlId: "bytes32", }, }, @@ -61,7 +61,7 @@ export default mudConfig({ keySchema: { namespace: "bytes16", }, - schema: { + valueSchema: { balance: "uint256", }, }, @@ -70,7 +70,7 @@ export default mudConfig({ keySchema: { resourceSelector: "bytes32", }, - schema: { + valueSchema: { system: "address", publicAccess: "bool", }, @@ -81,7 +81,7 @@ export default mudConfig({ keySchema: { system: "address", }, - schema: { + valueSchema: { resourceSelector: "bytes32", }, }, @@ -90,14 +90,14 @@ export default mudConfig({ keySchema: { resourceSelector: "bytes32", }, - schema: "bytes21[]", + valueSchema: "bytes21[]", }, ResourceType: { directory: "modules/core/tables", keySchema: { resourceSelector: "bytes32", }, - schema: { + valueSchema: { resourceType: "Resource", }, }, @@ -106,7 +106,7 @@ export default mudConfig({ keySchema: { functionSelector: "bytes4", }, - schema: { + valueSchema: { resourceSelector: "bytes32", systemFunctionSelector: "bytes4", }, @@ -117,7 +117,7 @@ export default mudConfig({ keySchema: { valueHash: "bytes32", }, - schema: { + valueSchema: { keysWithValue: "bytes32[]", // For now only supports 1 key per value }, tableIdArgument: true, @@ -125,7 +125,7 @@ export default mudConfig({ KeysInTable: { directory: "modules/keysintable/tables", keySchema: { sourceTable: "bytes32" }, - schema: { + valueSchema: { keys0: "bytes32[]", keys1: "bytes32[]", keys2: "bytes32[]", @@ -139,13 +139,13 @@ export default mudConfig({ sourceTable: "bytes32", keysHash: "bytes32", }, - schema: { has: "bool", index: "uint40" }, + valueSchema: { has: "bool", index: "uint40" }, dataStruct: false, }, UniqueEntity: { directory: "modules/uniqueentity/tables", keySchema: {}, - schema: "uint256", + valueSchema: "uint256", tableIdArgument: true, storeArgument: true, }, @@ -157,7 +157,7 @@ export default mudConfig({ resourceSelector: "bytes32", funcSelectorAndArgsHash: "bytes32", }, - schema: { + valueSchema: { availableCalls: "uint256", }, }, @@ -167,7 +167,7 @@ export default mudConfig({ delegator: "address", delegatee: "address", }, - schema: { + valueSchema: { maxTimestamp: "uint256", }, }, @@ -179,14 +179,14 @@ export default mudConfig({ Bool: { directory: "../test/tables", keySchema: {}, - schema: { + valueSchema: { value: "bool", }, tableIdArgument: true, }, AddressArray: { directory: "../test/tables", - schema: "address[]", + valueSchema: "address[]", tableIdArgument: true, }, }, diff --git a/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol b/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol index 6281cab124..00a5d3017c 100644 --- a/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol @@ -34,7 +34,7 @@ contract StoreRegistrationSystem is System, IWorldErrors { using ResourceSelector for bytes32; /** - * Register a table with given schema in the given namespace + * Register a table with the given config */ function registerTable( bytes32 resourceSelector, @@ -72,7 +72,7 @@ contract StoreRegistrationSystem is System, IWorldErrors { // Store the table resource type ResourceType.set(resourceSelector, Resource.TABLE); - // Register the table's schema + // Register the table StoreCore.registerTable(resourceSelector, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); } diff --git a/packages/world/src/modules/keysintable/getKeysInTable.sol b/packages/world/src/modules/keysintable/getKeysInTable.sol index 9cdfb1abe0..c6b709f5fc 100644 --- a/packages/world/src/modules/keysintable/getKeysInTable.sol +++ b/packages/world/src/modules/keysintable/getKeysInTable.sol @@ -18,14 +18,13 @@ function getKeysInTable(bytes32 tableId) view returns (bytes32[][] memory keyTup * Note: this module only supports up to 5 composite keys. */ - Schema schema = StoreSwitch.getKeySchema(tableId); - - uint256 numFields = schema.numFields(); + Schema keySchema = StoreSwitch.getKeySchema(tableId); + uint256 numFields = keySchema.numFields(); uint256 length = KeysInTable.lengthKeys0(tableId); keyTuples = new bytes32[][](length); for (uint256 i; i < length; i++) { - keyTuples[i] = new bytes32[](numFields); // the length of the key tuple depends on the schema + keyTuples[i] = new bytes32[](numFields); // the length of the key tuple depends on the key schema if (numFields > 0) { keyTuples[i][0] = KeysInTable.getItemKeys0(tableId, i); @@ -53,14 +52,14 @@ function getKeysInTable(IStore store, bytes32 tableId) view returns (bytes32[][] * Note: this module only supports up to 5 composite keys. */ - Schema schema = store.getKeySchema(tableId); + Schema keySchema = store.getKeySchema(tableId); - uint256 numFields = schema.numFields(); + uint256 numFields = keySchema.numFields(); uint256 length = KeysInTable.lengthKeys0(store, tableId); keyTuples = new bytes32[][](length); for (uint256 i; i < length; i++) { - keyTuples[i] = new bytes32[](numFields); // the length of the key tuple depends on the schema + keyTuples[i] = new bytes32[](numFields); // the length of the key tuple depends on the key schema if (numFields > 0) { keyTuples[i][0] = KeysInTable.getItemKeys0(store, tableId, i); diff --git a/packages/world/ts/register/index.test.ts b/packages/world/ts/register/index.test.ts index 454855a828..71d4d0c8e7 100644 --- a/packages/world/ts/register/index.test.ts +++ b/packages/world/ts/register/index.test.ts @@ -8,7 +8,7 @@ test("resolveWorldConfig requires unique table and system names", () => { mudConfig({ tables: { Selector: { - schema: "uint256", + valueSchema: "uint256", }, }, systems: { diff --git a/templates/phaser/packages/contracts/mud.config.ts b/templates/phaser/packages/contracts/mud.config.ts index 1dc8d7e90f..70edda1693 100644 --- a/templates/phaser/packages/contracts/mud.config.ts +++ b/templates/phaser/packages/contracts/mud.config.ts @@ -4,7 +4,7 @@ export default mudConfig({ tables: { Counter: { keySchema: {}, - schema: "uint32", + valueSchema: "uint32", }, }, }); diff --git a/templates/threejs/packages/contracts/mud.config.ts b/templates/threejs/packages/contracts/mud.config.ts index 3a04487138..6ee5c6a809 100644 --- a/templates/threejs/packages/contracts/mud.config.ts +++ b/templates/threejs/packages/contracts/mud.config.ts @@ -3,7 +3,7 @@ import { mudConfig } from "@latticexyz/world/register"; export default mudConfig({ tables: { Position: { - schema: { + valueSchema: { x: "int32", y: "int32", z: "int32", diff --git a/templates/vanilla/packages/contracts/mud.config.ts b/templates/vanilla/packages/contracts/mud.config.ts index 1dc8d7e90f..70edda1693 100644 --- a/templates/vanilla/packages/contracts/mud.config.ts +++ b/templates/vanilla/packages/contracts/mud.config.ts @@ -4,7 +4,7 @@ export default mudConfig({ tables: { Counter: { keySchema: {}, - schema: "uint32", + valueSchema: "uint32", }, }, }); From 3310148b29be68834bd63536123562c3ab6e8181 Mon Sep 17 00:00:00 2001 From: alvrs Date: Thu, 14 Sep 2023 13:16:32 +0100 Subject: [PATCH 02/19] rebuild --- .../contracts/src/codegen/tables/Multi.sol | 20 +++++----- .../contracts/src/codegen/tables/Number.sol | 12 +++--- .../src/codegen/tables/NumberList.sol | 10 ++--- .../contracts/src/codegen/tables/Vector.sol | 14 +++---- .../src/codegen/tables/CounterTable.sol | 10 ++--- .../src/codegen/tables/Inventory.sol | 16 ++++---- .../src/codegen/tables/MessageTable.sol | 10 ++--- .../src/codegen/tables/Dynamics1.sol | 22 +++++------ .../src/codegen/tables/Dynamics2.sol | 16 ++++---- .../src/codegen/tables/Ephemeral.sol | 12 +++--- .../src/codegen/tables/Singleton.sol | 16 ++++---- .../contracts/src/codegen/tables/Statics.sol | 38 +++++++++---------- .../store/src/codegen/tables/Callbacks.sol | 12 +++--- packages/store/src/codegen/tables/Hooks.sol | 12 +++--- .../store/src/codegen/tables/KeyEncoding.sol | 22 +++++------ packages/store/src/codegen/tables/Mixed.sol | 18 ++++----- .../store/src/codegen/tables/StoreHooks.sol | 12 +++--- packages/store/src/codegen/tables/Tables.sol | 22 +++++------ packages/store/src/codegen/tables/Vector2.sol | 14 +++---- .../src/modules/core/tables/Balances.sol | 12 +++--- .../modules/core/tables/FunctionSelectors.sol | 14 +++---- .../src/modules/core/tables/ResourceType.sol | 12 +++--- .../src/modules/core/tables/SystemHooks.sol | 12 +++--- .../modules/core/tables/SystemRegistry.sol | 12 +++--- .../world/src/modules/core/tables/Systems.sol | 14 +++---- .../keysintable/tables/KeysInTable.sol | 22 +++++------ .../keysintable/tables/UsedKeysIndex.sol | 16 ++++---- .../keyswithvalue/tables/KeysWithValue.sol | 12 +++--- .../tables/CallboundDelegations.sol | 18 ++++----- .../tables/TimeboundDelegations.sol | 14 +++---- .../uniqueentity/tables/UniqueEntity.sol | 10 ++--- packages/world/src/tables/Delegations.sol | 14 +++---- .../world/src/tables/InstalledModules.sol | 14 +++---- packages/world/src/tables/NamespaceOwner.sol | 12 +++--- packages/world/src/tables/ResourceAccess.sol | 14 +++---- packages/world/test/tables/AddressArray.sol | 12 +++--- packages/world/test/tables/Bool.sol | 10 ++--- .../contracts/src/codegen/tables/Counter.sol | 10 ++--- .../react/packages/contracts/mud.config.ts | 2 +- .../contracts/src/codegen/tables/Counter.sol | 10 ++--- .../contracts/src/codegen/tables/Position.sol | 16 ++++---- .../contracts/src/codegen/tables/Counter.sol | 10 ++--- 42 files changed, 300 insertions(+), 300 deletions(-) diff --git a/e2e/packages/contracts/src/codegen/tables/Multi.sol b/e2e/packages/contracts/src/codegen/tables/Multi.sol index 873f71588f..a634403932 100644 --- a/e2e/packages/contracts/src/codegen/tables/Multi.sol +++ b/e2e/packages/contracts/src/codegen/tables/Multi.sol @@ -38,22 +38,22 @@ library Multi { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](4); - _schema[0] = SchemaType.UINT32; - _schema[1] = SchemaType.BOOL; - _schema[2] = SchemaType.UINT256; - _schema[3] = SchemaType.INT120; + SchemaType[] memory _keySchema = new SchemaType[](4); + _keySchema[0] = SchemaType.UINT32; + _keySchema[1] = SchemaType.BOOL; + _keySchema[2] = SchemaType.UINT256; + _keySchema[3] = SchemaType.INT120; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](2); - _schema[0] = SchemaType.INT256; - _schema[1] = SchemaType.BOOL; + SchemaType[] memory _valueSchema = new SchemaType[](2); + _valueSchema[0] = SchemaType.INT256; + _valueSchema[1] = SchemaType.BOOL; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/e2e/packages/contracts/src/codegen/tables/Number.sol b/e2e/packages/contracts/src/codegen/tables/Number.sol index 40ac16b6df..01127f809c 100644 --- a/e2e/packages/contracts/src/codegen/tables/Number.sol +++ b/e2e/packages/contracts/src/codegen/tables/Number.sol @@ -32,18 +32,18 @@ library Number { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.UINT32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT32; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/e2e/packages/contracts/src/codegen/tables/NumberList.sol b/e2e/packages/contracts/src/codegen/tables/NumberList.sol index c3bd7fdaa6..60d34cc507 100644 --- a/e2e/packages/contracts/src/codegen/tables/NumberList.sol +++ b/e2e/packages/contracts/src/codegen/tables/NumberList.sol @@ -31,17 +31,17 @@ library NumberList { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](0); + SchemaType[] memory _keySchema = new SchemaType[](0); - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT32_ARRAY; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT32_ARRAY; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/e2e/packages/contracts/src/codegen/tables/Vector.sol b/e2e/packages/contracts/src/codegen/tables/Vector.sol index 5b95bbaaa5..e258fac50c 100644 --- a/e2e/packages/contracts/src/codegen/tables/Vector.sol +++ b/e2e/packages/contracts/src/codegen/tables/Vector.sol @@ -38,19 +38,19 @@ library Vector { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.UINT32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](2); - _schema[0] = SchemaType.INT32; - _schema[1] = SchemaType.INT32; + SchemaType[] memory _valueSchema = new SchemaType[](2); + _valueSchema[0] = SchemaType.INT32; + _valueSchema[1] = SchemaType.INT32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol index d21d510f08..ed4f112789 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/CounterTable.sol @@ -32,17 +32,17 @@ library CounterTable { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](0); + SchemaType[] memory _keySchema = new SchemaType[](0); - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT32; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol index 65a36496d5..96df3c93dd 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/Inventory.sol @@ -32,20 +32,20 @@ library Inventory { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](3); - _schema[0] = SchemaType.ADDRESS; - _schema[1] = SchemaType.UINT32; - _schema[2] = SchemaType.UINT32; + SchemaType[] memory _keySchema = new SchemaType[](3); + _keySchema[0] = SchemaType.ADDRESS; + _keySchema[1] = SchemaType.UINT32; + _keySchema[2] = SchemaType.UINT32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT32; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol index 849483b418..5fe5d13250 100644 --- a/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol +++ b/examples/minimal/packages/contracts/src/codegen/tables/MessageTable.sol @@ -31,17 +31,17 @@ library MessageTable { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](0); + SchemaType[] memory _keySchema = new SchemaType[](0); - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.STRING; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.STRING; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol index 177f030fde..368c3b73f4 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics1.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics1.sol @@ -39,22 +39,22 @@ library Dynamics1 { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](5); - _schema[0] = SchemaType.BYTES32_ARRAY; - _schema[1] = SchemaType.INT32_ARRAY; - _schema[2] = SchemaType.UINT128_ARRAY; - _schema[3] = SchemaType.ADDRESS_ARRAY; - _schema[4] = SchemaType.BOOL_ARRAY; - - return SchemaLib.encode(_schema); + SchemaType[] memory _valueSchema = new SchemaType[](5); + _valueSchema[0] = SchemaType.BYTES32_ARRAY; + _valueSchema[1] = SchemaType.INT32_ARRAY; + _valueSchema[2] = SchemaType.UINT128_ARRAY; + _valueSchema[3] = SchemaType.ADDRESS_ARRAY; + _valueSchema[4] = SchemaType.BOOL_ARRAY; + + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol index 7b9dfd6f1a..3bcbe30cd3 100644 --- a/packages/cli/contracts/src/codegen/tables/Dynamics2.sol +++ b/packages/cli/contracts/src/codegen/tables/Dynamics2.sol @@ -37,20 +37,20 @@ library Dynamics2 { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](3); - _schema[0] = SchemaType.UINT64_ARRAY; - _schema[1] = SchemaType.STRING; - _schema[2] = SchemaType.BYTES; + SchemaType[] memory _valueSchema = new SchemaType[](3); + _valueSchema[0] = SchemaType.UINT64_ARRAY; + _valueSchema[1] = SchemaType.STRING; + _valueSchema[2] = SchemaType.BYTES; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/cli/contracts/src/codegen/tables/Ephemeral.sol b/packages/cli/contracts/src/codegen/tables/Ephemeral.sol index 61225beb79..0f9cec20cc 100644 --- a/packages/cli/contracts/src/codegen/tables/Ephemeral.sol +++ b/packages/cli/contracts/src/codegen/tables/Ephemeral.sol @@ -32,18 +32,18 @@ library Ephemeral { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT256; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT256; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/cli/contracts/src/codegen/tables/Singleton.sol b/packages/cli/contracts/src/codegen/tables/Singleton.sol index 2c8f5b0f95..c309eedd60 100644 --- a/packages/cli/contracts/src/codegen/tables/Singleton.sol +++ b/packages/cli/contracts/src/codegen/tables/Singleton.sol @@ -32,20 +32,20 @@ library Singleton { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](0); + SchemaType[] memory _keySchema = new SchemaType[](0); - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](4); - _schema[0] = SchemaType.INT256; - _schema[1] = SchemaType.UINT32_ARRAY; - _schema[2] = SchemaType.UINT32_ARRAY; - _schema[3] = SchemaType.UINT32_ARRAY; + SchemaType[] memory _valueSchema = new SchemaType[](4); + _valueSchema[0] = SchemaType.INT256; + _valueSchema[1] = SchemaType.UINT32_ARRAY; + _valueSchema[2] = SchemaType.UINT32_ARRAY; + _valueSchema[3] = SchemaType.UINT32_ARRAY; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/cli/contracts/src/codegen/tables/Statics.sol b/packages/cli/contracts/src/codegen/tables/Statics.sol index e2af928e82..089552188c 100644 --- a/packages/cli/contracts/src/codegen/tables/Statics.sol +++ b/packages/cli/contracts/src/codegen/tables/Statics.sol @@ -51,30 +51,30 @@ library Statics { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](7); - _schema[0] = SchemaType.UINT256; - _schema[1] = SchemaType.INT32; - _schema[2] = SchemaType.BYTES16; - _schema[3] = SchemaType.ADDRESS; - _schema[4] = SchemaType.BOOL; - _schema[5] = SchemaType.UINT8; - _schema[6] = SchemaType.UINT8; + SchemaType[] memory _keySchema = new SchemaType[](7); + _keySchema[0] = SchemaType.UINT256; + _keySchema[1] = SchemaType.INT32; + _keySchema[2] = SchemaType.BYTES16; + _keySchema[3] = SchemaType.ADDRESS; + _keySchema[4] = SchemaType.BOOL; + _keySchema[5] = SchemaType.UINT8; + _keySchema[6] = SchemaType.UINT8; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](7); - _schema[0] = SchemaType.UINT256; - _schema[1] = SchemaType.INT32; - _schema[2] = SchemaType.BYTES16; - _schema[3] = SchemaType.ADDRESS; - _schema[4] = SchemaType.BOOL; - _schema[5] = SchemaType.UINT8; - _schema[6] = SchemaType.UINT8; - - return SchemaLib.encode(_schema); + SchemaType[] memory _valueSchema = new SchemaType[](7); + _valueSchema[0] = SchemaType.UINT256; + _valueSchema[1] = SchemaType.INT32; + _valueSchema[2] = SchemaType.BYTES16; + _valueSchema[3] = SchemaType.ADDRESS; + _valueSchema[4] = SchemaType.BOOL; + _valueSchema[5] = SchemaType.UINT8; + _valueSchema[6] = SchemaType.UINT8; + + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/store/src/codegen/tables/Callbacks.sol b/packages/store/src/codegen/tables/Callbacks.sol index f43519c60d..0126d86c18 100644 --- a/packages/store/src/codegen/tables/Callbacks.sol +++ b/packages/store/src/codegen/tables/Callbacks.sol @@ -31,18 +31,18 @@ library Callbacks { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES24_ARRAY; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.BYTES24_ARRAY; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/store/src/codegen/tables/Hooks.sol b/packages/store/src/codegen/tables/Hooks.sol index 8fca4a03b7..242d5c9730 100644 --- a/packages/store/src/codegen/tables/Hooks.sol +++ b/packages/store/src/codegen/tables/Hooks.sol @@ -28,18 +28,18 @@ library Hooks { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES21_ARRAY; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.BYTES21_ARRAY; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/store/src/codegen/tables/KeyEncoding.sol b/packages/store/src/codegen/tables/KeyEncoding.sol index 43d4ca2cce..f2344cf382 100644 --- a/packages/store/src/codegen/tables/KeyEncoding.sol +++ b/packages/store/src/codegen/tables/KeyEncoding.sol @@ -35,23 +35,23 @@ library KeyEncoding { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](6); - _schema[0] = SchemaType.UINT256; - _schema[1] = SchemaType.INT32; - _schema[2] = SchemaType.BYTES16; - _schema[3] = SchemaType.ADDRESS; - _schema[4] = SchemaType.BOOL; - _schema[5] = SchemaType.UINT8; + SchemaType[] memory _keySchema = new SchemaType[](6); + _keySchema[0] = SchemaType.UINT256; + _keySchema[1] = SchemaType.INT32; + _keySchema[2] = SchemaType.BYTES16; + _keySchema[3] = SchemaType.ADDRESS; + _keySchema[4] = SchemaType.BOOL; + _keySchema[5] = SchemaType.UINT8; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BOOL; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.BOOL; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/store/src/codegen/tables/Mixed.sol b/packages/store/src/codegen/tables/Mixed.sol index bba29cecd6..22f664c8e1 100644 --- a/packages/store/src/codegen/tables/Mixed.sol +++ b/packages/store/src/codegen/tables/Mixed.sol @@ -40,21 +40,21 @@ library Mixed { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](4); - _schema[0] = SchemaType.UINT32; - _schema[1] = SchemaType.UINT128; - _schema[2] = SchemaType.UINT32_ARRAY; - _schema[3] = SchemaType.STRING; + SchemaType[] memory _valueSchema = new SchemaType[](4); + _valueSchema[0] = SchemaType.UINT32; + _valueSchema[1] = SchemaType.UINT128; + _valueSchema[2] = SchemaType.UINT32_ARRAY; + _valueSchema[3] = SchemaType.STRING; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/store/src/codegen/tables/StoreHooks.sol b/packages/store/src/codegen/tables/StoreHooks.sol index 2168293bce..9b84a3549e 100644 --- a/packages/store/src/codegen/tables/StoreHooks.sol +++ b/packages/store/src/codegen/tables/StoreHooks.sol @@ -31,18 +31,18 @@ library StoreHooks { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES21_ARRAY; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.BYTES21_ARRAY; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/store/src/codegen/tables/Tables.sol b/packages/store/src/codegen/tables/Tables.sol index 535a57a44f..fc82b0dedb 100644 --- a/packages/store/src/codegen/tables/Tables.sol +++ b/packages/store/src/codegen/tables/Tables.sol @@ -42,22 +42,22 @@ library Tables { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](5); - _schema[0] = SchemaType.BYTES32; - _schema[1] = SchemaType.BYTES32; - _schema[2] = SchemaType.BYTES32; - _schema[3] = SchemaType.BYTES; - _schema[4] = SchemaType.BYTES; - - return SchemaLib.encode(_schema); + SchemaType[] memory _valueSchema = new SchemaType[](5); + _valueSchema[0] = SchemaType.BYTES32; + _valueSchema[1] = SchemaType.BYTES32; + _valueSchema[2] = SchemaType.BYTES32; + _valueSchema[3] = SchemaType.BYTES; + _valueSchema[4] = SchemaType.BYTES; + + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/store/src/codegen/tables/Vector2.sol b/packages/store/src/codegen/tables/Vector2.sol index 518695ee86..82a58d420b 100644 --- a/packages/store/src/codegen/tables/Vector2.sol +++ b/packages/store/src/codegen/tables/Vector2.sol @@ -38,19 +38,19 @@ library Vector2 { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](2); - _schema[0] = SchemaType.UINT32; - _schema[1] = SchemaType.UINT32; + SchemaType[] memory _valueSchema = new SchemaType[](2); + _valueSchema[0] = SchemaType.UINT32; + _valueSchema[1] = SchemaType.UINT32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/modules/core/tables/Balances.sol b/packages/world/src/modules/core/tables/Balances.sol index c1ccd74606..76f03b4f3c 100644 --- a/packages/world/src/modules/core/tables/Balances.sol +++ b/packages/world/src/modules/core/tables/Balances.sol @@ -32,18 +32,18 @@ library Balances { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES16; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES16; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT256; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT256; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/modules/core/tables/FunctionSelectors.sol b/packages/world/src/modules/core/tables/FunctionSelectors.sol index 70b3329a17..e3023b3273 100644 --- a/packages/world/src/modules/core/tables/FunctionSelectors.sol +++ b/packages/world/src/modules/core/tables/FunctionSelectors.sol @@ -33,19 +33,19 @@ library FunctionSelectors { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES4; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES4; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](2); - _schema[0] = SchemaType.BYTES32; - _schema[1] = SchemaType.BYTES4; + SchemaType[] memory _valueSchema = new SchemaType[](2); + _valueSchema[0] = SchemaType.BYTES32; + _valueSchema[1] = SchemaType.BYTES4; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/modules/core/tables/ResourceType.sol b/packages/world/src/modules/core/tables/ResourceType.sol index cf99407ecf..45ba98b6fb 100644 --- a/packages/world/src/modules/core/tables/ResourceType.sol +++ b/packages/world/src/modules/core/tables/ResourceType.sol @@ -35,18 +35,18 @@ library ResourceType { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT8; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT8; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/modules/core/tables/SystemHooks.sol b/packages/world/src/modules/core/tables/SystemHooks.sol index 891623d6b4..0bb1d03e8a 100644 --- a/packages/world/src/modules/core/tables/SystemHooks.sol +++ b/packages/world/src/modules/core/tables/SystemHooks.sol @@ -31,18 +31,18 @@ library SystemHooks { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES21_ARRAY; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.BYTES21_ARRAY; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/modules/core/tables/SystemRegistry.sol b/packages/world/src/modules/core/tables/SystemRegistry.sol index d560340662..1bae5fb67b 100644 --- a/packages/world/src/modules/core/tables/SystemRegistry.sol +++ b/packages/world/src/modules/core/tables/SystemRegistry.sol @@ -32,18 +32,18 @@ library SystemRegistry { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.ADDRESS; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.ADDRESS; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/modules/core/tables/Systems.sol b/packages/world/src/modules/core/tables/Systems.sol index 1be8fb6223..fa6622d37e 100644 --- a/packages/world/src/modules/core/tables/Systems.sol +++ b/packages/world/src/modules/core/tables/Systems.sol @@ -33,19 +33,19 @@ library Systems { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](2); - _schema[0] = SchemaType.ADDRESS; - _schema[1] = SchemaType.BOOL; + SchemaType[] memory _valueSchema = new SchemaType[](2); + _valueSchema[0] = SchemaType.ADDRESS; + _valueSchema[1] = SchemaType.BOOL; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/modules/keysintable/tables/KeysInTable.sol b/packages/world/src/modules/keysintable/tables/KeysInTable.sol index 0840d6c228..fe4a0ef4f6 100644 --- a/packages/world/src/modules/keysintable/tables/KeysInTable.sol +++ b/packages/world/src/modules/keysintable/tables/KeysInTable.sol @@ -39,22 +39,22 @@ library KeysInTable { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](5); - _schema[0] = SchemaType.BYTES32_ARRAY; - _schema[1] = SchemaType.BYTES32_ARRAY; - _schema[2] = SchemaType.BYTES32_ARRAY; - _schema[3] = SchemaType.BYTES32_ARRAY; - _schema[4] = SchemaType.BYTES32_ARRAY; - - return SchemaLib.encode(_schema); + SchemaType[] memory _valueSchema = new SchemaType[](5); + _valueSchema[0] = SchemaType.BYTES32_ARRAY; + _valueSchema[1] = SchemaType.BYTES32_ARRAY; + _valueSchema[2] = SchemaType.BYTES32_ARRAY; + _valueSchema[3] = SchemaType.BYTES32_ARRAY; + _valueSchema[4] = SchemaType.BYTES32_ARRAY; + + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol index 724610a783..b29e54cab8 100644 --- a/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol +++ b/packages/world/src/modules/keysintable/tables/UsedKeysIndex.sol @@ -33,20 +33,20 @@ library UsedKeysIndex { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](2); - _schema[0] = SchemaType.BYTES32; - _schema[1] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](2); + _keySchema[0] = SchemaType.BYTES32; + _keySchema[1] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](2); - _schema[0] = SchemaType.BOOL; - _schema[1] = SchemaType.UINT40; + SchemaType[] memory _valueSchema = new SchemaType[](2); + _valueSchema[0] = SchemaType.BOOL; + _valueSchema[1] = SchemaType.UINT40; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol index 7ef033db5b..2ae73a6568 100644 --- a/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol +++ b/packages/world/src/modules/keyswithvalue/tables/KeysWithValue.sol @@ -28,18 +28,18 @@ library KeysWithValue { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32_ARRAY; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.BYTES32_ARRAY; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol b/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol index 3f582631db..a2f0f2519b 100644 --- a/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol +++ b/packages/world/src/modules/std-delegations/tables/CallboundDelegations.sol @@ -32,21 +32,21 @@ library CallboundDelegations { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](4); - _schema[0] = SchemaType.ADDRESS; - _schema[1] = SchemaType.ADDRESS; - _schema[2] = SchemaType.BYTES32; - _schema[3] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](4); + _keySchema[0] = SchemaType.ADDRESS; + _keySchema[1] = SchemaType.ADDRESS; + _keySchema[2] = SchemaType.BYTES32; + _keySchema[3] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT256; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT256; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol b/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol index 40fd73e643..27a2552404 100644 --- a/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol +++ b/packages/world/src/modules/std-delegations/tables/TimeboundDelegations.sol @@ -32,19 +32,19 @@ library TimeboundDelegations { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](2); - _schema[0] = SchemaType.ADDRESS; - _schema[1] = SchemaType.ADDRESS; + SchemaType[] memory _keySchema = new SchemaType[](2); + _keySchema[0] = SchemaType.ADDRESS; + _keySchema[1] = SchemaType.ADDRESS; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT256; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT256; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol b/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol index 7adfa3d80d..092bde6646 100644 --- a/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol +++ b/packages/world/src/modules/uniqueentity/tables/UniqueEntity.sol @@ -29,17 +29,17 @@ library UniqueEntity { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](0); + SchemaType[] memory _keySchema = new SchemaType[](0); - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT256; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT256; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/tables/Delegations.sol b/packages/world/src/tables/Delegations.sol index bdc5bf5f4f..5889c445bd 100644 --- a/packages/world/src/tables/Delegations.sol +++ b/packages/world/src/tables/Delegations.sol @@ -32,19 +32,19 @@ library Delegations { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](2); - _schema[0] = SchemaType.ADDRESS; - _schema[1] = SchemaType.ADDRESS; + SchemaType[] memory _keySchema = new SchemaType[](2); + _keySchema[0] = SchemaType.ADDRESS; + _keySchema[1] = SchemaType.ADDRESS; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/tables/InstalledModules.sol b/packages/world/src/tables/InstalledModules.sol index 9a010b508d..9a03d507fa 100644 --- a/packages/world/src/tables/InstalledModules.sol +++ b/packages/world/src/tables/InstalledModules.sol @@ -36,19 +36,19 @@ library InstalledModules { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](2); - _schema[0] = SchemaType.BYTES16; - _schema[1] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](2); + _keySchema[0] = SchemaType.BYTES16; + _keySchema[1] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.ADDRESS; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.ADDRESS; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/tables/NamespaceOwner.sol b/packages/world/src/tables/NamespaceOwner.sol index 3a57ea199a..54033da9dd 100644 --- a/packages/world/src/tables/NamespaceOwner.sol +++ b/packages/world/src/tables/NamespaceOwner.sol @@ -32,18 +32,18 @@ library NamespaceOwner { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES16; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES16; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.ADDRESS; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.ADDRESS; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/src/tables/ResourceAccess.sol b/packages/world/src/tables/ResourceAccess.sol index 529c849038..f53abae8e7 100644 --- a/packages/world/src/tables/ResourceAccess.sol +++ b/packages/world/src/tables/ResourceAccess.sol @@ -32,19 +32,19 @@ library ResourceAccess { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](2); - _schema[0] = SchemaType.BYTES32; - _schema[1] = SchemaType.ADDRESS; + SchemaType[] memory _keySchema = new SchemaType[](2); + _keySchema[0] = SchemaType.BYTES32; + _keySchema[1] = SchemaType.ADDRESS; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BOOL; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.BOOL; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/test/tables/AddressArray.sol b/packages/world/test/tables/AddressArray.sol index 1daf1d0d6c..004e97be40 100644 --- a/packages/world/test/tables/AddressArray.sol +++ b/packages/world/test/tables/AddressArray.sol @@ -28,18 +28,18 @@ library AddressArray { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.ADDRESS_ARRAY; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.ADDRESS_ARRAY; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/packages/world/test/tables/Bool.sol b/packages/world/test/tables/Bool.sol index 73f02fd1af..955432d6b9 100644 --- a/packages/world/test/tables/Bool.sol +++ b/packages/world/test/tables/Bool.sol @@ -29,17 +29,17 @@ library Bool { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](0); + SchemaType[] memory _keySchema = new SchemaType[](0); - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BOOL; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.BOOL; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol b/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol index afb08c8ee5..302b905c36 100644 --- a/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/phaser/packages/contracts/src/codegen/tables/Counter.sol @@ -32,17 +32,17 @@ library Counter { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](0); + SchemaType[] memory _keySchema = new SchemaType[](0); - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT32; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/templates/react/packages/contracts/mud.config.ts b/templates/react/packages/contracts/mud.config.ts index 1dc8d7e90f..70edda1693 100644 --- a/templates/react/packages/contracts/mud.config.ts +++ b/templates/react/packages/contracts/mud.config.ts @@ -4,7 +4,7 @@ export default mudConfig({ tables: { Counter: { keySchema: {}, - schema: "uint32", + valueSchema: "uint32", }, }, }); diff --git a/templates/react/packages/contracts/src/codegen/tables/Counter.sol b/templates/react/packages/contracts/src/codegen/tables/Counter.sol index afb08c8ee5..302b905c36 100644 --- a/templates/react/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/react/packages/contracts/src/codegen/tables/Counter.sol @@ -32,17 +32,17 @@ library Counter { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](0); + SchemaType[] memory _keySchema = new SchemaType[](0); - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT32; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol index ab4731aba7..fa15b967dc 100644 --- a/templates/threejs/packages/contracts/src/codegen/tables/Position.sol +++ b/templates/threejs/packages/contracts/src/codegen/tables/Position.sol @@ -40,20 +40,20 @@ library Position { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.BYTES32; + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](3); - _schema[0] = SchemaType.INT32; - _schema[1] = SchemaType.INT32; - _schema[2] = SchemaType.INT32; + SchemaType[] memory _valueSchema = new SchemaType[](3); + _valueSchema[0] = SchemaType.INT32; + _valueSchema[1] = SchemaType.INT32; + _valueSchema[2] = SchemaType.INT32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ diff --git a/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol b/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol index afb08c8ee5..302b905c36 100644 --- a/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol +++ b/templates/vanilla/packages/contracts/src/codegen/tables/Counter.sol @@ -32,17 +32,17 @@ library Counter { /** Get the table's key schema */ function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](0); + SchemaType[] memory _keySchema = new SchemaType[](0); - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } /** Get the table's value schema */ function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT32; + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } /** Get the table's key names */ From aca9b6543e58ba07017b42992b7ea0028ebce1c1 Mon Sep 17 00:00:00 2001 From: alvrs Date: Thu, 14 Sep 2023 13:19:59 +0100 Subject: [PATCH 03/19] gas report --- packages/store/gas-report.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 0899ffa898..06772c450b 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -710,7 +710,7 @@ { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", - "name": "StoreCore: get schema (warm)", + "name": "StoreCore: get value schema (warm)", "gasUsed": 5033 }, { From 62239ef6ccc7bb88505a6ee9a149445137f4dc51 Mon Sep 17 00:00:00 2001 From: alvrs Date: Thu, 14 Sep 2023 13:55:17 +0100 Subject: [PATCH 04/19] fix tests --- packages/store-sync/src/recs/configToRecsComponents.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/store-sync/src/recs/configToRecsComponents.ts b/packages/store-sync/src/recs/configToRecsComponents.ts index f1b2e617e5..1d5b9e760e 100644 --- a/packages/store-sync/src/recs/configToRecsComponents.ts +++ b/packages/store-sync/src/recs/configToRecsComponents.ts @@ -15,7 +15,7 @@ export function configToRecsComponents( defineComponent( world, Object.fromEntries( - Object.entries(table.schema).map(([fieldName, schemaAbiType]) => [ + Object.entries(table.valueSchema).map(([fieldName, schemaAbiType]) => [ fieldName, schemaAbiTypeToRecsType[schemaAbiType as SchemaAbiType], ]) @@ -26,7 +26,7 @@ export function configToRecsComponents( componentName: tableName, tableName: `${config.namespace}:${tableName}`, keySchema: table.keySchema, - valueSchema: table.schema, + valueSchema: table.valueSchema, }, } ), From 7836de7364471f8a15198c73e09cde1c605bbea3 Mon Sep 17 00:00:00 2001 From: alvrs Date: Thu, 14 Sep 2023 14:06:26 +0100 Subject: [PATCH 05/19] fix tests --- packages/store-sync/src/recs/common.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/store-sync/src/recs/common.ts b/packages/store-sync/src/recs/common.ts index c384d5da13..d33aeb5b93 100644 --- a/packages/store-sync/src/recs/common.ts +++ b/packages/store-sync/src/recs/common.ts @@ -14,14 +14,14 @@ export type StoreComponentMetadata = RecsMetadata & { export type ConfigToRecsComponents = { [tableName in keyof TConfig["tables"] & string]: RecsComponent< { - [fieldName in keyof TConfig["tables"][tableName]["schema"] & string]: RecsType & - SchemaAbiTypeToRecsType; + [fieldName in keyof TConfig["tables"][tableName]["valueSchema"] & string]: RecsType & + SchemaAbiTypeToRecsType; }, StoreComponentMetadata & { componentName: tableName; tableName: `${TConfig["namespace"]}:${tableName}`; keySchema: TConfig["tables"][tableName]["keySchema"]; - valueSchema: TConfig["tables"][tableName]["schema"]; + valueSchema: TConfig["tables"][tableName]["valueSchema"]; } >; }; From 1597baf65efd2f4af3e49f246d281ed2acb968bc Mon Sep 17 00:00:00 2001 From: alvarius Date: Thu, 14 Sep 2023 14:22:32 +0100 Subject: [PATCH 06/19] Create cold-years-itch.md --- .changeset/cold-years-itch.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .changeset/cold-years-itch.md diff --git a/.changeset/cold-years-itch.md b/.changeset/cold-years-itch.md new file mode 100644 index 0000000000..55540911db --- /dev/null +++ b/.changeset/cold-years-itch.md @@ -0,0 +1,24 @@ +--- +"@latticexyz/cli": major +"@latticexyz/protocol-parser": major +"@latticexyz/store-sync": major +"@latticexyz/store": major +--- + +Renamed all occurrences of `schema` where it is used as "value schema" to `valueSchema` to clearly distinguish it from "key schema". +The only breaking change for users is the change from `schema` to `valueSchema` in `mud.config.ts`. + +```diff +// mud.config.ts +export default mudConfig({ + tables: { + CounterTable: { + keySchema: {}, +- schema: { ++ valueSchema: { + value: "uint32", + }, + }, + } +} +``` From 6f648498310403e132767db0dd5d0a1eb7e384c2 Mon Sep 17 00:00:00 2001 From: alvarius Date: Thu, 14 Sep 2023 18:02:03 +0100 Subject: [PATCH 07/19] Update .changeset/cold-years-itch.md Co-authored-by: Kevin Ingersoll --- .changeset/cold-years-itch.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/cold-years-itch.md b/.changeset/cold-years-itch.md index 55540911db..b132da0085 100644 --- a/.changeset/cold-years-itch.md +++ b/.changeset/cold-years-itch.md @@ -3,6 +3,7 @@ "@latticexyz/protocol-parser": major "@latticexyz/store-sync": major "@latticexyz/store": major +"create-mud": minor --- Renamed all occurrences of `schema` where it is used as "value schema" to `valueSchema` to clearly distinguish it from "key schema". From 14582af8bf0f719ebb83b5f8933f9b3bd0248420 Mon Sep 17 00:00:00 2001 From: alvrs Date: Thu, 14 Sep 2023 21:13:08 +0100 Subject: [PATCH 08/19] catch some more schemas --- docs/pages/client-side.mdx | 2 +- docs/pages/ecs.mdx | 2 +- docs/pages/quick-start.mdx | 9 ++++----- docs/pages/store/advanced-features.mdx | 12 +++++------ docs/pages/store/config.mdx | 12 +++++------ docs/pages/store/reading-and-writing.mdx | 8 ++++---- docs/pages/store/using-without-world.mdx | 19 ++++++++++++------ .../emojimon/a-wild-emojimon-appears.mdx | 20 +++++++++---------- .../tutorials/emojimon/map-and-terrain.mdx | 8 ++++---- .../emojimon/players-and-movement.mdx | 4 ++-- docs/pages/tutorials/minimal/add-table.mdx | 6 +++--- .../tutorials/walkthrough/minimal-onchain.mdx | 18 ++++++++--------- docs/pages/what-is-mud.mdx | 2 +- docs/pages/world/config.mdx | 2 +- docs/pages/world/modules.mdx | 4 ++-- docs/pages/world/querying.mdx | 2 +- docs/pages/world/subsystems.mdx | 4 ++-- docs/pages/world/world-101.mdx | 6 +++--- 18 files changed, 73 insertions(+), 67 deletions(-) diff --git a/docs/pages/client-side.mdx b/docs/pages/client-side.mdx index 287cd1b939..fc73319ed1 100644 --- a/docs/pages/client-side.mdx +++ b/docs/pages/client-side.mdx @@ -24,7 +24,7 @@ const config = mudConfig({ tables: { NameComponent: "string", PlayerComponent: "bool", - PositionComponent: { schema: { x: "int32", y: "int32" } }, + PositionComponent: { valueSchema: { x: "int32", y: "int32" } }, }, }); ``` diff --git a/docs/pages/ecs.mdx b/docs/pages/ecs.mdx index 03fe09b611..0f855a5da7 100644 --- a/docs/pages/ecs.mdx +++ b/docs/pages/ecs.mdx @@ -19,7 +19,7 @@ export default mudConfig({ tables: { PlayerComponent: "bool", PositionComponent: { - schema: { x: "int32", y: "int32" }, + valueSchema: { x: "int32", y: "int32" }, }, NameComponent: "string", DamageComponent: uint256, diff --git a/docs/pages/quick-start.mdx b/docs/pages/quick-start.mdx index e03fe5a60b..e8251e0f6f 100644 --- a/docs/pages/quick-start.mdx +++ b/docs/pages/quick-start.mdx @@ -81,7 +81,7 @@ export default mudConfig({ tables: { Counter: { keySchema: {}, - schema: "uint32", + valueSchema: "uint32", }, }, }); @@ -117,7 +117,7 @@ contract IncrementSystem is System { } ``` -The increment system is able to import `Counter` (from its autogenerated table schema) and operate on it by increasing its value by one. +The increment system is able to import `Counter` (from its autogenerated table library) and operate on it by increasing its value by one. Each system can contain any number of methods, though this system only has the single method—`increment`. These methods can then be called in the client to execute them in a transaction. @@ -127,7 +127,6 @@ The client package will vary depending on which template used (vanilla, react, p - You can adjust `createClientComponents.ts` to either override contract components or add client-only components. - If you are using chains other than foundry/anvil and lattice testnet, you can add them in `getNetworkConfig.ts` -- `createSystemCalls` represents how the client talks to the system contracts via our `worldSend` helper - `setup.ts` Beyond these files you can concern yourself simply with building out the frontend of the client. @@ -136,13 +135,13 @@ Beyond these files you can concern yourself simply with building out the fronten Now that you’re familiar with the basic structure of the client package, let’s go over how you can call on systems from the contracts package. -The starter project comes with `IncrementSystem.sol`—you can see it being called in `index.ts` (or `index.tsx` in the react template). +The starter project comes with `IncrementSystem.sol`—you can see it being called in `index.ts` (or `App.tsx` in the react template). ```tsx // Just for demonstration purposes: we create a global function that can be // called to invoke the Increment system contract via the world. (See IncrementSystem.sol.) (window as any).increment = async () => { - const tx = await worldSend("increment", []); + const tx = await worldContract.write.increment(); console.log("increment tx", tx); console.log("increment result", await tx.wait()); diff --git a/docs/pages/store/advanced-features.mdx b/docs/pages/store/advanced-features.mdx index e3ff1efea9..1a859967df 100644 --- a/docs/pages/store/advanced-features.mdx +++ b/docs/pages/store/advanced-features.mdx @@ -17,7 +17,7 @@ export default mudConfig({ tables: { CounterSingleton: { keySchema: {}, - schema: "uint256", + valueSchema: "uint256", }, }, }); @@ -48,7 +48,7 @@ import { mudConfig } from "@latticexyz/store/register"; export default mudConfig({ tables: { TradeExecuted: { - schema: { + valueSchema: { amount: "uint32", receiver: "bytes32", }, @@ -84,8 +84,8 @@ uint256 constant indexerTableId = uint256(keccak256("indexer.table")); contract MirrorSubscriber is IStoreHook { uint256 _table; - constructor(uint256 table, Schema schema, Schema keySchema) { - IStore(msg.sender).registerSchema(indexerTableId, schema, keySchema); + constructor(uint256 table, Schema keySchema, Schema valueSchema) { + IStore(msg.sender).registerSchema(indexerTableId, valueSchema, keySchema); _table = table; } @@ -110,9 +110,9 @@ Registering the hook can be done using the low-level Store API: ```solidity uint256 table = keccak256("table"); -Schema schema = SchemaLib.encode(SchemaType.UINT256, SchemaType.UINT256); +Schema valueSchema = SchemaLib.encode(SchemaType.UINT256, SchemaType.UINT256); Schema keySchema = SchemaLib.encode(SchemaType.UINT256); -MirrorSubscriber subscriber = new MirrorSubscriber(table, schema, keySchema); +MirrorSubscriber subscriber = new MirrorSubscriber(table, keySchema, valueSchema); StoreCore.registerStoreHook(table, subscriber); ``` diff --git a/docs/pages/store/config.mdx b/docs/pages/store/config.mdx index 386ac9e79b..36eacbcbdd 100644 --- a/docs/pages/store/config.mdx +++ b/docs/pages/store/config.mdx @@ -46,7 +46,7 @@ import { mudConfig } from "@latticexyz/store/register"; export default mudConfig({ tables: { MyTable: { - schema: { + valueSchema: { value: "uint32", }, }, @@ -62,7 +62,7 @@ The table configuration can have these properties: **`fileSelector` (optional)** _only used with the World framework_: a `string`: where to create the table in the namespace. -**`tableIdArgument` (optional)**: `bool`: whether to create getter and setter functions with the table ID as an argument, this is used to generate a single library to operate on multiple tables with the same schema and key structure. +**`tableIdArgument` (optional)**: `bool`: whether to create getter and setter functions with the table ID as an argument, this is used to generate a single library to operate on multiple tables with the same key and value structure. **`storeArgument` (optional)**: `bool`: whether to create getter and setter functions with the store address as an argument, this is used to generate a single library to operate on the same table in multiple stores. This adds new functions to the library, doubling the amount of functions created (each getter/setter will comes in a pair of “with `storeArgument`” and “without `storeArgument`”) @@ -86,7 +86,7 @@ Example: ```tsx tables: { MyTableWithTwoKeys: { - schema: { + valueSchema: { value1: "uint32", value2: "uint32", }, @@ -98,14 +98,14 @@ tables: { } ``` -**`schema` (required)**: an object with keys being the column name, and value being types from `SchemaType` +**`valueSchema` (required)**: an object with keys being the column name, and value being types from `SchemaType` Example: ```tsx tables: { MyTableWithFourValues: { - schema: { + valueSchema: { x: "uint32", y: "uint32", stringField: "string", @@ -135,7 +135,7 @@ Example: ```tsx tables: { MySingletonTable: { - schema: { + valueSchema: { value1: "uint32", value2: "uint32", }, diff --git a/docs/pages/store/reading-and-writing.mdx b/docs/pages/store/reading-and-writing.mdx index 229a678f4b..a2471147c2 100644 --- a/docs/pages/store/reading-and-writing.mdx +++ b/docs/pages/store/reading-and-writing.mdx @@ -21,7 +21,7 @@ This section assumes the existence of “MyTable” as described with the config // definition of MyTable tables: { MyTable: { - schema: { + valueSchema: { foo: "uint256", bar: "bool", fooArray: "uint256[]", // Store supports dynamic arrays @@ -106,7 +106,7 @@ This section assumes the existence of “MyTable” as described with the config // definition of MyTable tables: { MyTable: { - schema: { + valueSchema: { foo: "uint256", bar: "bool", }, @@ -147,8 +147,8 @@ uint256 tableId = uint256(keccak256("MyTable")); bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some.key"); // Retrieve a record -Schema schema = SchemaLib.encode(SchemaType.UINT256, SchemaType.UINT256); -bytes memory loadedData = StoreCore.getRecord(tableId, key, schema); +Schema valueSchema = SchemaLib.encode(SchemaType.UINT256, SchemaType.UINT256); +bytes memory loadedData = StoreCore.getRecord(tableId, key, valueSchema); uint256 foo = (uint256(Bytes.slice4(loadedData, 0))); uint256 bar = (uint256(Bytes.slice4(loadedData, 32))); ``` diff --git a/docs/pages/store/using-without-world.mdx b/docs/pages/store/using-without-world.mdx index 497f389adf..c1fc921b73 100644 --- a/docs/pages/store/using-without-world.mdx +++ b/docs/pages/store/using-without-world.mdx @@ -42,7 +42,7 @@ import { mudConfig } from "@latticexyz/store/register"; export default mudConfig({ tables: { MyTable: { - schema: { + valueSchema: { field1: "uint256", field2: "uint256", }, @@ -78,18 +78,25 @@ contract Contract is Store { ```solidity import { Store } from "@latticexyz/store/src/Store.sol"; import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; +import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol"; contract Contract is Store { constructor() { + bytes32 tableId = bytes32("MyTable"); + + FieldLayout fieldLayout = FieldLayoutLib.encode(32, 32); Schema keySchema = SchemaLib.encode(SchemaType.UINT256); - Schema schema = SchemaLib.encode(SchemaType.UINT256, SchemaType.UINT256); - uint256 table = uint256(keccak256("MyTable")); - StoreCore.registerSchema(table, schema, keySchema); - // Setting metadata is optional. It helps off-chain actors name columns + Schema valueSchema = SchemaLib.encode(SchemaType.UINT256, SchemaType.UINT256); + + string[] memory keyNames = new string[](1); + keyNames[0] = "field1"; + string[] memory fieldNames = new string[](2); fieldNames[0] = "field1"; fieldNames[1] = "field2"; - StoreSwitch.setMetadata(table, "MyTable", fieldNames); + + StoreCore.registerTable(tableId, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); } } ``` diff --git a/docs/pages/tutorials/emojimon/a-wild-emojimon-appears.mdx b/docs/pages/tutorials/emojimon/a-wild-emojimon-appears.mdx index 633dbb113e..2972511adc 100644 --- a/docs/pages/tutorials/emojimon/a-wild-emojimon-appears.mdx +++ b/docs/pages/tutorials/emojimon/a-wild-emojimon-appears.mdx @@ -46,7 +46,7 @@ export default mudConfig({ keySchema: { player: "bytes32", }, - schema: { + valueSchema: { exists: "bool", monster: "bytes32", catchAttempts: "uint256", @@ -57,7 +57,7 @@ export default mudConfig({ MapConfig: { keySchema: {}, dataStruct: false, - schema: { + valueSchema: { width: "uint32", height: "uint32", terrain: "bytes", @@ -68,7 +68,7 @@ export default mudConfig({ Player: "bool", Position: { dataStruct: false, - schema: { + valueSchema: { x: "uint32", y: "uint32", }, @@ -523,7 +523,7 @@ export default mudConfig({ keySchema: { player: "bytes32", }, - schema: { + valueSchema: { exists: "bool", monster: "bytes32", catchAttempts: "uint256", @@ -534,7 +534,7 @@ export default mudConfig({ MapConfig: { keySchema: {}, dataStruct: false, - schema: { + valueSchema: { width: "uint32", height: "uint32", terrain: "bytes", @@ -546,7 +546,7 @@ export default mudConfig({ Player: "bool", Position: { dataStruct: false, - schema: { + valueSchema: { x: "uint32", y: "uint32", }, @@ -749,7 +749,7 @@ export default mudConfig({ keySchema: { player: "bytes32", }, - schema: { + valueSchema: { exists: "bool", monster: "bytes32", catchAttempts: "uint256", @@ -760,7 +760,7 @@ export default mudConfig({ MapConfig: { keySchema: {}, dataStruct: false, - schema: { + valueSchema: { width: "uint32", height: "uint32", terrain: "bytes", @@ -772,7 +772,7 @@ export default mudConfig({ keySchema: { encounter: "bytes32", }, - schema: { + valueSchema: { result: "MonsterCatchResult", }, }, @@ -783,7 +783,7 @@ export default mudConfig({ Player: "bool", Position: { dataStruct: false, - schema: { + valueSchema: { x: "uint32", y: "uint32", }, diff --git a/docs/pages/tutorials/emojimon/map-and-terrain.mdx b/docs/pages/tutorials/emojimon/map-and-terrain.mdx index 7d57928e29..d2f8b5e643 100644 --- a/docs/pages/tutorials/emojimon/map-and-terrain.mdx +++ b/docs/pages/tutorials/emojimon/map-and-terrain.mdx @@ -27,7 +27,7 @@ export default mudConfig({ MapConfig: { keySchema: {}, dataStruct: false, - schema: { + valueSchema: { width: "uint32", height: "uint32", terrain: "bytes", @@ -37,7 +37,7 @@ export default mudConfig({ Player: "bool", Position: { dataStruct: false, - schema: { + valueSchema: { x: "uint32", y: "uint32", }, @@ -205,7 +205,7 @@ export default mudConfig({ MapConfig: { keySchema: {}, dataStruct: false, - schema: { + valueSchema: { width: "uint32", height: "uint32", terrain: "bytes", @@ -216,7 +216,7 @@ export default mudConfig({ Player: "bool", Position: { dataStruct: false, - schema: { + valueSchema: { x: "uint32", y: "uint32", }, diff --git a/docs/pages/tutorials/emojimon/players-and-movement.mdx b/docs/pages/tutorials/emojimon/players-and-movement.mdx index acb1703a84..e17c7ffd94 100644 --- a/docs/pages/tutorials/emojimon/players-and-movement.mdx +++ b/docs/pages/tutorials/emojimon/players-and-movement.mdx @@ -16,7 +16,7 @@ We're going to start by defining three new tables: 1. `Player: 'bool'` → determine which entities are players (e.g. distinct wallet addresses) 2. `Movable: 'bool'` → determine whether or not an entity can move -3. `Position: { schema: { x: 'uint32', y: 'uint32' } }` → determine which position an entity is located on a 2D grid +3. `Position: { valueSchema: { x: 'uint32', y: 'uint32' } }` → determine which position an entity is located on a 2D grid The syntax is as follows: @@ -34,7 +34,7 @@ export default mudConfig({ Player: "bool", Position: { dataStruct: false, - schema: { + valueSchema: { x: "uint32", y: "uint32", }, diff --git a/docs/pages/tutorials/minimal/add-table.mdx b/docs/pages/tutorials/minimal/add-table.mdx index 39a35466a7..800f9b0267 100644 --- a/docs/pages/tutorials/minimal/add-table.mdx +++ b/docs/pages/tutorials/minimal/add-table.mdx @@ -22,13 +22,13 @@ For the sake of simplicity, we will implement this in the `increment` function r tables: { Counter: { keySchema: {}, - schema: "uint32", + valueSchema: "uint32", }, History: { keySchema: { counterValue: "uint32", }, - schema: { + valueSchema: { blockNumber: "uint256", time: "uint256", }, @@ -45,7 +45,7 @@ For the sake of simplicity, we will implement this in the `increment` function r A MUD table has two schemas: - `keySchema`, the key used to find entries -- `schema`, the value in the entry (soon to be renamed to `valueSchema`) +- `valueSchema`, the value in the entry Each schema is represented as a structure with field names as keys, and the appropriate [Solidity data types](https://docs.soliditylang.org/en/latest/types.html) as their values. diff --git a/docs/pages/tutorials/walkthrough/minimal-onchain.mdx b/docs/pages/tutorials/walkthrough/minimal-onchain.mdx index 2cdb489d95..10cb260605 100644 --- a/docs/pages/tutorials/walkthrough/minimal-onchain.mdx +++ b/docs/pages/tutorials/walkthrough/minimal-onchain.mdx @@ -29,13 +29,13 @@ export default mudConfig({ tables: { Counter: { keySchema: {}, - schema: "uint32", + valueSchema: "uint32", }, Users: { keySchema: { user: "address", }, - schema: { + valueSchema: { score: "uint32", name: "string", }, @@ -128,18 +128,18 @@ The default namespace is empty. ```solidity library Counter { - /** Get the table's schema */ - function getSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](1); - _schema[0] = SchemaType.UINT32; + /** Get the table's value schema */ + function getValueSchema() internal pure returns (Schema) { + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.UINT32; - return SchemaLib.encode(_schema); + return SchemaLib.encode(_valueSchema); } function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](0); + SchemaType[] memory _keySchema = new SchemaType[](0); - return SchemaLib.encode(_schema); + return SchemaLib.encode(_keySchema); } ``` diff --git a/docs/pages/what-is-mud.mdx b/docs/pages/what-is-mud.mdx index 6f277d92e8..0a5e09b9b7 100644 --- a/docs/pages/what-is-mud.mdx +++ b/docs/pages/what-is-mud.mdx @@ -57,7 +57,7 @@ Allowance: { from: "address", to: "address", }, - schema: { + valueSchema: { amount: "uint256", }, } diff --git a/docs/pages/world/config.mdx b/docs/pages/world/config.mdx index e5af9a8bbe..ae021458b6 100644 --- a/docs/pages/world/config.mdx +++ b/docs/pages/world/config.mdx @@ -29,7 +29,7 @@ export default mudConfig({ }, tables: { CounterTable: { - schema: { + valueSchema: { value: "uint32", }, }, diff --git a/docs/pages/world/modules.mdx b/docs/pages/world/modules.mdx index 86b4b44dd6..5ae80689bb 100644 --- a/docs/pages/world/modules.mdx +++ b/docs/pages/world/modules.mdx @@ -96,7 +96,7 @@ Using `getKeysWithValue` to retrieve all NFTs owned by a specific address: ```solidity // assumes this ownership table: // Owners: { -// schema: "address", +// valueSchema: "address", // keySchema: { nftId: "uint256" } // } import { getKeysWithValue } from "@latticexyz/world/src/modules/keyswithvalue/getKeysWithValue.sol"; @@ -157,7 +157,7 @@ import { resolveTableId } from "@latticexyz/config"; export default mudConfig({ tables: { MyTable: { - schema: "uint32", + valueSchema: "uint32", }, }, modules: [ diff --git a/docs/pages/world/querying.mdx b/docs/pages/world/querying.mdx index 2cbe89a621..0a3cc1a53a 100644 --- a/docs/pages/world/querying.mdx +++ b/docs/pages/world/querying.mdx @@ -19,7 +19,7 @@ import { mudConfig } from "@latticexyz/world/register"; export default mudConfig({ tables: { Player: "bool", - Position: { schema: { x: "int32", y: "int32" } }, + Position: { valueSchema: { x: "int32", y: "int32" } }, }, }); ``` diff --git a/docs/pages/world/subsystems.mdx b/docs/pages/world/subsystems.mdx index 93e2561876..a1c2f1a481 100644 --- a/docs/pages/world/subsystems.mdx +++ b/docs/pages/world/subsystems.mdx @@ -28,11 +28,11 @@ export default mudConfig({ tables: { BalanceTable: { keySchema: { owner: "address"}, - schema: { amount: "uint256" }, + valueSchema: { amount: "uint256" }, }, OwnerTable: { keySchema: { token: "uint256" }, - schema: { owner: "address" }, + valueSchema: { owner: "address" }, }, }, }); diff --git a/docs/pages/world/world-101.mdx b/docs/pages/world/world-101.mdx index bd38836be7..84a3d247e8 100644 --- a/docs/pages/world/world-101.mdx +++ b/docs/pages/world/world-101.mdx @@ -126,7 +126,7 @@ export default mudConfig({ tables: { Counter: { keySchema: {}, - schema: "uint32", + valueSchema: "uint32", }, }, }); @@ -177,10 +177,10 @@ export default mudConfig({ tables: { Counter: { keySchema: {}, - schema: "uint32", + valueSchema: "uint32", }, Dog: { - schema: { + valueSchema: { owner: "address", name: "string", color: "string", From 1dd1b4810ae2408ceb5695f194beea5d273bc562 Mon Sep 17 00:00:00 2001 From: alvrs Date: Thu, 14 Sep 2023 16:34:40 +0100 Subject: [PATCH 09/19] feat: rename table to tableId --- docs/pages/store/advanced-features.mdx | 22 +- packages/block-logs-stream/README.md | 8 +- packages/store-sync/src/blockLogsToStorage.ts | 10 +- packages/store/gas-report.json | 20 +- packages/store/src/IStore.sol | 42 +- packages/store/src/IStoreHook.sol | 17 +- packages/store/src/StoreCore.sol | 8 +- packages/store/src/StoreRead.sol | 20 +- packages/store/src/StoreSwitch.sol | 102 ++--- packages/store/test/EchoSubscriber.sol | 24 +- packages/store/test/MirrorSubscriber.sol | 24 +- packages/store/test/StoreCore.t.sol | 362 +++++++++--------- packages/store/test/StoreCoreDynamic.t.sol | 8 +- packages/store/test/StoreCoreGas.t.sol | 188 ++++----- packages/store/test/StoreMock.sol | 40 +- packages/store/ts/storeEvents.ts | 8 +- .../modules/keysintable/KeysInTableHook.sol | 36 +- 17 files changed, 478 insertions(+), 461 deletions(-) diff --git a/docs/pages/store/advanced-features.mdx b/docs/pages/store/advanced-features.mdx index 1a859967df..caaa9c365d 100644 --- a/docs/pages/store/advanced-features.mdx +++ b/docs/pages/store/advanced-features.mdx @@ -82,25 +82,25 @@ This is an example of a Mirror hook which mirrors a table into another one: uint256 constant indexerTableId = uint256(keccak256("indexer.table")); contract MirrorSubscriber is IStoreHook { - uint256 _table; + bytes32 _tableId; constructor(uint256 table, Schema keySchema, Schema valueSchema) { IStore(msg.sender).registerSchema(indexerTableId, valueSchema, keySchema); - _table = table; + _tableId = tableId; } - function onSetRecord(uint256 table, bytes32[] memory key, bytes memory data) public { - if (_table != table) revert("invalid table"); + function onSetRecord(bytes32 tableId, bytes32[] memory key, bytes memory data) public { + if (_tableId != tableId) revert("invalid tableId"); StoreSwitch.setRecord(indexerTableId, key, data); } - function onSetField(uint256 table, bytes32[] memory key, uint8 schemaIndex, bytes memory data) public { - if (_table != table) revert("invalid table"); + function onSetField(bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, bytes memory data) public { + if (_tableId != tableId) revert("invalid tableId"); StoreSwitch.setField(indexerTableId, key, schemaIndex, data); } - function onDeleteRecord(uint256 table, bytes32[] memory key) public { - if (_table != table) revert("invalid table"); + function onDeleteRecord(bytes32 tableId, bytes32[] memory key) public { + if (_tableId != tableId) revert("invalid tableId"); StoreSwitch.deleteRecord(indexerTableId, key); } } @@ -109,11 +109,11 @@ contract MirrorSubscriber is IStoreHook { Registering the hook can be done using the low-level Store API: ```solidity -uint256 table = keccak256("table"); +bytes32 tableId = keccak256("table"); Schema valueSchema = SchemaLib.encode(SchemaType.UINT256, SchemaType.UINT256); Schema keySchema = SchemaLib.encode(SchemaType.UINT256); -MirrorSubscriber subscriber = new MirrorSubscriber(table, keySchema, valueSchema); -StoreCore.registerStoreHook(table, subscriber); +MirrorSubscriber subscriber = new MirrorSubscriber(tableId, keySchema, valueSchema); +StoreCore.registerStoreHook(tableId, subscriber); ``` ### Accessing Store from a `CALL` or `DELEGATECALL` transparently diff --git a/packages/block-logs-stream/README.md b/packages/block-logs-stream/README.md index 06ff3e3624..692c02423f 100644 --- a/packages/block-logs-stream/README.md +++ b/packages/block-logs-stream/README.md @@ -26,10 +26,10 @@ latestBlockNumber$ publicClient, address, events: parseAbi([ - "event StoreDeleteRecord(bytes32 table, bytes32[] key)", - "event StoreSetField(bytes32 table, bytes32[] key, uint8 schemaIndex, bytes data)", - "event StoreSetRecord(bytes32 table, bytes32[] key, bytes data)", - "event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data)", + "event StoreDeleteRecord(bytes32 tableId, bytes32[] key)", + "event StoreSetField(bytes32 tableId, bytes32[] key, uint8 schemaIndex, bytes data)", + "event StoreSetRecord(bytes32 tableId, bytes32[] key, bytes data)", + "event StoreEphemeralRecord(bytes32 tableId, bytes32[] key, bytes data)", ]), }), mergeMap(({ logs }) => from(groupLogsByBlockNumber(logs))) diff --git a/packages/store-sync/src/blockLogsToStorage.ts b/packages/store-sync/src/blockLogsToStorage.ts index f4af902b71..645db04c3f 100644 --- a/packages/store-sync/src/blockLogsToStorage.ts +++ b/packages/store-sync/src/blockLogsToStorage.ts @@ -36,7 +36,7 @@ export function blockLogsToStorage({ .map((log) => { try { if (log.eventName !== "StoreSetRecord") return; - if (log.args.table !== schemasTableId) return; + if (log.args.tableId !== schemasTableId) return; // TODO: refactor encode/decode to use Record schemas // TODO: refactor to decode key with protocol-parser utils @@ -87,8 +87,8 @@ export function blockLogsToStorage({ block.logs.map((log) => JSON.stringify({ address: getAddress(log.address), - tableId: log.args.table, - ...hexToTableId(log.args.table), + tableId: log.args.tableId, + ...hexToTableId(log.args.tableId), }) ) ) @@ -106,9 +106,9 @@ export function blockLogsToStorage({ const operations = block.logs .map((log): StorageOperation | undefined => { try { - const table = tables[`${getAddress(log.address)}:${log.args.table}`]; + const table = tables[`${getAddress(log.address)}:${log.args.tableId}`]; if (!table) { - debug("no table found for event, skipping", hexToTableId(log.args.table), log); + debug("no table found for event, skipping", hexToTableId(log.args.tableId), log); return; } diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 06772c450b..b0519b048d 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -626,13 +626,13 @@ { "file": "test/StoreCoreGas.t.sol", "test": "testHasFieldLayout", - "name": "Check for existence of table (existent)", + "name": "Check for existence of tableId (existent)", "gasUsed": 4465 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHasFieldLayout", - "name": "check for existence of table (non-existent)", + "name": "check for existence of tableId (non-existent)", "gasUsed": 6468 }, { @@ -644,19 +644,19 @@ { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", - "name": "set record on table with subscriber", + "name": "set record on tableId with subscriber", "gasUsed": 73748 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", - "name": "set static field on table with subscriber", + "name": "set static field on tableId with subscriber", "gasUsed": 25441 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", - "name": "delete record on table with subscriber", + "name": "delete record on tableId with subscriber", "gasUsed": 21483 }, { @@ -668,20 +668,20 @@ { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", - "name": "set (dynamic) record on table with subscriber", + "name": "set (dynamic) record on tableId with subscriber", "gasUsed": 167808 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", - "name": "set (dynamic) field on table with subscriber", + "name": "set (dynamic) field on tableId with subscriber", "gasUsed": 28269 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", - "name": "delete (dynamic) record on table with subscriber", - "gasUsed": 22901 + "name": "delete (dynamic) record on tableId with subscriber", + "gasUsed": 22905 }, { "file": "test/StoreCoreGas.t.sol", @@ -698,7 +698,7 @@ { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", - "name": "StoreCore: register table", + "name": "StoreCore: register tableId", "gasUsed": 620356 }, { diff --git a/packages/store/src/IStore.sol b/packages/store/src/IStore.sol index c2e48c9fb4..86031f0c32 100644 --- a/packages/store/src/IStore.sol +++ b/packages/store/src/IStore.sol @@ -7,22 +7,22 @@ import { Schema } from "./Schema.sol"; import { IStoreHook } from "./IStoreHook.sol"; interface IStoreRead { - function getFieldLayout(bytes32 table) external view returns (FieldLayout fieldLayout); + function getFieldLayout(bytes32 tableId) external view returns (FieldLayout fieldLayout); - function getValueSchema(bytes32 table) external view returns (Schema valueSchema); + function getValueSchema(bytes32 tableId) external view returns (Schema valueSchema); - function getKeySchema(bytes32 table) external view returns (Schema keySchema); + function getKeySchema(bytes32 tableId) external view returns (Schema keySchema); // Get full record (including full array) function getRecord( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, FieldLayout fieldLayout ) external view returns (bytes memory data); // Get partial data at schema index function getField( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, FieldLayout fieldLayout @@ -30,7 +30,7 @@ interface IStoreRead { // Get field length at schema index function getFieldLength( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, FieldLayout fieldLayout @@ -38,7 +38,7 @@ interface IStoreRead { // Get start:end slice of the field at schema index function getFieldSlice( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, FieldLayout fieldLayout, @@ -48,16 +48,16 @@ interface IStoreRead { } interface IStoreWrite { - event StoreSetRecord(bytes32 table, bytes32[] key, bytes data); - event StoreSetField(bytes32 table, bytes32[] key, uint8 schemaIndex, bytes data); - event StoreDeleteRecord(bytes32 table, bytes32[] key); + event StoreSetRecord(bytes32 tableId, bytes32[] key, bytes data); + event StoreSetField(bytes32 tableId, bytes32[] key, uint8 schemaIndex, bytes data); + event StoreDeleteRecord(bytes32 tableId, bytes32[] key); // Set full record (including full dynamic data) - function setRecord(bytes32 table, bytes32[] calldata key, bytes calldata data, FieldLayout fieldLayout) external; + function setRecord(bytes32 tableId, bytes32[] calldata key, bytes calldata data, FieldLayout fieldLayout) external; // Set partial data at schema index function setField( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, bytes calldata data, @@ -66,7 +66,7 @@ interface IStoreWrite { // Push encoded items to the dynamic field at schema index function pushToField( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, bytes calldata dataToPush, @@ -75,7 +75,7 @@ interface IStoreWrite { // Pop byte length from the dynamic field at schema index function popFromField( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, uint256 byteLengthToPop, @@ -84,7 +84,7 @@ interface IStoreWrite { // Change encoded items within the dynamic field at schema index function updateInField( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, uint256 startByteIndex, @@ -93,15 +93,15 @@ interface IStoreWrite { ) external; // Set full record (including full dynamic data) - function deleteRecord(bytes32 table, bytes32[] memory key, FieldLayout fieldLayout) external; + function deleteRecord(bytes32 tableId, bytes32[] memory key, FieldLayout fieldLayout) external; } interface IStoreEphemeral { - event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data); + event StoreEphemeralRecord(bytes32 tableId, bytes32[] key, bytes data); // Emit the ephemeral event without modifying storage function emitEphemeralRecord( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, bytes calldata data, FieldLayout fieldLayout @@ -124,7 +124,7 @@ interface IStoreData is IStoreRead, IStoreWrite { */ interface IStoreRegistration { function registerTable( - bytes32 table, + bytes32 tableId, FieldLayout fieldLayout, Schema keySchema, Schema valueSchema, @@ -133,10 +133,10 @@ interface IStoreRegistration { ) external; // Register hook to be called when a record or field is set or deleted - function registerStoreHook(bytes32 table, IStoreHook hookAddress, uint8 enabledHooksBitmap) external; + function registerStoreHook(bytes32 tableId, IStoreHook hookAddress, uint8 enabledHooksBitmap) external; // Unregister a hook for the given tableId - function unregisterStoreHook(bytes32 table, IStoreHook hookAddress) external; + function unregisterStoreHook(bytes32 tableId, IStoreHook hookAddress) external; } interface IStore is IStoreData, IStoreRegistration, IStoreEphemeral, IStoreErrors {} diff --git a/packages/store/src/IStoreHook.sol b/packages/store/src/IStoreHook.sol index ec967976c5..dd75547967 100644 --- a/packages/store/src/IStoreHook.sol +++ b/packages/store/src/IStoreHook.sol @@ -14,12 +14,17 @@ bytes4 constant STORE_HOOK_INTERFACE_ID = IStoreHook.onBeforeSetRecord.selector ERC165_INTERFACE_ID; interface IStoreHook is IERC165 { - function onBeforeSetRecord(bytes32 table, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) external; + function onBeforeSetRecord( + bytes32 tableId, + bytes32[] memory key, + bytes memory data, + FieldLayout fieldLayout + ) external; - function onAfterSetRecord(bytes32 table, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) external; + function onAfterSetRecord(bytes32 tableId, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) external; function onBeforeSetField( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, bytes memory data, @@ -27,14 +32,14 @@ interface IStoreHook is IERC165 { ) external; function onAfterSetField( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, bytes memory data, FieldLayout fieldLayout ) external; - function onBeforeDeleteRecord(bytes32 table, bytes32[] memory key, FieldLayout fieldLayout) external; + function onBeforeDeleteRecord(bytes32 tableId, bytes32[] memory key, FieldLayout fieldLayout) external; - function onAfterDeleteRecord(bytes32 table, bytes32[] memory key, FieldLayout fieldLayout) external; + function onAfterDeleteRecord(bytes32 tableId, bytes32[] memory key, FieldLayout fieldLayout) external; } diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index a9f2540143..112ab25a0f 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -17,10 +17,10 @@ import { StoreHookLib, StoreHookType } from "./StoreHook.sol"; library StoreCore { // note: the preimage of the tuple of keys used to index is part of the event, so it can be used by indexers - event StoreSetRecord(bytes32 table, bytes32[] key, bytes data); - event StoreSetField(bytes32 table, bytes32[] key, uint8 fieldIndex, bytes data); - event StoreDeleteRecord(bytes32 table, bytes32[] key); - event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data); + event StoreSetRecord(bytes32 tableId, bytes32[] key, bytes data); + event StoreSetField(bytes32 tableId, bytes32[] key, uint8 fieldIndex, bytes data); + event StoreDeleteRecord(bytes32 tableId, bytes32[] key); + event StoreEphemeralRecord(bytes32 tableId, bytes32[] key, bytes data); /** * Intialize the store address to use in StoreSwitch. diff --git a/packages/store/src/StoreRead.sol b/packages/store/src/StoreRead.sol index 425d66aee0..a4c35672b9 100644 --- a/packages/store/src/StoreRead.sol +++ b/packages/store/src/StoreRead.sol @@ -7,35 +7,35 @@ import { FieldLayout } from "./FieldLayout.sol"; import { Schema } from "./Schema.sol"; contract StoreRead is IStoreRead { - function getFieldLayout(bytes32 table) public view virtual returns (FieldLayout fieldLayout) { - fieldLayout = StoreCore.getFieldLayout(table); + function getFieldLayout(bytes32 tableId) public view virtual returns (FieldLayout fieldLayout) { + fieldLayout = StoreCore.getFieldLayout(tableId); } - function getValueSchema(bytes32 table) public view virtual returns (Schema valueSchema) { - valueSchema = StoreCore.getValueSchema(table); + function getValueSchema(bytes32 tableId) public view virtual returns (Schema valueSchema) { + valueSchema = StoreCore.getValueSchema(tableId); } - function getKeySchema(bytes32 table) public view virtual returns (Schema keySchema) { - keySchema = StoreCore.getKeySchema(table); + function getKeySchema(bytes32 tableId) public view virtual returns (Schema keySchema) { + keySchema = StoreCore.getKeySchema(tableId); } // Get full record (static and dynamic data) function getRecord( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, FieldLayout fieldLayout ) public view virtual returns (bytes memory data) { - data = StoreCore.getRecord(table, key, fieldLayout); + data = StoreCore.getRecord(tableId, key, fieldLayout); } // Get partial data at schema index function getField( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, FieldLayout fieldLayout ) public view virtual returns (bytes memory data) { - data = StoreCore.getField(table, key, schemaIndex, fieldLayout); + data = StoreCore.getField(tableId, key, schemaIndex, fieldLayout); } function getFieldLength( diff --git a/packages/store/src/StoreSwitch.sol b/packages/store/src/StoreSwitch.sol index 4182568096..86ddb3b22e 100644 --- a/packages/store/src/StoreSwitch.sol +++ b/packages/store/src/StoreSwitch.sol @@ -46,53 +46,53 @@ library StoreSwitch { _layout().storeAddress = _storeAddress; } - function registerStoreHook(bytes32 table, IStoreHook hookAddress, uint8 enabledHooksBitmap) internal { + function registerStoreHook(bytes32 tableId, IStoreHook hookAddress, uint8 enabledHooksBitmap) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.registerStoreHook(table, hookAddress, enabledHooksBitmap); + StoreCore.registerStoreHook(tableId, hookAddress, enabledHooksBitmap); } else { - IStore(_storeAddress).registerStoreHook(table, hookAddress, enabledHooksBitmap); + IStore(_storeAddress).registerStoreHook(tableId, hookAddress, enabledHooksBitmap); } } - function unregisterStoreHook(bytes32 table, IStoreHook hookAddress) internal { + function unregisterStoreHook(bytes32 tableId, IStoreHook hookAddress) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.unregisterStoreHook(table, hookAddress); + StoreCore.unregisterStoreHook(tableId, hookAddress); } else { - IStore(_storeAddress).unregisterStoreHook(table, hookAddress); + IStore(_storeAddress).unregisterStoreHook(tableId, hookAddress); } } - function getFieldLayout(bytes32 table) internal view returns (FieldLayout fieldLayout) { + function getFieldLayout(bytes32 tableId) internal view returns (FieldLayout fieldLayout) { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - fieldLayout = StoreCore.getFieldLayout(table); + fieldLayout = StoreCore.getFieldLayout(tableId); } else { - fieldLayout = IStore(_storeAddress).getFieldLayout(table); + fieldLayout = IStore(_storeAddress).getFieldLayout(tableId); } } - function getValueSchema(bytes32 table) internal view returns (Schema valueSchema) { + function getValueSchema(bytes32 tableId) internal view returns (Schema valueSchema) { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - valueSchema = StoreCore.getValueSchema(table); + valueSchema = StoreCore.getValueSchema(tableId); } else { - valueSchema = IStore(_storeAddress).getValueSchema(table); + valueSchema = IStore(_storeAddress).getValueSchema(tableId); } } - function getKeySchema(bytes32 table) internal view returns (Schema keySchema) { + function getKeySchema(bytes32 tableId) internal view returns (Schema keySchema) { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - keySchema = StoreCore.getKeySchema(table); + keySchema = StoreCore.getKeySchema(tableId); } else { - keySchema = IStore(_storeAddress).getKeySchema(table); + keySchema = IStore(_storeAddress).getKeySchema(tableId); } } function registerTable( - bytes32 table, + bytes32 tableId, FieldLayout fieldLayout, Schema keySchema, Schema valueSchema, @@ -101,23 +101,23 @@ library StoreSwitch { ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.registerTable(table, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); + StoreCore.registerTable(tableId, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); } else { - IStore(_storeAddress).registerTable(table, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); + IStore(_storeAddress).registerTable(tableId, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); } } - function setRecord(bytes32 table, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) internal { + function setRecord(bytes32 tableId, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.setRecord(table, key, data, fieldLayout); + StoreCore.setRecord(tableId, key, data, fieldLayout); } else { - IStore(_storeAddress).setRecord(table, key, data, fieldLayout); + IStore(_storeAddress).setRecord(tableId, key, data, fieldLayout); } } function setField( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 fieldIndex, bytes memory data, @@ -125,14 +125,14 @@ library StoreSwitch { ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.setField(table, key, fieldIndex, data, fieldLayout); + StoreCore.setField(tableId, key, fieldIndex, data, fieldLayout); } else { - IStore(_storeAddress).setField(table, key, fieldIndex, data, fieldLayout); + IStore(_storeAddress).setField(tableId, key, fieldIndex, data, fieldLayout); } } function pushToField( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 fieldIndex, bytes memory dataToPush, @@ -140,14 +140,14 @@ library StoreSwitch { ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.pushToField(table, key, fieldIndex, dataToPush, fieldLayout); + StoreCore.pushToField(tableId, key, fieldIndex, dataToPush, fieldLayout); } else { - IStore(_storeAddress).pushToField(table, key, fieldIndex, dataToPush, fieldLayout); + IStore(_storeAddress).pushToField(tableId, key, fieldIndex, dataToPush, fieldLayout); } } function popFromField( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 fieldIndex, uint256 byteLengthToPop, @@ -155,14 +155,14 @@ library StoreSwitch { ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.popFromField(table, key, fieldIndex, byteLengthToPop, fieldLayout); + StoreCore.popFromField(tableId, key, fieldIndex, byteLengthToPop, fieldLayout); } else { - IStore(_storeAddress).popFromField(table, key, fieldIndex, byteLengthToPop, fieldLayout); + IStore(_storeAddress).popFromField(tableId, key, fieldIndex, byteLengthToPop, fieldLayout); } } function updateInField( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 fieldIndex, uint256 startByteIndex, @@ -171,78 +171,78 @@ library StoreSwitch { ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.updateInField(table, key, fieldIndex, startByteIndex, dataToSet, fieldLayout); + StoreCore.updateInField(tableId, key, fieldIndex, startByteIndex, dataToSet, fieldLayout); } else { - IStore(_storeAddress).updateInField(table, key, fieldIndex, startByteIndex, dataToSet, fieldLayout); + IStore(_storeAddress).updateInField(tableId, key, fieldIndex, startByteIndex, dataToSet, fieldLayout); } } - function deleteRecord(bytes32 table, bytes32[] memory key, FieldLayout fieldLayout) internal { + function deleteRecord(bytes32 tableId, bytes32[] memory key, FieldLayout fieldLayout) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.deleteRecord(table, key, fieldLayout); + StoreCore.deleteRecord(tableId, key, fieldLayout); } else { - IStore(_storeAddress).deleteRecord(table, key, fieldLayout); + IStore(_storeAddress).deleteRecord(tableId, key, fieldLayout); } } function emitEphemeralRecord( - bytes32 table, + bytes32 tableId, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout ) internal { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - StoreCore.emitEphemeralRecord(table, key, data, fieldLayout); + StoreCore.emitEphemeralRecord(tableId, key, data, fieldLayout); } else { - IStore(_storeAddress).emitEphemeralRecord(table, key, data, fieldLayout); + IStore(_storeAddress).emitEphemeralRecord(tableId, key, data, fieldLayout); } } function getRecord( - bytes32 table, + bytes32 tableId, bytes32[] memory key, FieldLayout fieldLayout ) internal view returns (bytes memory) { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - return StoreCore.getRecord(table, key, fieldLayout); + return StoreCore.getRecord(tableId, key, fieldLayout); } else { - return IStore(_storeAddress).getRecord(table, key, fieldLayout); + return IStore(_storeAddress).getRecord(tableId, key, fieldLayout); } } function getField( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 fieldIndex, FieldLayout fieldLayout ) internal view returns (bytes memory) { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - return StoreCore.getField(table, key, fieldIndex, fieldLayout); + return StoreCore.getField(tableId, key, fieldIndex, fieldLayout); } else { - return IStore(_storeAddress).getField(table, key, fieldIndex, fieldLayout); + return IStore(_storeAddress).getField(tableId, key, fieldIndex, fieldLayout); } } function getFieldLength( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 fieldIndex, FieldLayout fieldLayout ) internal view returns (uint256) { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - return StoreCore.getFieldLength(table, key, fieldIndex, fieldLayout); + return StoreCore.getFieldLength(tableId, key, fieldIndex, fieldLayout); } else { - return IStore(_storeAddress).getFieldLength(table, key, fieldIndex, fieldLayout); + return IStore(_storeAddress).getFieldLength(tableId, key, fieldIndex, fieldLayout); } } function getFieldSlice( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 fieldIndex, FieldLayout fieldLayout, @@ -251,9 +251,9 @@ library StoreSwitch { ) internal view returns (bytes memory) { address _storeAddress = getStoreAddress(); if (_storeAddress == address(this)) { - return StoreCore.getFieldSlice(table, key, fieldIndex, fieldLayout, start, end); + return StoreCore.getFieldSlice(tableId, key, fieldIndex, fieldLayout, start, end); } else { - return IStore(_storeAddress).getFieldSlice(table, key, fieldIndex, fieldLayout, start, end); + return IStore(_storeAddress).getFieldSlice(tableId, key, fieldIndex, fieldLayout, start, end); } } } diff --git a/packages/store/test/EchoSubscriber.sol b/packages/store/test/EchoSubscriber.sol index b93fef9aa9..b9e23c6b41 100644 --- a/packages/store/test/EchoSubscriber.sol +++ b/packages/store/test/EchoSubscriber.sol @@ -7,39 +7,39 @@ import { StoreHook } from "../src/StoreHook.sol"; contract EchoSubscriber is StoreHook { event HookCalled(bytes); - function onBeforeSetRecord(bytes32 table, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) public { - emit HookCalled(abi.encode(table, key, data, fieldLayout)); + function onBeforeSetRecord(bytes32 tableId, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) public { + emit HookCalled(abi.encode(tableId, key, data, fieldLayout)); } - function onAfterSetRecord(bytes32 table, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) public { - emit HookCalled(abi.encode(table, key, data, fieldLayout)); + function onAfterSetRecord(bytes32 tableId, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) public { + emit HookCalled(abi.encode(tableId, key, data, fieldLayout)); } function onBeforeSetField( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, bytes memory data, FieldLayout fieldLayout ) public { - emit HookCalled(abi.encode(table, key, schemaIndex, data, fieldLayout)); + emit HookCalled(abi.encode(tableId, key, schemaIndex, data, fieldLayout)); } function onAfterSetField( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, bytes memory data, FieldLayout fieldLayout ) public { - emit HookCalled(abi.encode(table, key, schemaIndex, data, fieldLayout)); + emit HookCalled(abi.encode(tableId, key, schemaIndex, data, fieldLayout)); } - function onBeforeDeleteRecord(bytes32 table, bytes32[] memory key, FieldLayout fieldLayout) public { - emit HookCalled(abi.encode(table, key, fieldLayout)); + function onBeforeDeleteRecord(bytes32 tableId, bytes32[] memory key, FieldLayout fieldLayout) public { + emit HookCalled(abi.encode(tableId, key, fieldLayout)); } - function onAfterDeleteRecord(bytes32 table, bytes32[] memory key, FieldLayout fieldLayout) public { - emit HookCalled(abi.encode(table, key, fieldLayout)); + function onAfterDeleteRecord(bytes32 tableId, bytes32[] memory key, FieldLayout fieldLayout) public { + emit HookCalled(abi.encode(tableId, key, fieldLayout)); } } diff --git a/packages/store/test/MirrorSubscriber.sol b/packages/store/test/MirrorSubscriber.sol index fe4d1d5c34..d30b615679 100644 --- a/packages/store/test/MirrorSubscriber.sol +++ b/packages/store/test/MirrorSubscriber.sol @@ -7,13 +7,13 @@ import { StoreSwitch } from "../src/StoreSwitch.sol"; import { FieldLayout } from "../src/FieldLayout.sol"; import { Schema } from "../src/Schema.sol"; -bytes32 constant indexerTableId = keccak256("indexer.table"); +bytes32 constant indexerTableId = keccak256("indexer.tableId"); contract MirrorSubscriber is StoreHook { - bytes32 _table; + bytes32 _tableId; constructor( - bytes32 table, + bytes32 tableId, FieldLayout fieldLayout, Schema keySchema, Schema valueSchema, @@ -21,26 +21,26 @@ contract MirrorSubscriber is StoreHook { string[] memory fieldNames ) { IStore(msg.sender).registerTable(indexerTableId, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); - _table = table; + _tableId = tableId; } - function onBeforeSetRecord(bytes32 table, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) public { - if (table != table) revert("invalid table"); + function onBeforeSetRecord(bytes32 tableId, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) public { + if (tableId != tableId) revert("invalid tableId"); StoreSwitch.setRecord(indexerTableId, key, data, fieldLayout); } - function onAfterSetRecord(bytes32 table, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) public { + function onAfterSetRecord(bytes32 tableId, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) public { // NOOP } function onBeforeSetField( - bytes32 table, + bytes32 tableId, bytes32[] memory key, uint8 schemaIndex, bytes memory data, FieldLayout fieldLayout ) public { - if (table != table) revert("invalid table"); + if (tableId != tableId) revert("invalid tableId"); StoreSwitch.setField(indexerTableId, key, schemaIndex, data, fieldLayout); } @@ -48,12 +48,12 @@ contract MirrorSubscriber is StoreHook { // NOOP } - function onBeforeDeleteRecord(bytes32 table, bytes32[] memory key, FieldLayout fieldLayout) public { - if (table != table) revert("invalid table"); + function onBeforeDeleteRecord(bytes32 tableId, bytes32[] memory key, FieldLayout fieldLayout) public { + if (tableId != tableId) revert("invalid tableId"); StoreSwitch.deleteRecord(indexerTableId, key, fieldLayout); } - function onAfterDeleteRecord(bytes32 table, bytes32[] memory key, FieldLayout fieldLayout) public { + function onAfterDeleteRecord(bytes32 tableId, bytes32[] memory key, FieldLayout fieldLayout) public { // NOOP } } diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index f6e37eac36..2737f417f2 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -55,11 +55,11 @@ contract StoreCoreTest is Test, StoreMock { fieldNames[2] = "value3"; fieldNames[3] = "value4"; - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); // Expect a StoreSetRecord event to be emitted bytes32[] memory key = new bytes32[](1); - key[0] = bytes32(table); + key[0] = bytes32(tableId); vm.expectEmit(true, true, true, true); emit StoreSetRecord( TablesTableId, @@ -72,16 +72,16 @@ contract StoreCoreTest is Test, StoreMock { abi.encode(fieldNames) ) ); - IStore(this).registerTable(table, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); + IStore(this).registerTable(tableId, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); - assertEq(IStore(this).getFieldLayout(table).unwrap(), fieldLayout.unwrap()); - assertEq(IStore(this).getValueSchema(table).unwrap(), valueSchema.unwrap()); - assertEq(IStore(this).getKeySchema(table).unwrap(), keySchema.unwrap()); + assertEq(IStore(this).getFieldLayout(tableId).unwrap(), fieldLayout.unwrap()); + assertEq(IStore(this).getValueSchema(tableId).unwrap(), valueSchema.unwrap()); + assertEq(IStore(this).getKeySchema(tableId).unwrap(), keySchema.unwrap()); - bytes memory loadedKeyNames = Tables.getAbiEncodedKeyNames(IStore(this), table); + bytes memory loadedKeyNames = Tables.getAbiEncodedKeyNames(IStore(this), tableId); assertEq(loadedKeyNames, abi.encode(keyNames)); - bytes memory loadedFieldNames = Tables.getAbiEncodedFieldNames(IStore(this), table); + bytes memory loadedFieldNames = Tables.getAbiEncodedFieldNames(IStore(this), tableId); assertEq(loadedFieldNames, abi.encode(fieldNames)); } @@ -89,7 +89,7 @@ contract StoreCoreTest is Test, StoreMock { string[] memory keyNames = new string[](2); string[] memory fieldNames = new string[](4); IStore(this).registerTable( - keccak256("table"), + keccak256("tableId"), FieldLayout.wrap(keccak256("random bytes as value field layout")), Schema.wrap(keccak256("random bytes as key schema")), Schema.wrap(keccak256("random bytes as value schema")), @@ -108,35 +108,47 @@ contract StoreCoreTest is Test, StoreMock { SchemaType.UINT8, SchemaType.UINT16 ); - bytes32 table = keccak256("some.table"); - bytes32 table2 = keccak256("other.table"); - IStore(this).registerTable(table, fieldLayout, defaultKeySchema, valueSchema, keyNames, fieldNames); + bytes32 tableId = keccak256("some.tableId"); + bytes32 tableId2 = keccak256("other.tableId"); + IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, keyNames, fieldNames); - assertTrue(StoreCore.hasTable(table)); - assertFalse(StoreCore.hasTable(table2)); + assertTrue(StoreCore.hasTable(tableId)); + assertFalse(StoreCore.hasTable(tableId2)); - IStore(this).getFieldLayout(table); - IStore(this).getValueSchema(table); - IStore(this).getKeySchema(table); + IStore(this).getFieldLayout(tableId); + IStore(this).getValueSchema(tableId); + IStore(this).getKeySchema(tableId); vm.expectRevert( - abi.encodeWithSelector(IStoreErrors.StoreCore_TableNotFound.selector, table2, string(abi.encodePacked(table2))) + abi.encodeWithSelector( + IStoreErrors.StoreCore_TableNotFound.selector, + tableId2, + string(abi.encodePacked(tableId2)) + ) ); - IStore(this).getFieldLayout(table2); + IStore(this).getFieldLayout(tableId2); vm.expectRevert( - abi.encodeWithSelector(IStoreErrors.StoreCore_TableNotFound.selector, table2, string(abi.encodePacked(table2))) + abi.encodeWithSelector( + IStoreErrors.StoreCore_TableNotFound.selector, + tableId2, + string(abi.encodePacked(tableId2)) + ) ); - IStore(this).getValueSchema(table2); + IStore(this).getValueSchema(tableId2); vm.expectRevert( - abi.encodeWithSelector(IStoreErrors.StoreCore_TableNotFound.selector, table2, string(abi.encodePacked(table2))) + abi.encodeWithSelector( + IStoreErrors.StoreCore_TableNotFound.selector, + tableId2, + string(abi.encodePacked(tableId2)) + ) ); - IStore(this).getKeySchema(table2); + IStore(this).getKeySchema(tableId2); } function testRegisterTableRevertNames() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(1, 0); Schema keySchema = SchemaEncodeHelper.encode( SchemaType.UINT8, @@ -148,17 +160,17 @@ contract StoreCoreTest is Test, StoreMock { string[] memory fourNames = new string[](4); string[] memory oneName = new string[](1); - // Register table with invalid key names + // Register tableId with invalid key names vm.expectRevert(abi.encodeWithSelector(IStoreErrors.StoreCore_InvalidKeyNamesLength.selector, 4, 1)); - IStore(this).registerTable(table, fieldLayout, keySchema, valueSchema, oneName, oneName); + IStore(this).registerTable(tableId, fieldLayout, keySchema, valueSchema, oneName, oneName); - // Register table with invalid value names + // Register tableId with invalid value names vm.expectRevert(abi.encodeWithSelector(IStoreErrors.StoreCore_InvalidFieldNamesLength.selector, 1, 4)); - IStore(this).registerTable(table, fieldLayout, keySchema, valueSchema, fourNames, fourNames); + IStore(this).registerTable(tableId, fieldLayout, keySchema, valueSchema, fourNames, fourNames); } function testSetAndGetDynamicDataLength() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(1, 2, 4, 2); Schema valueSchema = SchemaEncodeHelper.encode( @@ -169,40 +181,40 @@ contract StoreCoreTest is Test, StoreMock { SchemaType.UINT32_ARRAY ); - // Register table - IStore(this).registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](5)); + // Register tableId + IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](5)); // Create some key bytes32[] memory key = new bytes32[](1); key[0] = bytes32("some key"); // Set dynamic data length of dynamic index 0 - StoreCoreInternal._setDynamicDataLengthAtIndex(table, key, 0, 10); + StoreCoreInternal._setDynamicDataLengthAtIndex(tableId, key, 0, 10); - PackedCounter encodedLength = StoreCoreInternal._loadEncodedDynamicDataLength(table, key); + PackedCounter encodedLength = StoreCoreInternal._loadEncodedDynamicDataLength(tableId, key); assertEq(encodedLength.atIndex(0), 10); assertEq(encodedLength.atIndex(1), 0); assertEq(encodedLength.total(), 10); // Set dynamic data length of dynamic index 1 - StoreCoreInternal._setDynamicDataLengthAtIndex(table, key, 1, 99); + StoreCoreInternal._setDynamicDataLengthAtIndex(tableId, key, 1, 99); - encodedLength = StoreCoreInternal._loadEncodedDynamicDataLength(table, key); + encodedLength = StoreCoreInternal._loadEncodedDynamicDataLength(tableId, key); assertEq(encodedLength.atIndex(0), 10); assertEq(encodedLength.atIndex(1), 99); assertEq(encodedLength.total(), 109); // Reduce dynamic data length of dynamic index 0 again - StoreCoreInternal._setDynamicDataLengthAtIndex(table, key, 0, 5); + StoreCoreInternal._setDynamicDataLengthAtIndex(tableId, key, 0, 5); - encodedLength = StoreCoreInternal._loadEncodedDynamicDataLength(table, key); + encodedLength = StoreCoreInternal._loadEncodedDynamicDataLength(tableId, key); assertEq(encodedLength.atIndex(0), 5); assertEq(encodedLength.atIndex(1), 99); assertEq(encodedLength.total(), 104); } function testSetAndGetStaticData() public { - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(1, 2, 1, 2, 0); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT8, @@ -211,8 +223,8 @@ contract StoreCoreTest is Test, StoreMock { SchemaType.UINT16 ); - bytes32 table = keccak256("some.table"); - IStore(this).registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); + bytes32 tableId = keccak256("some.tableId"); + IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); // Set data bytes memory data = abi.encodePacked(bytes1(0x01), bytes2(0x0203), bytes1(0x04), bytes2(0x0506)); @@ -222,18 +234,18 @@ contract StoreCoreTest is Test, StoreMock { // Expect a StoreSetRecord event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetRecord(table, key, data); + emit StoreSetRecord(tableId, key, data); - IStore(this).setRecord(table, key, data, fieldLayout); + IStore(this).setRecord(tableId, key, data, fieldLayout); // Get data - bytes memory loadedData = IStore(this).getRecord(table, key, fieldLayout); + bytes memory loadedData = IStore(this).getRecord(tableId, key, fieldLayout); assertTrue(Bytes.equals(data, loadedData)); } function testFailSetAndGetStaticData() public { - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(1, 2, 1, 2, 0); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT8, @@ -241,8 +253,8 @@ contract StoreCoreTest is Test, StoreMock { SchemaType.UINT8, SchemaType.UINT16 ); - bytes32 table = keccak256("some.table"); - IStore(this).registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); + bytes32 tableId = keccak256("some.tableId"); + IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); // Set data bytes memory data = abi.encodePacked(bytes1(0x01), bytes2(0x0203), bytes1(0x04)); @@ -251,15 +263,15 @@ contract StoreCoreTest is Test, StoreMock { key[0] = keccak256("some.key"); // This should fail because the data is not 6 bytes long - IStore(this).setRecord(table, key, data, fieldLayout); + IStore(this).setRecord(tableId, key, data, fieldLayout); } function testSetAndGetStaticDataSpanningWords() public { - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 32, 0); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT256); - bytes32 table = keccak256("some.table"); - IStore(this).registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); + bytes32 tableId = keccak256("some.tableId"); + IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); // Set data bytes memory data = abi.encodePacked( @@ -272,27 +284,27 @@ contract StoreCoreTest is Test, StoreMock { // Expect a StoreSetRecord event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetRecord(table, key, data); + emit StoreSetRecord(tableId, key, data); - IStore(this).setRecord(table, key, data, fieldLayout); + IStore(this).setRecord(tableId, key, data, fieldLayout); // Get data - bytes memory loadedData = IStore(this).getRecord(table, key, fieldLayout); + bytes memory loadedData = IStore(this).getRecord(tableId, key, fieldLayout); assertTrue(Bytes.equals(data, loadedData)); } function testSetAndGetDynamicData() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY ); - IStore(this).registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); + IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); bytes16 firstDataBytes = bytes16(0x0102030405060708090a0b0c0d0e0f10); @@ -332,13 +344,13 @@ contract StoreCoreTest is Test, StoreMock { // Expect a StoreSetRecord event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetRecord(table, key, data); + emit StoreSetRecord(tableId, key, data); // Set data - IStore(this).setRecord(table, key, data, fieldLayout); + IStore(this).setRecord(tableId, key, data, fieldLayout); // Get data - bytes memory loadedData = IStore(this).getRecord(table, key, fieldLayout); + bytes memory loadedData = IStore(this).getRecord(tableId, key, fieldLayout); assertEq(loadedData.length, data.length); assertEq(keccak256(loadedData), keccak256(data)); @@ -358,9 +370,9 @@ contract StoreCoreTest is Test, StoreMock { } function testSetAndGetField() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, @@ -368,7 +380,7 @@ contract StoreCoreTest is Test, StoreMock { SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY ); - IStore(this).registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); + IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); bytes16 firstDataBytes = bytes16(0x0102030405060708090a0b0c0d0e0f10); @@ -380,24 +392,24 @@ contract StoreCoreTest is Test, StoreMock { // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetField(table, key, 0, firstDataPacked); + emit StoreSetField(tableId, key, 0, firstDataPacked); // Set first field - IStore(this).setField(table, key, 0, firstDataPacked, fieldLayout); + IStore(this).setField(tableId, key, 0, firstDataPacked, fieldLayout); //////////////// // Static data //////////////// // Get first field - bytes memory loadedData = IStore(this).getField(table, key, 0, fieldLayout); + bytes memory loadedData = IStore(this).getField(tableId, key, 0, fieldLayout); // Verify loaded data is correct assertEq(loadedData.length, 16); assertEq(bytes16(loadedData), bytes16(firstDataBytes)); // Verify the second index is not set yet - assertEq(uint256(bytes32(IStore(this).getField(table, key, 1, fieldLayout))), 0); + assertEq(uint256(bytes32(IStore(this).getField(tableId, key, 1, fieldLayout))), 0); // Set second field bytes32 secondDataBytes = keccak256("some data"); @@ -406,27 +418,27 @@ contract StoreCoreTest is Test, StoreMock { // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetField(table, key, 1, secondDataPacked); + emit StoreSetField(tableId, key, 1, secondDataPacked); - IStore(this).setField(table, key, 1, secondDataPacked, fieldLayout); + IStore(this).setField(tableId, key, 1, secondDataPacked, fieldLayout); // Get second field - loadedData = IStore(this).getField(table, key, 1, fieldLayout); + loadedData = IStore(this).getField(tableId, key, 1, fieldLayout); // Verify loaded data is correct assertEq(loadedData.length, 32); assertEq(bytes32(loadedData), secondDataBytes); // Verify the first field didn't change - assertEq(bytes16(IStore(this).getField(table, key, 0, fieldLayout)), bytes16(firstDataBytes)); + assertEq(bytes16(IStore(this).getField(tableId, key, 0, fieldLayout)), bytes16(firstDataBytes)); // Verify the full static data is correct - assertEq(IStore(this).getFieldLayout(table).staticDataLength(), 48); - assertEq(IStore(this).getValueSchema(table).staticDataLength(), 48); - assertEq(Bytes.slice16(IStore(this).getRecord(table, key, fieldLayout), 0), firstDataBytes); - assertEq(Bytes.slice32(IStore(this).getRecord(table, key, fieldLayout), 16), secondDataBytes); + assertEq(IStore(this).getFieldLayout(tableId).staticDataLength(), 48); + assertEq(IStore(this).getValueSchema(tableId).staticDataLength(), 48); + assertEq(Bytes.slice16(IStore(this).getRecord(tableId, key, fieldLayout), 0), firstDataBytes); + assertEq(Bytes.slice32(IStore(this).getRecord(tableId, key, fieldLayout), 16), secondDataBytes); assertEq( - keccak256(SliceLib.getSubslice(IStore(this).getRecord(table, key, fieldLayout), 0, 48).toBytes()), + keccak256(SliceLib.getSubslice(IStore(this).getRecord(tableId, key, fieldLayout), 0, 48).toBytes()), keccak256(abi.encodePacked(firstDataBytes, secondDataBytes)) ); @@ -453,13 +465,13 @@ contract StoreCoreTest is Test, StoreMock { // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetField(table, key, 2, thirdDataBytes); + emit StoreSetField(tableId, key, 2, thirdDataBytes); // Set third field - IStore(this).setField(table, key, 2, thirdDataBytes, fieldLayout); + IStore(this).setField(tableId, key, 2, thirdDataBytes, fieldLayout); // Get third field - loadedData = IStore(this).getField(table, key, 2, fieldLayout); + loadedData = IStore(this).getField(tableId, key, 2, fieldLayout); // Verify loaded data is correct assertEq(SliceLib.fromBytes(loadedData).decodeArray_uint32().length, 2); @@ -467,21 +479,21 @@ contract StoreCoreTest is Test, StoreMock { assertEq(keccak256(loadedData), keccak256(thirdDataBytes)); // Verify the fourth field is not set yet - assertEq(IStore(this).getField(table, key, 3, fieldLayout).length, 0); + assertEq(IStore(this).getField(tableId, key, 3, fieldLayout).length, 0); // Verify none of the previous fields were impacted - assertEq(bytes16(IStore(this).getField(table, key, 0, fieldLayout)), bytes16(firstDataBytes)); - assertEq(bytes32(IStore(this).getField(table, key, 1, fieldLayout)), bytes32(secondDataBytes)); + assertEq(bytes16(IStore(this).getField(tableId, key, 0, fieldLayout)), bytes16(firstDataBytes)); + assertEq(bytes32(IStore(this).getField(tableId, key, 1, fieldLayout)), bytes32(secondDataBytes)); // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetField(table, key, 3, fourthDataBytes); + emit StoreSetField(tableId, key, 3, fourthDataBytes); // Set fourth field - IStore(this).setField(table, key, 3, fourthDataBytes, fieldLayout); + IStore(this).setField(tableId, key, 3, fourthDataBytes, fieldLayout); // Get fourth field - loadedData = IStore(this).getField(table, key, 3, fieldLayout); + loadedData = IStore(this).getField(tableId, key, 3, fieldLayout); // Verify loaded data is correct assertEq(loadedData.length, fourthDataBytes.length); @@ -490,7 +502,7 @@ contract StoreCoreTest is Test, StoreMock { // Verify all fields are correct PackedCounter encodedLengths = PackedCounterLib.pack(uint40(thirdDataBytes.length), uint40(fourthDataBytes.length)); assertEq( - keccak256(IStore(this).getRecord(table, key, fieldLayout)), + keccak256(IStore(this).getRecord(tableId, key, fieldLayout)), keccak256( abi.encodePacked(firstDataBytes, secondDataBytes, encodedLengths.unwrap(), thirdDataBytes, fourthDataBytes) ) @@ -498,16 +510,16 @@ contract StoreCoreTest is Test, StoreMock { } function testDeleteData() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY ); - IStore(this).registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); + IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); bytes16 firstDataBytes = bytes16(0x0102030405060708090a0b0c0d0e0f10); @@ -546,28 +558,28 @@ contract StoreCoreTest is Test, StoreMock { key[0] = bytes32("some.key"); // Set data - IStore(this).setRecord(table, key, data, fieldLayout); + IStore(this).setRecord(tableId, key, data, fieldLayout); // Get data - bytes memory loadedData = IStore(this).getRecord(table, key, fieldLayout); + bytes memory loadedData = IStore(this).getRecord(tableId, key, fieldLayout); assertEq(loadedData.length, data.length); assertEq(keccak256(loadedData), keccak256(data)); // Expect a StoreDeleteRecord event to be emitted vm.expectEmit(true, true, true, true); - emit StoreDeleteRecord(table, key); + emit StoreDeleteRecord(tableId, key); // Delete data - IStore(this).deleteRecord(table, key, fieldLayout); + IStore(this).deleteRecord(tableId, key, fieldLayout); // Verify data is deleted - loadedData = IStore(this).getRecord(table, key, fieldLayout); + loadedData = IStore(this).getRecord(tableId, key, fieldLayout); assertEq(keccak256(loadedData), keccak256(new bytes(fieldLayout.staticDataLength()))); } struct TestPushToFieldData { - bytes32 table; + bytes32 tableId; bytes32[] key; bytes32 firstDataBytes; bytes secondDataBytes; @@ -582,9 +594,9 @@ contract StoreCoreTest is Test, StoreMock { function testPushToField() public { TestPushToFieldData memory data = TestPushToFieldData(0, new bytes32[](0), 0, "", "", "", "", "", "", ""); - data.table = keccak256("some.table"); + data.tableId = keccak256("some.tableId"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT256, @@ -592,7 +604,7 @@ contract StoreCoreTest is Test, StoreMock { SchemaType.UINT32_ARRAY ); IStore(this).registerTable( - data.table, + data.tableId, fieldLayout, defaultKeySchema, valueSchema, @@ -622,10 +634,10 @@ contract StoreCoreTest is Test, StoreMock { } // Set fields - IStore(this).setField(data.table, data.key, 0, abi.encodePacked(data.firstDataBytes), fieldLayout); - IStore(this).setField(data.table, data.key, 1, data.secondDataBytes, fieldLayout); + IStore(this).setField(data.tableId, data.key, 0, abi.encodePacked(data.firstDataBytes), fieldLayout); + IStore(this).setField(data.tableId, data.key, 1, data.secondDataBytes, fieldLayout); // Initialize a field with push - IStore(this).pushToField(data.table, data.key, 2, data.thirdDataBytes, fieldLayout); + IStore(this).pushToField(data.tableId, data.key, 2, data.thirdDataBytes, fieldLayout); // Create data to push { @@ -637,13 +649,13 @@ contract StoreCoreTest is Test, StoreMock { // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetField(data.table, data.key, 1, data.newSecondDataBytes); + emit StoreSetField(data.tableId, data.key, 1, data.newSecondDataBytes); // Push to second field - IStore(this).pushToField(data.table, data.key, 1, data.secondDataToPush, fieldLayout); + IStore(this).pushToField(data.tableId, data.key, 1, data.secondDataToPush, fieldLayout); // Get second field - data.loadedData = IStore(this).getField(data.table, data.key, 1, fieldLayout); + data.loadedData = IStore(this).getField(data.tableId, data.key, 1, fieldLayout); // Verify loaded data is correct assertEq(SliceLib.fromBytes(data.loadedData).decodeArray_uint32().length, 2 + 1); @@ -651,8 +663,8 @@ contract StoreCoreTest is Test, StoreMock { assertEq(data.loadedData, data.newSecondDataBytes); // Verify none of the other fields were impacted - assertEq(bytes32(IStore(this).getField(data.table, data.key, 0, fieldLayout)), data.firstDataBytes); - assertEq(IStore(this).getField(data.table, data.key, 2, fieldLayout), data.thirdDataBytes); + assertEq(bytes32(IStore(this).getField(data.tableId, data.key, 0, fieldLayout)), data.firstDataBytes); + assertEq(IStore(this).getField(data.tableId, data.key, 2, fieldLayout), data.thirdDataBytes); // Create data to push { @@ -673,13 +685,13 @@ contract StoreCoreTest is Test, StoreMock { // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetField(data.table, data.key, 2, data.newThirdDataBytes); + emit StoreSetField(data.tableId, data.key, 2, data.newThirdDataBytes); // Push to third field - IStore(this).pushToField(data.table, data.key, 2, data.thirdDataToPush, fieldLayout); + IStore(this).pushToField(data.tableId, data.key, 2, data.thirdDataToPush, fieldLayout); // Get third field - data.loadedData = IStore(this).getField(data.table, data.key, 2, fieldLayout); + data.loadedData = IStore(this).getField(data.tableId, data.key, 2, fieldLayout); // Verify loaded data is correct assertEq(SliceLib.fromBytes(data.loadedData).decodeArray_uint32().length, 3 + 10); @@ -687,12 +699,12 @@ contract StoreCoreTest is Test, StoreMock { assertEq(data.loadedData, data.newThirdDataBytes); // Verify none of the other fields were impacted - assertEq(bytes32(IStore(this).getField(data.table, data.key, 0, fieldLayout)), data.firstDataBytes); - assertEq(IStore(this).getField(data.table, data.key, 1, fieldLayout), data.newSecondDataBytes); + assertEq(bytes32(IStore(this).getField(data.tableId, data.key, 0, fieldLayout)), data.firstDataBytes); + assertEq(IStore(this).getField(data.tableId, data.key, 1, fieldLayout), data.newSecondDataBytes); } struct TestUpdateInFieldData { - bytes32 table; + bytes32 tableId; bytes32[] key; bytes32 firstDataBytes; uint32[] secondData; @@ -722,9 +734,9 @@ contract StoreCoreTest is Test, StoreMock { "" ); - data.table = keccak256("some.table"); + data.tableId = keccak256("some.tableId"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT256, @@ -732,7 +744,7 @@ contract StoreCoreTest is Test, StoreMock { SchemaType.UINT64_ARRAY ); IStore(this).registerTable( - data.table, + data.tableId, fieldLayout, defaultKeySchema, valueSchema, @@ -761,9 +773,9 @@ contract StoreCoreTest is Test, StoreMock { data.thirdDataBytes = EncodeArray.encode(data.thirdData); // Set fields - IStore(this).setField(data.table, data.key, 0, abi.encodePacked(data.firstDataBytes), fieldLayout); - IStore(this).setField(data.table, data.key, 1, data.secondDataBytes, fieldLayout); - IStore(this).setField(data.table, data.key, 2, data.thirdDataBytes, fieldLayout); + IStore(this).setField(data.tableId, data.key, 0, abi.encodePacked(data.firstDataBytes), fieldLayout); + IStore(this).setField(data.tableId, data.key, 1, data.secondDataBytes, fieldLayout); + IStore(this).setField(data.tableId, data.key, 2, data.thirdDataBytes, fieldLayout); // Create data to use for the update { @@ -776,13 +788,13 @@ contract StoreCoreTest is Test, StoreMock { // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetField(data.table, data.key, 1, data.newSecondDataBytes); + emit StoreSetField(data.tableId, data.key, 1, data.newSecondDataBytes); // Update index 1 in second field (4 = byte length of uint32) - IStore(this).updateInField(data.table, data.key, 1, 4 * 1, data.secondDataForUpdate, fieldLayout); + IStore(this).updateInField(data.tableId, data.key, 1, 4 * 1, data.secondDataForUpdate, fieldLayout); // Get second field - data.loadedData = IStore(this).getField(data.table, data.key, 1, fieldLayout); + data.loadedData = IStore(this).getField(data.tableId, data.key, 1, fieldLayout); // Verify loaded data is correct assertEq(SliceLib.fromBytes(data.loadedData).decodeArray_uint32().length, data.secondData.length); @@ -790,8 +802,8 @@ contract StoreCoreTest is Test, StoreMock { assertEq(data.loadedData, data.newSecondDataBytes); // Verify none of the other fields were impacted - assertEq(bytes32(IStore(this).getField(data.table, data.key, 0, fieldLayout)), data.firstDataBytes); - assertEq(IStore(this).getField(data.table, data.key, 2, fieldLayout), data.thirdDataBytes); + assertEq(bytes32(IStore(this).getField(data.tableId, data.key, 0, fieldLayout)), data.firstDataBytes); + assertEq(IStore(this).getField(data.tableId, data.key, 2, fieldLayout), data.thirdDataBytes); // Create data for update { @@ -814,13 +826,13 @@ contract StoreCoreTest is Test, StoreMock { // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetField(data.table, data.key, 2, data.newThirdDataBytes); + emit StoreSetField(data.tableId, data.key, 2, data.newThirdDataBytes); // Update indexes 1,2,3,4 in third field (8 = byte length of uint64) - IStore(this).updateInField(data.table, data.key, 2, 8 * 1, data.thirdDataForUpdate, fieldLayout); + IStore(this).updateInField(data.tableId, data.key, 2, 8 * 1, data.thirdDataForUpdate, fieldLayout); // Get third field - data.loadedData = IStore(this).getField(data.table, data.key, 2, fieldLayout); + data.loadedData = IStore(this).getField(data.tableId, data.key, 2, fieldLayout); // Verify loaded data is correct assertEq(SliceLib.fromBytes(data.loadedData).decodeArray_uint64().length, data.thirdData.length); @@ -828,56 +840,56 @@ contract StoreCoreTest is Test, StoreMock { assertEq(data.loadedData, data.newThirdDataBytes); // Verify none of the other fields were impacted - assertEq(bytes32(IStore(this).getField(data.table, data.key, 0, fieldLayout)), data.firstDataBytes); - assertEq(IStore(this).getField(data.table, data.key, 1, fieldLayout), data.newSecondDataBytes); + assertEq(bytes32(IStore(this).getField(data.tableId, data.key, 0, fieldLayout)), data.firstDataBytes); + assertEq(IStore(this).getField(data.tableId, data.key, 1, fieldLayout), data.newSecondDataBytes); // startByteIndex must not overflow vm.expectRevert( abi.encodeWithSelector(IStoreErrors.StoreCore_DataIndexOverflow.selector, type(uint40).max, type(uint56).max) ); - IStore(this).updateInField(data.table, data.key, 2, type(uint56).max, data.thirdDataForUpdate, fieldLayout); + IStore(this).updateInField(data.tableId, data.key, 2, type(uint56).max, data.thirdDataForUpdate, fieldLayout); } function testAccessEmptyData() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(4, 1); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT32, SchemaType.UINT32_ARRAY); - IStore(this).registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); + IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); // Create key bytes32[] memory key = new bytes32[](1); key[0] = bytes32("some.key"); - bytes memory data1 = IStore(this).getRecord(table, key, fieldLayout); + bytes memory data1 = IStore(this).getRecord(tableId, key, fieldLayout); assertEq(data1.length, fieldLayout.staticDataLength()); - bytes memory data2 = IStore(this).getField(table, key, 0, fieldLayout); + bytes memory data2 = IStore(this).getField(tableId, key, 0, fieldLayout); assertEq(data2.length, fieldLayout.staticDataLength()); - bytes memory data3 = IStore(this).getField(table, key, 1, fieldLayout); + bytes memory data3 = IStore(this).getField(tableId, key, 1, fieldLayout); assertEq(data3.length, 0); - uint256 data3Length = IStore(this).getFieldLength(table, key, 1, fieldLayout); + uint256 data3Length = IStore(this).getFieldLength(tableId, key, 1, fieldLayout); assertEq(data3Length, 0); - bytes memory data3Slice = IStore(this).getFieldSlice(table, key, 1, fieldLayout, 0, 0); + bytes memory data3Slice = IStore(this).getFieldSlice(tableId, key, 1, fieldLayout, 0, 0); assertEq(data3Slice.length, 0); } function testRegisterHook() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some key"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 0); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128); - IStore(this).registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](1)); + IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](1)); // Create subscriber MirrorSubscriber subscriber = new MirrorSubscriber( - table, + tableId, fieldLayout, defaultKeySchema, valueSchema, @@ -886,7 +898,7 @@ contract StoreCoreTest is Test, StoreMock { ); IStore(this).registerStoreHook( - table, + tableId, subscriber, StoreHookLib.encodeBitmap({ onBeforeSetRecord: true, @@ -900,36 +912,36 @@ contract StoreCoreTest is Test, StoreMock { bytes memory data = abi.encodePacked(bytes16(0x0102030405060708090a0b0c0d0e0f10)); - IStore(this).setRecord(table, key, data, fieldLayout); + IStore(this).setRecord(tableId, key, data, fieldLayout); - // Get data from indexed table - the indexer should have mirrored the data there + // Get data from indexed tableId - the indexer should have mirrored the data there bytes memory indexedData = IStore(this).getRecord(indexerTableId, key, fieldLayout); assertEq(keccak256(data), keccak256(indexedData)); data = abi.encodePacked(bytes16(0x1112131415161718191a1b1c1d1e1f20)); - IStore(this).setField(table, key, 0, data, fieldLayout); + IStore(this).setField(tableId, key, 0, data, fieldLayout); - // Get data from indexed table - the indexer should have mirrored the data there + // Get data from indexed tableId - the indexer should have mirrored the data there indexedData = IStore(this).getRecord(indexerTableId, key, fieldLayout); assertEq(keccak256(data), keccak256(indexedData)); - IStore(this).deleteRecord(table, key, fieldLayout); + IStore(this).deleteRecord(tableId, key, fieldLayout); - // Get data from indexed table - the indexer should have mirrored the data there + // Get data from indexed tableId - the indexer should have mirrored the data there indexedData = IStore(this).getRecord(indexerTableId, key, fieldLayout); assertEq(keccak256(indexedData), keccak256(abi.encodePacked(bytes16(0)))); } function testUnregisterHook() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some key"); - // Register table's value schema + // Register tableId's value schema FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 0); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128); - IStore(this).registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](1)); + IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](1)); // Create a RevertSubscriber and an EchoSubscriber RevertSubscriber revertSubscriber = new RevertSubscriber(); @@ -937,7 +949,7 @@ contract StoreCoreTest is Test, StoreMock { // Register both subscribers IStore(this).registerStoreHook( - table, + tableId, revertSubscriber, StoreHookLib.encodeBitmap({ onBeforeSetRecord: true, @@ -950,7 +962,7 @@ contract StoreCoreTest is Test, StoreMock { ); // Register both subscribers IStore(this).registerStoreHook( - table, + tableId, echoSubscriber, StoreHookLib.encodeBitmap({ onBeforeSetRecord: true, @@ -966,63 +978,63 @@ contract StoreCoreTest is Test, StoreMock { // Expect a revert when the RevertSubscriber's onBeforeSetRecord hook is called vm.expectRevert(bytes("onBeforeSetRecord")); - IStore(this).setRecord(table, key, data, fieldLayout); + IStore(this).setRecord(tableId, key, data, fieldLayout); // Expect a revert when the RevertSubscriber's onBeforeSetField hook is called vm.expectRevert(bytes("onBeforeSetField")); - IStore(this).setField(table, key, 0, data, fieldLayout); + IStore(this).setField(tableId, key, 0, data, fieldLayout); // Expect a revert when the RevertSubscriber's onBeforeDeleteRecord hook is called vm.expectRevert(bytes("onBeforeDeleteRecord")); - IStore(this).deleteRecord(table, key, fieldLayout); + IStore(this).deleteRecord(tableId, key, fieldLayout); // Unregister the RevertSubscriber - IStore(this).unregisterStoreHook(table, revertSubscriber); + IStore(this).unregisterStoreHook(tableId, revertSubscriber); // Expect a HookCalled event to be emitted when the EchoSubscriber's onBeforeSetRecord hook is called vm.expectEmit(true, true, true, true); - emit HookCalled(abi.encode(table, key, data, fieldLayout)); + emit HookCalled(abi.encode(tableId, key, data, fieldLayout)); // Expect a HookCalled event to be emitted when the EchoSubscriber's onAfterSetRecord hook is called vm.expectEmit(true, true, true, true); - emit HookCalled(abi.encode(table, key, data, fieldLayout)); + emit HookCalled(abi.encode(tableId, key, data, fieldLayout)); - IStore(this).setRecord(table, key, data, fieldLayout); + IStore(this).setRecord(tableId, key, data, fieldLayout); // Expect a HookCalled event to be emitted when the EchoSubscriber's onBeforeSetField hook is called vm.expectEmit(true, true, true, true); - emit HookCalled(abi.encode(table, key, uint8(0), data, fieldLayout)); + emit HookCalled(abi.encode(tableId, key, uint8(0), data, fieldLayout)); // Expect a HookCalled event to be emitted when the EchoSubscriber's onAfterSetField hook is called vm.expectEmit(true, true, true, true); - emit HookCalled(abi.encode(table, key, uint8(0), data, fieldLayout)); + emit HookCalled(abi.encode(tableId, key, uint8(0), data, fieldLayout)); - IStore(this).setField(table, key, 0, data, fieldLayout); + IStore(this).setField(tableId, key, 0, data, fieldLayout); // Expect a HookCalled event to be emitted when the EchoSubscriber's onBeforeDeleteRecord hook is called vm.expectEmit(true, true, true, true); - emit HookCalled(abi.encode(table, key, fieldLayout)); + emit HookCalled(abi.encode(tableId, key, fieldLayout)); // Expect a HookCalled event to be emitted when the EchoSubscriber's onAfterDeleteRecord hook is called vm.expectEmit(true, true, true, true); - emit HookCalled(abi.encode(table, key, fieldLayout)); + emit HookCalled(abi.encode(tableId, key, fieldLayout)); - IStore(this).deleteRecord(table, key, fieldLayout); + IStore(this).deleteRecord(tableId, key, fieldLayout); } function testHooksDynamicData() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some key"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 1); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT32_ARRAY); - IStore(this).registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); + IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); // Create subscriber MirrorSubscriber subscriber = new MirrorSubscriber( - table, + tableId, fieldLayout, defaultKeySchema, valueSchema, @@ -1031,7 +1043,7 @@ contract StoreCoreTest is Test, StoreMock { ); IStore(this).registerStoreHook( - table, + tableId, subscriber, StoreHookLib.encodeBitmap({ onBeforeSetRecord: true, @@ -1051,9 +1063,9 @@ contract StoreCoreTest is Test, StoreMock { bytes memory staticData = abi.encodePacked(bytes16(0x0102030405060708090a0b0c0d0e0f10)); bytes memory data = abi.encodePacked(staticData, dynamicData); - IStore(this).setRecord(table, key, data, fieldLayout); + IStore(this).setRecord(tableId, key, data, fieldLayout); - // Get data from indexed table - the indexer should have mirrored the data there + // Get data from indexed tableId - the indexer should have mirrored the data there bytes memory indexedData = IStore(this).getRecord(indexerTableId, key, fieldLayout); assertEq(keccak256(data), keccak256(indexedData)); @@ -1063,15 +1075,15 @@ contract StoreCoreTest is Test, StoreMock { dynamicData = abi.encodePacked(encodedArrayDataLength.unwrap(), arrayDataBytes); data = abi.encodePacked(staticData, dynamicData); - IStore(this).setField(table, key, 1, arrayDataBytes, fieldLayout); + IStore(this).setField(tableId, key, 1, arrayDataBytes, fieldLayout); - // Get data from indexed table - the indexer should have mirrored the data there + // Get data from indexed tableId - the indexer should have mirrored the data there indexedData = IStore(this).getRecord(indexerTableId, key, fieldLayout); assertEq(keccak256(data), keccak256(indexedData)); - IStore(this).deleteRecord(table, key, fieldLayout); + IStore(this).deleteRecord(tableId, key, fieldLayout); - // Get data from indexed table - the indexer should have mirrored the data there + // Get data from indexed tableId - the indexer should have mirrored the data there indexedData = IStore(this).getRecord(indexerTableId, key, fieldLayout); assertEq(keccak256(indexedData), keccak256(abi.encodePacked(bytes16(0)))); } diff --git a/packages/store/test/StoreCoreDynamic.t.sol b/packages/store/test/StoreCoreDynamic.t.sol index a29d56eaa5..dc0e2cf37c 100644 --- a/packages/store/test/StoreCoreDynamic.t.sol +++ b/packages/store/test/StoreCoreDynamic.t.sol @@ -17,7 +17,7 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { Schema internal defaultKeySchema = SchemaEncodeHelper.encode(SchemaType.BYTES32); bytes32[] internal _key; - bytes32 internal _table = keccak256("some.table"); + bytes32 internal _table = keccak256("some.tableId"); bytes32 internal firstDataBytes; uint32[] internal secondData; @@ -27,17 +27,17 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { // Expose an external popFromField function for testing purposes of indexers (see testHooks) function popFromField( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, uint256 byteLengthToPop, FieldLayout fieldLayout ) public override { - StoreCore.popFromField(table, key, schemaIndex, byteLengthToPop, fieldLayout); + StoreCore.popFromField(tableId, key, schemaIndex, byteLengthToPop, fieldLayout); } function setUp() public { - // Register table's value schema + // Register tableId's value schema FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT256, diff --git a/packages/store/test/StoreCoreGas.t.sol b/packages/store/test/StoreCoreGas.t.sol index d09dc15539..122e0127cf 100644 --- a/packages/store/test/StoreCoreGas.t.sol +++ b/packages/store/test/StoreCoreGas.t.sol @@ -41,7 +41,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { SchemaType.UINT16 ); Schema keySchema = SchemaEncodeHelper.encode(SchemaType.UINT8, SchemaType.UINT16); - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); string[] memory keyNames = new string[](2); keyNames[0] = "key1"; @@ -52,20 +52,20 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { fieldNames[2] = "value3"; fieldNames[3] = "value4"; - startGasReport("StoreCore: register table"); - StoreCore.registerTable(table, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); + startGasReport("StoreCore: register tableId"); + StoreCore.registerTable(tableId, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); endGasReport(); startGasReport("StoreCore: get field layout (warm)"); - StoreCore.getFieldLayout(table); + StoreCore.getFieldLayout(tableId); endGasReport(); startGasReport("StoreCore: get value schema (warm)"); - StoreCore.getValueSchema(table); + StoreCore.getValueSchema(tableId); endGasReport(); startGasReport("StoreCore: get key schema (warm)"); - StoreCore.getKeySchema(table); + StoreCore.getKeySchema(tableId); endGasReport(); } @@ -77,21 +77,21 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { SchemaType.UINT16 ); FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(1, 2, 1, 2, 0); - bytes32 table = keccak256("some.table"); - bytes32 table2 = keccak256("other.table"); - StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); + bytes32 tableId = keccak256("some.tableId"); + bytes32 table2 = keccak256("other.tableId"); + StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); - startGasReport("Check for existence of table (existent)"); - StoreCore.hasTable(table); + startGasReport("Check for existence of tableId (existent)"); + StoreCore.hasTable(tableId); endGasReport(); - startGasReport("check for existence of table (non-existent)"); + startGasReport("check for existence of tableId (non-existent)"); StoreCore.hasTable(table2); endGasReport(); } function testSetAndGetDynamicDataLength() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT8, @@ -103,8 +103,8 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(1, 2, 4, 2); - // Register table - StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](5)); + // Register tableId + StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](5)); // Create some key bytes32[] memory key = new bytes32[](1); @@ -112,22 +112,22 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Set dynamic data length of dynamic index 0 startGasReport("set dynamic length of dynamic index 0"); - StoreCoreInternal._setDynamicDataLengthAtIndex(table, key, 0, 10); + StoreCoreInternal._setDynamicDataLengthAtIndex(tableId, key, 0, 10); endGasReport(); // Set dynamic data length of dynamic index 1 startGasReport("set dynamic length of dynamic index 1"); - StoreCoreInternal._setDynamicDataLengthAtIndex(table, key, 1, 99); + StoreCoreInternal._setDynamicDataLengthAtIndex(tableId, key, 1, 99); endGasReport(); // Reduce dynamic data length of dynamic index 0 again startGasReport("reduce dynamic length of dynamic index 0"); - StoreCoreInternal._setDynamicDataLengthAtIndex(table, key, 0, 5); + StoreCoreInternal._setDynamicDataLengthAtIndex(tableId, key, 0, 5); endGasReport(); } function testSetAndGetStaticData() public { - // Register table + // Register tableId Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT8, SchemaType.UINT16, @@ -135,8 +135,8 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { SchemaType.UINT16 ); FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(1, 2, 1, 2, 0); - bytes32 table = keccak256("some.table"); - StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); + bytes32 tableId = keccak256("some.tableId"); + StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); // Set data bytes memory data = abi.encodePacked(bytes1(0x01), bytes2(0x0203), bytes1(0x04), bytes2(0x0506)); @@ -144,21 +144,21 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { key[0] = keccak256("some.key"); startGasReport("set static record (1 slot)"); - StoreCore.setRecord(table, key, data, fieldLayout); + StoreCore.setRecord(tableId, key, data, fieldLayout); endGasReport(); // Get data startGasReport("get static record (1 slot)"); - StoreCore.getRecord(table, key, fieldLayout); + StoreCore.getRecord(tableId, key, fieldLayout); endGasReport(); } function testSetAndGetStaticDataSpanningWords() public { - // Register table + // Register tableId Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT256); FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 32, 0); - bytes32 table = keccak256("some.table"); - StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); + bytes32 tableId = keccak256("some.tableId"); + StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); // Set data bytes memory data = abi.encodePacked( @@ -170,26 +170,26 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { key[0] = keccak256("some.key"); startGasReport("set static record (2 slots)"); - StoreCore.setRecord(table, key, data, fieldLayout); + StoreCore.setRecord(tableId, key, data, fieldLayout); endGasReport(); // Get data startGasReport("get static record (2 slots)"); - StoreCore.getRecord(table, key, fieldLayout); + StoreCore.getRecord(tableId, key, fieldLayout); endGasReport(); } function testSetAndGetDynamicData() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY ); - StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); + StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); bytes16 firstDataBytes = bytes16(0x0102030405060708090a0b0c0d0e0f10); @@ -229,12 +229,12 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Set data startGasReport("set complex record with dynamic data (4 slots)"); - StoreCore.setRecord(table, key, data, fieldLayout); + StoreCore.setRecord(tableId, key, data, fieldLayout); endGasReport(); // Get data startGasReport("get complex record with dynamic data (4 slots)"); - StoreCore.getRecord(table, key, fieldLayout); + StoreCore.getRecord(tableId, key, fieldLayout); endGasReport(); // Compare gas - setting the data as raw struct @@ -256,9 +256,9 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { } function testSetAndGetField() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, @@ -266,7 +266,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY ); - StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); + StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); bytes16 firstDataBytes = bytes16(0x0102030405060708090a0b0c0d0e0f10); @@ -278,7 +278,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Set first field startGasReport("set static field (1 slot)"); - StoreCore.setField(table, key, 0, firstDataPacked, fieldLayout); + StoreCore.setField(tableId, key, 0, firstDataPacked, fieldLayout); endGasReport(); //////////////// @@ -287,7 +287,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Get first field startGasReport("get static field (1 slot)"); - StoreCore.getField(table, key, 0, fieldLayout); + StoreCore.getField(tableId, key, 0, fieldLayout); endGasReport(); // Set second field @@ -295,12 +295,12 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes memory secondDataPacked = abi.encodePacked(secondDataBytes); startGasReport("set static field (overlap 2 slot)"); - StoreCore.setField(table, key, 1, secondDataPacked, fieldLayout); + StoreCore.setField(tableId, key, 1, secondDataPacked, fieldLayout); endGasReport(); // Get second field startGasReport("get static field (overlap 2 slot)"); - StoreCore.getField(table, key, 1, fieldLayout); + StoreCore.getField(tableId, key, 1, fieldLayout); endGasReport(); //////////////// @@ -326,36 +326,36 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Set third field startGasReport("set dynamic field (1 slot, first dynamic field)"); - StoreCore.setField(table, key, 2, thirdDataBytes, fieldLayout); + StoreCore.setField(tableId, key, 2, thirdDataBytes, fieldLayout); endGasReport(); // Get third field startGasReport("get dynamic field (1 slot, first dynamic field)"); - StoreCore.getField(table, key, 2, fieldLayout); + StoreCore.getField(tableId, key, 2, fieldLayout); endGasReport(); // Set fourth field startGasReport("set dynamic field (1 slot, second dynamic field)"); - StoreCore.setField(table, key, 3, fourthDataBytes, fieldLayout); + StoreCore.setField(tableId, key, 3, fourthDataBytes, fieldLayout); endGasReport(); // Get fourth field startGasReport("get dynamic field (1 slot, second dynamic field)"); - StoreCore.getField(table, key, 3, fieldLayout); + StoreCore.getField(tableId, key, 3, fieldLayout); endGasReport(); } function testDeleteData() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY ); - StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); + StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); bytes16 firstDataBytes = bytes16(0x0102030405060708090a0b0c0d0e0f10); @@ -394,25 +394,25 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { key[0] = bytes32("some.key"); // Set data - StoreCore.setRecord(table, key, data, fieldLayout); + StoreCore.setRecord(tableId, key, data, fieldLayout); // Delete data startGasReport("delete record (complex data, 3 slots)"); - StoreCore.deleteRecord(table, key, fieldLayout); + StoreCore.deleteRecord(tableId, key, fieldLayout); endGasReport(); } function testPushToField() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT256, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY ); - StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); + StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); // Create key bytes32[] memory key = new bytes32[](1); @@ -437,10 +437,10 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { } // Set fields - StoreCore.setField(table, key, 0, abi.encodePacked(firstDataBytes), fieldLayout); - StoreCore.setField(table, key, 1, secondDataBytes, fieldLayout); + StoreCore.setField(tableId, key, 0, abi.encodePacked(firstDataBytes), fieldLayout); + StoreCore.setField(tableId, key, 1, secondDataBytes, fieldLayout); // Initialize a field with push - StoreCore.pushToField(table, key, 2, thirdDataBytes, fieldLayout); + StoreCore.pushToField(tableId, key, 2, thirdDataBytes, fieldLayout); // Create data to push bytes memory secondDataToPush; @@ -452,7 +452,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Push to second field startGasReport("push to field (1 slot, 1 uint32 item)"); - StoreCore.pushToField(table, key, 1, secondDataToPush, fieldLayout); + StoreCore.pushToField(tableId, key, 1, secondDataToPush, fieldLayout); endGasReport(); // Create data to push @@ -474,7 +474,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Push to third field startGasReport("push to field (2 slots, 10 uint32 items)"); - StoreCore.pushToField(table, key, 2, thirdDataToPush, fieldLayout); + StoreCore.pushToField(tableId, key, 2, thirdDataToPush, fieldLayout); endGasReport(); } @@ -490,16 +490,16 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { function testUpdateInField() public { TestUpdateInFieldData memory data = TestUpdateInFieldData("", "", "", "", "", "", ""); - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT256, SchemaType.UINT32_ARRAY, SchemaType.UINT64_ARRAY ); - StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); + StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); // Create key bytes32[] memory key = new bytes32[](1); @@ -522,9 +522,9 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { data.thirdDataBytes = EncodeArray.encode(thirdData); // Set fields - StoreCore.setField(table, key, 0, abi.encodePacked(data.firstDataBytes), fieldLayout); - StoreCore.setField(table, key, 1, data.secondDataBytes, fieldLayout); - StoreCore.setField(table, key, 2, data.thirdDataBytes, fieldLayout); + StoreCore.setField(tableId, key, 0, abi.encodePacked(data.firstDataBytes), fieldLayout); + StoreCore.setField(tableId, key, 1, data.secondDataBytes, fieldLayout); + StoreCore.setField(tableId, key, 2, data.thirdDataBytes, fieldLayout); // Create data to use for the update { @@ -537,7 +537,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Update index 1 in second field (4 = byte length of uint32) startGasReport("update in field (1 slot, 1 uint32 item)"); - StoreCore.updateInField(table, key, 1, 4 * 1, data.secondDataForUpdate, fieldLayout); + StoreCore.updateInField(tableId, key, 1, 4 * 1, data.secondDataForUpdate, fieldLayout); endGasReport(); // Create data for update @@ -561,55 +561,55 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { // Update indexes 1,2,3,4 in third field (8 = byte length of uint64) startGasReport("push to field (2 slots, 6 uint64 items)"); - StoreCore.updateInField(table, key, 2, 8 * 1, data.thirdDataForUpdate, fieldLayout); + StoreCore.updateInField(tableId, key, 2, 8 * 1, data.thirdDataForUpdate, fieldLayout); endGasReport(); } function testAccessEmptyData() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(4, 1); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT32, SchemaType.UINT32_ARRAY); - StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); + StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); // Create key bytes32[] memory key = new bytes32[](1); key[0] = bytes32("some.key"); startGasReport("access non-existing record"); - StoreCore.getRecord(table, key, fieldLayout); + StoreCore.getRecord(tableId, key, fieldLayout); endGasReport(); startGasReport("access static field of non-existing record"); - StoreCore.getField(table, key, 0, fieldLayout); + StoreCore.getField(tableId, key, 0, fieldLayout); endGasReport(); startGasReport("access dynamic field of non-existing record"); - StoreCore.getField(table, key, 1, fieldLayout); + StoreCore.getField(tableId, key, 1, fieldLayout); endGasReport(); startGasReport("access length of dynamic field of non-existing record"); - StoreCore.getFieldLength(table, key, 1, fieldLayout); + StoreCore.getFieldLength(tableId, key, 1, fieldLayout); endGasReport(); startGasReport("access slice of dynamic field of non-existing record"); - StoreCore.getFieldSlice(table, key, 1, fieldLayout, 0, 0); + StoreCore.getFieldSlice(tableId, key, 1, fieldLayout, 0, 0); endGasReport(); } function testHooks() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some key"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 0); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128); - StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](1)); + StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](1)); // Create subscriber MirrorSubscriber subscriber = new MirrorSubscriber( - table, + tableId, fieldLayout, defaultKeySchema, valueSchema, @@ -619,7 +619,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { startGasReport("register subscriber"); StoreCore.registerStoreHook( - table, + tableId, subscriber, StoreHookLib.encodeBitmap({ onBeforeSetRecord: true, @@ -634,34 +634,34 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes memory data = abi.encodePacked(bytes16(0x0102030405060708090a0b0c0d0e0f10)); - startGasReport("set record on table with subscriber"); - StoreCore.setRecord(table, key, data, fieldLayout); + startGasReport("set record on tableId with subscriber"); + StoreCore.setRecord(tableId, key, data, fieldLayout); endGasReport(); data = abi.encodePacked(bytes16(0x1112131415161718191a1b1c1d1e1f20)); - startGasReport("set static field on table with subscriber"); - StoreCore.setField(table, key, 0, data, fieldLayout); + startGasReport("set static field on tableId with subscriber"); + StoreCore.setField(tableId, key, 0, data, fieldLayout); endGasReport(); - startGasReport("delete record on table with subscriber"); - StoreCore.deleteRecord(table, key, fieldLayout); + startGasReport("delete record on tableId with subscriber"); + StoreCore.deleteRecord(tableId, key, fieldLayout); endGasReport(); } function testHooksDynamicData() public { - bytes32 table = keccak256("some.table"); + bytes32 tableId = keccak256("some.tableId"); bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some key"); - // Register table + // Register tableId FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 1); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT32_ARRAY); - StoreCore.registerTable(table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); + StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); // Create subscriber MirrorSubscriber subscriber = new MirrorSubscriber( - table, + tableId, fieldLayout, defaultKeySchema, valueSchema, @@ -671,7 +671,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { startGasReport("register subscriber"); StoreCore.registerStoreHook( - table, + tableId, subscriber, StoreHookLib.encodeBitmap({ onBeforeSetRecord: true, @@ -692,8 +692,8 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes memory staticData = abi.encodePacked(bytes16(0x0102030405060708090a0b0c0d0e0f10)); bytes memory data = abi.encodePacked(staticData, dynamicData); - startGasReport("set (dynamic) record on table with subscriber"); - StoreCore.setRecord(table, key, data, fieldLayout); + startGasReport("set (dynamic) record on tableId with subscriber"); + StoreCore.setRecord(tableId, key, data, fieldLayout); endGasReport(); // Update dynamic data @@ -702,12 +702,12 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { dynamicData = abi.encodePacked(encodedArrayDataLength.unwrap(), arrayDataBytes); data = abi.encodePacked(staticData, dynamicData); - startGasReport("set (dynamic) field on table with subscriber"); - StoreCore.setField(table, key, 1, arrayDataBytes, fieldLayout); + startGasReport("set (dynamic) field on tableId with subscriber"); + StoreCore.setField(tableId, key, 1, arrayDataBytes, fieldLayout); endGasReport(); - startGasReport("delete (dynamic) record on table with subscriber"); - StoreCore.deleteRecord(table, key, fieldLayout); + startGasReport("delete (dynamic) record on tableId with subscriber"); + StoreCore.deleteRecord(tableId, key, fieldLayout); endGasReport(); } } diff --git a/packages/store/test/StoreMock.sol b/packages/store/test/StoreMock.sol index 8338942a8a..7f41e95ba7 100644 --- a/packages/store/test/StoreMock.sol +++ b/packages/store/test/StoreMock.sol @@ -18,92 +18,92 @@ contract StoreMock is IStore, StoreRead { // Set full record (including full dynamic data) function setRecord( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, bytes calldata data, FieldLayout fieldLayout ) public virtual { - StoreCore.setRecord(table, key, data, fieldLayout); + StoreCore.setRecord(tableId, key, data, fieldLayout); } // Set partial data at schema index function setField( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, bytes calldata data, FieldLayout fieldLayout ) public virtual { - StoreCore.setField(table, key, schemaIndex, data, fieldLayout); + StoreCore.setField(tableId, key, schemaIndex, data, fieldLayout); } // Push encoded items to the dynamic field at schema index function pushToField( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, bytes calldata dataToPush, FieldLayout fieldLayout ) public virtual { - StoreCore.pushToField(table, key, schemaIndex, dataToPush, fieldLayout); + StoreCore.pushToField(tableId, key, schemaIndex, dataToPush, fieldLayout); } // Pop byte length from the dynamic field at schema index function popFromField( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, uint256 byteLengthToPop, FieldLayout fieldLayout ) public virtual { - StoreCore.popFromField(table, key, schemaIndex, byteLengthToPop, fieldLayout); + StoreCore.popFromField(tableId, key, schemaIndex, byteLengthToPop, fieldLayout); } // Change encoded items within the dynamic field at schema index function updateInField( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, uint8 schemaIndex, uint256 startByteIndex, bytes calldata dataToSet, FieldLayout fieldLayout ) public virtual { - StoreCore.updateInField(table, key, schemaIndex, startByteIndex, dataToSet, fieldLayout); + StoreCore.updateInField(tableId, key, schemaIndex, startByteIndex, dataToSet, fieldLayout); } // Set full record (including full dynamic data) - function deleteRecord(bytes32 table, bytes32[] memory key, FieldLayout fieldLayout) public virtual { - StoreCore.deleteRecord(table, key, fieldLayout); + function deleteRecord(bytes32 tableId, bytes32[] memory key, FieldLayout fieldLayout) public virtual { + StoreCore.deleteRecord(tableId, key, fieldLayout); } // Emit the ephemeral event without modifying storage function emitEphemeralRecord( - bytes32 table, + bytes32 tableId, bytes32[] calldata key, bytes calldata data, FieldLayout fieldLayout ) public virtual { - StoreCore.emitEphemeralRecord(table, key, data, fieldLayout); + StoreCore.emitEphemeralRecord(tableId, key, data, fieldLayout); } function registerTable( - bytes32 table, + bytes32 tableId, FieldLayout fieldLayout, Schema keySchema, Schema valueSchema, string[] calldata keyNames, string[] calldata fieldNames ) public virtual { - StoreCore.registerTable(table, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); + StoreCore.registerTable(tableId, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); } // Register hook to be called when a record or field is set or deleted - function registerStoreHook(bytes32 table, IStoreHook hookAddress, uint8 enabledHooksBitmap) public virtual { - StoreCore.registerStoreHook(table, hookAddress, enabledHooksBitmap); + function registerStoreHook(bytes32 tableId, IStoreHook hookAddress, uint8 enabledHooksBitmap) public virtual { + StoreCore.registerStoreHook(tableId, hookAddress, enabledHooksBitmap); } // Unregister hook to be called when a record or field is set or deleted - function unregisterStoreHook(bytes32 table, IStoreHook hookAddress) public virtual { - StoreCore.unregisterStoreHook(table, hookAddress); + function unregisterStoreHook(bytes32 tableId, IStoreHook hookAddress) public virtual { + StoreCore.unregisterStoreHook(tableId, hookAddress); } } diff --git a/packages/store/ts/storeEvents.ts b/packages/store/ts/storeEvents.ts index f65d884db5..c2cb00a604 100644 --- a/packages/store/ts/storeEvents.ts +++ b/packages/store/ts/storeEvents.ts @@ -1,6 +1,6 @@ export const storeEvents = [ - "event StoreDeleteRecord(bytes32 table, bytes32[] key)", - "event StoreSetField(bytes32 table, bytes32[] key, uint8 schemaIndex, bytes data)", - "event StoreSetRecord(bytes32 table, bytes32[] key, bytes data)", - "event StoreEphemeralRecord(bytes32 table, bytes32[] key, bytes data)", + "event StoreDeleteRecord(bytes32 tableId, bytes32[] key)", + "event StoreSetField(bytes32 tableId, bytes32[] key, uint8 schemaIndex, bytes data)", + "event StoreSetRecord(bytes32 tableId, bytes32[] key, bytes data)", + "event StoreEphemeralRecord(bytes32 tableId, bytes32[] key, bytes data)", ] as const; diff --git a/packages/world/src/modules/keysintable/KeysInTableHook.sol b/packages/world/src/modules/keysintable/KeysInTableHook.sol index 2e9a449324..e1ece311dc 100644 --- a/packages/world/src/modules/keysintable/KeysInTableHook.sol +++ b/packages/world/src/modules/keysintable/KeysInTableHook.sol @@ -8,17 +8,17 @@ import { KeysInTable } from "./tables/KeysInTable.sol"; import { UsedKeysIndex } from "./tables/UsedKeysIndex.sol"; /** - * Note: if a table with composite keys is used, only the first key is indexed + * Note: if a tableId with composite keys is used, only the first key is indexed */ contract KeysInTableHook is StoreHook { function handleSet(bytes32 tableId, bytes32[] memory key) internal { bytes32 keysHash = keccak256(abi.encode(key)); - // If the key has not yet been set in the table... + // If the key has not yet been set in the tableId... if (!UsedKeysIndex.getHas(tableId, keysHash)) { uint40 length = uint40(KeysInTable.lengthKeys0(tableId)); - // Push the key to the list of keys in this table + // Push the key to the list of keys in this tableId if (key.length > 0) { KeysInTable.pushKeys0(tableId, key[0]); if (key.length > 1) { @@ -40,35 +40,35 @@ contract KeysInTableHook is StoreHook { } } - function onBeforeSetRecord(bytes32 table, bytes32[] memory key, bytes memory, FieldLayout) public { - handleSet(table, key); + function onBeforeSetRecord(bytes32 tableId, bytes32[] memory key, bytes memory, FieldLayout) public { + handleSet(tableId, key); } - function onAfterSetRecord(bytes32 table, bytes32[] memory key, bytes memory, FieldLayout) public { + function onAfterSetRecord(bytes32 tableId, bytes32[] memory key, bytes memory, FieldLayout) public { // NOOP } - function onBeforeSetField(bytes32 table, bytes32[] memory key, uint8, bytes memory, FieldLayout) public { + function onBeforeSetField(bytes32 tableId, bytes32[] memory key, uint8, bytes memory, FieldLayout) public { // NOOP } - function onAfterSetField(bytes32 table, bytes32[] memory key, uint8, bytes memory, FieldLayout) public { - handleSet(table, key); + function onAfterSetField(bytes32 tableId, bytes32[] memory key, uint8, bytes memory, FieldLayout) public { + handleSet(tableId, key); } function onBeforeDeleteRecord(bytes32 tableId, bytes32[] memory key, FieldLayout) public { bytes32 keysHash = keccak256(abi.encode(key)); (bool has, uint40 index) = UsedKeysIndex.get(tableId, keysHash); - // If the key was part of the table... + // If the key was part of the tableId... if (has) { - // Delete the index as the key is not in the table + // Delete the index as the key is not in the tableId UsedKeysIndex.deleteRecord(tableId, keysHash); uint40 length = uint40(KeysInTable.lengthKeys0(tableId)); if (length == 1) { - // Delete the list of keys in this table + // Delete the list of keys in this tableId KeysInTable.deleteRecord(tableId); } else { if (key.length > 0) { @@ -77,7 +77,7 @@ contract KeysInTableHook is StoreHook { bytes32 lastKey = KeysInTable.getItemKeys0(tableId, length - 1); lastKeyTuple[0] = lastKey; - // Remove the key from the list of keys in this table + // Remove the key from the list of keys in this tableId KeysInTable.updateKeys0(tableId, index, lastKey); KeysInTable.popKeys0(tableId); @@ -85,7 +85,7 @@ contract KeysInTableHook is StoreHook { lastKey = KeysInTable.getItemKeys1(tableId, length - 1); lastKeyTuple[1] = lastKey; - // Remove the key from the list of keys in this table + // Remove the key from the list of keys in this tableId KeysInTable.updateKeys1(tableId, index, lastKey); KeysInTable.popKeys1(tableId); @@ -93,7 +93,7 @@ contract KeysInTableHook is StoreHook { lastKey = KeysInTable.getItemKeys2(tableId, length - 1); lastKeyTuple[2] = lastKey; - // Swap and pop the key from the list of keys in this table + // Swap and pop the key from the list of keys in this tableId KeysInTable.updateKeys2(tableId, index, lastKey); KeysInTable.popKeys2(tableId); @@ -101,7 +101,7 @@ contract KeysInTableHook is StoreHook { lastKey = KeysInTable.getItemKeys3(tableId, length - 1); lastKeyTuple[3] = lastKey; - // Remove the key from the list of keys in this table + // Remove the key from the list of keys in this tableId KeysInTable.updateKeys3(tableId, index, lastKey); KeysInTable.popKeys3(tableId); @@ -109,7 +109,7 @@ contract KeysInTableHook is StoreHook { lastKey = KeysInTable.getItemKeys4(tableId, length - 1); lastKeyTuple[4] = lastKey; - // Remove the key from the list of keys in this table + // Remove the key from the list of keys in this tableId KeysInTable.updateKeys4(tableId, index, lastKey); KeysInTable.popKeys4(tableId); } @@ -125,7 +125,7 @@ contract KeysInTableHook is StoreHook { } } - function onAfterDeleteRecord(bytes32 table, bytes32[] memory key, FieldLayout fieldLayout) public { + function onAfterDeleteRecord(bytes32 tableId, bytes32[] memory key, FieldLayout fieldLayout) public { // NOOP } } From da8a13ea7805ded324964e1400f1c9b250b97bba Mon Sep 17 00:00:00 2001 From: alvrs Date: Thu, 14 Sep 2023 17:10:50 +0100 Subject: [PATCH 10/19] fix some tests --- packages/store-sync/src/blockLogsToStorage.test.ts | 8 ++++---- packages/store-sync/src/postgres/postgresStorage.test.ts | 4 ++-- packages/store-sync/src/sqlite/createSqliteTable.test.ts | 4 +++- packages/store-sync/src/sqlite/sqliteStorage.test.ts | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/store-sync/src/blockLogsToStorage.test.ts b/packages/store-sync/src/blockLogsToStorage.test.ts index 3e256adfb2..d1adbaa602 100644 --- a/packages/store-sync/src/blockLogsToStorage.test.ts +++ b/packages/store-sync/src/blockLogsToStorage.test.ts @@ -59,7 +59,7 @@ describe("blockLogsToStorage", () => { logIndex: 53, removed: false, args: { - table: "0x6d756473746f726500000000000000005461626c657300000000000000000000", + tableId: "0x6d756473746f726500000000000000005461626c657300000000000000000000", key: ["0x00000000000000000000000000000000496e76656e746f727900000000000000"], data: "0x0004010004000000000000000000000000000000000000000000000000000000001c030061030300000000000000000000000000000000000000000000000000000401000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000001600000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000056f776e657200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046974656d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b6974656d56617269616e740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006616d6f756e740000000000000000000000000000000000000000000000000000", }, @@ -76,7 +76,7 @@ describe("blockLogsToStorage", () => { logIndex: 88, removed: false, args: { - table: "0x00000000000000000000000000000000496e76656e746f727900000000000000", + tableId: "0x00000000000000000000000000000000496e76656e746f727900000000000000", key: [ "0x000000000000000000000000796eb990a3f9c431c69149c7a168b91596d87f60", "0x0000000000000000000000000000000000000000000000000000000000000001", @@ -116,7 +116,7 @@ describe("blockLogsToStorage", () => { "0x0000000000000000000000000000000000000000000000000000000000000001", ], "schemaIndex": 0, - "table": "0x00000000000000000000000000000000496e76656e746f727900000000000000", + "tableId": "0x00000000000000000000000000000000496e76656e746f727900000000000000", }, "blockHash": "0x03e962e7402b2ab295b92feac342a132111dd14b0d1fd4d4a0456fdc77981577", "blockNumber": 5448n, @@ -170,7 +170,7 @@ describe("blockLogsToStorage", () => { "0x0000000000000000000000000000000000000000000000000000000000000001", ], "schemaIndex": 0, - "table": "0x00000000000000000000000000000000496e76656e746f727900000000000000", + "tableId": "0x00000000000000000000000000000000496e76656e746f727900000000000000", }, "blockHash": "0x03e962e7402b2ab295b92feac342a132111dd14b0d1fd4d4a0456fdc77981577", "blockNumber": 5448n, diff --git a/packages/store-sync/src/postgres/postgresStorage.test.ts b/packages/store-sync/src/postgres/postgresStorage.test.ts index 171823647a..710ba387fc 100644 --- a/packages/store-sync/src/postgres/postgresStorage.test.ts +++ b/packages/store-sync/src/postgres/postgresStorage.test.ts @@ -46,7 +46,7 @@ describe("postgresStorage", async () => { logIndex: 54, removed: false, args: { - table: "0x000000000000000000000000000000005265736f757263655479706500000000", + tableId: "0x000000000000000000000000000000005265736f757263655479706500000000", key: ["0x00000000000000000000000000000000496e76656e746f727900000000000000"], schemaIndex: 0, data: "0x02", @@ -64,7 +64,7 @@ describe("postgresStorage", async () => { logIndex: 55, removed: false, args: { - table: "0x6d756473746f726500000000000000005461626c657300000000000000000000", + tableId: "0x6d756473746f726500000000000000005461626c657300000000000000000000", key: ["0x00000000000000000000000000000000496e76656e746f727900000000000000"], data: "0x0004010004000000000000000000000000000000000000000000000000000000001c030061030300000000000000000000000000000000000000000000000000000401000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000001600000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000056f776e657200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046974656d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b6974656d56617269616e740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006616d6f756e740000000000000000000000000000000000000000000000000000", }, diff --git a/packages/store-sync/src/sqlite/createSqliteTable.test.ts b/packages/store-sync/src/sqlite/createSqliteTable.test.ts index 756055c09d..c67dbed045 100644 --- a/packages/store-sync/src/sqlite/createSqliteTable.test.ts +++ b/packages/store-sync/src/sqlite/createSqliteTable.test.ts @@ -2,7 +2,7 @@ import { describe, it, expect } from "vitest"; import { createSqliteTable } from "./createSqliteTable"; describe("createSqliteTable", () => { - it("should create table from schema", async () => { + it.only("should create table from schema", async () => { const table = createSqliteTable({ address: "0xffffffffffffffffffffffffffffffffffffffff", namespace: "test", @@ -11,6 +11,8 @@ describe("createSqliteTable", () => { valueSchema: { name: "string", addr: "address" }, }); + console.log("table", table); + expect(table).toMatchInlineSnapshot(` SQLiteTable { "__isDeleted": SQLiteBoolean { diff --git a/packages/store-sync/src/sqlite/sqliteStorage.test.ts b/packages/store-sync/src/sqlite/sqliteStorage.test.ts index 2377d45176..1047ff4262 100644 --- a/packages/store-sync/src/sqlite/sqliteStorage.test.ts +++ b/packages/store-sync/src/sqlite/sqliteStorage.test.ts @@ -52,7 +52,7 @@ describe("sqliteStorage", async () => { logIndex: 54, removed: false, args: { - table: "0x000000000000000000000000000000005265736f757263655479706500000000", + tableId: "0x000000000000000000000000000000005265736f757263655479706500000000", key: ["0x00000000000000000000000000000000496e76656e746f727900000000000000"], schemaIndex: 0, data: "0x02", @@ -70,7 +70,7 @@ describe("sqliteStorage", async () => { logIndex: 55, removed: false, args: { - table: "0x6d756473746f726500000000000000005461626c657300000000000000000000", + tableId: "0x6d756473746f726500000000000000005461626c657300000000000000000000", key: ["0x00000000000000000000000000000000496e76656e746f727900000000000000"], data: "0x0004010004000000000000000000000000000000000000000000000000000000001c030061030300000000000000000000000000000000000000000000000000000401000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000001600000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000056f776e657200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000046974656d00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b6974656d56617269616e740000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000006616d6f756e740000000000000000000000000000000000000000000000000000", }, From df00ceb1a323b6f86c286c7f06c1e79e9d868849 Mon Sep 17 00:00:00 2001 From: alvrs Date: Thu, 14 Sep 2023 17:11:14 +0100 Subject: [PATCH 11/19] remove debug log --- packages/store-sync/src/sqlite/createSqliteTable.test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/store-sync/src/sqlite/createSqliteTable.test.ts b/packages/store-sync/src/sqlite/createSqliteTable.test.ts index c67dbed045..756055c09d 100644 --- a/packages/store-sync/src/sqlite/createSqliteTable.test.ts +++ b/packages/store-sync/src/sqlite/createSqliteTable.test.ts @@ -2,7 +2,7 @@ import { describe, it, expect } from "vitest"; import { createSqliteTable } from "./createSqliteTable"; describe("createSqliteTable", () => { - it.only("should create table from schema", async () => { + it("should create table from schema", async () => { const table = createSqliteTable({ address: "0xffffffffffffffffffffffffffffffffffffffff", namespace: "test", @@ -11,8 +11,6 @@ describe("createSqliteTable", () => { valueSchema: { name: "string", addr: "address" }, }); - console.log("table", table); - expect(table).toMatchInlineSnapshot(` SQLiteTable { "__isDeleted": SQLiteBoolean { From abf5712ea4b015c6eeb98a55a904da65a92b3fda Mon Sep 17 00:00:00 2001 From: alvarius Date: Thu, 14 Sep 2023 18:08:16 +0100 Subject: [PATCH 12/19] Create metal-hounds-drum.md --- .changeset/metal-hounds-drum.md | 38 +++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .changeset/metal-hounds-drum.md diff --git a/.changeset/metal-hounds-drum.md b/.changeset/metal-hounds-drum.md new file mode 100644 index 0000000000..f041da2353 --- /dev/null +++ b/.changeset/metal-hounds-drum.md @@ -0,0 +1,38 @@ +--- +"@latticexyz/block-logs-stream": patch +"@latticexyz/store-sync": patch +"@latticexyz/store": patch +--- + +Renamed all occurrences of `table` where it is used as "table ID" to `tableId`. +This is only a breaking change for consumers who manually decode `Store` events, but not for consumers who use the MUD libraries. + +```diff +event StoreSetRecord( +- bytes32 table, ++ bytes32 tableId, + bytes32[] key, + bytes data +); + +event StoreSetField( +- bytes32 table, ++ bytes32 tableId, + bytes32[] key, + uint8 fieldIndex, + bytes data +); + +event StoreDeleteRecord( +- bytes32 table, ++ bytes32 tableId, + bytes32[] key +); + +event StoreEphemeralRecord( +- bytes32 table, ++ bytes32 tableId, + bytes32[] key, + bytes data +); +``` From a4d55f44ddfc6698fbd0df0481e38af366ffa077 Mon Sep 17 00:00:00 2001 From: alvrs Date: Thu, 14 Sep 2023 21:29:59 +0100 Subject: [PATCH 13/19] catch some more table id --- docs/pages/store/advanced-features.mdx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/pages/store/advanced-features.mdx b/docs/pages/store/advanced-features.mdx index caaa9c365d..6784d64b7b 100644 --- a/docs/pages/store/advanced-features.mdx +++ b/docs/pages/store/advanced-features.mdx @@ -79,12 +79,12 @@ It is possible to register hooks on tables, allowing additional logic to be exec This is an example of a Mirror hook which mirrors a table into another one: ```solidity -uint256 constant indexerTableId = uint256(keccak256("indexer.table")); +bytes32 constant indexerTableId = bytes32("indexer.table"); contract MirrorSubscriber is IStoreHook { bytes32 _tableId; - constructor(uint256 table, Schema keySchema, Schema valueSchema) { + constructor(bytes32 tableId, Schema keySchema, Schema valueSchema) { IStore(msg.sender).registerSchema(indexerTableId, valueSchema, keySchema); _tableId = tableId; } @@ -109,7 +109,7 @@ contract MirrorSubscriber is IStoreHook { Registering the hook can be done using the low-level Store API: ```solidity -bytes32 tableId = keccak256("table"); +bytes32 tableId = bytes32("table"); Schema valueSchema = SchemaLib.encode(SchemaType.UINT256, SchemaType.UINT256); Schema keySchema = SchemaLib.encode(SchemaType.UINT256); MirrorSubscriber subscriber = new MirrorSubscriber(tableId, keySchema, valueSchema); From 09755c6ec2df34d27a7aee8c9b4eeae19dc4fdf8 Mon Sep 17 00:00:00 2001 From: alvrs Date: Thu, 14 Sep 2023 21:44:29 +0100 Subject: [PATCH 14/19] remove invalid comments --- packages/store/test/StoreCoreDynamic.t.sol | 70 +++++++++---------- .../modules/keysintable/KeysInTableHook.sol | 15 ++-- 2 files changed, 40 insertions(+), 45 deletions(-) diff --git a/packages/store/test/StoreCoreDynamic.t.sol b/packages/store/test/StoreCoreDynamic.t.sol index dc0e2cf37c..c781320cf7 100644 --- a/packages/store/test/StoreCoreDynamic.t.sol +++ b/packages/store/test/StoreCoreDynamic.t.sol @@ -17,7 +17,7 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { Schema internal defaultKeySchema = SchemaEncodeHelper.encode(SchemaType.BYTES32); bytes32[] internal _key; - bytes32 internal _table = keccak256("some.tableId"); + bytes32 internal _tableId = keccak256("some.tableId"); bytes32 internal firstDataBytes; uint32[] internal secondData; @@ -37,14 +37,14 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { } function setUp() public { - // Register tableId's value schema + // Register table's value schema FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT256, SchemaType.UINT32_ARRAY, SchemaType.UINT32_ARRAY ); - StoreCore.registerTable(_table, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); + StoreCore.registerTable(_tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](3)); // Create key _key = new bytes32[](1); @@ -73,14 +73,14 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { thirdDataBytes = EncodeArray.encode(thirdData); // Set fields - StoreCore.setField(_table, _key, 0, abi.encodePacked(firstDataBytes), fieldLayout); - StoreCore.setField(_table, _key, 1, secondDataBytes, fieldLayout); + StoreCore.setField(_tableId, _key, 0, abi.encodePacked(firstDataBytes), fieldLayout); + StoreCore.setField(_tableId, _key, 1, secondDataBytes, fieldLayout); // Initialize a field with push - StoreCore.pushToField(_table, _key, 2, thirdDataBytes, fieldLayout); + StoreCore.pushToField(_tableId, _key, 2, thirdDataBytes, fieldLayout); } function testPopFromSecondField() public { - FieldLayout fieldLayout = StoreCore.getFieldLayout(_table); + FieldLayout fieldLayout = StoreCore.getFieldLayout(_tableId); bytes memory dataBytes = secondDataBytes; // Prepare expected data @@ -92,34 +92,34 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { // Expect a StoreSetField event to be emitted vm.expectEmit(true, true, true, true); - emit StoreSetField(_table, _key, 1, newDataBytes); + emit StoreSetField(_tableId, _key, 1, newDataBytes); // Pop from second field startGasReport("pop from field (cold, 1 slot, 1 uint32 item)"); - StoreCore.popFromField(_table, _key, 1, byteLengthToPop, fieldLayout); + StoreCore.popFromField(_tableId, _key, 1, byteLengthToPop, fieldLayout); endGasReport(); // Get second field - bytes memory loadedData = StoreCore.getField(_table, _key, 1, fieldLayout); + bytes memory loadedData = StoreCore.getField(_tableId, _key, 1, fieldLayout); // Verify loaded data is correct assertEq(loadedData, newDataBytes); // Reset the second field and pop again (but warm this time) - StoreCore.setField(_table, _key, 1, dataBytes, fieldLayout); + StoreCore.setField(_tableId, _key, 1, dataBytes, fieldLayout); startGasReport("pop from field (warm, 1 slot, 1 uint32 item)"); - StoreCore.popFromField(_table, _key, 1, byteLengthToPop, fieldLayout); + StoreCore.popFromField(_tableId, _key, 1, byteLengthToPop, fieldLayout); endGasReport(); // Get second field - loadedData = StoreCore.getField(_table, _key, 1, fieldLayout); + loadedData = StoreCore.getField(_tableId, _key, 1, fieldLayout); // Verify loaded data is correct assertEq(loadedData, newDataBytes); // Verify none of the other fields were impacted - assertEq(bytes32(StoreCore.getField(_table, _key, 0, fieldLayout)), firstDataBytes); - assertEq(StoreCore.getField(_table, _key, 2, fieldLayout), thirdDataBytes); + assertEq(bytes32(StoreCore.getField(_tableId, _key, 0, fieldLayout)), firstDataBytes); + assertEq(StoreCore.getField(_tableId, _key, 2, fieldLayout), thirdDataBytes); } function testPopFromThirdField() public { - FieldLayout fieldLayout = StoreCore.getFieldLayout(_table); + FieldLayout fieldLayout = StoreCore.getFieldLayout(_tableId); bytes memory dataBytes = thirdDataBytes; // Prepare expected data @@ -131,74 +131,74 @@ contract StoreCoreDynamicTest is Test, GasReporter, StoreMock { // Expect a StoreSetField event to be emitted after pop vm.expectEmit(true, true, true, true); - emit StoreSetField(_table, _key, 2, dataBytes); + emit StoreSetField(_tableId, _key, 2, dataBytes); // Pop from the field startGasReport("pop from field (cold, 2 slots, 10 uint32 items)"); - StoreCore.popFromField(_table, _key, 2, byteLengthToPop, fieldLayout); + StoreCore.popFromField(_tableId, _key, 2, byteLengthToPop, fieldLayout); endGasReport(); // Load and verify the field - bytes memory loadedData = StoreCore.getField(_table, _key, 2, fieldLayout); + bytes memory loadedData = StoreCore.getField(_tableId, _key, 2, fieldLayout); assertEq(loadedData, newDataBytes); // Reset the field and pop again (but warm this time) - StoreCore.setField(_table, _key, 2, dataBytes, fieldLayout); + StoreCore.setField(_tableId, _key, 2, dataBytes, fieldLayout); startGasReport("pop from field (warm, 2 slots, 10 uint32 items)"); - StoreCore.popFromField(_table, _key, 2, byteLengthToPop, fieldLayout); + StoreCore.popFromField(_tableId, _key, 2, byteLengthToPop, fieldLayout); endGasReport(); // Load and verify the field - loadedData = StoreCore.getField(_table, _key, 2, fieldLayout); + loadedData = StoreCore.getField(_tableId, _key, 2, fieldLayout); assertEq(loadedData, newDataBytes); // Verify none of the other fields were impacted - assertEq(bytes32(StoreCore.getField(_table, _key, 0, fieldLayout)), firstDataBytes); - assertEq(StoreCore.getField(_table, _key, 1, fieldLayout), secondDataBytes); + assertEq(bytes32(StoreCore.getField(_tableId, _key, 0, fieldLayout)), firstDataBytes); + assertEq(StoreCore.getField(_tableId, _key, 1, fieldLayout), secondDataBytes); } function testGetSecondFieldLength() public { - FieldLayout fieldLayout = StoreCore.getFieldLayout(_table); + FieldLayout fieldLayout = StoreCore.getFieldLayout(_tableId); startGasReport("get field length (cold, 1 slot)"); - uint256 length = StoreCore.getFieldLength(_table, _key, 1, fieldLayout); + uint256 length = StoreCore.getFieldLength(_tableId, _key, 1, fieldLayout); endGasReport(); assertEq(length, secondDataBytes.length); startGasReport("get field length (warm, 1 slot)"); - length = StoreCore.getFieldLength(_table, _key, 1, fieldLayout); + length = StoreCore.getFieldLength(_tableId, _key, 1, fieldLayout); endGasReport(); assertEq(length, secondDataBytes.length); } function testGetThirdFieldLength() public { - FieldLayout fieldLayout = StoreCore.getFieldLayout(_table); + FieldLayout fieldLayout = StoreCore.getFieldLayout(_tableId); startGasReport("get field length (warm due to , 2 slots)"); - uint256 length = StoreCore.getFieldLength(_table, _key, 2, fieldLayout); + uint256 length = StoreCore.getFieldLength(_tableId, _key, 2, fieldLayout); endGasReport(); assertEq(length, thirdDataBytes.length); startGasReport("get field length (warm, 2 slots)"); - length = StoreCore.getFieldLength(_table, _key, 2, fieldLayout); + length = StoreCore.getFieldLength(_tableId, _key, 2, fieldLayout); endGasReport(); assertEq(length, thirdDataBytes.length); } function testGetFieldSlice() public { - FieldLayout fieldLayout = StoreCore.getFieldLayout(_table); + FieldLayout fieldLayout = StoreCore.getFieldLayout(_tableId); startGasReport("get field slice (cold, 1 slot)"); - bytes memory secondFieldSlice = StoreCore.getFieldSlice(_table, _key, 1, fieldLayout, 0, 4); + bytes memory secondFieldSlice = StoreCore.getFieldSlice(_tableId, _key, 1, fieldLayout, 0, 4); endGasReport(); assertEq(secondFieldSlice, SliceLib.getSubslice(secondDataBytes, 0, 4).toBytes()); startGasReport("get field slice (warm, 1 slot)"); - secondFieldSlice = StoreCore.getFieldSlice(_table, _key, 1, fieldLayout, 4, 8); + secondFieldSlice = StoreCore.getFieldSlice(_tableId, _key, 1, fieldLayout, 4, 8); endGasReport(); assertEq(secondFieldSlice, SliceLib.getSubslice(secondDataBytes, 4, 8).toBytes()); startGasReport("get field slice (semi-cold, 1 slot)"); - bytes memory thirdFieldSlice = StoreCore.getFieldSlice(_table, _key, 2, fieldLayout, 4, 32); + bytes memory thirdFieldSlice = StoreCore.getFieldSlice(_tableId, _key, 2, fieldLayout, 4, 32); endGasReport(); assertEq(thirdFieldSlice, SliceLib.getSubslice(thirdDataBytes, 4, 32).toBytes()); startGasReport("get field slice (warm, 2 slots)"); - thirdFieldSlice = StoreCore.getFieldSlice(_table, _key, 2, fieldLayout, 8, 40); + thirdFieldSlice = StoreCore.getFieldSlice(_tableId, _key, 2, fieldLayout, 8, 40); endGasReport(); assertEq(thirdFieldSlice, SliceLib.getSubslice(thirdDataBytes, 8, 40).toBytes()); } diff --git a/packages/world/src/modules/keysintable/KeysInTableHook.sol b/packages/world/src/modules/keysintable/KeysInTableHook.sol index e1ece311dc..1953bea6ea 100644 --- a/packages/world/src/modules/keysintable/KeysInTableHook.sol +++ b/packages/world/src/modules/keysintable/KeysInTableHook.sol @@ -14,11 +14,11 @@ contract KeysInTableHook is StoreHook { function handleSet(bytes32 tableId, bytes32[] memory key) internal { bytes32 keysHash = keccak256(abi.encode(key)); - // If the key has not yet been set in the tableId... + // If the key has not yet been set in the table... if (!UsedKeysIndex.getHas(tableId, keysHash)) { uint40 length = uint40(KeysInTable.lengthKeys0(tableId)); - // Push the key to the list of keys in this tableId + // Push the key to the list of keys in this table if (key.length > 0) { KeysInTable.pushKeys0(tableId, key[0]); if (key.length > 1) { @@ -60,15 +60,15 @@ contract KeysInTableHook is StoreHook { bytes32 keysHash = keccak256(abi.encode(key)); (bool has, uint40 index) = UsedKeysIndex.get(tableId, keysHash); - // If the key was part of the tableId... + // If the key was part of the table... if (has) { - // Delete the index as the key is not in the tableId + // Delete the index as the key is not in the table UsedKeysIndex.deleteRecord(tableId, keysHash); uint40 length = uint40(KeysInTable.lengthKeys0(tableId)); if (length == 1) { - // Delete the list of keys in this tableId + // Delete the list of keys in this table KeysInTable.deleteRecord(tableId); } else { if (key.length > 0) { @@ -77,7 +77,6 @@ contract KeysInTableHook is StoreHook { bytes32 lastKey = KeysInTable.getItemKeys0(tableId, length - 1); lastKeyTuple[0] = lastKey; - // Remove the key from the list of keys in this tableId KeysInTable.updateKeys0(tableId, index, lastKey); KeysInTable.popKeys0(tableId); @@ -85,7 +84,6 @@ contract KeysInTableHook is StoreHook { lastKey = KeysInTable.getItemKeys1(tableId, length - 1); lastKeyTuple[1] = lastKey; - // Remove the key from the list of keys in this tableId KeysInTable.updateKeys1(tableId, index, lastKey); KeysInTable.popKeys1(tableId); @@ -93,7 +91,6 @@ contract KeysInTableHook is StoreHook { lastKey = KeysInTable.getItemKeys2(tableId, length - 1); lastKeyTuple[2] = lastKey; - // Swap and pop the key from the list of keys in this tableId KeysInTable.updateKeys2(tableId, index, lastKey); KeysInTable.popKeys2(tableId); @@ -101,7 +98,6 @@ contract KeysInTableHook is StoreHook { lastKey = KeysInTable.getItemKeys3(tableId, length - 1); lastKeyTuple[3] = lastKey; - // Remove the key from the list of keys in this tableId KeysInTable.updateKeys3(tableId, index, lastKey); KeysInTable.popKeys3(tableId); @@ -109,7 +105,6 @@ contract KeysInTableHook is StoreHook { lastKey = KeysInTable.getItemKeys4(tableId, length - 1); lastKeyTuple[4] = lastKey; - // Remove the key from the list of keys in this tableId KeysInTable.updateKeys4(tableId, index, lastKey); KeysInTable.popKeys4(tableId); } From 90d3e7468ab5185ebe6088c2d785c7b1f247b73d Mon Sep 17 00:00:00 2001 From: alvrs Date: Thu, 14 Sep 2023 22:31:23 +0100 Subject: [PATCH 15/19] fix tests --- test-data/world-logs.json | 604 +++++++++++++++++++------------------- 1 file changed, 309 insertions(+), 295 deletions(-) diff --git a/test-data/world-logs.json b/test-data/world-logs.json index 97dea80c14..1f79d89f7e 100644 --- a/test-data/world-logs.json +++ b/test-data/world-logs.json @@ -5,9 +5,9 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000016d756473746f726500000000000000005461626c65730000000000000000000000000000000000000000000000000000000000000000000000000000000003400060030220202000000000000000000000000000000000000000000000000000002001005f000000000000000000000000000000000000000000000000000000006003025f5f5fc4c40000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000000a0000000000002c000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000077461626c654964000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000500000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000000b6669656c644c61796f757400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000096b6579536368656d610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000b76616c7565536368656d610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000012616269456e636f6465644b65794e616d657300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014616269456e636f6465644669656c644e616d6573000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xd84cbdaf74c599ed411fd63e23c3d4aedd492d53efe8347769008829bab2f507", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", "transactionIndex": "0x0", "logIndex": "0x0", "transactionLogIndex": "0x0", @@ -19,9 +19,9 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000016d756473746f7265000000000000000053746f7265486f6f6b7300000000000000000000000000000000000000000000000000000000000000000000000001c00000000100000000000000000000000000000000000000000000000000000000002001005f00000000000000000000000000000000000000000000000000000000000001b600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000a00000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000036b65790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000576616c7565000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xd84cbdaf74c599ed411fd63e23c3d4aedd492d53efe8347769008829bab2f507", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", "transactionIndex": "0x0", "logIndex": "0x1", "transactionLogIndex": "0x1", @@ -33,9 +33,9 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000004e616d6573706163654f776e6572000000000000000000000000000000000000000000000000000000000000000001c00014010014000000000000000000000000000000000000000000000000000000001001004f000000000000000000000000000000000000000000000000000000001401006100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000a00000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000096e616d657370616365000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000056f776e6572000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xd84cbdaf74c599ed411fd63e23c3d4aedd492d53efe8347769008829bab2f507", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", "transactionIndex": "0x0", "logIndex": "0x2", "transactionLogIndex": "0x2", @@ -44,12 +44,12 @@ { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" + "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], - "data": "0x000000000000000000000000000000004e616d6573706163654f776e657200000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xd84cbdaf74c599ed411fd63e23c3d4aedd492d53efe8347769008829bab2f507", + "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000042616c616e636573000000000000000000000000000000000000000000000000000000000000000000000000000001c00020010020000000000000000000000000000000000000000000000000000000001001004f000000000000000000000000000000000000000000000000000000002001001f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000a00000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000096e616d6573706163650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000762616c616e636500000000000000000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", "transactionIndex": "0x0", "logIndex": "0x3", "transactionLogIndex": "0x3", @@ -60,13 +60,13 @@ "topics": [ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], - "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000042616c616e636573000000000000000000000000000000000000000000000000000000000000000000000000000001c00020010020000000000000000000000000000000000000000000000000000000001001004f000000000000000000000000000000000000000000000000000000002001001f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000a00000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000096e616d6573706163650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000762616c616e636500000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", - "logIndex": "0x5", - "transactionLogIndex": "0x0", + "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000496e7374616c6c65644d6f64756c657300000000000000000000000000000000000000000000000000000000000002200014010014000000000000000000000000000000000000000000000000000000003002004f5f0000000000000000000000000000000000000000000000000000001401006100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000100000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000a6d6f64756c654e616d6500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d617267756d656e74734861736800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d6d6f64756c654164647265737300000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", + "logIndex": "0x4", + "transactionLogIndex": "0x4", "removed": false }, { @@ -74,13 +74,13 @@ "topics": [ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], - "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000496e7374616c6c65644d6f64756c657300000000000000000000000000000000000000000000000000000000000002200014010014000000000000000000000000000000000000000000000000000000003002004f5f0000000000000000000000000000000000000000000000000000001401006100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000100000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000a6d6f64756c654e616d6500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d617267756d656e74734861736800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000d6d6f64756c654164647265737300000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", - "logIndex": "0x6", - "transactionLogIndex": "0x1", + "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000044656c65676174696f6e730000000000000000000000000000000000000000000000000000000000000000000000022000200100200000000000000000000000000000000000000000000000000000000028020061610000000000000000000000000000000000000000000000000000002001005f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000100000000000001a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000964656c656761746f720000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000964656c6567617465650000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001364656c65676174696f6e436f6e74726f6c496400000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", + "logIndex": "0x5", + "transactionLogIndex": "0x5", "removed": false }, { @@ -89,12 +89,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000005265736f75726365416363657373000000000000000000000000000000000000000000000000000000000000000002200001010001000000000000000000000000000000000000000000000000000000003402005f610000000000000000000000000000000000000000000000000000000101006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000100000000000001a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000107265736f7572636553656c6563746f7200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000663616c6c6572000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000066163636573730000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", - "logIndex": "0x7", - "transactionLogIndex": "0x2", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", + "logIndex": "0x6", + "transactionLogIndex": "0x6", "removed": false }, { @@ -103,12 +103,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000053797374656d7300000000000000000000000000000000000000000000000000000000000000000000000000000002200015020014010000000000000000000000000000000000000000000000000000002001005f0000000000000000000000000000000000000000000000000000000015020061600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000a0000000000001a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000107265736f7572636553656c6563746f72000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000673797374656d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c7075626c69634163636573730000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", - "logIndex": "0x8", - "transactionLogIndex": "0x3", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", + "logIndex": "0x7", + "transactionLogIndex": "0x7", "removed": false }, { @@ -117,12 +117,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000022000240200200400000000000000000000000000000000000000000000000000000004010043000000000000000000000000000000000000000000000000000000002402005f430000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000a0000000000001a0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001066756e6374696f6e53656c6563746f7200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000107265736f7572636553656c6563746f7200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001673797374656d46756e6374696f6e53656c6563746f7200000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", - "logIndex": "0x9", - "transactionLogIndex": "0x4", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", + "logIndex": "0x8", + "transactionLogIndex": "0x8", "removed": false }, { @@ -131,12 +131,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000053797374656d486f6f6b73000000000000000000000000000000000000000000000000000000000000000000000001c00000000100000000000000000000000000000000000000000000000000000000002001005f00000000000000000000000000000000000000000000000000000000000001b600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000a00000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000107265736f7572636553656c6563746f7200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000576616c7565000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", - "logIndex": "0xa", - "transactionLogIndex": "0x5", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", + "logIndex": "0x9", + "transactionLogIndex": "0x9", "removed": false }, { @@ -145,12 +145,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000053797374656d5265676973747279000000000000000000000000000000000000000000000000000000000000000001c000200100200000000000000000000000000000000000000000000000000000000014010061000000000000000000000000000000000000000000000000000000002001005f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000a000000000000140000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000673797374656d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000107265736f7572636553656c6563746f7200000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", - "logIndex": "0xb", - "transactionLogIndex": "0x6", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", + "logIndex": "0xa", + "transactionLogIndex": "0xa", "removed": false }, { @@ -159,12 +159,26 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000005265736f75726365547970650000000000000000000000000000000000000000000000000000000000000000000001c00001010001000000000000000000000000000000000000000000000000000000002001005f000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000a00000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000107265736f7572636553656c6563746f7200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c7265736f75726365547970650000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", + "logIndex": "0xb", + "transactionLogIndex": "0xb", + "removed": false + }, + { + "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", + "topics": [ + "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" + ], + "data": "0x000000000000000000000000000000004e616d6573706163654f776e657200000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014f39fd6e51aad88f6f4ce6ab8827279cfffb92266000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0xc", - "transactionLogIndex": "0x7", + "transactionLogIndex": "0xc", "removed": false }, { @@ -173,12 +187,12 @@ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], "data": "0x000000000000000000000000000000005265736f7572636541636365737300000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb9226600000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0xd", - "transactionLogIndex": "0x8", + "transactionLogIndex": "0xd", "removed": false }, { @@ -187,12 +201,12 @@ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], "data": "0x000000000000000000000000000000005265736f7572636554797065000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0xe", - "transactionLogIndex": "0x9", + "transactionLogIndex": "0xe", "removed": false }, { @@ -201,12 +215,12 @@ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], "data": "0x000000000000000000000000000000005265736f7572636554797065000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000636f72652e730000000000000000000000000000000000000000000000000000000000000000000000000000000000010300000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0xf", - "transactionLogIndex": "0xa", + "transactionLogIndex": "0xf", "removed": false }, { @@ -215,12 +229,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000053797374656d73000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000636f72652e73000000000000000000000000000000000000000000000000000000000000000000000000000000000015cafac3dd18ac6c6e92c921884f9e4176737c052c010000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x10", - "transactionLogIndex": "0xb", + "transactionLogIndex": "0x10", "removed": false }, { @@ -229,12 +243,12 @@ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], "data": "0x0000000000000000000000000000000053797374656d526567697374727900000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000cafac3dd18ac6c6e92c921884f9e4176737c052c000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000636f72652e7300000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x11", - "transactionLogIndex": "0xc", + "transactionLogIndex": "0x11", "removed": false }, { @@ -243,12 +257,12 @@ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], "data": "0x000000000000000000000000000000005265736f7572636541636365737300000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000cafac3dd18ac6c6e92c921884f9e4176737c052c00000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x12", - "transactionLogIndex": "0xd", + "transactionLogIndex": "0x12", "removed": false }, { @@ -257,12 +271,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000140554c3a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e730000000000000000000040554c3a00000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x13", - "transactionLogIndex": "0xe", + "transactionLogIndex": "0x13", "removed": false }, { @@ -271,12 +285,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000018d53b20800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e73000000000000000000008d53b20800000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x14", - "transactionLogIndex": "0xf", + "transactionLogIndex": "0x14", "removed": false }, { @@ -285,12 +299,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000125f6221000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e730000000000000000000025f6221000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x15", - "transactionLogIndex": "0x10", + "transactionLogIndex": "0x15", "removed": false }, { @@ -299,12 +313,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000012bfaa27400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e73000000000000000000002bfaa27400000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x16", - "transactionLogIndex": "0x11", + "transactionLogIndex": "0x16", "removed": false }, { @@ -313,12 +327,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000121293ca000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e730000000000000000000021293ca000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x17", - "transactionLogIndex": "0x12", + "transactionLogIndex": "0x17", "removed": false }, { @@ -327,12 +341,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000018818929400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e73000000000000000000008818929400000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x18", - "transactionLogIndex": "0x13", + "transactionLogIndex": "0x18", "removed": false }, { @@ -341,12 +355,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000018da798da00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e73000000000000000000008da798da00000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x19", - "transactionLogIndex": "0x14", + "transactionLogIndex": "0x19", "removed": false }, { @@ -355,12 +369,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010ba51f4900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e73000000000000000000000ba51f4900000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x1a", - "transactionLogIndex": "0x15", + "transactionLogIndex": "0x1a", "removed": false }, { @@ -369,12 +383,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001530f4b6000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e7300000000000000000000530f4b6000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x1b", - "transactionLogIndex": "0x16", + "transactionLogIndex": "0x1b", "removed": false }, { @@ -383,12 +397,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000010560912900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e73000000000000000000000560912900000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x1c", - "transactionLogIndex": "0x17", + "transactionLogIndex": "0x1c", "removed": false }, { @@ -397,12 +411,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001a886545e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e7300000000000000000000a886545e00000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x1d", - "transactionLogIndex": "0x18", + "transactionLogIndex": "0x1d", "removed": false }, { @@ -411,12 +425,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001d5f8337f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e7300000000000000000000d5f8337f00000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x1e", - "transactionLogIndex": "0x19", + "transactionLogIndex": "0x1e", "removed": false }, { @@ -425,12 +439,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001a92813ad00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e7300000000000000000000a92813ad00000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x1f", - "transactionLogIndex": "0x1a", + "transactionLogIndex": "0x1f", "removed": false }, { @@ -439,12 +453,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000013350b6a900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e73000000000000000000003350b6a900000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x20", - "transactionLogIndex": "0x1b", + "transactionLogIndex": "0x20", "removed": false }, { @@ -453,12 +467,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000013c03a51c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e73000000000000000000003c03a51c00000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x21", - "transactionLogIndex": "0x1c", + "transactionLogIndex": "0x21", "removed": false }, { @@ -467,12 +481,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001b7a3c75600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e7300000000000000000000b7a3c75600000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x22", - "transactionLogIndex": "0x1d", + "transactionLogIndex": "0x22", "removed": false }, { @@ -481,12 +495,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000011d2257ba00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000636f72652e73000000000000000000001d2257ba00000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x23", - "transactionLogIndex": "0x1e", + "transactionLogIndex": "0x23", "removed": false }, { @@ -495,12 +509,12 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x00000000000000000000000000000000496e7374616c6c65644d6f64756c6573000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002636f72652e6d0000000000000000000000000000000000000000000000000000c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a4700000000000000000000000000000000000000000000000000000000000000014e7f1725e7734ce288f8367e1bb143e90bb3f0512000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x99deb14acfd37070907742a1e1132b770fa6d08a4ac6cf48c67c26ddd9ab1fa2", - "transactionIndex": "0x7", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xae82b15a8c62db1e23d9c523e730d9b861eed20529b8cff4d3452f86ae3149df", + "transactionIndex": "0x0", "logIndex": "0x24", - "transactionLogIndex": "0x1f", + "transactionLogIndex": "0x24", "removed": false }, { @@ -509,10 +523,10 @@ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], "data": "0x000000000000000000000000000000005265736f7572636554797065000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000004e756d6265724c69737400000000000000000000000000000000000000000000000000000000000000000000000000010200000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x2a37be40264ec61f831b80f2ba86de357880aca3543deef9af1da49f512d767a", - "transactionIndex": "0x8", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0x7bca8d7dabf72bfa9ff127d2d2fac95a747b5cbd45e44d820789f14a6d340d2f", + "transactionIndex": "0x1", "logIndex": "0x25", "transactionLogIndex": "0x0", "removed": false @@ -523,10 +537,10 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000004e756d6265724c697374000000000000000000000000000000000000000000000000000000000000000000000000016000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000040000000000000e000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000576616c7565000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x2a37be40264ec61f831b80f2ba86de357880aca3543deef9af1da49f512d767a", - "transactionIndex": "0x8", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0x7bca8d7dabf72bfa9ff127d2d2fac95a747b5cbd45e44d820789f14a6d340d2f", + "transactionIndex": "0x1", "logIndex": "0x26", "transactionLogIndex": "0x1", "removed": false @@ -536,11 +550,11 @@ "topics": [ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], - "data": "0x000000000000000000000000000000005265736f7572636554797065000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000566563746f720000000000000000000000000000000000000000000000000000000000000000000000000000000000010200000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xf0a076b9fa7fba5660e3ea38e2cc3f839ac119fafe6e621a52dd4d48412547b6", - "transactionIndex": "0x9", + "data": "0x000000000000000000000000000000005265736f7572636554797065000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000437573746f6d4572726f72735379737400000000000000000000000000000000000000000000000000000000000000010300000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xb5f9defc11305940c4b08a6f34cdb4a671fde33905f288048b70c85b1d0875eb", + "transactionIndex": "0x2", "logIndex": "0x27", "transactionLogIndex": "0x0", "removed": false @@ -550,11 +564,11 @@ "topics": [ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], - "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000566563746f72000000000000000000000000000000000000000000000000000000000000000000000000000000000220000802000404000000000000000000000000000000000000000000000000000000040100030000000000000000000000000000000000000000000000000000000008020023230000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000a0000000000001a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000036b6579000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001780000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017900000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xf0a076b9fa7fba5660e3ea38e2cc3f839ac119fafe6e621a52dd4d48412547b6", - "transactionIndex": "0x9", + "data": "0x0000000000000000000000000000000053797374656d73000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000437573746f6d4572726f72735379737400000000000000000000000000000000000000000000000000000000000000155fc8d32690cc91d4c39d9d3abcbd16989f875707010000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xb5f9defc11305940c4b08a6f34cdb4a671fde33905f288048b70c85b1d0875eb", + "transactionIndex": "0x2", "logIndex": "0x28", "transactionLogIndex": "0x1", "removed": false @@ -564,27 +578,27 @@ "topics": [ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], - "data": "0x000000000000000000000000000000005265736f7572636554797065000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000004e756d6265720000000000000000000000000000000000000000000000000000000000000000000000000000000000010200000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xa22266979e22263283f576d1dc598465908c7cd4ed7d40c7434a1887a94a773b", - "transactionIndex": "0xa", + "data": "0x0000000000000000000000000000000053797374656d526567697374727900000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000005fc8d32690cc91d4c39d9d3abcbd16989f875707000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000437573746f6d4572726f727353797374", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xb5f9defc11305940c4b08a6f34cdb4a671fde33905f288048b70c85b1d0875eb", + "transactionIndex": "0x2", "logIndex": "0x29", - "transactionLogIndex": "0x0", + "transactionLogIndex": "0x2", "removed": false }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" + "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], - "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000004e756d6265720000000000000000000000000000000000000000000000000000000000000000000000000000000001c000040100040000000000000000000000000000000000000000000000000000000004010003000000000000000000000000000000000000000000000000000000000401000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000a00000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000036b65790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000576616c7565000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xa22266979e22263283f576d1dc598465908c7cd4ed7d40c7434a1887a94a773b", - "transactionIndex": "0xa", + "data": "0x000000000000000000000000000000005265736f7572636541636365737300000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000005fc8d32690cc91d4c39d9d3abcbd16989f87570700000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xb5f9defc11305940c4b08a6f34cdb4a671fde33905f288048b70c85b1d0875eb", + "transactionIndex": "0x2", "logIndex": "0x2a", - "transactionLogIndex": "0x1", + "transactionLogIndex": "0x3", "removed": false }, { @@ -592,11 +606,11 @@ "topics": [ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], - "data": "0x000000000000000000000000000000005265736f7572636554797065000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000437573746f6d4572726f72735379737400000000000000000000000000000000000000000000000000000000000000010300000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xa019744ca59e63a91c327629d7137ec2d851787e922d8d9f48c8e74c3b622453", - "transactionIndex": "0xb", + "data": "0x000000000000000000000000000000005265736f7572636554797065000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000004e756d6265724c69737453797374656d00000000000000000000000000000000000000000000000000000000000000010300000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0x5e56042175cee9139c0439cc0df13d0efbdb1a57e93e5353f8fc713ea061bfce", + "transactionIndex": "0x3", "logIndex": "0x2b", "transactionLogIndex": "0x0", "removed": false @@ -606,11 +620,11 @@ "topics": [ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], - "data": "0x0000000000000000000000000000000053797374656d73000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000437573746f6d4572726f72735379737400000000000000000000000000000000000000000000000000000000000000155fc8d32690cc91d4c39d9d3abcbd16989f875707010000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xa019744ca59e63a91c327629d7137ec2d851787e922d8d9f48c8e74c3b622453", - "transactionIndex": "0xb", + "data": "0x0000000000000000000000000000000053797374656d73000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000004e756d6265724c69737453797374656d00000000000000000000000000000000000000000000000000000000000000150165878a594ca255338adfa4d48449f69242eb8f010000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0x5e56042175cee9139c0439cc0df13d0efbdb1a57e93e5353f8fc713ea061bfce", + "transactionIndex": "0x3", "logIndex": "0x2c", "transactionLogIndex": "0x1", "removed": false @@ -620,11 +634,11 @@ "topics": [ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], - "data": "0x0000000000000000000000000000000053797374656d526567697374727900000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000005fc8d32690cc91d4c39d9d3abcbd16989f875707000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000437573746f6d4572726f727353797374", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xa019744ca59e63a91c327629d7137ec2d851787e922d8d9f48c8e74c3b622453", - "transactionIndex": "0xb", + "data": "0x0000000000000000000000000000000053797374656d526567697374727900000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000004e756d6265724c69737453797374656d", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0x5e56042175cee9139c0439cc0df13d0efbdb1a57e93e5353f8fc713ea061bfce", + "transactionIndex": "0x3", "logIndex": "0x2d", "transactionLogIndex": "0x2", "removed": false @@ -634,11 +648,11 @@ "topics": [ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], - "data": "0x000000000000000000000000000000005265736f7572636541636365737300000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000005fc8d32690cc91d4c39d9d3abcbd16989f87570700000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xa019744ca59e63a91c327629d7137ec2d851787e922d8d9f48c8e74c3b622453", - "transactionIndex": "0xb", + "data": "0x000000000000000000000000000000005265736f7572636541636365737300000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f00000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0x5e56042175cee9139c0439cc0df13d0efbdb1a57e93e5353f8fc713ea061bfce", + "transactionIndex": "0x3", "logIndex": "0x2e", "transactionLogIndex": "0x3", "removed": false @@ -648,11 +662,11 @@ "topics": [ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], - "data": "0x000000000000000000000000000000005265736f7572636554797065000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000004e756d6265724c69737453797374656d00000000000000000000000000000000000000000000000000000000000000010300000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x63c06061f3c8f9e8dfe3dfcf955082539d44d2bccefe66b943c5f481337b5f61", - "transactionIndex": "0xc", + "data": "0x000000000000000000000000000000005265736f7572636554797065000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000566563746f720000000000000000000000000000000000000000000000000000000000000000000000000000000000010200000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xb3febd63ed51098bd7062390e4e859508e55a1bbfa5ee8ec197a4df93586f632", + "transactionIndex": "0x4", "logIndex": "0x2f", "transactionLogIndex": "0x0", "removed": false @@ -662,11 +676,11 @@ "topics": [ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], - "data": "0x0000000000000000000000000000000053797374656d73000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000004e756d6265724c69737453797374656d00000000000000000000000000000000000000000000000000000000000000150165878a594ca255338adfa4d48449f69242eb8f010000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x63c06061f3c8f9e8dfe3dfcf955082539d44d2bccefe66b943c5f481337b5f61", - "transactionIndex": "0xc", + "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000566563746f72000000000000000000000000000000000000000000000000000000000000000000000000000000000220000802000404000000000000000000000000000000000000000000000000000000040100030000000000000000000000000000000000000000000000000000000008020023230000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000a0000000000001a000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000036b6579000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001780000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000017900000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xb3febd63ed51098bd7062390e4e859508e55a1bbfa5ee8ec197a4df93586f632", + "transactionIndex": "0x4", "logIndex": "0x30", "transactionLogIndex": "0x1", "removed": false @@ -676,27 +690,27 @@ "topics": [ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], - "data": "0x0000000000000000000000000000000053797374656d526567697374727900000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000004e756d6265724c69737453797374656d", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x63c06061f3c8f9e8dfe3dfcf955082539d44d2bccefe66b943c5f481337b5f61", - "transactionIndex": "0xc", + "data": "0x000000000000000000000000000000005265736f7572636554797065000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000004e756d6265720000000000000000000000000000000000000000000000000000000000000000000000000000000000010200000000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xd9aea844188d36cd599b3d9ddd523b1269131ec10ebf5b107a50bffe8a03985e", + "transactionIndex": "0x5", "logIndex": "0x31", - "transactionLogIndex": "0x2", + "transactionLogIndex": "0x0", "removed": false }, { "address": "0x5fbdb2315678afecb367f032d93f642f64180aa3", "topics": [ - "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" + "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], - "data": "0x000000000000000000000000000000005265736f7572636541636365737300000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000165878a594ca255338adfa4d48449f69242eb8f00000000000000000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x63c06061f3c8f9e8dfe3dfcf955082539d44d2bccefe66b943c5f481337b5f61", - "transactionIndex": "0xc", + "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000004e756d6265720000000000000000000000000000000000000000000000000000000000000000000000000000000001c000040100040000000000000000000000000000000000000000000000000000000004010003000000000000000000000000000000000000000000000000000000000401000300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000a00000000000014000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000036b65790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000576616c7565000000000000000000000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xd9aea844188d36cd599b3d9ddd523b1269131ec10ebf5b107a50bffe8a03985e", + "transactionIndex": "0x5", "logIndex": "0x32", - "transactionLogIndex": "0x3", + "transactionLogIndex": "0x1", "removed": false }, { @@ -705,10 +719,10 @@ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], "data": "0x000000000000000000000000000000005265736f7572636554797065000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000004d756c7469000000000000000000000000000000000000000000000000000000000000000000000000000000000000010200000000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xd24893f65a6b85dc7d9644726e7f03fddc4edc256d956f2965ef800c134e0719", - "transactionIndex": "0xd", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xa50c88a503c25f17dc6c8e4cc779f15341f6f8242da501989a64ec87a8f5a85b", + "transactionIndex": "0x6", "logIndex": "0x33", "transactionLogIndex": "0x0", "removed": false @@ -719,10 +733,10 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x6d756473746f726500000000000000005461626c657300000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000004d756c74690000000000000000000000000000000000000000000000000000000000000000000000000000000000034000210200200100000000000000000000000000000000000000000000000000000034040003601f2e000000000000000000000000000000000000000000000000002102003f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000001c0000000000002c000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000016100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000162000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001630000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000016400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000036e756d0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000576616c7565000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xd24893f65a6b85dc7d9644726e7f03fddc4edc256d956f2965ef800c134e0719", - "transactionIndex": "0xd", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0xa50c88a503c25f17dc6c8e4cc779f15341f6f8242da501989a64ec87a8f5a85b", + "transactionIndex": "0x6", "logIndex": "0x34", "transactionLogIndex": "0x1", "removed": false @@ -732,11 +746,11 @@ "topics": [ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], - "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000015f644e3c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000437573746f6d4572726f7273537973745f644e3c00000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x7457d2e10dd336429a4077839674b8a346fb220ff17b4058a0a385b981b58cb5", - "transactionIndex": "0xe", + "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001306d61a5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000004e756d6265724c69737453797374656d306d61a500000000000000000000000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0x2fc64bbab454451eca5989fa793399718795f92515de1032447065da3dec0201", + "transactionIndex": "0x7", "logIndex": "0x35", "transactionLogIndex": "0x0", "removed": false @@ -747,10 +761,10 @@ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001b8a44c7c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000004e756d6265724c69737453797374656db8a44c7c00000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x21e16439547f1c2a365efc548780b3cbd47ef74bdbbd55cde27c9d55458842f2", - "transactionIndex": "0xf", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0x704d3a95376db47cabae3ba83743e46e1eb751b82a9b622af5a555e109d59a66", + "transactionIndex": "0x8", "logIndex": "0x36", "transactionLogIndex": "0x0", "removed": false @@ -760,11 +774,11 @@ "topics": [ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], - "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001306d61a5000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000004e756d6265724c69737453797374656d306d61a500000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xe76907051c864ea6d12f038a0423ac6043ffe4aedf405378f25c6f8a63dc038c", - "transactionIndex": "0x10", + "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001f7f0e440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000004e756d6265724c69737453797374656df7f0e44000000000000000000000000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0x39116de046d5a63b1624f2556f78148c5bfaf0011b126598d96615cbbf89dc7f", + "transactionIndex": "0x9", "logIndex": "0x37", "transactionLogIndex": "0x0", "removed": false @@ -774,11 +788,11 @@ "topics": [ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], - "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001a4ece52c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000004e756d6265724c69737453797374656da4ece52c00000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0x83c2546f45504545c8921d74dce1335f7db65f2c573b14971dc283a0abb427a2", - "transactionIndex": "0x11", + "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000015f644e3c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000000000000437573746f6d4572726f7273537973745f644e3c00000000000000000000000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0x6f143315ee4b6e8f64a70bf520ea301db90a677eda48a9f423bd5d1f5b4a1c28", + "transactionIndex": "0xa", "logIndex": "0x38", "transactionLogIndex": "0x0", "removed": false @@ -788,11 +802,11 @@ "topics": [ "0x912af873e852235aae78a1d25ae9bb28b616a67c36898c53a14fd8184504ee32" ], - "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001f7f0e440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000004e756d6265724c69737453797374656df7f0e44000000000000000000000000000000000000000000000000000000000", - "blockHash": "0xc69c386d859fa05880ce8c651bf668d7db8b91b038ace616e20d7502917815e0", - "blockNumber": "0x2", - "transactionHash": "0xaee239c8f1398730a2f5e8c2426cd47f8d39a4c66e2d73155b4dcd73f3b45e68", - "transactionIndex": "0x12", + "data": "0x0000000000000000000000000000000046756e6374696f6e53656c6563746f72000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001a4ece52c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000004e756d6265724c69737453797374656da4ece52c00000000000000000000000000000000000000000000000000000000", + "blockHash": "0x29d9d51112d3304c99e265986b1b441446c3384dc8268d11e105c6f86c4a85ac", + "blockNumber": "0x4", + "transactionHash": "0x0f4f8c0ea36e9e8e88cdd2f5719f2ffa36a3698bdf7fe2b8443685d35517d6ea", + "transactionIndex": "0xb", "logIndex": "0x39", "transactionLogIndex": "0x0", "removed": false @@ -803,9 +817,9 @@ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], "data": "0x000000000000000000000000000000004e756d6265724c6973740000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000001a400000000000000000000000000000000000000000000000000000000", - "blockHash": "0x54705c7c1c71954d18db182c27c85def952826a0f7c9e09e933ad90a29e1ccd9", - "blockNumber": "0x3", - "transactionHash": "0xedae06dc8024b7b364f6ef80597edfb3c595b4b0eba21b9f0afb683c0ad4ea64", + "blockHash": "0xaff54c40af4b26fae5bfcbb5187e698f5e4a54c338fac1e9ddbcdef5eb979c6b", + "blockNumber": "0x5", + "transactionHash": "0x6b11c4b4d9257da889cd755a9aef98068339dea0770f3c43def5293c47977876", "transactionIndex": "0x0", "logIndex": "0x0", "transactionLogIndex": "0x0", @@ -817,9 +831,9 @@ "0xd01f9f1368f831528fc9fe6442366b2b7d957fbfff3bcf7c24d9ab5fe51f8c46" ], "data": "0x000000000000000000000000000000004e756d6265724c6973740000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008000001a400000045000000000000000000000000000000000000000000000000", - "blockHash": "0x54705c7c1c71954d18db182c27c85def952826a0f7c9e09e933ad90a29e1ccd9", - "blockNumber": "0x3", - "transactionHash": "0xf457c087993354a5ca9d86b59df3f8d355d23fb441386fb70bddf09770e3bc21", + "blockHash": "0xaff54c40af4b26fae5bfcbb5187e698f5e4a54c338fac1e9ddbcdef5eb979c6b", + "blockNumber": "0x5", + "transactionHash": "0x2453e912dfab0eed54e6140d2f5c829034fe51fa844767991510eb71ecff8a3b", "transactionIndex": "0x1", "logIndex": "0x1", "transactionLogIndex": "0x0", From 036387b72d699605005d41de1e0374ddb43a5494 Mon Sep 17 00:00:00 2001 From: alvrs Date: Fri, 15 Sep 2023 11:00:40 +0100 Subject: [PATCH 16/19] review feedback --- packages/store/test/StoreCoreGas.t.sol | 42 +++++++++---------- .../modules/keysintable/KeysInTableHook.sol | 2 +- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/store/test/StoreCoreGas.t.sol b/packages/store/test/StoreCoreGas.t.sol index 122e0127cf..58f768d935 100644 --- a/packages/store/test/StoreCoreGas.t.sol +++ b/packages/store/test/StoreCoreGas.t.sol @@ -52,7 +52,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { fieldNames[2] = "value3"; fieldNames[3] = "value4"; - startGasReport("StoreCore: register tableId"); + startGasReport("StoreCore: Register table"); StoreCore.registerTable(tableId, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); endGasReport(); @@ -78,15 +78,15 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { ); FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(1, 2, 1, 2, 0); bytes32 tableId = keccak256("some.tableId"); - bytes32 table2 = keccak256("other.tableId"); + bytes32 tableId2 = keccak256("other.tableId"); StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](4)); - startGasReport("Check for existence of tableId (existent)"); + startGasReport("Check for existence of table (existent)"); StoreCore.hasTable(tableId); endGasReport(); - startGasReport("check for existence of tableId (non-existent)"); - StoreCore.hasTable(table2); + startGasReport("check for existence of table (non-existent)"); + StoreCore.hasTable(tableId2); endGasReport(); } @@ -103,7 +103,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(1, 2, 4, 2); - // Register tableId + // Register table StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](5)); // Create some key @@ -127,7 +127,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { } function testSetAndGetStaticData() public { - // Register tableId + // Register table Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT8, SchemaType.UINT16, @@ -154,7 +154,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { } function testSetAndGetStaticDataSpanningWords() public { - // Register tableId + // Register table Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT256); FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 32, 0); bytes32 tableId = keccak256("some.tableId"); @@ -182,7 +182,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { function testSetAndGetDynamicData() public { bytes32 tableId = keccak256("some.tableId"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, @@ -258,7 +258,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { function testSetAndGetField() public { bytes32 tableId = keccak256("some.tableId"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, @@ -348,7 +348,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { function testDeleteData() public { bytes32 tableId = keccak256("some.tableId"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, @@ -405,7 +405,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { function testPushToField() public { bytes32 tableId = keccak256("some.tableId"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT256, @@ -492,7 +492,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { TestUpdateInFieldData memory data = TestUpdateInFieldData("", "", "", "", "", "", ""); bytes32 tableId = keccak256("some.tableId"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT256, @@ -602,7 +602,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some key"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 0); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128); StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](1)); @@ -634,17 +634,17 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes memory data = abi.encodePacked(bytes16(0x0102030405060708090a0b0c0d0e0f10)); - startGasReport("set record on tableId with subscriber"); + startGasReport("set record on table with subscriber"); StoreCore.setRecord(tableId, key, data, fieldLayout); endGasReport(); data = abi.encodePacked(bytes16(0x1112131415161718191a1b1c1d1e1f20)); - startGasReport("set static field on tableId with subscriber"); + startGasReport("set static field on table with subscriber"); StoreCore.setField(tableId, key, 0, data, fieldLayout); endGasReport(); - startGasReport("delete record on tableId with subscriber"); + startGasReport("delete record on table with subscriber"); StoreCore.deleteRecord(tableId, key, fieldLayout); endGasReport(); } @@ -654,7 +654,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some key"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 1); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT32_ARRAY); StoreCore.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); @@ -692,7 +692,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { bytes memory staticData = abi.encodePacked(bytes16(0x0102030405060708090a0b0c0d0e0f10)); bytes memory data = abi.encodePacked(staticData, dynamicData); - startGasReport("set (dynamic) record on tableId with subscriber"); + startGasReport("set (dynamic) record on table with subscriber"); StoreCore.setRecord(tableId, key, data, fieldLayout); endGasReport(); @@ -702,11 +702,11 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { dynamicData = abi.encodePacked(encodedArrayDataLength.unwrap(), arrayDataBytes); data = abi.encodePacked(staticData, dynamicData); - startGasReport("set (dynamic) field on tableId with subscriber"); + startGasReport("set (dynamic) field on table with subscriber"); StoreCore.setField(tableId, key, 1, arrayDataBytes, fieldLayout); endGasReport(); - startGasReport("delete (dynamic) record on tableId with subscriber"); + startGasReport("delete (dynamic) record on table with subscriber"); StoreCore.deleteRecord(tableId, key, fieldLayout); endGasReport(); } diff --git a/packages/world/src/modules/keysintable/KeysInTableHook.sol b/packages/world/src/modules/keysintable/KeysInTableHook.sol index 1953bea6ea..706ebac740 100644 --- a/packages/world/src/modules/keysintable/KeysInTableHook.sol +++ b/packages/world/src/modules/keysintable/KeysInTableHook.sol @@ -8,7 +8,7 @@ import { KeysInTable } from "./tables/KeysInTable.sol"; import { UsedKeysIndex } from "./tables/UsedKeysIndex.sol"; /** - * Note: if a tableId with composite keys is used, only the first key is indexed + * Note: if a table with composite keys is used, only the first key is indexed */ contract KeysInTableHook is StoreHook { function handleSet(bytes32 tableId, bytes32[] memory key) internal { From 8a8fa98738ff112b63132408a06ff3abc455e9cf Mon Sep 17 00:00:00 2001 From: alvrs Date: Fri, 15 Sep 2023 11:17:58 +0100 Subject: [PATCH 17/19] remove more instances of tableId and revert invalid ones --- packages/store/src/StoreCore.sol | 2 +- packages/store/test/StoreCore.t.sol | 40 ++++++++++---------- packages/world/test/World.t.sol | 24 ++---------- packages/world/test/WorldDynamicUpdate.t.sol | 12 +----- 4 files changed, 26 insertions(+), 52 deletions(-) diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 112ab25a0f..46f010e9e8 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -165,7 +165,7 @@ library StoreCore { * Set full data record for the given tableId and key tuple and field layout */ function setRecord(bytes32 tableId, bytes32[] memory key, bytes memory data, FieldLayout fieldLayout) internal { - // verify the value has the correct length for the tableId (based on the tableId's field layout) + // verify the value has the correct length for the table (based on the table's field layout) // to prevent invalid data from being stored // Verify static data length + dynamic data length matches the given data diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index 2737f417f2..ad1b84685b 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -160,11 +160,11 @@ contract StoreCoreTest is Test, StoreMock { string[] memory fourNames = new string[](4); string[] memory oneName = new string[](1); - // Register tableId with invalid key names + // Register table with invalid key names vm.expectRevert(abi.encodeWithSelector(IStoreErrors.StoreCore_InvalidKeyNamesLength.selector, 4, 1)); IStore(this).registerTable(tableId, fieldLayout, keySchema, valueSchema, oneName, oneName); - // Register tableId with invalid value names + // Register table with invalid value names vm.expectRevert(abi.encodeWithSelector(IStoreErrors.StoreCore_InvalidFieldNamesLength.selector, 1, 4)); IStore(this).registerTable(tableId, fieldLayout, keySchema, valueSchema, fourNames, fourNames); } @@ -181,7 +181,7 @@ contract StoreCoreTest is Test, StoreMock { SchemaType.UINT32_ARRAY ); - // Register tableId + // Register table IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](5)); // Create some key @@ -214,7 +214,7 @@ contract StoreCoreTest is Test, StoreMock { } function testSetAndGetStaticData() public { - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(1, 2, 1, 2, 0); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT8, @@ -245,7 +245,7 @@ contract StoreCoreTest is Test, StoreMock { } function testFailSetAndGetStaticData() public { - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(1, 2, 1, 2, 0); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT8, @@ -267,7 +267,7 @@ contract StoreCoreTest is Test, StoreMock { } function testSetAndGetStaticDataSpanningWords() public { - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 32, 0); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT256); bytes32 tableId = keccak256("some.tableId"); @@ -297,7 +297,7 @@ contract StoreCoreTest is Test, StoreMock { function testSetAndGetDynamicData() public { bytes32 tableId = keccak256("some.tableId"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, @@ -372,7 +372,7 @@ contract StoreCoreTest is Test, StoreMock { function testSetAndGetField() public { bytes32 tableId = keccak256("some.tableId"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, @@ -512,7 +512,7 @@ contract StoreCoreTest is Test, StoreMock { function testDeleteData() public { bytes32 tableId = keccak256("some.tableId"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT128, @@ -596,7 +596,7 @@ contract StoreCoreTest is Test, StoreMock { data.tableId = keccak256("some.tableId"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT256, @@ -736,7 +736,7 @@ contract StoreCoreTest is Test, StoreMock { data.tableId = keccak256("some.tableId"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(32, 2); Schema valueSchema = SchemaEncodeHelper.encode( SchemaType.UINT256, @@ -882,7 +882,7 @@ contract StoreCoreTest is Test, StoreMock { bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some key"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 0); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128); IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](1)); @@ -914,7 +914,7 @@ contract StoreCoreTest is Test, StoreMock { IStore(this).setRecord(tableId, key, data, fieldLayout); - // Get data from indexed tableId - the indexer should have mirrored the data there + // Get data from indexed table - the indexer should have mirrored the data there bytes memory indexedData = IStore(this).getRecord(indexerTableId, key, fieldLayout); assertEq(keccak256(data), keccak256(indexedData)); @@ -922,13 +922,13 @@ contract StoreCoreTest is Test, StoreMock { IStore(this).setField(tableId, key, 0, data, fieldLayout); - // Get data from indexed tableId - the indexer should have mirrored the data there + // Get data from indexed table - the indexer should have mirrored the data there indexedData = IStore(this).getRecord(indexerTableId, key, fieldLayout); assertEq(keccak256(data), keccak256(indexedData)); IStore(this).deleteRecord(tableId, key, fieldLayout); - // Get data from indexed tableId - the indexer should have mirrored the data there + // Get data from indexed table - the indexer should have mirrored the data there indexedData = IStore(this).getRecord(indexerTableId, key, fieldLayout); assertEq(keccak256(indexedData), keccak256(abi.encodePacked(bytes16(0)))); } @@ -938,7 +938,7 @@ contract StoreCoreTest is Test, StoreMock { bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some key"); - // Register tableId's value schema + // Register table's value schema FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 0); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128); IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](1)); @@ -1027,7 +1027,7 @@ contract StoreCoreTest is Test, StoreMock { bytes32[] memory key = new bytes32[](1); key[0] = keccak256("some key"); - // Register tableId + // Register table FieldLayout fieldLayout = FieldLayoutEncodeHelper.encode(16, 1); Schema valueSchema = SchemaEncodeHelper.encode(SchemaType.UINT128, SchemaType.UINT32_ARRAY); IStore(this).registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](2)); @@ -1065,7 +1065,7 @@ contract StoreCoreTest is Test, StoreMock { IStore(this).setRecord(tableId, key, data, fieldLayout); - // Get data from indexed tableId - the indexer should have mirrored the data there + // Get data from indexed table - the indexer should have mirrored the data there bytes memory indexedData = IStore(this).getRecord(indexerTableId, key, fieldLayout); assertEq(keccak256(data), keccak256(indexedData)); @@ -1077,13 +1077,13 @@ contract StoreCoreTest is Test, StoreMock { IStore(this).setField(tableId, key, 1, arrayDataBytes, fieldLayout); - // Get data from indexed tableId - the indexer should have mirrored the data there + // Get data from indexed table - the indexer should have mirrored the data there indexedData = IStore(this).getRecord(indexerTableId, key, fieldLayout); assertEq(keccak256(data), keccak256(indexedData)); IStore(this).deleteRecord(tableId, key, fieldLayout); - // Get data from indexed tableId - the indexer should have mirrored the data there + // Get data from indexed table - the indexer should have mirrored the data there indexedData = IStore(this).getRecord(indexerTableId, key, fieldLayout); assertEq(keccak256(indexedData), keccak256(abi.encodePacked(bytes16(0)))); } diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index 640782c591..f130c04ebe 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -559,17 +559,7 @@ contract WorldTest is Test, GasReporter { // Expect the data to be written assertTrue(Bool.get(world, tableId)); - // Write data to the table via its tableId - world.setField(tableId, singletonKey, 0, abi.encodePacked(false), fieldLayout); - - // Expect the data to be written - assertFalse(Bool.get(world, tableId)); - - // Expect an error when trying to write from an address that doesn't have access when calling via the namespace - _expectAccessDenied(address(0x01), "testSetField", "testTable"); - world.setField(tableId, singletonKey, 0, abi.encodePacked(true), fieldLayout); - - // Expect an error when trying to write from an address that doesn't have access when calling via the tableId + // Expect an error when trying to write from an address that doesn't have access _expectAccessDenied(address(0x01), "testSetField", "testTable"); world.setField(tableId, singletonKey, 0, abi.encodePacked(true), fieldLayout); @@ -630,7 +620,7 @@ contract WorldTest is Test, GasReporter { // Register a new table world.registerTable(tableId, fieldLayout, defaultKeySchema, valueSchema, new string[](1), new string[](1)); - // Write data to the table via the namespace and expect it to be written + // Write data to the table and expect it to be written world.setRecord(tableId, singletonKey, abi.encodePacked(true), fieldLayout); assertTrue(Bool.get(world, tableId)); @@ -641,15 +631,7 @@ contract WorldTest is Test, GasReporter { // expect it to be deleted assertFalse(Bool.get(world, tableId)); - // Write data to the table via the namespace and expect it to be written - world.setRecord(tableId, singletonKey, abi.encodePacked(true), fieldLayout); - assertTrue(Bool.get(world, tableId)); - - // Delete the record via the tableId and expect it to be deleted - world.deleteRecord(tableId, singletonKey, fieldLayout); - assertFalse(Bool.get(world, tableId)); - - // Write data to the table via the namespace and expect it to be written + // Write data to the table and expect it to be written world.setRecord(tableId, singletonKey, abi.encodePacked(true), fieldLayout); assertTrue(Bool.get(world, tableId)); diff --git a/packages/world/test/WorldDynamicUpdate.t.sol b/packages/world/test/WorldDynamicUpdate.t.sol index fe84fdbc75..e2bea13264 100644 --- a/packages/world/test/WorldDynamicUpdate.t.sol +++ b/packages/world/test/WorldDynamicUpdate.t.sol @@ -128,11 +128,7 @@ contract UpdateInFieldTest is Test, GasReporter { assertEq(loadedData[i], initData[i]); } - // Expect an error when trying to write from an address that doesn't have access (via namespace/name) - _expectAccessDenied(address(0x01), tableId); - world.popFromField(tableId, keyTuple, 0, 20, fieldLayout); - - // Expect an error when trying to write from an address that doesn't have access (via tableId) + // Expect an error when trying to write from an address that doesn't have access _expectAccessDenied(address(0x01), tableId); world.popFromField(tableId, keyTuple, 0, 20, fieldLayout); @@ -170,11 +166,7 @@ contract UpdateInFieldTest is Test, GasReporter { initData[1] = dataForUpdate[0]; assertEq(AddressArray.get(world, tableId, key), initData); - // Expect an error when trying to write from an address that doesn't have access (via namespace/name) - _expectAccessDenied(address(0x01), tableId); - world.updateInField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate), fieldLayout); - - // Expect an error when trying to write from an address that doesn't have access (via tableId) + // Expect an error when trying to write from an address that doesn't have access _expectAccessDenied(address(0x01), tableId); world.updateInField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate), fieldLayout); From fb85f1064c0ad9f77c66a76e147ac261ede29bd7 Mon Sep 17 00:00:00 2001 From: alvrs Date: Fri, 15 Sep 2023 11:28:36 +0100 Subject: [PATCH 18/19] gas report --- packages/store/gas-report.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index b0519b048d..0c0fea234d 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -626,13 +626,13 @@ { "file": "test/StoreCoreGas.t.sol", "test": "testHasFieldLayout", - "name": "Check for existence of tableId (existent)", + "name": "Check for existence of table (existent)", "gasUsed": 4465 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHasFieldLayout", - "name": "check for existence of tableId (non-existent)", + "name": "check for existence of table (non-existent)", "gasUsed": 6468 }, { @@ -644,19 +644,19 @@ { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", - "name": "set record on tableId with subscriber", + "name": "set record on table with subscriber", "gasUsed": 73748 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", - "name": "set static field on tableId with subscriber", + "name": "set static field on table with subscriber", "gasUsed": 25441 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooks", - "name": "delete record on tableId with subscriber", + "name": "delete record on table with subscriber", "gasUsed": 21483 }, { @@ -668,20 +668,20 @@ { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", - "name": "set (dynamic) record on tableId with subscriber", + "name": "set (dynamic) record on table with subscriber", "gasUsed": 167808 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", - "name": "set (dynamic) field on tableId with subscriber", + "name": "set (dynamic) field on table with subscriber", "gasUsed": 28269 }, { "file": "test/StoreCoreGas.t.sol", "test": "testHooksDynamicData", - "name": "delete (dynamic) record on tableId with subscriber", - "gasUsed": 22905 + "name": "delete (dynamic) record on table with subscriber", + "gasUsed": 22901 }, { "file": "test/StoreCoreGas.t.sol", @@ -698,7 +698,7 @@ { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", - "name": "StoreCore: register tableId", + "name": "StoreCore: Register table", "gasUsed": 620356 }, { From 8854d926a98ef37eb495a239aa0c184a796b7511 Mon Sep 17 00:00:00 2001 From: alvrs Date: Fri, 15 Sep 2023 12:26:05 +0100 Subject: [PATCH 19/19] gas report --- packages/store/gas-report.json | 2 +- packages/store/test/StoreCoreGas.t.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/store/gas-report.json b/packages/store/gas-report.json index 0c0fea234d..06772c450b 100644 --- a/packages/store/gas-report.json +++ b/packages/store/gas-report.json @@ -698,7 +698,7 @@ { "file": "test/StoreCoreGas.t.sol", "test": "testRegisterAndGetFieldLayout", - "name": "StoreCore: Register table", + "name": "StoreCore: register table", "gasUsed": 620356 }, { diff --git a/packages/store/test/StoreCoreGas.t.sol b/packages/store/test/StoreCoreGas.t.sol index 58f768d935..8a826be357 100644 --- a/packages/store/test/StoreCoreGas.t.sol +++ b/packages/store/test/StoreCoreGas.t.sol @@ -52,7 +52,7 @@ contract StoreCoreGasTest is Test, GasReporter, StoreMock { fieldNames[2] = "value3"; fieldNames[3] = "value4"; - startGasReport("StoreCore: Register table"); + startGasReport("StoreCore: register table"); StoreCore.registerTable(tableId, fieldLayout, keySchema, valueSchema, keyNames, fieldNames); endGasReport();