diff --git a/packages/cli/src/deploy/getResourceAccess.ts b/packages/cli/src/deploy/getResourceAccess.ts index 6a793979bc..61ecd4f688 100644 --- a/packages/cli/src/deploy/getResourceAccess.ts +++ b/packages/cli/src/deploy/getResourceAccess.ts @@ -19,6 +19,7 @@ export async function getResourceAccess({ const blockLogs = await fetchBlockLogs({ fromBlock: worldDeploy.deployBlock, toBlock: worldDeploy.stateBlock, + maxBlockRange: 100_000n, async getLogs({ fromBlock, toBlock }) { return getStoreLogs(client, { address: worldDeploy.address, diff --git a/packages/cli/src/deploy/getResourceIds.ts b/packages/cli/src/deploy/getResourceIds.ts index cd050e5f43..d0714c4a2d 100644 --- a/packages/cli/src/deploy/getResourceIds.ts +++ b/packages/cli/src/deploy/getResourceIds.ts @@ -17,6 +17,7 @@ export async function getResourceIds({ const blockLogs = await fetchBlockLogs({ fromBlock: worldDeploy.deployBlock, toBlock: worldDeploy.stateBlock, + maxBlockRange: 100_000n, async getLogs({ fromBlock, toBlock }) { return getStoreLogs(client, { address: worldDeploy.address, diff --git a/packages/cli/src/deploy/getTables.ts b/packages/cli/src/deploy/getTables.ts index f2624dc112..196b24421e 100644 --- a/packages/cli/src/deploy/getTables.ts +++ b/packages/cli/src/deploy/getTables.ts @@ -30,6 +30,7 @@ export async function getTables({ const blockLogs = await fetchBlockLogs({ fromBlock: worldDeploy.deployBlock, toBlock: worldDeploy.stateBlock, + maxBlockRange: 100_000n, async getLogs({ fromBlock, toBlock }) { return getStoreLogs(client, { address: worldDeploy.address, diff --git a/packages/cli/src/pull/pull.ts b/packages/cli/src/pull/pull.ts index 30bda1bd40..8616c6f5d4 100644 --- a/packages/cli/src/pull/pull.ts +++ b/packages/cli/src/pull/pull.ts @@ -1,4 +1,4 @@ -import { Address, Client, hexToString, parseAbi, stringToHex } from "viem"; +import { Address, Client, hexToString, parseAbiItem, stringToHex } from "viem"; import { getTables } from "../deploy/getTables"; import { getWorldDeploy } from "../deploy/getWorldDeploy"; import { getSchemaTypes } from "@latticexyz/protocol-parser/internal"; @@ -13,6 +13,7 @@ import { abiToInterface, formatSolidity, formatTypescript } from "@latticexyz/co import { debug } from "./debug"; import { defineWorld } from "@latticexyz/world"; import { findUp } from "find-up"; +import { isDefined } from "@latticexyz/common/utils"; const ignoredNamespaces = new Set(["store", "world", "metadata"]); @@ -106,12 +107,29 @@ export async function pull({ rootDir, client, worldAddress, replace }: PullOptio // If empty or unset ABI in metadata table, backfill with world functions. // These don't have parameter names or return values, but better than nothing? - const abi = parseAbi( - metadataAbi.length ? metadataAbi : functions.map((func) => `function ${func.systemFunctionSignature}`), - ); - const worldAbi = parseAbi( - metadataWorldAbi.length ? metadataWorldAbi : functions.map((func) => `function ${func.signature}`), - ); + const abi = ( + metadataAbi.length ? metadataAbi : functions.map((func) => `function ${func.systemFunctionSignature}`) + ) + .map((sig) => { + try { + return parseAbiItem(sig); + } catch { + debug(`Skipping invalid system signature: ${sig}`); + } + }) + .filter(isDefined); + + const worldAbi = ( + metadataWorldAbi.length ? metadataWorldAbi : functions.map((func) => `function ${func.signature}`) + ) + .map((sig) => { + try { + return parseAbiItem(sig); + } catch { + debug(`Skipping invalid world signature: ${sig}`); + } + }) + .filter(isDefined); return { namespaceId, diff --git a/packages/common/src/codegen/render-solidity/abiToInterface.ts b/packages/common/src/codegen/render-solidity/abiToInterface.ts index ab81d96db7..ce624d696d 100644 --- a/packages/common/src/codegen/render-solidity/abiToInterface.ts +++ b/packages/common/src/codegen/render-solidity/abiToInterface.ts @@ -4,9 +4,10 @@ import { renderedSolidityHeader } from "./common"; import { hexToResource } from "../../hexToResource"; function formatParam(param: AbiParameter): string { - return param.type === "string" || param.type === "bytes" || param.type === "tuple" || param.type.endsWith("]") - ? `${formatAbiParameter(param)} memory` - : formatAbiParameter(param); + // return param.type === "string" || param.type === "bytes" || param.type === "tuple" || param.type.endsWith("]") + // ? `${formatAbiParameter(param)} memory` + // : formatAbiParameter(param); + return formatAbiParameter(param); } function formatFunction(item: AbiFunction): string {