Skip to content

Commit

Permalink
refactor: remove */config/v2 exports (#3322)
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored Oct 23, 2024
1 parent dfc2d64 commit 1712814
Show file tree
Hide file tree
Showing 34 changed files with 46 additions and 62 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CollapseCode } from "../../../components/CollapseCode";
import { CollapseCode } from "../../components/CollapseCode";

# Extending a World Permissionlessly
# Extending a World

On this page you learn how to modify a `World` that is already deployed to the blockchain, without using a privileged address, such as the one that initially deployed it.
If you want to learn how to modify a `World` before it is deployed, [see the hello world page](../hello-world).
Expand Down Expand Up @@ -660,7 +660,7 @@ We will fix these problems now.
1. Now you can click **Increment** in the user interface and create messages.
The user interface does not display those messages, but you can open the **MUD Dev Tools**, click the **Components** tab, and select **messagings\_\_Messages** to view them.

![The extended UI with the messages shown in the MUD Dev Tools](./extend-ui-with-msgs.png)
![The extended UI with the messages shown in the MUD Dev Tools](./extending-a-world/extend-ui-with-msgs.png)

### Read the counter

Expand Down Expand Up @@ -696,7 +696,7 @@ We will now fix this.

<CollapseCode>

```ts filename="setupNetwork.ts" copy showLineNumbers {24-25,38,96}
```ts filename="setupNetwork.ts" copy showLineNumbers {34,92}
/*
* The MUD client code is built on top of viem
* (https://viem.sh/docs/getting-started.html).
Expand All @@ -719,10 +719,6 @@ We will now fix this.
import IWorldAbi from "contracts/out/IWorld.sol/IWorld.abi.json";
import { createBurnerAccount, transportObserver, ContractWrite } from "@latticexyz/common";
import { transactionQueue, writeObserver } from "@latticexyz/common/actions";

import { resolveConfig } from "@latticexyz/store/internal";
import { storeToV1 } from "@latticexyz/store/config/v2";

import { Subject, share } from "rxjs";

/*
Expand Down Expand Up @@ -792,7 +788,7 @@ We will now fix this.
address: networkConfig.worldAddress as Hex,
publicClient,
startBlock: BigInt(networkConfig.initialBlockNumber),
tables: resolveConfig(storeToV1(counterConfig)).tables,
tables: counterConfig.tables,
});

return {
Expand Down
3 changes: 0 additions & 3 deletions docs/pages/guides/extending-a-world/_meta.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/dev-tools/src/mount.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Store as StoreConfig } from "@latticexyz/store/config/v2";
import type { Store as StoreConfig } from "@latticexyz/store";
import type { DevToolsOptions } from "./common";

const containerId = "mud-dev-tools";
Expand Down
2 changes: 1 addition & 1 deletion packages/stash/src/actions/decodeKey.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it } from "vitest";
import { createStash } from "../createStash";
import { defineStore } from "@latticexyz/store/config/v2";
import { defineStore } from "@latticexyz/store";
import { setRecord } from "./setRecord";
import { encodeKey } from "./encodeKey";
import { attest } from "@ark/attest";
Expand Down
2 changes: 1 addition & 1 deletion packages/stash/src/actions/encodeKey.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { attest } from "@ark/attest";
import { describe, it } from "vitest";
import { encodeKey } from "./encodeKey";
import { defineTable } from "@latticexyz/store/config/v2";
import { defineTable } from "@latticexyz/store/internal";

describe("encodeKey", () => {
it("should encode a key to a string", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/stash/src/actions/getTable.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { attest } from "@ark/attest";
import { defineTable } from "@latticexyz/store/config/v2";
import { defineTable } from "@latticexyz/store/internal";
import { describe, it, expect, vi } from "vitest";
import { createStash } from "../createStash";
import { getTable } from "./getTable";
Expand Down
2 changes: 1 addition & 1 deletion packages/stash/src/actions/getTableConfig.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineTable } from "@latticexyz/store/config/v2";
import { defineTable } from "@latticexyz/store/internal";
import { describe, it } from "vitest";
import { createStash } from "../createStash";
import { attest } from "@ark/attest";
Expand Down
2 changes: 1 addition & 1 deletion packages/stash/src/actions/registerTable.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { attest } from "@ark/attest";
import { defineTable } from "@latticexyz/store/config/v2";
import { defineTable } from "@latticexyz/store/internal";
import { describe, it, expect } from "vitest";
import { createStash } from "../createStash";
import { registerTable } from "./registerTable";
Expand Down
2 changes: 1 addition & 1 deletion packages/stash/src/actions/setRecord.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineStore } from "@latticexyz/store/config/v2";
import { defineStore } from "@latticexyz/store";
import { describe, it } from "vitest";
import { createStash } from "../createStash";
import { attest } from "@ark/attest";
Expand Down
2 changes: 1 addition & 1 deletion packages/stash/src/apiEquality.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createStash } from "./createStash";
import { attest } from "@ark/attest";
import { BoundTable } from "./actions/getTable";
import { DefaultActions } from "./decorators/defaultActions";
import { defineTable } from "@latticexyz/store/config/v2";
import { defineTable } from "@latticexyz/store/internal";

describe("stash actions, bound table", () => {
const stash = createStash();
Expand Down
2 changes: 1 addition & 1 deletion packages/stash/src/boundTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createStash } from "./createStash";
import { BoundTable } from "./actions/getTable";
import { Stash } from "./common";
import { DefaultActions } from "./decorators/defaultActions";
import { defineTable } from "@latticexyz/store/config/v2";
import { defineTable } from "@latticexyz/store/internal";

describe("BoundTable", () => {
const tableConfig = defineTable({
Expand Down
3 changes: 2 additions & 1 deletion packages/stash/src/createStash.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { describe, expect, it, vi } from "vitest";
import { attest } from "@ark/attest";
import { CreateStashResult, createStash } from "./createStash";
import { defineStore, defineTable } from "@latticexyz/store/config/v2";
import { defineStore } from "@latticexyz/store";
import { defineTable } from "@latticexyz/store/internal";
import { Hex } from "viem";

describe("createStash", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/stash/src/createStash.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MutableState, Stash, StoreConfig, StoreSubscribers, TableSubscribers } from "./common";
import { DefaultActions, defaultActions } from "./decorators/defaultActions";
import { extend } from "./actions/extend";
import { Table } from "@latticexyz/store/config/v2";
import { Table } from "@latticexyz/store/internal";

export type Config = StoreConfig;

Expand Down
2 changes: 1 addition & 1 deletion packages/stash/src/decorators/defaultActions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { attest } from "@ark/attest";
import { defineStore } from "@latticexyz/store";
import { describe, expect, it, vi } from "vitest";
import { createStash } from "../createStash";
import { defineTable } from "@latticexyz/store/config/v2";
import { defineTable } from "@latticexyz/store/internal";
import { In } from "../queryFragments";
import { Hex } from "viem";
import { runQuery } from "../actions";
Expand Down
2 changes: 1 addition & 1 deletion packages/store-sync/src/logToRecord.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable max-len */
import { describe, it, expect } from "vitest";
import { defineTable } from "@latticexyz/store/config/v2";
import { defineTable } from "@latticexyz/store/internal";
import { logToRecord } from "./logToRecord";

describe("logToRecord", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/store-sync/src/recordToLog.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable max-len */
import { describe, it, expect } from "vitest";
import { recordToLog } from "./recordToLog";
import { defineTable } from "@latticexyz/store/config/v2";
import { defineTable } from "@latticexyz/store/internal";
import { logToRecord } from "./logToRecord";

describe("recordToLog", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/store-sync/src/stash/syncToStash.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getRecord, setRecord, registerTable, Stash } from "@latticexyz/stash/internal";
import { createStorageAdapter } from "./createStorageAdapter";
import { defineTable } from "@latticexyz/store/config/v2";
import { defineTable } from "@latticexyz/store/internal";
import { SyncStep } from "../SyncStep";
import { SyncOptions, SyncResult } from "../common";
import { createStoreSync } from "../createStoreSync";
Expand Down
4 changes: 0 additions & 4 deletions packages/store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
"./internal": "./dist/internal.js",
"./mud.config": "./dist/mud.config.js",
"./codegen": "./dist/codegen.js",
"./config/v2": "./dist/config/v2.js",
"./out/*": "./out/*"
},
"typesVersions": {
Expand All @@ -30,9 +29,6 @@
],
"codegen": [
"./dist/codegen.d.ts"
],
"config/v2": [
"./dist/config/v2.d.ts"
]
}
},
Expand Down
13 changes: 0 additions & 13 deletions packages/store/ts/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SchemaAbiType, SchemaAbiTypeToPrimitiveType, StaticAbiType } from "@latticexyz/schema-type/internal";
import { Hex } from "viem";

export type KeySchema = {
readonly [k: string]: {
Expand All @@ -12,18 +11,6 @@ export type ValueSchema = {
};
};

export type Table = {
readonly tableId: Hex;
readonly namespace: string;
readonly name: string;
readonly keySchema: KeySchema;
readonly valueSchema: ValueSchema;
};

export type Tables = {
readonly [k: string]: Table;
};

/** Map a table schema like `{ value: { type: "uint256" } }` to its primitive types like `{ value: bigint }` */
export type SchemaToPrimitives<schema extends ValueSchema> = {
readonly [key in keyof schema]: SchemaAbiTypeToPrimitiveType<schema[key]["type"]>;
Expand Down
2 changes: 2 additions & 0 deletions packages/store/ts/config/v2/generics.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// TODO: move to common/utils

export type get<input, key> = key extends keyof input ? input[key] : undefined;

export function get<input, key extends PropertyKey>(input: input, key: key): get<input, key> {
Expand Down
13 changes: 13 additions & 0 deletions packages/store/ts/exports/internal.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
export * from "../common";
export * from "../getStoreLogs";
export * from "../flattenStoreLogs";

export * from "../config/v2/input";
export * from "../config/v2/output";
export * from "../config/v2/store";
export * from "../config/v2/generics";
export * from "../config/v2/defaults";
export * from "../config/v2/table";
export * from "../config/v2/tables";
export * from "../config/v2/tableShorthand";
export * from "../config/v2/namespace";
export * from "../config/v2/namespaces";
export * from "../config/v2/scope";
export * from "../config/v2/flattenNamespacedTables";
1 change: 0 additions & 1 deletion packages/store/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export default defineConfig((opts) => ({
index: "ts/exports/index.ts",
internal: "ts/exports/internal.ts",
codegen: "ts/codegen/index.ts",
"config/v2": "ts/config/v2/index.ts",
},
target: "esnext",
format: ["esm"],
Expand Down
4 changes: 0 additions & 4 deletions packages/world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
".": "./dist/index.js",
"./internal": "./dist/internal.js",
"./mud.config": "./dist/mud.config.js",
"./config/v2": "./dist/config/v2.js",
"./node": "./dist/node.js",
"./out/*": "./out/*"
},
Expand All @@ -28,9 +27,6 @@
"mud.config": [
"./dist/mud.config.d.ts"
],
"config/v2": [
"./dist/config/v2.d.ts"
],
"node": [
"./dist/node.d.ts"
]
Expand Down
2 changes: 1 addition & 1 deletion packages/world/ts/config/v2/codegen.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isObject, mergeIfUndefined } from "@latticexyz/store/config/v2";
import { isObject, mergeIfUndefined } from "@latticexyz/store/internal";
import { CODEGEN_DEFAULTS } from "./defaults";

export type resolveCodegen<codegen> = codegen extends {}
Expand Down
2 changes: 1 addition & 1 deletion packages/world/ts/config/v2/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mergeIfUndefined, isObject } from "@latticexyz/store/config/v2";
import { mergeIfUndefined, isObject } from "@latticexyz/store/internal";
import { DEPLOY_DEFAULTS } from "./defaults";

export type resolveDeploy<deploy> = deploy extends {} ? mergeIfUndefined<deploy, DEPLOY_DEFAULTS> : DEPLOY_DEFAULTS;
Expand Down
2 changes: 1 addition & 1 deletion packages/world/ts/config/v2/input.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { StoreInput, NamespaceInput as StoreNamespaceInput } from "@latticexyz/store/config/v2";
import { StoreInput, NamespaceInput as StoreNamespaceInput } from "@latticexyz/store/internal";
import { DynamicResolution, ValueWithType } from "./dynamicResolution";
import { Codegen, SystemDeploy } from "./output";

Expand Down
2 changes: 1 addition & 1 deletion packages/world/ts/config/v2/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
resolveNamespace as resolveStoreNamespace,
Scope,
AbiTypeScope,
} from "@latticexyz/store/config/v2";
} from "@latticexyz/store/internal";
import { resolveSystems, validateSystems } from "./systems";
import { show } from "@ark/util";

Expand Down
2 changes: 1 addition & 1 deletion packages/world/ts/config/v2/namespaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { show, flatMorph } from "@ark/util";
import { NamespacesInput } from "./input";
import { validateNamespace, resolveNamespace } from "./namespace";
import { groupBy } from "@latticexyz/common/utils";
import { AbiTypeScope, Scope, isObject, mergeIfUndefined } from "@latticexyz/store/config/v2";
import { AbiTypeScope, Scope, isObject, mergeIfUndefined } from "@latticexyz/store/internal";

// Copied from store/ts/config/v2/namespaces.ts but using world namespace validate/resolve methods
// TODO: figure out how to dedupe these?
Expand Down
2 changes: 1 addition & 1 deletion packages/world/ts/config/v2/output.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Store } from "@latticexyz/store";
import { Namespace as StoreNamespace } from "@latticexyz/store/config/v2";
import { Namespace as StoreNamespace } from "@latticexyz/store/internal";
import { DynamicResolution, ValueWithType } from "./dynamicResolution";
import { Hex } from "viem";

Expand Down
2 changes: 1 addition & 1 deletion packages/world/ts/config/v2/system.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SYSTEM_DEFAULTS, SYSTEM_DEPLOY_DEFAULTS } from "./defaults";
import { SystemInput } from "./input";
import { hasOwnKey, mergeIfUndefined } from "@latticexyz/store/config/v2";
import { hasOwnKey, mergeIfUndefined } from "@latticexyz/store/internal";
import { ErrorMessage, narrow, requiredKeyOf, show } from "@ark/util";
import { Hex } from "viem";
import { resourceToHex } from "@latticexyz/common";
Expand Down
2 changes: 1 addition & 1 deletion packages/world/ts/config/v2/systems.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ErrorMessage } from "@ark/util";
import { isObject } from "@latticexyz/store/config/v2";
import { isObject } from "@latticexyz/store/internal";
import { SystemsInput } from "./input";
import { resolveSystem, validateSystem } from "./system";

Expand Down
4 changes: 2 additions & 2 deletions packages/world/ts/config/v2/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import {
validateStore,
flattenNamespacedTables,
CONFIG_DEFAULTS as STORE_CONFIG_DEFAULTS,
} from "@latticexyz/store/config/v2";
} from "@latticexyz/store/internal";
import { SystemsInput, WorldInput } from "./input";
import { CONFIG_DEFAULTS, MODULE_DEFAULTS } from "./defaults";
import { resolveSystems, validateSystems } from "./systems";
import { resolveNamespaces, validateNamespaces } from "./namespaces";
import { resolveCodegen } from "./codegen";
import { resolveDeploy } from "./deploy";
import type { World } from "./output.js";
import { StoreInput } from "@latticexyz/store/config/v2";
import { StoreInput } from "@latticexyz/store";

export type validateWorld<input> = {
readonly [key in keyof input]: key extends "namespaces"
Expand Down
1 change: 0 additions & 1 deletion packages/world/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export default defineConfig((opts) => ({
"mud.config": "mud.config.ts",
index: "ts/exports/index.ts",
internal: "ts/exports/internal.ts",
"config/v2": "ts/config/v2/index.ts",
node: "ts/node/index.ts",
},
target: "esnext",
Expand Down
2 changes: 0 additions & 2 deletions tsconfig.paths.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,13 @@
"@latticexyz/store": ["./packages/store/ts/exports/index.ts"],
"@latticexyz/store/mud.config": ["./packages/store/mud.config.ts"],
"@latticexyz/store/codegen": ["./packages/store/ts/codegen/index.ts"],
"@latticexyz/store/config/v2": ["./packages/store/ts/config/v2/index.ts"],
"@latticexyz/store/out/*": ["./packages/store/out/*"],
"@latticexyz/store/*": ["./packages/store/ts/exports/*.ts"],
"@latticexyz/store-sync": ["./packages/store-sync/src/index.ts"],
"@latticexyz/store-sync/*": ["./packages/store-sync/src/*"],
"@latticexyz/utils": ["./packages/utils/src/index.ts"],
"@latticexyz/world": ["./packages/world/ts/exports/index.ts"],
"@latticexyz/world/mud.config": ["./packages/world/mud.config.ts"],
"@latticexyz/world/config/v2": ["./packages/world/ts/config/v2/index.ts"],
"@latticexyz/world/node": ["./packages/world/ts/node/index.ts"],
"@latticexyz/world/out/*": ["./packages/world/out/*"],
"@latticexyz/world/*": ["./packages/world/ts/exports/*.ts"],
Expand Down

0 comments on commit 1712814

Please sign in to comment.