Skip to content

Latest commit

 

History

History
839 lines (507 loc) · 37.2 KB

File metadata and controls

839 lines (507 loc) · 37.2 KB

Change Log

2.0.0-next.10

Patch Changes

  • Updated dependencies []:
    • @latticexyz/schema-type@2.0.0-next.10
    • @latticexyz/utils@2.0.0-next.10

2.0.0-next.9

Patch Changes

  • Updated dependencies [92de5998]:
    • @latticexyz/schema-type@2.0.0-next.9
    • @latticexyz/utils@2.0.0-next.9

2.0.0-next.8

Patch Changes

  • Updated dependencies []:
    • @latticexyz/schema-type@2.0.0-next.8
    • @latticexyz/utils@2.0.0-next.8

2.0.0-next.7

Patch Changes

  • Updated dependencies []:
    • @latticexyz/schema-type@2.0.0-next.7
    • @latticexyz/utils@2.0.0-next.7

2.0.0-next.6

Patch Changes

  • Updated dependencies []:
    • @latticexyz/schema-type@2.0.0-next.6
    • @latticexyz/utils@2.0.0-next.6

2.0.0-next.5

Patch Changes

  • Updated dependencies []:
    • @latticexyz/schema-type@2.0.0-next.5
    • @latticexyz/utils@2.0.0-next.5

2.0.0-next.4

Minor Changes

  • #1351 c14f8bf1 Thanks @holic! - - Moved createActionSystem from std-client to recs package and updated it to better support v2 sync stack.

    If you want to use createActionSystem alongside syncToRecs, 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 waitForComponentValueIn that caused the promise to not resolve if the component value was already set when the function was called.

    • Fixed a bug in createActionSystem that 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's updates instead of just the component name.

        actions.add({
          updates: () => [
            {
      -       component: "Resource",
      +       component: Resource,
              ...
            }
          ],
          ...
        });

Patch Changes

  • #1340 ce7125a1 Thanks @holic! - Removes solecs package. 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 with pnpm create mud@next your-app-name.

  • Updated dependencies []:

    • @latticexyz/schema-type@2.0.0-next.4
    • @latticexyz/utils@2.0.0-next.4

2.0.0-next.3

Patch Changes

  • Updated dependencies []:
    • @latticexyz/schema-type@2.0.0-next.3
    • @latticexyz/utils@2.0.0-next.3

2.0.0-next.2

Patch Changes

  • Updated dependencies [b8a6158d]:
    • @latticexyz/schema-type@2.0.0-next.2
    • @latticexyz/utils@2.0.0-next.2

2.0.0-next.1

Patch Changes

  • #1214 60cfd089 Thanks @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 recs package, including encodeEntity and decodeEntity utilities for composite keys.

    If you're using store-cache and useRow/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 replace store-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.

    1. Add @latticexyz/store-sync package to your app's client package and make sure viem is pinned to version 1.3.1 (otherwise you may get type errors)

    2. In your supportedChains.ts, replace foundry chain with our new mudFoundry chain.

      - 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];
    3. In getNetworkConfig.ts, remove the return type (to let TS infer it for now), remove now-unused config values, and add the viem chain object.

      - 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,
      + };
    4. In setupNetwork.ts, replace setupMUDV2Network with syncToRecs.

      - 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 setupNetwork is 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,
      + };
    5. Update createSystemCalls with the new return type of setupNetwork.

        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);
           };
    6. (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 LoadingState component, you'll want to migrate to the new SyncProgress:

    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 afdba793 Thanks @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, 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
  • Updated dependencies [b02f9d0e]:

    • @latticexyz/schema-type@2.0.0-next.1
    • @latticexyz/utils@2.0.0-next.1

2.0.0-next.0

Patch Changes

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

1.42.0 (2023-04-13)

Bug Fixes

  • recs,cli: fix bigint in recs and tsgen (#563) (29fefae)
  • recs: overridden component update stream should return the overridden component (#544) (9af097d)

Features

  • 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)

Bug Fixes

  • package entry points, peer dep versions (#409) (66a7fd6)

Reverts

  • 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)

Features

  • ecs-browser: replace react syntax highlighter with shiki and bundler with tsup (#262) (915506d)

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)

Bug Fixes

  • new entities should be included in overrides (#290) (878ee2a)

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)

Bug Fixes

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)

Features

  • recs: add util to clear cache of local cache component (#217) (30a5868)

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)

Features

  • expose registerComponent method from setupMUDNetwork (#207) (4b078bd)

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)

Bug Fixes

  • 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)

Bug Fixes

  • make OverridableComponent conform with Component type (#180) (c9d2c31)

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)

Bug Fixes

  • recs: change internal query behavior to match previous version (47b8834)

Features

  • 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)

Features

  • recs: add support for custom type in component (#158) (fdc781d)

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)

Bug Fixes

  • 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)

Bug Fixes

  • fix mud.dev build and improve responsiveness (#134) (a3f2b24)

Features

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)

Bug Fixes

  • better getComponentValueStrict error message, small std-client fixes (#121) (5c78b82)

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)

Bug Fixes

  • recs: fix fragment types in system definitions (#109) (c74f393)

Features

  • 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)

Features

0.2.0 (2022-07-05)

Features

BREAKING CHANGES

  • 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

0.1.0 (2022-05-23)

Features

  • @mud/recs: add @mud/recs (aaf6d0f)