Skip to content

Commit

Permalink
Merge branch 'main' into authcall/protocol-parser-go
Browse files Browse the repository at this point in the history
  • Loading branch information
authcall authored Jul 27, 2023
2 parents 9cd5373 + b02f9d0 commit 4d76fba
Show file tree
Hide file tree
Showing 152 changed files with 3,770 additions and 907 deletions.
7 changes: 7 additions & 0 deletions .changeset/modern-bikes-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@latticexyz/block-logs-stream": minor
"@latticexyz/store-sync": minor
---

- Replace `blockEventsToStorage` with `blockLogsToStorage` that exposes a `storeOperations` callback to perform database writes from store operations. This helps encapsulates database adapters into a single wrapper/instance of `blockLogsToStorage` and allows for wrapping a block of store operations in a database transaction.
- Add `toBlock` option to `groupLogsByBlockNumber` and remove `blockHash` from results. This helps track the last block number for a given set of logs when used in the context of RxJS streams.
5 changes: 5 additions & 0 deletions .changeset/pink-horses-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/schema-type": minor
---

add type narrowing `isStaticAbiType`
53 changes: 53 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"mode": "pre",
"tag": "next",
"initialVersions": {
"@latticexyz/block-logs-stream": "1.42.0",
"@latticexyz/cli": "1.42.0",
"@latticexyz/common": "1.42.0",
"@latticexyz/config": "1.42.0",
"create-mud": "1.42.0",
"@latticexyz/dev-tools": "1.42.0",
"@latticexyz/ecs-browser": "1.42.0",
"@latticexyz/gas-report": "1.42.0",
"@latticexyz/network": "1.42.0",
"@latticexyz/noise": "1.42.0",
"@latticexyz/phaserx": "1.42.0",
"@latticexyz/protocol-parser": "1.42.0",
"@latticexyz/react": "1.42.0",
"@latticexyz/recs": "1.42.0",
"@latticexyz/schema-type": "1.42.0",
"@latticexyz/services": "1.42.0",
"@latticexyz/solecs": "1.42.0",
"solhint-config-mud": "1.42.0",
"solhint-plugin-mud": "1.42.0",
"@latticexyz/std-client": "1.42.0",
"@latticexyz/std-contracts": "1.42.0",
"@latticexyz/store": "1.42.0",
"@latticexyz/store-cache": "1.42.0",
"@latticexyz/store-sync": "1.42.0",
"@latticexyz/utils": "1.42.0",
"@latticexyz/world": "1.42.0"
},
"changesets": [
"eighty-tigers-argue",
"fast-ears-hug",
"itchy-kids-relax",
"many-phones-study",
"modern-bikes-build",
"nasty-waves-divide",
"nice-pandas-knock",
"olive-parrots-move",
"perfect-mangos-cry",
"quick-numbers-flash",
"rare-planes-draw",
"selfish-cycles-retire",
"soft-boxes-smile",
"spotty-sheep-warn",
"stale-cooks-reflect",
"strange-candles-shout",
"strange-ducks-float",
"thin-buses-reply",
"tricky-frogs-beam"
]
}
26 changes: 26 additions & 0 deletions .changeset/soft-boxes-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
"@latticexyz/store-sync": minor
---

`blockLogsToStorage(sqliteStorage(...))` converts block logs to SQLite operations. You can use it like:

```ts
import { drizzle } from "drizzle-orm/better-sqlite3";
import Database from "better-sqlite3";
import { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";
import { createPublicClient } from "viem";
import { blockLogsToStorage } from "@latticexyz/store-sync";
import { sqliteStorage } from "@latticexyz/store-sync/sqlite";

const database = drizzle(new Database('store.db')) as any as BaseSQLiteDatabase<"sync", void>;
const publicClient = createPublicClient({ ... });

blockLogs$
.pipe(
concatMap(blockLogsToStorage(sqliteStorage({ database, publicClient }))),
tap(({ blockNumber, operations }) => {
console.log("stored", operations.length, "operations for block", blockNumber);
})
)
.subscribe();
```
18 changes: 18 additions & 0 deletions .changeset/stale-cooks-reflect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
"@latticexyz/block-logs-stream": patch
"@latticexyz/cli": patch
"@latticexyz/common": patch
"@latticexyz/dev-tools": patch
"@latticexyz/network": patch
"@latticexyz/protocol-parser": patch
"@latticexyz/schema-type": patch
"@latticexyz/std-client": patch
"@latticexyz/store-cache": patch
"@latticexyz/store-sync": patch
"@latticexyz/store": patch
create-mud: patch
---

- bump to viem 1.3.0 and abitype 0.9.3
- move `@wagmi/chains` imports to `viem/chains`
- refine a few types
13 changes: 13 additions & 0 deletions .changeset/strange-ducks-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@latticexyz/common": minor
---

`TableId.toHex()` now truncates name/namespace to 16 bytes each, to properly fit into a `bytes32` hex string.

Also adds a few utils we'll need in the indexer:

- `bigIntMin` is similar to `Math.min` but for `bigint`s
- `bigIntMax` is similar to `Math.max` but for `bigint`s
- `bigIntSort` for sorting an array of `bigint`s
- `chunk` to split an array into chunks
- `wait` returns a `Promise` that resolves after specified number of milliseconds
15 changes: 15 additions & 0 deletions .changeset/weak-mails-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@latticexyz/cli": patch
"@latticexyz/recs": patch
"@latticexyz/std-client": patch
---

Update RECS components with v2 key/value schemas. This helps with encoding/decoding composite keys and strong types for keys/values.

This may break if you were previously dependent on `component.id`, `component.metadata.componentId`, or `component.metadata.tableId`:

- `component.id` is now the on-chain `bytes32` hex representation of the table ID
- `component.metadata.componentName` is the table name (e.g. `Position`)
- `component.metadata.tableName` is the namespaced table name (e.g. `myworld:Position`)
- `component.metadata.keySchema` is an object with key names and their corresponding ABI types
- `component.metadata.valueSchema` is an object with field names and their corresponding ABI types
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18
18.16.1
3 changes: 1 addition & 2 deletions e2e/packages/client-vanilla/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"@latticexyz/std-client": "link:../../../packages/std-client",
"@latticexyz/utils": "link:../../../packages/utils",
"@latticexyz/world": "link:../../../packages/world",
"@wagmi/chains": "^0.2.22",
"async-mutex": "^0.4.0",
"contracts": "workspace:*",
"ethers": "^5.7.2",
Expand All @@ -33,7 +32,7 @@
"react": "^18.2.0",
"rxjs": "7.5.5",
"threads": "^1.7.0",
"viem": "1.1.7"
"viem": "1.3.1"
},
"devDependencies": {
"rimraf": "^3.0.2",
Expand Down
41 changes: 24 additions & 17 deletions e2e/packages/client-vanilla/src/mud/contractComponents.ts
Original file line number Diff line number Diff line change
@@ -1,70 +1,77 @@
/* Autogenerated file. Do not edit manually. */

import { TableId } from "@latticexyz/common";
import { defineComponent, Type as RecsType, World } from "@latticexyz/recs";

export function defineContractComponents(world: World) {
return {
Number: (() => {
const tableId = new TableId("", "Number");
return defineComponent(
world,
{
value: RecsType.Number,
},
{
id: "0x000000000000000000000000000000004e756d62657200000000000000000000",
metadata: {
contractId: tableId.toHex(),
tableId: tableId.toString(),
componentName: "Number",
tableName: ":Number",
keySchema: { key: "uint32" },
valueSchema: { value: "uint32" },
},
}
} as const
);
})(),
Vector: (() => {
const tableId = new TableId("", "Vector");
return defineComponent(
world,
{
x: RecsType.Number,
y: RecsType.Number,
},
{
id: "0x00000000000000000000000000000000566563746f7200000000000000000000",
metadata: {
contractId: tableId.toHex(),
tableId: tableId.toString(),
componentName: "Vector",
tableName: ":Vector",
keySchema: { key: "uint32" },
valueSchema: { x: "int32", y: "int32" },
},
}
} as const
);
})(),
NumberList: (() => {
const tableId = new TableId("", "NumberList");
return defineComponent(
world,
{
value: RecsType.NumberArray,
},
{
id: "0x000000000000000000000000000000004e756d6265724c697374000000000000",
metadata: {
contractId: tableId.toHex(),
tableId: tableId.toString(),
componentName: "NumberList",
tableName: ":NumberList",
keySchema: {},
valueSchema: { value: "uint32[]" },
},
}
} as const
);
})(),
Multi: (() => {
const tableId = new TableId("", "Multi");
return defineComponent(
world,
{
num: RecsType.BigInt,
value: RecsType.Boolean,
},
{
id: "0x000000000000000000000000000000004d756c74690000000000000000000000",
metadata: {
contractId: tableId.toHex(),
tableId: tableId.toString(),
componentName: "Multi",
tableName: ":Multi",
keySchema: { a: "uint32", b: "bool", c: "uint256", d: "int120" },
valueSchema: { num: "int256", value: "bool" },
},
}
} as const
);
})(),
};
Expand Down
2 changes: 1 addition & 1 deletion e2e/packages/client-vanilla/src/mud/supportedChains.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MUDChain, latticeTestnet } from "@latticexyz/common/chains";
import { foundry } from "@wagmi/chains";
import { foundry } from "viem/chains";

// If you are deploying to chains other than anvil or Lattice testnet, add them here
export const supportedChains: MUDChain[] = [foundry, latticeTestnet];
2 changes: 1 addition & 1 deletion e2e/packages/sync-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"execa": "^7.1.1",
"jsdom": "^22.0.0",
"typescript": "5.1.6",
"viem": "1.0.6",
"viem": "1.3.1",
"vite": "^4.2.1",
"vitest": "^0.31.0"
}
Expand Down
Loading

0 comments on commit 4d76fba

Please sign in to comment.