Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into account-kit
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Apr 19, 2024
2 parents 5e1a248 + 534e772 commit 586b9be
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-apes-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@latticexyz/cli": patch
---

Fixed an issue where deploys were warning about mismatched bytecode when the bytecode was correct and what we expect.
5 changes: 5 additions & 0 deletions .changeset/shiny-donuts-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"create-mud": patch
---

Made `worlds.json`'s `address` type more like viem's `Hex` type so it's easy to pass through as an argument.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ You can see the fix in [PR #2680](https://github.com/latticexyz/mud/pull/2680).

## How the bug was discovered

![Untitled](https://prod-files-secure.s3.us-west-2.amazonaws.com/0857dec6-6364-4f79-87ea-ff7da1ce8868/7add321e-9294-4edb-a874-32029cd5660a/Untitled.png)
![Screen capture from Discord of how it was discovered](./2024-04-17-discovery.png)

Marcineq from Minters raised that they were getting incorrect values from the `getItem` method for static arrays.

Expand Down
2 changes: 1 addition & 1 deletion e2e/packages/contracts/worlds.json.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
declare const worlds: Partial<Record<string, { address: string; blockNumber?: number }>>;
declare const worlds: Partial<Record<string, { address: `0x${string}`; blockNumber?: number }>>;
export default worlds;
2 changes: 1 addition & 1 deletion examples/minimal/packages/contracts/worlds.json.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
declare const worlds: Partial<Record<string, { address: string; blockNumber?: number }>>;
declare const worlds: Partial<Record<string, { address: `0x${string}`; blockNumber?: number }>>;
export default worlds;
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
declare const worlds: Partial<Record<string, { address: string; blockNumber?: number }>>;
declare const worlds: Partial<Record<string, { address: `0x${string}`; blockNumber?: number }>>;
export default worlds;
4 changes: 2 additions & 2 deletions packages/cli/src/deploy/create2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ git checkout b3bb19c
npm install
npm run build
cd output
jq --arg bc "$(cat bytecode.txt)" '. + {bytecode: $bc}' deployment.json > deployment-with-bytecode.json
mv deployment-with-bytecode.json deployment.json
jq --arg bc "$(cat bytecode.txt)" '. + {creationCode: $bc}' deployment.json > deployment-with-creationCode.json
mv deployment-with-creationCode.json deployment.json
cp deployment.json ../path/to/this/dir
```
2 changes: 1 addition & 1 deletion packages/cli/src/deploy/create2/deployment.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"signerAddress": "3fab184622dc19b6109349b94811493bf2a45362",
"transaction": "f8a58085174876e800830186a08080b853604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf31ba02222222222222222222222222222222222222222222222222222222222222222a02222222222222222222222222222222222222222222222222222222222222222",
"address": "4e59b44847b379578588920ca78fbf26c0b4956c",
"bytecode": "604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"
"creationCode": "604580600e600039806000f350fe7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe03601600081602082378035828234f58015156039578182fd5b8082525050506014600cf3"
}
8 changes: 4 additions & 4 deletions packages/cli/src/deploy/ensureDeployer.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { Account, Address, Chain, Client, Transport } from "viem";
import { Account, Address, Chain, Client, Transport, sliceHex } from "viem";
import { getBalance, getBytecode, sendRawTransaction, sendTransaction, waitForTransactionReceipt } from "viem/actions";
import deployment from "./create2/deployment.json";
import { debug } from "./debug";

const deployer = `0x${deployment.address}` as const;
const deployerBytecode = `0x${deployment.bytecode}` as const;

export async function ensureDeployer(client: Client<Transport, Chain | undefined, Account>): Promise<Address> {
const bytecode = await getBytecode(client, { address: deployer });
if (bytecode) {
debug("found CREATE2 deployer at", deployer);
if (bytecode !== deployerBytecode) {
// check if deployed bytecode is the same as the expected bytecode (minus 14-bytes creation code prefix)
if (bytecode !== sliceHex(`0x${deployment.creationCode}`, 14)) {
console.warn(
`\n ⚠️ Bytecode for deployer at ${deployer} did not match the expected CREATE2 bytecode. You may have unexpected results.\n`,
);
Expand Down Expand Up @@ -53,7 +53,7 @@ export async function ensureDeployer(client: Client<Transport, Chain | undefined
debug("deploying CREATE2 deployer");
return sendTransaction(client, {
chain: client.chain ?? null,
data: deployerBytecode,
data: `0x${deployment.creationCode}`,
});
}
throw error;
Expand Down
2 changes: 1 addition & 1 deletion templates/phaser/packages/contracts/worlds.json.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
declare const worlds: Partial<Record<string, { address: string; blockNumber?: number }>>;
declare const worlds: Partial<Record<string, { address: `0x${string}`; blockNumber?: number }>>;
export default worlds;
2 changes: 1 addition & 1 deletion templates/react-ecs/packages/contracts/worlds.json.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
declare const worlds: Partial<Record<string, { address: string; blockNumber?: number }>>;
declare const worlds: Partial<Record<string, { address: `0x${string}`; blockNumber?: number }>>;
export default worlds;
2 changes: 1 addition & 1 deletion templates/react/packages/contracts/worlds.json.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
declare const worlds: Partial<Record<string, { address: string; blockNumber?: number }>>;
declare const worlds: Partial<Record<string, { address: `0x${string}`; blockNumber?: number }>>;
export default worlds;
2 changes: 1 addition & 1 deletion templates/threejs/packages/contracts/worlds.json.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
declare const worlds: Partial<Record<string, { address: string; blockNumber?: number }>>;
declare const worlds: Partial<Record<string, { address: `0x${string}`; blockNumber?: number }>>;
export default worlds;
2 changes: 1 addition & 1 deletion templates/vanilla/packages/contracts/worlds.json.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
declare const worlds: Partial<Record<string, { address: string; blockNumber?: number }>>;
declare const worlds: Partial<Record<string, { address: `0x${string}`; blockNumber?: number }>>;
export default worlds;

0 comments on commit 586b9be

Please sign in to comment.