Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions packages/cli/src/contracts/LibDeploy.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ import { SystemStorage } from "solecs/SystemStorage.sol";

// Components (requires 'components=...' remapping in project's remappings.txt)
<% components.forEach(component => { -%>
import { <%= component %>, ID as <%= component %>ID } from "components/<%- component %>.sol";
<% const componentName = component.split("/").pop(); %>
import { <%= componentName %>, ID as <%= componentName %>ID } from "components/<%- component %>.sol";
<% }); -%>

// Systems (requires 'systems=...' remapping in project's remappings.txt)
<% systems.forEach(system => { -%>
import { <%= system.name %>, ID as <%= system.name %>ID } from "systems/<%- system.name %>.sol";
<% const systemName=system.name.split("/").pop(); %>
import { <%= systemName %>, ID as <%= systemName %>ID } from "systems/<%- system.name %>.sol";
<% }); -%>

<% if (initializers.length > 0) { -%>
// Initializer libraries (requires 'libraries=...' remapping in project's remappings.txt)
<% initializers.forEach((initializer) => { -%>
import { <%= initializer %> } from "libraries/<%- initializer %>.sol";
<% const initializerName=initializer.name.split("/").pop(); %>
import { <%= initializerName %> } from "libraries/<%- initializer %>.sol";
<% }); -%>
<% } -%>

Expand Down Expand Up @@ -57,9 +60,9 @@ library LibDeploy {
if (!_reuseComponents) {
IComponent comp;
<% components.forEach(component => { -%>

console.log("Deploying <%= component %>");
comp = new <%= component %>(address(result.world));
<% const componentName=component.split("/").pop(); %>
console.log("Deploying <%= componentName %>");
comp = new <%= componentName %>(address(result.world));
console.log(address(comp));
<% });-%>
}
Expand All @@ -73,7 +76,8 @@ library LibDeploy {
SystemStorage.init(result.world, result.world.components());

<% initializers.forEach((name) => { -%>
<%= name -%>.init(result.world);
<% const initializerName=name.split("/").pop(); %>
<%= initializerName -%>.init(result.world);
<% }); -%>
}
}
Expand All @@ -99,17 +103,19 @@ library LibDeploy {
ISystem system;
IUint256Component components = world.components();
<% systems.forEach(system => { -%>

console.log("Deploying <%= system.name %>");
system = new <%= system.name %>(world, address(components));
world.registerSystem(address(system), <%= system.name %>ID);
<% const systemName=system.name.split("/").pop(); %>
console.log("Deploying <%= systemName %>");
system = new <%= systemName %>(world, address(components));
world.registerSystem(address(system), <%= systemName %>ID);
<% system.writeAccess?.forEach(component => { -%>
<% if (component === "*") { -%>
<% const componentName=component.split("/").pop(); %>
<% if (componentName === "*") { -%>
<% components.forEach(comp=> { -%>
authorizeWriter(components, <%= comp %>ID, address(system));
<% const compName=comp.split("/").pop(); %>
authorizeWriter(components, <%= compName %>ID, address(system));
<% });-%>
<% } else { -%>
authorizeWriter(components, <%= component %>ID, address(system));
authorizeWriter(components, <%= componentName %>ID, address(system));
<% } -%>
<% });-%>
<% if (system.initialize) { -%>
Expand Down