From 6bff86017ccdc78f4f67695d13f12b47cd310f42 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Thu, 14 Sep 2023 11:43:05 +0100 Subject: [PATCH] style: improve readability of codegen code (#1474) --- .gitattributes | 5 +- packages/store/ts/codegen/ephemeral.ts | 54 ++-- packages/store/ts/codegen/record.ts | 76 +++--- packages/store/ts/codegen/renderTable.ts | 233 +++++++++--------- packages/store/ts/codegen/renderTableIndex.ts | 17 +- .../codegen/tightcoder/renderDecodeSlice.ts | 21 +- .../codegen/tightcoder/renderEncodeArray.ts | 23 +- .../ts/codegen/tightcoder/renderFunctions.ts | 4 +- .../tightcoder/renderTightCoderAutoTest.ts | 15 +- .../render-solidity/renderSystemInterface.ts | 30 +-- .../ts/node/render-solidity/renderWorld.ts | 23 +- 11 files changed, 248 insertions(+), 253 deletions(-) diff --git a/.gitattributes b/.gitattributes index 694020c62d..58a6e9be45 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,4 @@ # suppress diffs for codegen in PRs -**/abi/**/* linguist-generated=true -**/codegen/**/* linguist-generated=true +**/abi/**/*.json linguist-generated=true +**/abi/**/*.json.d.ts linguist-generated=true +**/codegen/**/*.sol linguist-generated=true diff --git a/packages/store/ts/codegen/ephemeral.ts b/packages/store/ts/codegen/ephemeral.ts index d3a0a92458..c7fbc9ba4f 100644 --- a/packages/store/ts/codegen/ephemeral.ts +++ b/packages/store/ts/codegen/ephemeral.ts @@ -8,41 +8,41 @@ export function renderEphemeralMethods(options: RenderTableOptions) { let result = renderWithStore( storeArgument, (_typedStore, _store, _commentSuffix) => ` - /** Emit the ephemeral event using individual values${_commentSuffix} */ - function emitEphemeral(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - renderArguments(options.fields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`)), - ])}) internal { - bytes memory _data = encode(${renderArguments(options.fields.map(({ name }) => name))}); + /** Emit the ephemeral event using individual values${_commentSuffix} */ + function emitEphemeral(${renderArguments([ + _typedStore, + _typedTableId, + _typedKeyArgs, + renderArguments(options.fields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`)), + ])}) internal { + bytes memory _data = encode(${renderArguments(options.fields.map(({ name }) => name))}); - ${_keyTupleDefinition} + ${_keyTupleDefinition} - ${_store}.emitEphemeralRecord(_tableId, _keyTuple, _data, getFieldLayout()); - } - ` + ${_store}.emitEphemeralRecord(_tableId, _keyTuple, _data, getFieldLayout()); + } + ` ); if (structName !== undefined) { result += renderWithStore( storeArgument, (_typedStore, _store, _commentSuffix, _untypedStore) => ` - /** Emit the ephemeral event using the data struct${_commentSuffix} */ - function emitEphemeral(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - `${structName} memory _table`, - ])}) internal { - emitEphemeral(${renderArguments([ - _untypedStore, - _tableId, - _keyArgs, - renderArguments(options.fields.map(({ name }) => `_table.${name}`)), - ])}); - } - ` + /** Emit the ephemeral event using the data struct${_commentSuffix} */ + function emitEphemeral(${renderArguments([ + _typedStore, + _typedTableId, + _typedKeyArgs, + `${structName} memory _table`, + ])}) internal { + emitEphemeral(${renderArguments([ + _untypedStore, + _tableId, + _keyArgs, + renderArguments(options.fields.map(({ name }) => `_table.${name}`)), + ])}); + } + ` ); } diff --git a/packages/store/ts/codegen/record.ts b/packages/store/ts/codegen/record.ts index 7cfccd77f6..f334a01247 100644 --- a/packages/store/ts/codegen/record.ts +++ b/packages/store/ts/codegen/record.ts @@ -15,57 +15,57 @@ export function renderRecordMethods(options: RenderTableOptions) { let result = renderWithStore( storeArgument, (_typedStore, _store, _commentSuffix) => ` - /** Get the full data${_commentSuffix} */ - function get(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - ])}) internal view returns (${renderDecodedRecord(options)}) { - ${_keyTupleDefinition} - bytes memory _blob = ${_store}.getRecord(_tableId, _keyTuple, getFieldLayout()); - return decode(_blob); - } - ` + /** Get the full data${_commentSuffix} */ + function get(${renderArguments([ + _typedStore, + _typedTableId, + _typedKeyArgs, + ])}) internal view returns (${renderDecodedRecord(options)}) { + ${_keyTupleDefinition} + bytes memory _blob = ${_store}.getRecord(_tableId, _keyTuple, getFieldLayout()); + return decode(_blob); + } + ` ); result += renderWithStore( storeArgument, (_typedStore, _store, _commentSuffix) => ` - /** Set the full data using individual values${_commentSuffix} */ - function set(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - renderArguments(options.fields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`)), - ])}) internal { - bytes memory _data = encode(${renderArguments(options.fields.map(({ name }) => name))}); + /** Set the full data using individual values${_commentSuffix} */ + function set(${renderArguments([ + _typedStore, + _typedTableId, + _typedKeyArgs, + renderArguments(options.fields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`)), + ])}) internal { + bytes memory _data = encode(${renderArguments(options.fields.map(({ name }) => name))}); - ${_keyTupleDefinition} + ${_keyTupleDefinition} - ${_store}.setRecord(_tableId, _keyTuple, _data, getFieldLayout()); - } - ` + ${_store}.setRecord(_tableId, _keyTuple, _data, getFieldLayout()); + } + ` ); if (structName !== undefined) { result += renderWithStore( storeArgument, (_typedStore, _store, _commentSuffix, _untypedStore) => ` - /** Set the full data using the data struct${_commentSuffix} */ - function set(${renderArguments([ - _typedStore, - _typedTableId, - _typedKeyArgs, - `${structName} memory _table`, - ])}) internal { - set(${renderArguments([ - _untypedStore, - _tableId, - _keyArgs, - renderArguments(options.fields.map(({ name }) => `_table.${name}`)), - ])}); - } - ` + /** Set the full data using the data struct${_commentSuffix} */ + function set(${renderArguments([ + _typedStore, + _typedTableId, + _typedKeyArgs, + `${structName} memory _table`, + ])}) internal { + set(${renderArguments([ + _untypedStore, + _tableId, + _keyArgs, + renderArguments(options.fields.map(({ name }) => `_table.${name}`)), + ])}); + } + ` ); } diff --git a/packages/store/ts/codegen/renderTable.ts b/packages/store/ts/codegen/renderTable.ts index 31187893f5..cc19b244ef 100644 --- a/packages/store/ts/codegen/renderTable.ts +++ b/packages/store/ts/codegen/renderTable.ts @@ -34,135 +34,138 @@ export function renderTable(options: RenderTableOptions) { const { _typedTableId, _typedKeyArgs, _keyTupleDefinition } = renderCommonData(options); const shouldRenderDelete = !withEphemeralMethods; - return `${renderedSolidityHeader} - -// Import schema type -import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; - -// Import store internals -import { IStore } from "${storeImportPath}IStore.sol"; -import { StoreSwitch } from "${storeImportPath}StoreSwitch.sol"; -import { StoreCore } from "${storeImportPath}StoreCore.sol"; -import { Bytes } from "${storeImportPath}Bytes.sol"; -import { Memory } from "${storeImportPath}Memory.sol"; -import { SliceLib } from "${storeImportPath}Slice.sol"; -import { EncodeArray } from "${storeImportPath}tightcoder/EncodeArray.sol"; -import { FieldLayout, FieldLayoutLib } from "${storeImportPath}FieldLayout.sol"; -import { Schema, SchemaLib } from "${storeImportPath}Schema.sol"; -import { PackedCounter, PackedCounterLib } from "${storeImportPath}PackedCounter.sol"; - -${ - imports.length > 0 - ? ` - // Import user types - ${renderRelativeImports(imports)} - ` - : "" -} + return ` + ${renderedSolidityHeader} + + // Import schema type + import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; + + // Import store internals + import { IStore } from "${storeImportPath}IStore.sol"; + import { StoreSwitch } from "${storeImportPath}StoreSwitch.sol"; + import { StoreCore } from "${storeImportPath}StoreCore.sol"; + import { Bytes } from "${storeImportPath}Bytes.sol"; + import { Memory } from "${storeImportPath}Memory.sol"; + import { SliceLib } from "${storeImportPath}Slice.sol"; + import { EncodeArray } from "${storeImportPath}tightcoder/EncodeArray.sol"; + import { FieldLayout, FieldLayoutLib } from "${storeImportPath}FieldLayout.sol"; + import { Schema, SchemaLib } from "${storeImportPath}Schema.sol"; + import { PackedCounter, PackedCounterLib } from "${storeImportPath}PackedCounter.sol"; + + ${ + imports.length > 0 + ? ` + // Import user types + ${renderRelativeImports(imports)} + ` + : "" + } -${staticResourceData ? renderTableId(staticResourceData).tableIdDefinition : ""} + ${staticResourceData ? renderTableId(staticResourceData).tableIdDefinition : ""} -${ - !structName - ? "" - : ` - struct ${structName} { - ${renderList(fields, ({ name, typeId }) => `${typeId} ${name};`)} - } -` -} + ${ + !structName + ? "" + : ` + struct ${structName} { + ${renderList(fields, ({ name, typeId }) => `${typeId} ${name};`)} + } + ` + } -library ${libraryName} { - /** Get the table values' field layout */ - function getFieldLayout() internal pure returns (FieldLayout) { - uint256[] memory _fieldLayout = new uint256[](${staticFields.length}); - ${renderList(staticFields, ({ staticByteLength }, index) => `_fieldLayout[${index}] = ${staticByteLength};`)} + library ${libraryName} { + /** Get the table values' field layout */ + function getFieldLayout() internal pure returns (FieldLayout) { + uint256[] memory _fieldLayout = new uint256[](${staticFields.length}); + ${renderList(staticFields, ({ staticByteLength }, index) => `_fieldLayout[${index}] = ${staticByteLength};`)} - return FieldLayoutLib.encode(_fieldLayout, ${dynamicFields.length}); - } + return FieldLayoutLib.encode(_fieldLayout, ${dynamicFields.length}); + } - /** Get the table's key schema */ - function getKeySchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](${keyTuple.length}); - ${renderList(keyTuple, ({ enumName }, index) => `_schema[${index}] = SchemaType.${enumName};`)} + /** Get the table's key schema */ + function getKeySchema() internal pure returns (Schema) { + SchemaType[] memory _schema = new SchemaType[](${keyTuple.length}); + ${renderList(keyTuple, ({ enumName }, index) => `_schema[${index}] = SchemaType.${enumName};`)} - return SchemaLib.encode(_schema); - } + return SchemaLib.encode(_schema); + } - /** Get the table's value schema */ - function getValueSchema() internal pure returns (Schema) { - SchemaType[] memory _schema = new SchemaType[](${fields.length}); - ${renderList(fields, ({ enumName }, index) => `_schema[${index}] = SchemaType.${enumName};`)} + /** Get the table's value schema */ + function getValueSchema() internal pure returns (Schema) { + SchemaType[] memory _schema = new SchemaType[](${fields.length}); + ${renderList(fields, ({ enumName }, index) => `_schema[${index}] = SchemaType.${enumName};`)} - return SchemaLib.encode(_schema); - } + return SchemaLib.encode(_schema); + } - /** Get the table's key names */ - function getKeyNames() internal pure returns (string[] memory keyNames) { - keyNames = new string[](${keyTuple.length}); - ${renderList(keyTuple, (keyElement, index) => `keyNames[${index}] = "${keyElement.name}";`)} - } + /** Get the table's key names */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](${keyTuple.length}); + ${renderList(keyTuple, (keyElement, index) => `keyNames[${index}] = "${keyElement.name}";`)} + } - /** Get the table's field names */ - function getFieldNames() internal pure returns (string[] memory fieldNames) { - fieldNames = new string[](${fields.length}); - ${renderList(fields, (field, index) => `fieldNames[${index}] = "${field.name}";`)} - } + /** Get the table's field names */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](${fields.length}); + ${renderList(fields, (field, index) => `fieldNames[${index}] = "${field.name}";`)} + } - ${renderWithStore( - storeArgument, - (_typedStore, _store, _commentSuffix) => ` - /** Register the table with its config${_commentSuffix} */ - function register(${renderArguments([_typedStore, _typedTableId])}) internal { - ${_store}.registerTable(_tableId, getFieldLayout(), getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames()); - } - ` - )} - - ${withFieldMethods ? renderFieldMethods(options) : ""} - - ${withRecordMethods ? renderRecordMethods(options) : ""} - - ${withEphemeralMethods ? renderEphemeralMethods(options) : ""} - - /** Tightly pack full data using this table's field layout */ - function encode(${renderArguments( - options.fields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`) - )}) internal pure returns (bytes memory) { - ${renderEncodedLengths(dynamicFields)} - return abi.encodePacked(${renderArguments([ - renderArguments(staticFields.map(({ name }) => name)), - ...(dynamicFields.length === 0 - ? [] - : ["_encodedLengths.unwrap()", renderArguments(dynamicFields.map((field) => renderEncodeFieldSingle(field)))]), - ])}); - } - - /** Encode keys as a bytes32 array using this table's field layout */ - function encodeKeyTuple(${renderArguments([_typedKeyArgs])}) internal pure returns (bytes32[] memory) { - ${_keyTupleDefinition} - return _keyTuple; - } + ${renderWithStore( + storeArgument, + (_typedStore, _store, _commentSuffix) => ` + /** Register the table with its config${_commentSuffix} */ + function register(${renderArguments([_typedStore, _typedTableId])}) internal { + ${_store}.registerTable(_tableId, getFieldLayout(), getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames()); + } + ` + )} + + ${withFieldMethods ? renderFieldMethods(options) : ""} + + ${withRecordMethods ? renderRecordMethods(options) : ""} + + ${withEphemeralMethods ? renderEphemeralMethods(options) : ""} + + /** Tightly pack full data using this table's field layout */ + function encode(${renderArguments( + options.fields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`) + )}) internal pure returns (bytes memory) { + ${renderEncodedLengths(dynamicFields)} + return abi.encodePacked(${renderArguments([ + renderArguments(staticFields.map(({ name }) => name)), + ...(dynamicFields.length === 0 + ? [] + : [ + "_encodedLengths.unwrap()", + renderArguments(dynamicFields.map((field) => renderEncodeFieldSingle(field))), + ]), + ])}); + } + + /** Encode keys as a bytes32 array using this table's field layout */ + function encodeKeyTuple(${renderArguments([_typedKeyArgs])}) internal pure returns (bytes32[] memory) { + ${_keyTupleDefinition} + return _keyTuple; + } - ${ - shouldRenderDelete - ? renderWithStore( - storeArgument, - (_typedStore, _store, _commentSuffix) => ` - /* Delete all data for given keys${_commentSuffix} */ - function deleteRecord(${renderArguments([_typedStore, _typedTableId, _typedKeyArgs])}) internal { - ${_keyTupleDefinition} - ${_store}.deleteRecord(_tableId, _keyTuple, getFieldLayout()); + ${ + shouldRenderDelete + ? renderWithStore( + storeArgument, + (_typedStore, _store, _commentSuffix) => ` + /* Delete all data for given keys${_commentSuffix} */ + function deleteRecord(${renderArguments([_typedStore, _typedTableId, _typedKeyArgs])}) internal { + ${_keyTupleDefinition} + ${_store}.deleteRecord(_tableId, _keyTuple, getFieldLayout()); + } + ` + ) + : "" + } } - ` - ) - : "" - } -} - -${renderTypeHelpers(options)} -`; + ${renderTypeHelpers(options)} + `; } function renderEncodedLengths(dynamicFields: RenderDynamicField[]) { diff --git a/packages/store/ts/codegen/renderTableIndex.ts b/packages/store/ts/codegen/renderTableIndex.ts index af74dcfea3..3ad6a51cb0 100644 --- a/packages/store/ts/codegen/renderTableIndex.ts +++ b/packages/store/ts/codegen/renderTableIndex.ts @@ -2,14 +2,15 @@ import { posixPath, renderList, renderedSolidityHeader } from "@latticexyz/commo import { TableOptions } from "./tableOptions"; export function renderTableIndex(options: TableOptions[]) { - return `${renderedSolidityHeader} + return ` + ${renderedSolidityHeader} -${renderList(options, ({ outputPath, tableName, renderOptions: { structName, staticResourceData } }) => { - const imports = [tableName]; - if (structName) imports.push(structName); - if (staticResourceData) imports.push(`${tableName}TableId`); + ${renderList(options, ({ outputPath, tableName, renderOptions: { structName, staticResourceData } }) => { + const imports = [tableName]; + if (structName) imports.push(structName); + if (staticResourceData) imports.push(`${tableName}TableId`); - return `import { ${imports.join(", ")} } from "./${posixPath(outputPath)}";`; -})} -`; + return `import { ${imports.join(", ")} } from "./${posixPath(outputPath)}";`; + })} + `; } diff --git a/packages/store/ts/codegen/tightcoder/renderDecodeSlice.ts b/packages/store/ts/codegen/tightcoder/renderDecodeSlice.ts index 11745263de..8eb4ac44f5 100644 --- a/packages/store/ts/codegen/tightcoder/renderDecodeSlice.ts +++ b/packages/store/ts/codegen/tightcoder/renderDecodeSlice.ts @@ -3,20 +3,19 @@ import { staticAbiTypeToByteLength, staticAbiTypes } from "@latticexyz/schema-ty import { renderTightCoderDecode } from "./renderFunctions"; export function renderDecodeSlice() { - let result = `${renderedSolidityHeader} + return ` + ${renderedSolidityHeader} import { TightCoder } from "./TightCoder.sol"; import { Slice } from "../Slice.sol"; library DecodeSlice { - `; - - for (const staticAbiType of staticAbiTypes) { - const staticByteLength = staticAbiTypeToByteLength[staticAbiType]; - result += renderTightCoderDecode({ internalTypeId: staticAbiType, staticByteLength }); - } - - result += ` + ${staticAbiTypes + .map((staticAbiType) => + renderTightCoderDecode({ + internalTypeId: staticAbiType, + staticByteLength: staticAbiTypeToByteLength[staticAbiType], + }) + ) + .join("\n")} } `; - - return result; } diff --git a/packages/store/ts/codegen/tightcoder/renderEncodeArray.ts b/packages/store/ts/codegen/tightcoder/renderEncodeArray.ts index 5e9206ee47..b27f1e21d2 100644 --- a/packages/store/ts/codegen/tightcoder/renderEncodeArray.ts +++ b/packages/store/ts/codegen/tightcoder/renderEncodeArray.ts @@ -3,19 +3,18 @@ import { staticAbiTypeToByteLength, staticAbiTypes } from "@latticexyz/schema-ty import { renderTightCoderEncode } from "./renderFunctions"; export function renderEncodeArray() { - let result = `${renderedSolidityHeader} + return ` + ${renderedSolidityHeader} import { TightCoder } from "./TightCoder.sol"; library EncodeArray { + ${staticAbiTypes + .map((staticAbiType) => + renderTightCoderEncode({ + internalTypeId: staticAbiType, + staticByteLength: staticAbiTypeToByteLength[staticAbiType], + }) + ) + .join("\n")} + } `; - - for (const staticAbiType of staticAbiTypes) { - const staticByteLength = staticAbiTypeToByteLength[staticAbiType]; - result += renderTightCoderEncode({ internalTypeId: staticAbiType, staticByteLength }); - } - - result += ` - } - `; - - return result; } diff --git a/packages/store/ts/codegen/tightcoder/renderFunctions.ts b/packages/store/ts/codegen/tightcoder/renderFunctions.ts index d8065f2d93..00cd98a450 100644 --- a/packages/store/ts/codegen/tightcoder/renderFunctions.ts +++ b/packages/store/ts/codegen/tightcoder/renderFunctions.ts @@ -16,7 +16,7 @@ export function renderTightCoderDecode(element: { internalTypeId: string; static _output := _genericArray } } - `.trim(); + `; } export function renderTightCoderEncode(element: { internalTypeId: string; staticByteLength: number }) { @@ -32,5 +32,5 @@ export function renderTightCoderEncode(element: { internalTypeId: string; static ${getLeftPaddingBits(element)} ); } - `.trim(); + `; } diff --git a/packages/store/ts/codegen/tightcoder/renderTightCoderAutoTest.ts b/packages/store/ts/codegen/tightcoder/renderTightCoderAutoTest.ts index 84f9cb9a86..77ee228488 100644 --- a/packages/store/ts/codegen/tightcoder/renderTightCoderAutoTest.ts +++ b/packages/store/ts/codegen/tightcoder/renderTightCoderAutoTest.ts @@ -22,26 +22,19 @@ export function renderTightCoderAutoTestFunction({ typeId }: { typeId: string }) assertEq(decoded[1], val1); assertEq(decoded[2], val2); } - `.trim(); + `; } export function renderTightCoderAutoTest() { - let result = `${renderedSolidityHeader} + return ` + ${renderedSolidityHeader} import { Test } from "forge-std/Test.sol"; import { EncodeArray } from "../../src/tightcoder/EncodeArray.sol"; import { SliceLib } from "../../src/Slice.sol"; contract TightCoderAutoTest is Test { - `; - - for (const staticAbiType of staticAbiTypes) { - result += renderTightCoderAutoTestFunction({ typeId: staticAbiType }); - } - - result += ` + ${staticAbiTypes.map((staticAbiType) => renderTightCoderAutoTestFunction({ typeId: staticAbiType })).join("")} } `; - - return result; } diff --git a/packages/world/ts/node/render-solidity/renderSystemInterface.ts b/packages/world/ts/node/render-solidity/renderSystemInterface.ts index f2dcf7fde4..b52a596a9b 100644 --- a/packages/world/ts/node/render-solidity/renderSystemInterface.ts +++ b/packages/world/ts/node/render-solidity/renderSystemInterface.ts @@ -4,24 +4,24 @@ import { RenderSystemInterfaceOptions } from "./types"; export function renderSystemInterface(options: RenderSystemInterfaceOptions) { const { imports, name, functionPrefix, functions, errors } = options; - return `${renderedSolidityHeader} + return ` + ${renderedSolidityHeader} -${renderImports(imports)} + ${renderImports(imports)} -interface ${name} { - ${renderList(errors, ({ name, parameters }) => `error ${name}(${renderArguments(parameters)});`)} + interface ${name} { + ${renderList(errors, ({ name, parameters }) => `error ${name}(${renderArguments(parameters)});`)} - ${renderList( - functions, - ({ name, parameters, stateMutability, returnParameters }) => ` - function ${functionPrefix}${name}( - ${renderArguments(parameters)} - ) external ${stateMutability} ${renderReturnParameters(returnParameters)}; - ` - )} -} - -`; + ${renderList( + functions, + ({ name, parameters, stateMutability, returnParameters }) => ` + function ${functionPrefix}${name}( + ${renderArguments(parameters)} + ) external ${stateMutability} ${renderReturnParameters(returnParameters)}; + ` + )} + } + `; } function renderReturnParameters(returnParameters: string[]) { diff --git a/packages/world/ts/node/render-solidity/renderWorld.ts b/packages/world/ts/node/render-solidity/renderWorld.ts index f6eb71b818..c4493b75d6 100644 --- a/packages/world/ts/node/render-solidity/renderWorld.ts +++ b/packages/world/ts/node/render-solidity/renderWorld.ts @@ -23,19 +23,18 @@ export function renderWorld(options: RenderWorldOptions) { ]; const importSymbols = [...baseImports, ...imports].map(({ symbol }) => symbol); - return `${renderedSolidityHeader} + return ` + ${renderedSolidityHeader} -${renderAbsoluteImports(baseImports)} + ${renderAbsoluteImports(baseImports)} -${renderRelativeImports(imports)} + ${renderRelativeImports(imports)} -/** - * The ${interfaceName} interface includes all systems dynamically added to the World - * during the deploy process. - */ -interface ${interfaceName} is ${renderArguments(importSymbols)} { - -} - -`; + /** + * The ${interfaceName} interface includes all systems dynamically added to the World + * during the deploy process. + */ + interface ${interfaceName} is ${renderArguments(importSymbols)} { + } + `; }