mud

MUD is a framework for building ambitious onchain applications

MIT License

Downloads
318.4K
Stars
643
Committers
80

Bot releases are visible (Hide)

mud - @latticexyz/[email protected]

Published by github-actions[bot] about 1 year ago

Patch Changes

mud - @latticexyz/[email protected]

Published by github-actions[bot] about 1 year ago

Patch Changes

mud - @latticexyz/[email protected]

Published by github-actions[bot] about 1 year ago

Patch Changes

mud - @latticexyz/[email protected]

Published by github-actions[bot] about 1 year ago

mud - @latticexyz/[email protected]

Published by github-actions[bot] about 1 year ago

Patch Changes

mud - @latticexyz/[email protected]

Published by github-actions[bot] about 1 year ago

mud - @latticexyz/[email protected]

Published by github-actions[bot] about 1 year ago

Patch Changes

mud - @latticexyz/[email protected]

Published by github-actions[bot] about 1 year ago

Patch Changes

mud - [email protected]

Published by github-actions[bot] about 1 year ago

Major 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!
    }
    
mud - @latticexyz/[email protected]

Published by github-actions[bot] about 1 year ago

Patch Changes

mud - @latticexyz/[email protected]

Published by github-actions[bot] about 1 year ago

Major 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!
    }
    
  • #1258 6c673325 Thanks @holic! - Add tableIdToHex and hexToTableId pure functions and move/deprecate TableId.

  • #1261 cd5abcc3 Thanks @holic! - Add utils for using viem with MUD

    • createContract is a wrapper around viem's getContract but with better nonce handling for faster executing of transactions. It has the same arguments and return type as getContract.
    • createNonceManager helps track local nonces, used by createContract.

    Also renames mudTransportObserver to transportObserver.

Minor Changes

  • #1245 3fb9ce28 Thanks @holic! - Add utils for using viem with MUD

    • mudFoundry chain with a transaction request formatter that temporarily removes max fees to work better with anvil --base-fee 0
    • createBurnerAccount that also temporarily removes max fees during transaction signing to work better with anvil --base-fee 0
    • mudTransportObserver that will soon let MUD Dev Tools observe transactions

    You can use them like:

    import { createBurnerAccount, mudTransportObserver } from "@latticexyz/common";
    import { mudFoundry } from "@latticexyz/common/chains";
    
    createWalletClient({
      account: createBurnerAccount(privateKey),
      chain: mudFoundry,
      transport: mudTransportObserver(http()),
      pollingInterval: 1000,
    });
    
  • #1266 6071163f Thanks @holic! - - Moves zero gas fee override to createContract until https://github.com/wagmi-dev/viem/pull/963 or similar feature lands

    • Skip simulation if gas is provided

Patch Changes

  • #1271 35c9f33d Thanks @holic! - - Remove need for tx queue in createContract

  • #1210 cc2c8da0 Thanks @dk1a! - - Refactor tightcoder to use typescript functions instead of ejs

    • Optimize TightCoder library
    • Add isLeftAligned and getLeftPaddingBits common codegen helpers
  • Updated dependencies [b02f9d0e]:

mud - @latticexyz/[email protected]

Published by github-actions[bot] about 1 year ago

Patch Changes

  • #1178 168a4cb4 Thanks @TheGreatAxios! - Add support for legacy transactions in deploy script by falling back to gasPrice if lastBaseFeePerGas is not available

  • #1206 e259ef79 Thanks @holic! - Generated contractComponents now properly import World as type

  • #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!
    }
    
  • #1258 6c673325 Thanks @holic! - Add tableIdToHex and hexToTableId pure functions and move/deprecate TableId.

  • #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 [3236f799, c963b46c, 3fb9ce28, 35c9f33d, 5c965a91, b02f9d0e, 60cfd089, 6071163f, 6c673325, cd5abcc3, cc2c8da0]:

mud - @latticexyz/[email protected]

Published by github-actions[bot] about 1 year ago

Patch Changes

mud - @latticexyz/[email protected]

Published by github-actions[bot] over 1 year ago

Minor Changes

  • #1061 a7b30c79 Thanks @dk1a! - Rename MudV2Test to MudTest and move from @latticexyz/std-contracts to @latticexyz/store.

    // old import
    import { MudV2Test } from "@latticexyz/std-contracts/src/test/MudV2Test.t.sol";
    // new import
    import { MudTest } from "@latticexyz/store/src/MudTest.sol";
    

    Refactor StoreSwitch to use a storage slot instead of function isStore() to determine which contract is Store:

    • Previously StoreSwitch called isStore() on msg.sender to determine if msg.sender is a Store contract. If the call succeeded, the Store methods were called on msg.sender, otherwise the data was written to the own storage.
    • With this change StoreSwitch instead checks for an address in a known storage slot. If the address equals the own address, data is written to the own storage. If it is an external address, Store methods are called on this address. If it is unset (address(0)), store methods are called on msg.sender.
    • In practice this has the same effect as before: By default the World contracts sets its own address in StoreSwitch, while System contracts keep the Store address undefined, so Systems write to their caller (World) if they are executed via call or directly to the World storage if they are executed via delegatecall.
    • Besides gas savings, this change has two additional benefits:
      1. it is now possible for Systems to explicitly set a Store address to make them exclusive to that Store and
      2. table libraries can now be used in tests without having to provide an explicit Store argument, because the MudTest base contract redirects reads and writes to the internal World contract.

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

  • world: allow world to access own functions via external calls (#609) (98047f7)
  • world: give World contract access to root namespace (#575) (cbef50d)

Features

  • add support for key schemas (#480) (37aec2e)
  • align git dep versions (#577) (2b5fb5e)
  • cli: add encode function to all tables (#498) (564604c)
  • cli: add module config to CLI (#494) (263c828)
  • cli: add registerFunctionSelectors to deploy cli (#501) (de3d459)
  • cli: add worldgen (#496) (e84c0c8)
  • cli: allow customization of IWorld interface name via mud config, change world/IWorld to world/IBaseWorld (#545) (38b355c)
  • cli: allow static arrays as abi types in store config and tablegen (#509) (588d037)
  • cli: improve storeArgument, refactor cli (#500) (bb68670)
  • cli: set storeArgument to true by default (#553) (cb1ecbc)
  • cli: use a central codegen dir for tablegen and worldgen (#585) (7500b11)
  • cli: use abi types in store config (#507) (12a739f)
  • cli: use json for gas report output (#607) (bea12ca)
  • config: separate config from cli (#600) (cd224a5)
  • use IErrors in IStore and IWorldCore (#573) (4f9ed7b)
  • v2 event decoding (#415) (374ed54)
  • world,store: add updateInField (#525) (0ac76fd)
  • world: add naive ReverseMappingHook/Module (#487) (36aaaef)
  • world: add support for modules, add RegistrationModule, add CoreModule (#482) (624cbbc)
  • world: add UniqueEntityModule (#552) (983e26a)
  • world: allow payable systems (#568) (b63aca8)
  • world: allow registration of function selectors in the World, split out RegisterSystem from World (#481) (ba0166f)
  • world: index first key for KeysWithValueModule on tables with composite keys (#569) (bcba109)
  • world: ReverseMapping: infer target table id from source table id, add getKeysWithValue util (#490) (f69e3dc)
  • world: simplify access control to namespaces instead of routes (#467) (945f2ef)

1.41.0 (2023-03-09)

Bug Fixes

  • cli: add missing await to tablegen, fix formatting (#472) (4313c27)
  • world: fix schema order (#464) (3d137dd)

Features

  • add pushToField to Store and World (#434) (b665efc)
  • cli: add setMetadata to autogen of table libraries (#466) (1e129fe)
  • cli: add v2 deployment script (#450) (1db37a5)
  • cli: user types and route/path separation (#454) (758bf03)

1.40.0 (2023-03-03)

Features

  • add StoreMetadata table for table name and field names to Store and World (#428) (ae39ace)
  • v2 - add store, world and schema-type, cli table code generation (#422) (cb731e0)

BREAKING CHANGES

  • This commit removes the deprecated mud deploy CLI command. Use mud deploy-contracts instead.
mud - @latticexyz/[email protected]

Published by github-actions[bot] over 1 year ago

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)

Features

1.41.0 (2023-03-09)

Note: Version bump only for package @latticexyz/utils

1.40.0 (2023-03-03)

Note: Version bump only for package @latticexyz/utils

1.39.0 (2023-02-22)

Note: Version bump only for package @latticexyz/utils

1.38.0 (2023-02-22)

Note: Version bump only for package @latticexyz/utils

mud - @latticexyz/[email protected]

Published by github-actions[bot] over 1 year ago

Minor Changes

  • #1075 904fd7d4 Thanks @holic! - Add store sync package

  • #1176 eeb15cc0 Thanks @holic! - - 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.
  • #1185 69a96f10 Thanks @holic! - blockLogsToStorage(sqliteStorage(...)) converts block logs to SQLite operations. You can use it like:

    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();
    

Patch Changes

mud - @latticexyz/[email protected]

Published by github-actions[bot] over 1 year ago

Patch Changes

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

mud - @latticexyz/[email protected]

Published by github-actions[bot] over 1 year ago

Minor Changes

  • #1147 66cc35a8 Thanks @dk1a! - Create gas-report package, move gas-report cli command and GasReporter contract to it

  • #1061 a7b30c79 Thanks @dk1a! - Rename MudV2Test to MudTest and move from @latticexyz/std-contracts to @latticexyz/store.

    // old import
    import { MudV2Test } from "@latticexyz/std-contracts/src/test/MudV2Test.t.sol";
    // new import
    import { MudTest } from "@latticexyz/store/src/MudTest.sol";
    

    Refactor StoreSwitch to use a storage slot instead of function isStore() to determine which contract is Store:

    • Previously StoreSwitch called isStore() on msg.sender to determine if msg.sender is a Store contract. If the call succeeded, the Store methods were called on msg.sender, otherwise the data was written to the own storage.
    • With this change StoreSwitch instead checks for an address in a known storage slot. If the address equals the own address, data is written to the own storage. If it is an external address, Store methods are called on this address. If it is unset (address(0)), store methods are called on msg.sender.
    • In practice this has the same effect as before: By default the World contracts sets its own address in StoreSwitch, while System contracts keep the Store address undefined, so Systems write to their caller (World) if they are executed via call or directly to the World storage if they are executed via delegatecall.
    • Besides gas savings, this change has two additional benefits:
      1. it is now possible for Systems to explicitly set a Store address to make them exclusive to that Store and
      2. table libraries can now be used in tests without having to provide an explicit Store argument, because the MudTest base contract redirects reads and writes to the internal World contract.

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

  • cli: account for getRecord's trimming (#574) (9c5317a)

Features

  • add support for key schemas (#480) (37aec2e)
  • cli: add encode function to all tables (#498) (564604c)
  • cli: add module config to CLI (#494) (263c828)
  • cli: allow static arrays as abi types in store config and tablegen (#509) (588d037)
  • cli: improve storeArgument, refactor cli (#500) (bb68670)
  • cli: set storeArgument to true by default (#553) (cb1ecbc)
  • cli: use a central codegen dir for tablegen and worldgen (#585) (7500b11)
  • cli: use abi types in store config (#507) (12a739f)
  • cli: use json for gas report output (#607) (bea12ca)
  • config: separate config from cli (#600) (cd224a5)
  • store: add metadata to the schema table (#550) (55ab704)
  • use IErrors in IStore and IWorldCore (#573) (4f9ed7b)
  • v2 event decoding (#415) (374ed54)
  • world,store: add updateInField (#525) (0ac76fd)
  • world: add naive ReverseMappingHook/Module (#487) (36aaaef)
  • world: add support for modules, add RegistrationModule, add CoreModule (#482) (624cbbc)
  • world: add UniqueEntityModule (#552) (983e26a)
  • world: allow registration of function selectors in the World, split out RegisterSystem from World (#481) (ba0166f)
  • world: simplify access control to namespaces instead of routes (#467) (945f2ef)

1.41.0 (2023-03-09)

Bug Fixes

  • cli: add missing await to tablegen, fix formatting (#472) (4313c27)

Features

  • add pushToField to Store and World (#434) (b665efc)
  • cli: add setMetadata to autogen of table libraries (#466) (1e129fe)
  • cli: add v2 deployment script (#450) (1db37a5)
  • cli: user types and route/path separation (#454) (758bf03)

1.40.0 (2023-03-03)

Features

  • add StoreMetadata table for table name and field names to Store and World (#428) (ae39ace)
  • v2 - add store, world and schema-type, cli table code generation (#422) (cb731e0)

BREAKING CHANGES

  • This commit removes the deprecated mud deploy CLI command. Use mud deploy-contracts instead.
mud - @latticexyz/[email protected]

Published by github-actions[bot] over 1 year ago

Minor Changes

  • #1061 a7b30c79 Thanks @dk1a! - Rename MudV2Test to MudTest and move from @latticexyz/std-contracts to @latticexyz/store.

    // old import
    import { MudV2Test } from "@latticexyz/std-contracts/src/test/MudV2Test.t.sol";
    // new import
    import { MudTest } from "@latticexyz/store/src/MudTest.sol";
    

    Refactor StoreSwitch to use a storage slot instead of function isStore() to determine which contract is Store:

    • Previously StoreSwitch called isStore() on msg.sender to determine if msg.sender is a Store contract. If the call succeeded, the Store methods were called on msg.sender, otherwise the data was written to the own storage.
    • With this change StoreSwitch instead checks for an address in a known storage slot. If the address equals the own address, data is written to the own storage. If it is an external address, Store methods are called on this address. If it is unset (address(0)), store methods are called on msg.sender.
    • In practice this has the same effect as before: By default the World contracts sets its own address in StoreSwitch, while System contracts keep the Store address undefined, so Systems write to their caller (World) if they are executed via call or directly to the World storage if they are executed via delegatecall.
    • Besides gas savings, this change has two additional benefits:
      1. it is now possible for Systems to explicitly set a Store address to make them exclusive to that Store and
      2. table libraries can now be used in tests without having to provide an explicit Store argument, because the MudTest base contract redirects reads and writes to the internal World contract.

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)

Features

1.41.0 (2023-03-09)

Note: Version bump only for package @latticexyz/std-contracts

1.40.0 (2023-03-03)

Note: Version bump only for package @latticexyz/std-contracts

1.39.0 (2023-02-22)

Note: Version bump only for package @latticexyz/std-contracts

1.38.0 (2023-02-22)

Note: Version bump only for package @latticexyz/std-contracts

mud - @latticexyz/[email protected]

Published by github-actions[bot] over 1 year ago

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

Features

  • cli/recs/std-client: add ts definitions generator (#536) (dd1efa6)
  • config: separate config from cli (#600) (cd224a5)
  • network,recs,std-client: support StoreSetField before StoreSetRecord (#581) (f259f90), closes #479 #523
  • network: add option to sync in main thread instead of worker (#522) (4e8e7d7)
  • network: integrate initial sync from MODE (#493) (7d06c1b)
  • std-client: add getBurnerWallet util (#546) (f427b50)
  • std-client: move v2 setup to its own function/file (#526) (ef5b4c2)
  • use viem when creating burner wallet (#576) (d5d22e0)
  • v2 event decoding (#415) (374ed54)

1.41.0 (2023-03-09)

Note: Version bump only for package @latticexyz/std-client

1.40.0 (2023-03-03)

Note: Version bump only for package @latticexyz/std-client

1.39.0 (2023-02-22)

Note: Version bump only for package @latticexyz/std-client

1.38.0 (2023-02-22)

Note: Version bump only for package @latticexyz/std-client