- Updated dependencies []:
- @latticexyz/schema-type@2.0.0-next.10
- @latticexyz/utils@2.0.0-next.10
- Updated dependencies [
92de5998]:- @latticexyz/schema-type@2.0.0-next.9
- @latticexyz/utils@2.0.0-next.9
- Updated dependencies []:
- @latticexyz/schema-type@2.0.0-next.8
- @latticexyz/utils@2.0.0-next.8
- Updated dependencies []:
- @latticexyz/schema-type@2.0.0-next.7
- @latticexyz/utils@2.0.0-next.7
- Updated dependencies []:
- @latticexyz/schema-type@2.0.0-next.6
- @latticexyz/utils@2.0.0-next.6
- Updated dependencies []:
- @latticexyz/schema-type@2.0.0-next.5
- @latticexyz/utils@2.0.0-next.5
-
#1351
c14f8bf1Thanks @holic! - - MovedcreateActionSystemfromstd-clienttorecspackage and updated it to better support v2 sync stack.If you want to use
createActionSystemalongsidesyncToRecs, you'll need to pass in arguments like so:import { syncToRecs } from "@latticexyz/store-sync/recs"; import { createActionSystem } from "@latticexyz/recs/deprecated"; import { from, mergeMap } from "rxjs"; const { blockLogsStorage$, waitForTransaction } = syncToRecs({ world, ... }); const txReduced$ = blockLogsStorage$.pipe( mergeMap(({ operations }) => from(operations.map((op) => op.log?.transactionHash).filter(isDefined))) ); const actionSystem = createActionSystem(world, txReduced$, waitForTransaction);
-
Fixed a bug in
waitForComponentValueInthat caused the promise to not resolve if the component value was already set when the function was called. -
Fixed a bug in
createActionSystemthat caused optimistic updates to be incorrectly propagated to requirement checks. To fix the bug, you must now pass in the full component object to the action'supdatesinstead of just the component name.actions.add({ updates: () => [ { - component: "Resource", + component: Resource, ... } ], ... });
-
-
#1340
ce7125a1Thanks @holic! - Removessolecspackage. These were v1 contracts, now entirely replaced by our v2 tooling. See the MUD docs for building with v2 or create a new project from our v2 templates withpnpm create mud@next your-app-name. -
Updated dependencies []:
- @latticexyz/schema-type@2.0.0-next.4
- @latticexyz/utils@2.0.0-next.4
- Updated dependencies []:
- @latticexyz/schema-type@2.0.0-next.3
- @latticexyz/utils@2.0.0-next.3
- Updated dependencies [
b8a6158d]:- @latticexyz/schema-type@2.0.0-next.2
- @latticexyz/utils@2.0.0-next.2
-
#1214
60cfd089Thanks @holic! - Templates and examples now use MUD's new sync packages, all built on top of viem. This greatly speeds up and stabilizes our networking code and improves types throughout.These new sync packages come with support for our
recspackage, includingencodeEntityanddecodeEntityutilities for composite keys.If you're using
store-cacheanduseRow/useRows, you should wait to upgrade until we have a suitable replacement for those libraries. We're working on a sql.js-powered sync module that will replacestore-cache.Migrate existing RECS apps to new sync packages
As you migrate, you may find some features replaced, removed, or not included by default. Please open an issue and let us know if we missed anything.
-
Add
@latticexyz/store-syncpackage to your app'sclientpackage and make sureviemis pinned to version1.3.1(otherwise you may get type errors) -
In your
supportedChains.ts, replacefoundrychain with our newmudFoundrychain.- import { foundry } from "viem/chains"; - import { MUDChain, latticeTestnet } from "@latticexyz/common/chains"; + import { MUDChain, latticeTestnet, mudFoundry } from "@latticexyz/common/chains"; - export const supportedChains: MUDChain[] = [foundry, latticeTestnet]; + export const supportedChains: MUDChain[] = [mudFoundry, latticeTestnet];
-
In
getNetworkConfig.ts, remove the return type (to let TS infer it for now), remove now-unused config values, and add the viemchainobject.- export async function getNetworkConfig(): Promise<NetworkConfig> { + export async function getNetworkConfig() {
const initialBlockNumber = params.has("initialBlockNumber") ? Number(params.get("initialBlockNumber")) - : world?.blockNumber ?? -1; // -1 will attempt to find the block number from RPC + : world?.blockNumber ?? 0n;+ return { + privateKey: getBurnerWallet().value, + chain, + worldAddress, + initialBlockNumber, + faucetServiceUrl: params.get("faucet") ?? chain.faucetUrl, + };
-
In
setupNetwork.ts, replacesetupMUDV2NetworkwithsyncToRecs.- import { setupMUDV2Network } from "@latticexyz/std-client"; - import { createFastTxExecutor, createFaucetService, getSnapSyncRecords } from "@latticexyz/network"; + import { createFaucetService } from "@latticexyz/network"; + import { createPublicClient, fallback, webSocket, http, createWalletClient, getContract, Hex, parseEther, ClientConfig } from "viem"; + import { encodeEntity, syncToRecs } from "@latticexyz/store-sync/recs"; + import { createBurnerAccount, createContract, transportObserver } from "@latticexyz/common";
- const result = await setupMUDV2Network({ - ... - }); + const clientOptions = { + chain: networkConfig.chain, + transport: transportObserver(fallback([webSocket(), http()])), + pollingInterval: 1000, + } as const satisfies ClientConfig; + const publicClient = createPublicClient(clientOptions); + const burnerAccount = createBurnerAccount(networkConfig.privateKey as Hex); + const burnerWalletClient = createWalletClient({ + ...clientOptions, + account: burnerAccount, + }); + const { components, latestBlock$, blockStorageOperations$, waitForTransaction } = await syncToRecs({ + world, + config: storeConfig, + address: networkConfig.worldAddress as Hex, + publicClient, + components: contractComponents, + startBlock: BigInt(networkConfig.initialBlockNumber), + indexerUrl: networkConfig.indexerUrl ?? undefined, + }); + const worldContract = createContract({ + address: networkConfig.worldAddress as Hex, + abi: IWorld__factory.abi, + publicClient, + walletClient: burnerWalletClient, + });
// Request drip from faucet - const signer = result.network.signer.get(); - if (networkConfig.faucetServiceUrl && signer) { - const address = await signer.getAddress(); + if (networkConfig.faucetServiceUrl) { + const address = burnerAccount.address;
const requestDrip = async () => { - const balance = await signer.getBalance(); + const balance = await publicClient.getBalance({ address }); console.info(`[Dev Faucet]: Player balance -> ${balance}`); - const lowBalance = balance?.lte(utils.parseEther("1")); + const lowBalance = balance < parseEther("1");You can remove the previous ethers
worldContract, snap sync code, and fast transaction executor.The return of
setupNetworkis a bit different than before, so you may have to do corresponding app changes.+ return { + world, + components, + playerEntity: encodeEntity({ address: "address" }, { address: burnerWalletClient.account.address }), + publicClient, + walletClient: burnerWalletClient, + latestBlock$, + blockStorageOperations$, + waitForTransaction, + worldContract, + };
-
Update
createSystemCallswith the new return type ofsetupNetwork.export function createSystemCalls( - { worldSend, txReduced$, singletonEntity }: SetupNetworkResult, + { worldContract, waitForTransaction }: SetupNetworkResult, { Counter }: ClientComponents ) { const increment = async () => { - const tx = await worldSend("increment", []); - await awaitStreamValue(txReduced$, (txHash) => txHash === tx.hash); + const tx = await worldContract.write.increment(); + await waitForTransaction(tx); return getComponentValue(Counter, singletonEntity); };
-
(optional) If you still need a clock, you can create it with:
import { map, filter } from "rxjs"; import { createClock } from "@latticexyz/network"; const clock = createClock({ period: 1000, initialTime: 0, syncInterval: 5000, }); world.registerDisposer(() => clock.dispose()); latestBlock$ .pipe( map((block) => Number(block.timestamp) * 1000), // Map to timestamp in ms filter((blockTimestamp) => blockTimestamp !== clock.lastUpdateTime), // Ignore if the clock was already refreshed with this block filter((blockTimestamp) => blockTimestamp !== clock.currentTime) // Ignore if the current local timestamp is correct ) .subscribe(clock.update); // Update the local clock
If you're using the previous
LoadingStatecomponent, you'll want to migrate to the newSyncProgress:import { SyncStep, singletonEntity } from "@latticexyz/store-sync/recs"; const syncProgress = useComponentValue(SyncProgress, singletonEntity, { message: "Connecting", percentage: 0, step: SyncStep.INITIALIZE, }); if (syncProgress.step === SyncStep.LIVE) { // we're live! }
-
-
#1195
afdba793Thanks @holic! - 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, orcomponent.metadata.tableId:component.idis now the on-chainbytes32hex representation of the table IDcomponent.metadata.componentNameis the table name (e.g.Position)component.metadata.tableNameis the namespaced table name (e.g.myworld:Position)component.metadata.keySchemais an object with key names and their corresponding ABI typescomponent.metadata.valueSchemais an object with field names and their corresponding ABI types
-
Updated dependencies [
b02f9d0e]:- @latticexyz/schema-type@2.0.0-next.1
- @latticexyz/utils@2.0.0-next.1
-
#1167
1e2ad78eThanks @holic! - improve RECS error messages for v2 components -
Updated dependencies [
48909d15,f03531d9,4e4a3415,53522998]:- @latticexyz/schema-type@2.0.0-next.0
- @latticexyz/utils@2.0.0-next.0
All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.
1.42.0 (2023-04-13)
- recs,cli: fix bigint in recs and tsgen (#563) (29fefae)
- recs: overridden component update stream should return the overridden component (#544) (9af097d)
- cli/recs/std-client: add ts definitions generator (#536) (dd1efa6)
- cli: improve storeArgument, refactor cli (#500) (bb68670)
- cli: use abi types in store config (#507) (12a739f)
- network,recs,std-client: support StoreSetField before StoreSetRecord (#581) (f259f90), closes #479 #523
- network: integrate initial sync from MODE (#493) (7d06c1b)
- v2 event decoding (#415) (374ed54)
1.41.0 (2023-03-09)
Note: Version bump only for package @latticexyz/recs
1.40.0 (2023-03-03)
Note: Version bump only for package @latticexyz/recs
1.39.0 (2023-02-22)
Note: Version bump only for package @latticexyz/recs
1.38.0 (2023-02-22)
Note: Version bump only for package @latticexyz/recs
1.37.1 (2023-02-17)
Note: Version bump only for package @latticexyz/recs
1.37.0 (2023-02-16)
- Revert "chore(release): publish v1.37.0" (c934f53)
1.36.1 (2023-02-16)
Note: Version bump only for package @latticexyz/recs
1.35.0 (2023-02-15)
Note: Version bump only for package @latticexyz/recs
1.34.0 (2023-01-29)
Note: Version bump only for package @latticexyz/recs
1.33.1 (2023-01-12)
Note: Version bump only for package @latticexyz/recs
1.33.0 (2023-01-12)
Note: Version bump only for package @latticexyz/recs
1.32.0 (2023-01-06)
1.31.3 (2022-12-16)
Note: Version bump only for package @latticexyz/recs
1.31.2 (2022-12-15)
Note: Version bump only for package @latticexyz/recs
1.31.1 (2022-12-15)
1.31.0 (2022-12-14)
Note: Version bump only for package @latticexyz/recs
1.30.1 (2022-12-02)
Note: Version bump only for package @latticexyz/recs
1.30.0 (2022-12-02)
Note: Version bump only for package @latticexyz/recs
1.29.0 (2022-11-29)
Note: Version bump only for package @latticexyz/recs
1.28.1 (2022-11-24)
1.28.0 (2022-11-20)
Note: Version bump only for package @latticexyz/recs
1.26.0 (2022-11-07)
Note: Version bump only for package @latticexyz/recs
1.25.1 (2022-11-03)
Note: Version bump only for package @latticexyz/recs
1.25.0 (2022-11-03)
Note: Version bump only for package @latticexyz/recs
1.24.1 (2022-10-29)
Note: Version bump only for package @latticexyz/recs
1.24.0 (2022-10-28)
Note: Version bump only for package @latticexyz/recs
1.23.1 (2022-10-28)
Note: Version bump only for package @latticexyz/recs
1.23.0 (2022-10-26)
Note: Version bump only for package @latticexyz/recs
1.22.0 (2022-10-26)
Note: Version bump only for package @latticexyz/recs
1.21.0 (2022-10-26)
Note: Version bump only for package @latticexyz/recs
1.20.0 (2022-10-22)
1.19.0 (2022-10-21)
Note: Version bump only for package @latticexyz/recs
1.18.0 (2022-10-21)
Note: Version bump only for package @latticexyz/recs
1.17.0 (2022-10-19)
Note: Version bump only for package @latticexyz/recs
1.16.0 (2022-10-19)
Note: Version bump only for package @latticexyz/recs
1.15.0 (2022-10-18)
Note: Version bump only for package @latticexyz/recs
1.14.2 (2022-10-18)
Note: Version bump only for package @latticexyz/recs
1.14.1 (2022-10-18)
Note: Version bump only for package @latticexyz/recs
1.14.0 (2022-10-18)
1.13.0 (2022-10-15)
Note: Version bump only for package @latticexyz/recs
1.12.0 (2022-10-12)
Note: Version bump only for package @latticexyz/recs
1.11.0 (2022-10-11)
Note: Version bump only for package @latticexyz/recs
1.10.0 (2022-10-11)
Note: Version bump only for package @latticexyz/recs
1.9.0 (2022-10-11)
- solecs): only allow components to register their own updates, feat(std-client: add support for multiple overrides per component per action (#199) (d8dd63e)
1.8.0 (2022-10-07)
Note: Version bump only for package @latticexyz/recs
1.7.1 (2022-10-06)
Note: Version bump only for package @latticexyz/recs
1.7.0 (2022-10-06)
Note: Version bump only for package @latticexyz/recs
1.6.0 (2022-10-04)
1.5.1 (2022-10-03)
Note: Version bump only for package @latticexyz/recs
1.5.0 (2022-10-03)
Note: Version bump only for package @latticexyz/recs
1.4.1 (2022-10-03)
Note: Version bump only for package @latticexyz/recs
1.4.0 (2022-10-03)
Note: Version bump only for package @latticexyz/recs
1.3.0 (2022-09-30)
- recs: change internal query behavior to match previous version (47b8834)
- recs: add local cache component (#169) (09058f6)
- recs: allow multiple subscribers per query update$ (6d13531)
1.2.0 (2022-09-29)
Note: Version bump only for package @latticexyz/recs
1.1.0 (2022-09-28)
Note: Version bump only for package @latticexyz/recs
1.0.0 (2022-09-27)
Note: Version bump only for package @latticexyz/recs
0.16.4 (2022-09-26)
Note: Version bump only for package @latticexyz/recs
0.16.3 (2022-09-26)
Note: Version bump only for package @latticexyz/recs
0.16.2 (2022-09-26)
Note: Version bump only for package @latticexyz/recs
0.16.1 (2022-09-26)
Note: Version bump only for package @latticexyz/recs
0.16.0 (2022-09-26)
0.15.1 (2022-09-23)
Note: Version bump only for package @latticexyz/recs
0.15.0 (2022-09-21)
Note: Version bump only for package @latticexyz/recs
0.14.2 (2022-09-21)
Note: Version bump only for package @latticexyz/recs
0.14.1 (2022-09-21)
Note: Version bump only for package @latticexyz/recs
0.14.0 (2022-09-20)
Note: Version bump only for package @latticexyz/recs
0.13.0 (2022-09-19)
Note: Version bump only for package @latticexyz/recs
0.12.0 (2022-09-16)
Note: Version bump only for package @latticexyz/recs
0.11.1 (2022-09-15)
- do not run prepack multiple times when publishing (4f6f4c3)
0.11.0 (2022-09-15)
Note: Version bump only for package @latticexyz/recs
0.10.0 (2022-09-14)
Note: Version bump only for package @latticexyz/recs
0.9.0 (2022-09-13)
Note: Version bump only for package @latticexyz/recs
0.8.1 (2022-08-22)
Note: Version bump only for package @latticexyz/recs
0.8.0 (2022-08-22)
0.7.0 (2022-08-19)
Note: Version bump only for package @latticexyz/recs
0.6.0 (2022-08-15)
Note: Version bump only for package @latticexyz/recs
0.5.1 (2022-08-05)
Note: Version bump only for package @latticexyz/recs
0.5.0 (2022-08-05)
0.4.3 (2022-07-30)
Note: Version bump only for package @latticexyz/recs
0.4.2 (2022-07-29)
Note: Version bump only for package @latticexyz/recs
0.4.1 (2022-07-29)
Note: Version bump only for package @latticexyz/recs
0.4.0 (2022-07-29)
- allow component overrides to be null (f9baf44)
0.3.2 (2022-07-26)
Note: Version bump only for package @latticexyz/recs
0.3.1 (2022-07-26)
Note: Version bump only for package @latticexyz/recs
0.3.0 (2022-07-26)
- mudwar prototype (nyc sprint 2) (#59) (a3db20e), closes #58 #61 #64 #62 #66 #69 #72 #73 #74 #76 #75 #77 #78 #79 #80 #82 #86 #83 #81 #85 #84 #87 #91 #88 #90 #92 #93 #89 #94 #95 #98 #100 #97 #101 #105 #106
- new systems pattern (#63) (fb6197b)
0.2.0 (2022-07-05)
- add webworker architecture for contract/client sync, add cache webworker (#10) (4ef9f90), closes #14
- component browser 📈 (#16) (37af75e)
- on-chain maps (nyc sprint 1) (#38) (089c46d), closes #17 #20 #18 #25 #26 #27 #28 #29 #30 #31 #33 #32 #34 #35 #36 #37 #39 #40 #41 #42 #43 #44 #45 #46 #48 #49 #50
- recs: add more granular type assertion function for introspecting Component schema types (#8) (48331f9)
- recs: add optional parameters to reaction and autorun systems (451209f)
- recs: expose raw schema on component (69d9b89)
- recs: rewrite for performance improvements (without integrating in ri) (#22) (887564d)
-
Components have to implement a getSchema() function
-
feat(network): make Sync worker return a stream of ECS events (prev contract events)
-
feat(ri-contracts): integrate solecs change (add getSchema to components)
-
feat(ri-client): integrate network package changes
-
feat(network): store ECS state in cache
-
feat(network): load state from cache
-
feat(utils): add more utils for iterables
-
refactor(network): clean up
-
feat(network): generalize component value decoder function, add tests
-
fix(network): make it possible to subscribe to ecsStream from sync worker multiple times
-
fix(network): start sync from provided initial block number
-
feat(network): move storing ecs to indexDB to its own Cache worker
-
feat(network): create separate cache for every World contract address
-
fix(network): fix issues discovered during live review
-
chore: remove unused import
-
Update packages/network/src/createBlockNumberStream.ts
Co-authored-by: ludens ludens@lattice.xyz
-
feat(network): add clock syncInterval as config parameter
-
feat(utils): emit values through componentToStream and observableToStream only if non-null
-
feat(network): add chain id to cache id, disable loading from cache on hardhat
-
fix(contracts): change Position and EntityType schema to int32/uint32 to fit in js number
-
docs(client): fix typos in comments
-
fix(network): fix tests
-
fix(scripting): integrate new network package into ri scripting
-
fix(network): fix sending multiple requests for component schema if many events get reduced
0.1.8 (2022-05-25)
Note: Version bump only for package @latticexyz/recs
0.1.7 (2022-05-25)
Note: Version bump only for package @latticexyz/recs
0.1.6 (2022-05-25)
Note: Version bump only for package @latticexyz/recs
0.1.5 (2022-05-24)
Note: Version bump only for package @latticexyz/recs
0.1.4 (2022-05-24)
Note: Version bump only for package @latticexyz/recs
0.1.3 (2022-05-23)
Note: Version bump only for package @latticexyz/recs
0.1.2 (2022-05-23)
Note: Version bump only for package @latticexyz/recs
0.1.1 (2022-05-23)
Note: Version bump only for package @latticexyz/recs
- @mud/recs: add @mud/recs (aaf6d0f)