diff --git a/packages/cli/src/commands/abigen.ts b/packages/cli/src/commands/abigen.ts index a61b630fc3..03d71a57e3 100644 --- a/packages/cli/src/commands/abigen.ts +++ b/packages/cli/src/commands/abigen.ts @@ -44,7 +44,7 @@ export async function abigenHandler(opts: Options) { const systems = await getSystems({ client, worldDeploy }); - systems.map(abigen); + systems.map((system) => abigen(system.functions.map((func) => func.systemFunctionSignature))); } export default commandModule; diff --git a/packages/world/ts/node/render-solidity/abigen.ts b/packages/world/ts/node/render-solidity/abigen.ts index 11ddc6a8f0..52392b6daa 100644 --- a/packages/world/ts/node/render-solidity/abigen.ts +++ b/packages/world/ts/node/render-solidity/abigen.ts @@ -1,54 +1,8 @@ -import { Abi, Address, Hex } from "viem"; +import { Abi } from "viem"; -type DeterministicContract = { - readonly prepareDeploy: ( - deployer: Address, - libraries: readonly Library[], - ) => { - readonly address: Address; - readonly bytecode: Hex; - }; - readonly deployedBytecodeSize: number; - readonly abi: Abi; -}; - -type Library = DeterministicContract & { - /** - * Path to library source file, e.g. `src/libraries/SomeLib.sol` - */ - path: string; - /** - * Library name, e.g. `SomeLib` - */ - name: string; -}; - -// map over each and decode signature -type WorldFunction = { - readonly signature: string; - readonly selector: Hex; - readonly systemId: Hex; - readonly systemFunctionSignature: string; - readonly systemFunctionSelector: Hex; -}; - -type System = DeterministicContract & { - readonly namespace: string; - readonly name: string; - readonly systemId: Hex; - readonly allowAll: boolean; - readonly allowedAddresses: readonly Hex[]; - readonly allowedSystemIds: readonly Hex[]; - readonly functions: readonly WorldFunction[]; -}; - -type DeployedSystem = Omit & { - address: Address; -}; - -export function abigen(system: DeployedSystem): Abi { - const abi = system.functions.map((func) => { - const match = func.systemFunctionSignature.match(/^([a-zA-Z_]\w*)\((.*)\)$/); +export function abigen(systemFunctionSignatures: readonly string[]): Abi { + const abi = systemFunctionSignatures.map((systemFunctionSignature) => { + const match = systemFunctionSignature.match(/^([a-zA-Z_]\w*)\((.*)\)$/); if (!match) { throw new Error("Invalid signature"); }