Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into entrykit
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Oct 25, 2024
2 parents 0033091 + b8afc07 commit 13adf1a
Show file tree
Hide file tree
Showing 71 changed files with 772 additions and 109 deletions.
5 changes: 0 additions & 5 deletions .changeset/gentle-carrots-kneel.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/little-ways-change.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/perfect-zebras-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/explorer": patch
---

When accessing a new table in Explore tab, the SQL editor now encloses column names that are also PostgreSQL keywords in double quotes in order to prevent invalid queries.
32 changes: 0 additions & 32 deletions .changeset/twenty-boats-burn.md

This file was deleted.

47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
## Version 2.2.14

Release date: Thu Oct 24 2024

### Patch changes

**[fix(cli): support public library methods in modules (#3308)](https://github.com/latticexyz/mud/commit/8eaad304db2fe9ae79f087ec7860928f734039d4)** (@latticexyz/cli)

Added support for deploying public libraries used within modules.

**[fix(cli): support public library methods in modules (#3308)](https://github.com/latticexyz/mud/commit/8eaad304db2fe9ae79f087ec7860928f734039d4)** (@latticexyz/world-module-erc20, @latticexyz/world-modules)

Changed ERC20 and ERC721 related modules to use public library methods instead of manual `delegatecall`s.

**[feat(stash): add useStash and improve other helpers (#3320)](https://github.com/latticexyz/mud/commit/93d0e763cca0facaaa20d7bde861c98c298f08ad)** (@latticexyz/stash)

Added `useStash` React hook. It's heavily inspired by Zustand's `useStore` and accepts a stash, a state selector, an an optional equality function to avoid unnecessary re-render cycles when returning unstable values.

Also updated `getRecord` and `getRecords` to each take either a `stash` or `state` object for more ergonomic use with `useStash`.

```ts
import { useStash } from "@latticexyz/stash/react";
import { getRecord } from "@latticexyz/stash";
import config from "../mud.config";

const tables = config.namespaces.app.tables;

export function PlayerName({ playerId }) {
const record = useStash(stash, (state) => getRecord({ state, table: tables.Player, key: { playerId } }));
...
}
```

```ts
import isEqual from "fast-deep-equal";
import { useStash } from "@latticexyz/stash/react";
import { getRecords } from "@latticexyz/stash";
import config from "../mud.config";

export function PlayerNames() {
const record = useStash(stash, (state) => getRecords({ state, table: tables.Player }), { isEqual });
...
}
```

---

## Version 2.2.13

Release date: Wed Oct 23 2024
Expand Down
47 changes: 47 additions & 0 deletions docs/pages/changelog.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
## Version 2.2.14

Release date: Thu Oct 24 2024

### Patch changes

**[fix(cli): support public library methods in modules (#3308)](https://github.com/latticexyz/mud/commit/8eaad304db2fe9ae79f087ec7860928f734039d4)** (@latticexyz/cli)

Added support for deploying public libraries used within modules.

**[fix(cli): support public library methods in modules (#3308)](https://github.com/latticexyz/mud/commit/8eaad304db2fe9ae79f087ec7860928f734039d4)** (@latticexyz/world-module-erc20, @latticexyz/world-modules)

Changed ERC20 and ERC721 related modules to use public library methods instead of manual `delegatecall`s.

**[feat(stash): add useStash and improve other helpers (#3320)](https://github.com/latticexyz/mud/commit/93d0e763cca0facaaa20d7bde861c98c298f08ad)** (@latticexyz/stash)

Added `useStash` React hook. It's heavily inspired by Zustand's `useStore` and accepts a stash, a state selector, an an optional equality function to avoid unnecessary re-render cycles when returning unstable values.

Also updated `getRecord` and `getRecords` to each take either a `stash` or `state` object for more ergonomic use with `useStash`.

```ts
import { useStash } from "@latticexyz/stash/react";
import { getRecord } from "@latticexyz/stash";
import config from "../mud.config";

const tables = config.namespaces.app.tables;

export function PlayerName({ playerId }) {
const record = useStash(stash, (state) => getRecord({ state, table: tables.Player, key: { playerId } }));
...
}
```

```ts
import isEqual from "fast-deep-equal";
import { useStash } from "@latticexyz/stash/react";
import { getRecords } from "@latticexyz/stash";
import config from "../mud.config";

export function PlayerNames() {
const record = useStash(stash, (state) => getRecords({ state, table: tables.Player }), { isEqual });
...
}
```

---

## Version 2.2.13

Release date: Wed Oct 23 2024
Expand Down
2 changes: 2 additions & 0 deletions packages/abi-ts/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# @latticexyz/abi-ts

## 2.2.14

## 2.2.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/abi-ts/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@latticexyz/abi-ts",
"version": "2.2.13",
"version": "2.2.14",
"description": "Create TypeScript type declaration files (`.d.ts`) for your ABI JSON files.",
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions packages/block-logs-stream/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @latticexyz/block-logs-stream

## 2.2.14

### Patch Changes

- @latticexyz/common@2.2.14

## 2.2.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/block-logs-stream/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@latticexyz/block-logs-stream",
"version": "2.2.13",
"version": "2.2.14",
"description": "Create a stream of EVM block logs for events",
"repository": {
"type": "git",
Expand Down
17 changes: 17 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Change Log

## 2.2.14

### Patch Changes

- 8eaad30: Added support for deploying public libraries used within modules.
- @latticexyz/abi-ts@2.2.14
- @latticexyz/block-logs-stream@2.2.14
- @latticexyz/common@2.2.14
- @latticexyz/config@2.2.14
- @latticexyz/gas-report@2.2.14
- @latticexyz/protocol-parser@2.2.14
- @latticexyz/schema-type@2.2.14
- @latticexyz/store@2.2.14
- @latticexyz/utils@2.2.14
- @latticexyz/world@2.2.14
- @latticexyz/world-module-metadata@2.2.14

## 2.2.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@latticexyz/cli",
"version": "2.2.13",
"version": "2.2.14",
"description": "Command line interface for mud",
"repository": {
"type": "git",
Expand Down
6 changes: 6 additions & 0 deletions packages/common/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## 2.2.14

### Patch Changes

- @latticexyz/schema-type@2.2.14

## 2.2.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@latticexyz/common",
"version": "2.2.13",
"version": "2.2.14",
"description": "Common low level logic shared between packages",
"repository": {
"type": "git",
Expand Down
7 changes: 7 additions & 0 deletions packages/config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## 2.2.14

### Patch Changes

- @latticexyz/common@2.2.14
- @latticexyz/schema-type@2.2.14

## 2.2.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@latticexyz/config",
"version": "2.2.13",
"version": "2.2.14",
"description": "Config for Store and World",
"repository": {
"type": "git",
Expand Down
2 changes: 2 additions & 0 deletions packages/create-mud/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Change Log

## 2.2.14

## 2.2.13

## 2.2.12
Expand Down
2 changes: 1 addition & 1 deletion packages/create-mud/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-mud",
"version": "2.2.13",
"version": "2.2.14",
"description": "Create a new MUD project",
"license": "MIT",
"author": "Lattice <[email protected]>",
Expand Down
13 changes: 13 additions & 0 deletions packages/dev-tools/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @latticexyz/dev-tools

## 2.2.14

### Patch Changes

- @latticexyz/store-sync@2.2.14
- @latticexyz/common@2.2.14
- @latticexyz/react@2.2.14
- @latticexyz/recs@2.2.14
- @latticexyz/schema-type@2.2.14
- @latticexyz/store@2.2.14
- @latticexyz/utils@2.2.14
- @latticexyz/world@2.2.14

## 2.2.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-tools/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@latticexyz/dev-tools",
"version": "2.2.13",
"version": "2.2.14",
"description": "MUD developer tools",
"repository": {
"type": "git",
Expand Down
13 changes: 13 additions & 0 deletions packages/explorer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @latticexyz/explorer

## 2.2.14

### Patch Changes

- @latticexyz/store-sync@2.2.14
- @latticexyz/store-indexer@2.2.14
- @latticexyz/common@2.2.14
- @latticexyz/config@2.2.14
- @latticexyz/protocol-parser@2.2.14
- @latticexyz/schema-type@2.2.14
- @latticexyz/store@2.2.14
- @latticexyz/world@2.2.14

## 2.2.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/explorer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@latticexyz/explorer",
"version": "2.2.13",
"version": "2.2.14",
"description": "World Explorer is a tool for visually exploring and manipulating the state of worlds",
"type": "module",
"exports": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function WorldsForm({ worlds }: { worlds: Address[] }) {
function onLuckyWorld() {
if (worlds.length > 0) {
const luckyAddress = worlds[Math.floor(Math.random() * worlds.length)];
router.push(getWorldUrl(chainName as string, luckyAddress));
router.push(getWorldUrl(chainName as string, luckyAddress as Address));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ export function EditableTableCell({ name, table, keyTuple, value: defaultValue }
const account = useAccount();

const valueSchema = getValueSchema(table);
const fieldType = valueSchema[name as never].type;
const fieldType = valueSchema?.[name as never]?.type;

const { mutate, isPending } = useMutation({
mutationFn: async (newValue: unknown) => {
if (!fieldType) throw new Error("Field type not found");

const fieldIndex = getFieldIndex<ValueSchema>(getSchemaTypes(valueSchema), name);
const encodedFieldValue = encodeField(fieldType, newValue);
const txHash = await writeContract(wagmiConfig, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { indexerForChainId } from "../../../../utils/indexerForChainId";
import { SQLEditor } from "./SQLEditor";
import { TableSelector } from "./TableSelector";
import { TablesViewer } from "./TablesViewer";
import { postgresKeywords } from "./consts";

export function Explorer() {
const { worldAddress } = useParams();
Expand All @@ -31,7 +32,10 @@ export function Explorer() {
if (indexer.type === "sqlite") {
setQuery(`SELECT * FROM "${tableName}"`);
} else {
setQuery(`SELECT ${Object.keys(table.schema).join(", ")} FROM ${tableName}`);
const columns = Object.keys(table.schema).map((column) =>
postgresKeywords.includes(column.toLowerCase()) ? `"${column}"` : column,
);
setQuery(`SELECT ${columns.join(", ")} FROM ${tableName}`);
}
}
}, [chainId, setQuery, selectedTableId, table, worldAddress, prevSelectedTableId, query, indexer.type]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function TableSelector({ tables }: { tables?: Table[] }) {
const selectedTableConfig = tables?.find(({ tableId }) => tableId === selectedTableId);

useEffect(() => {
if (!selectedTableId && Array.isArray(tables) && tables.length > 0) {
if (!selectedTableId && tables?.[0]) {
setTableId(tables[0].tableId);
}
}, [selectedTableId, setTableId, tables]);
Expand Down
Loading

0 comments on commit 13adf1a

Please sign in to comment.