Skip to content

Commit

Permalink
skip bad signatures, fix interface gen
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Oct 6, 2024
1 parent 855f819 commit 706a16c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/cli/src/deploy/getResourceAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/deploy/getResourceIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/deploy/getTables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 25 additions & 7 deletions packages/cli/src/pull/pull.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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"]);

Expand Down Expand Up @@ -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,
Expand Down
7 changes: 4 additions & 3 deletions packages/common/src/codegen/render-solidity/abiToInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 706a16c

Please sign in to comment.