Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into holic/store-sync-recs
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Jul 31, 2023
2 parents 84c54cd + b24502c commit 543334c
Show file tree
Hide file tree
Showing 68 changed files with 3,389 additions and 403 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-hotels-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/cli": patch
---

Add support for legacy transactions in deploy script by falling back to `gasPrice` if `lastBaseFeePerGas` is not available
5 changes: 5 additions & 0 deletions .changeset/big-goats-prove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/services": patch
---

protocol-parser in Go
5 changes: 5 additions & 0 deletions .changeset/brave-rings-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/store": patch
---

Optimize storage library
6 changes: 6 additions & 0 deletions .changeset/mean-pans-study.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@latticexyz/cli": patch
"@latticexyz/std-client": patch
---

Generated `contractComponents` now properly import `World` as type
5 changes: 4 additions & 1 deletion .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ jobs:
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# Remove this once https://github.com/changesets/changesets/issues/1195 is addressed
- name: Temporarily exit pre-release mode to release a snapshot
run: pnpm changeset pre exit

- name: Clean
shell: bash
run: pnpm turbo run clean --force --concurrency 10
Expand All @@ -44,4 +48,3 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist
**/types/ethers-contracts
**/.next
templates/phaser/packages/art
templates/phaser/packages/art
**/contractComponents.ts
6 changes: 5 additions & 1 deletion docs/components/Logo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ export default function Logo() {
const [src, setSrc] = useState("/logo512-white.png"); // default to the dark theme logo
const { theme } = useTheme();

// useEffect(() => {
// setSrc(theme === "light" ? "/logo512-black.png" : "/logo512-white.png");
//}, [theme]);

useEffect(() => {
setSrc(theme === "light" ? "/logo512-black.png" : "/logo512-white.png");
setSrc(theme === "light" ? "/mud-cover-photo.png" : "/mud-cover-photo.png");
}, [theme]);

return <img src={src} alt="MUD logo" />;
Expand Down
9 changes: 4 additions & 5 deletions docs/components/WarningBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ import React from "react";
const WarningBox = ({ title, message }) => {
const styles = {
container: {
backgroundColor: "#ffebee",
backgroundColor: "#FDF2F3",
borderRadius: "4px",
boxShadow: "0 2px 1px -1px rgba(0, 0, 0, 0.2), 0 1px 1px 0 rgba(0, 0, 0, 0.14), 0 1px 3px 0 rgba(0, 0, 0, 0.12)",
border: "1px solid #E8D9DA",
padding: "12px 20px",
margin: "16px 0",
color: "#b71c1c",
color: "#7D221C",
},
header: {
display: "flex",
alignItems: "center",
fontSize: "1rem",
fontWeight: "bold",
lineHeight: "1.43",
letterSpacing: "0.01071em",
},
icon: {
marginRight: "12px",
Expand All @@ -26,8 +25,8 @@ const WarningBox = ({ title, message }) => {
fontSize: "1rem",
fontWeight: "400",
lineHeight: "1.43",
letterSpacing: "0.01071em",
paddingLeft: "34px",
color: "#995A56",
},
};

Expand Down
6 changes: 6 additions & 0 deletions docs/pages/_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export default {
plugins: "Plugins",
tutorials: "Tutorials",
contribute: "Contribute",
roadmap: {
title: "Roadmap",
type: "page",
href: "https://roadmap.mud.dev",
newWindow: true,
},
community: {
title: "Community",
type: "page",
Expand Down
36 changes: 24 additions & 12 deletions docs/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,34 @@ import Logo from "../components/Logo";
<>
<p>
Please note that MUD v2 is still under development and some APIs may change! Stay up to date with MUD core
development, changes, and roadmap by checking out the{" "}
<a href="https://github.com/latticexyz/mud" target="_blank" style={{ textDecoration: "underline" }}>
development, changes, and&nbsp;
<a href="https://roadmap.mud.dev" target="_blank" style={{ textDecoration: "underline", color: "#7D221C" }}>
roadmap
</a> by checking out the <a
href="https://github.com/latticexyz/mud"
target="_blank"
style={{ textDecoration: "underline", color: "#7D221C" }}
>
Github repo
</a>{" "}
and join the{" "}
<a href="https://lattice.xyz/discord" target="_blank" style={{ textDecoration: "underline" }}>
MUD Discord
</a> and join the <a
href="https://lattice.xyz/discord"
target="_blank"
style={{ textDecoration: "underline", color: "#7D221C" }}
>
MUD Discord.
</a>{" "}
</p>
<div style={{ height: "12px" }} />
</>
}
/>
<div style={{ display: "flex", justifyContent: "center" }}>
<div style={{ width: "200px", marginBottom: "20px" }}>
<div style={{ marginBottom: "24px", marginTop: "12px" }}>
<Logo />
</div>
</div>

# MUD

## Introduction
# MUD Introduction

MUD is a framework for ambitious Ethereum applications. It compresses the complexity of building EVM apps with a tightly integrated software stack.

Expand All @@ -45,9 +52,14 @@ MUD is maximally onchain: the entire application state lives in the EVM, and the

## Community support

[Join our Discord](https://lattice.xyz/discord) to get support and connect with the community!
Check out the following resources to learn more and get support:

Check out our [community wiki](https://community.mud.dev) for MUD projects and MUD-related articles, videos, and podcasts.
- [Discord](https://lattice.xyz/discord): get support and connect with the community!
- [New releases](https://github.com/latticexyz/mud/releases): see recent changes to MUD.
- [Roadmap](https://roadmap.mud.dev): a high-level overview of what we'll be working on next.
- [Status](https://status.mud.dev): take a look at ongoing and upcoming initatives.
- [Contribute](https://contribute.mud.dev): start contributing with some good first tasks.
- [Community wiki](https://community.mud.dev): for MUD projects and MUD-related articles, videos, and podcasts.

## License

Expand Down
14 changes: 12 additions & 2 deletions docs/pages/world/world-101.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,29 @@ Now we can import our new table, and write something to it. Let’s write a func
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;
import { System } from "@latticexyz/world/src/System.sol";
import { Dog } from "../codegen/tables/Dog.sol"; // import table we created
import { Dog, DogData } from "../codegen/tables/Dog.sol"; // import table we created
contract MySystem is System {
function addEntry(string memory name, string memory color) public returns (bytes32) {
bytes32 key = bytes32(abi.encodePacked(block.number, msg.sender, gasleft())); // creating a random key for the record
address owner = _msgSender(); // IMPORTANT: always refer to the msg.sender using the _msgSender() function
Dog.set(key, {owner: owner, name: name, color: color}); // creating our record!
Dog.set(key, DogData({ owner: owner, name: name, color: color })); // creating our record!
return key;
}
}
```

That’s it! `MySystem`, just like `IncrementSystem`, will have access to Dog given they are in the same namespace.

We can run `pnpm mud worldgen` in the contract folder to recreate the systems.

```bash
> pnpm mud worldgen
Generated system interface: src/codegen/world/IIncrementSystem.sol
Generated system interface: src/codegen/world/IMySystem.sol
Generated system interface: src/codegen/world/IWorld.sol
```

After this step, the filesystem of the World is like this:

```bash
Expand Down
Binary file added docs/public/mud-cover-photo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion e2e/packages/client-vanilla/src/mud/contractComponents.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* Autogenerated file. Do not edit manually. */

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

export function defineContractComponents(world: World) {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* Autogenerated file. Do not edit manually. */

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

export function defineContractComponents(world: World) {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* Autogenerated file. Do not edit manually. */

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

export function defineContractComponents(world: World) {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* Autogenerated file. Do not edit manually. */

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

export function defineContractComponents(world: World) {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/render-ts/renderRecsV1Tables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function renderRecsV1Tables(options: RecsV1TableOptions) {

return `/* Autogenerated file. Do not edit manually. */
import { defineComponent, Type as RecsType, World } from "@latticexyz/recs";
import { defineComponent, Type as RecsType, type World } from "@latticexyz/recs";
export function defineContractComponents(world: World) {
return {
Expand Down
38 changes: 27 additions & 11 deletions packages/cli/src/utils/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ export async function deploy(
console.log("Initial nonce", nonce);

// Compute maxFeePerGas and maxPriorityFeePerGas like ethers, but allow for a multiplier to allow replacing pending transactions
let maxPriorityFeePerGas: number;
let maxFeePerGas: BigNumber;
let maxPriorityFeePerGas: number | undefined;
let maxFeePerGas: BigNumber | undefined;
let gasPrice: BigNumber | undefined;

await setInternalFeePerGas(priorityFeeMultiplier);

// Catch all to await any promises before exiting the script
Expand Down Expand Up @@ -402,6 +404,7 @@ export async function deploy(
nonce: nonce++,
maxPriorityFeePerGas,
maxFeePerGas,
gasPrice,
})
.then((c) => (disableTxWait ? c : c.deployed()));

Expand Down Expand Up @@ -497,7 +500,7 @@ export async function deploy(
const gasLimit = await contract.estimateGas[func].apply(null, args);
console.log(chalk.gray(`executing transaction: ${functionName} with nonce ${nonce}`));
const txPromise = contract[func]
.apply(null, [...args, { gasLimit, nonce: nonce++, maxPriorityFeePerGas, maxFeePerGas }])
.apply(null, [...args, { gasLimit, nonce: nonce++, maxPriorityFeePerGas, maxFeePerGas, gasPrice }])
.then((tx: any) => (confirmations === 0 ? tx : tx.wait(confirmations)));
promises.push(txPromise);
return txPromise;
Expand Down Expand Up @@ -542,15 +545,28 @@ export async function deploy(
async function setInternalFeePerGas(multiplier: number) {
// Compute maxFeePerGas and maxPriorityFeePerGas like ethers, but allow for a multiplier to allow replacing pending transactions
const feeData = await provider.getFeeData();
if (!feeData.lastBaseFeePerGas) throw new MUDError("Can not fetch lastBaseFeePerGas from RPC");
if (!feeData.lastBaseFeePerGas.eq(0) && (await signer.getBalance()).eq(0)) {
throw new MUDError(`Attempting to deploy to a chain with non-zero base fee with an account that has no balance.
If you're deploying to the Lattice testnet, you can fund your account by running 'pnpm mud faucet --address ${await signer.getAddress()}'`);
}

// Set the priority fee to 0 for development chains with no base fee, to allow transactions from unfunded wallets
maxPriorityFeePerGas = feeData.lastBaseFeePerGas.eq(0) ? 0 : Math.floor(1_500_000_000 * multiplier);
maxFeePerGas = feeData.lastBaseFeePerGas.mul(2).add(maxPriorityFeePerGas);
if (feeData.lastBaseFeePerGas) {
if (!feeData.lastBaseFeePerGas.eq(0) && (await signer.getBalance()).eq(0)) {
throw new MUDError(`Attempting to deploy to a chain with non-zero base fee with an account that has no balance.
If you're deploying to the Lattice testnet, you can fund your account by running 'pnpm mud faucet --address ${await signer.getAddress()}'`);
}

// Set the priority fee to 0 for development chains with no base fee, to allow transactions from unfunded wallets
maxPriorityFeePerGas = feeData.lastBaseFeePerGas.eq(0) ? 0 : Math.floor(1_500_000_000 * multiplier);
maxFeePerGas = feeData.lastBaseFeePerGas.mul(2).add(maxPriorityFeePerGas);
} else if (feeData.gasPrice) {
// Legacy chains with gasPrice instead of maxFeePerGas
if (!feeData.gasPrice.eq(0) && (await signer.getBalance()).eq(0)) {
throw new MUDError(
`Attempting to deploy to a chain with non-zero gas price with an account that has no balance.`
);
}

gasPrice = feeData.gasPrice;
} else {
throw new MUDError("Can not fetch fee data from RPC");
}
}
}

Expand Down
Loading

0 comments on commit 543334c

Please sign in to comment.