Skip to content

Instantly share code, notes, and snippets.

@wighawag
Last active May 4, 2023 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wighawag/081e9d1fe14f2f17c477eaa8f1253c5a to your computer and use it in GitHub Desktop.
Save wighawag/081e9d1fe14f2f17c477eaa8f1253c5a to your computer and use it in GitHub Desktop.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {Deployer} from "forge-deploy/Deployer.sol";
import {DefaultDeployerFunction, DeployOptions} from "forge-deploy/DefaultDeployerFunction.sol";
// --------------------------------------------------------------------------------------------
// GENERATED
// --------------------------------------------------------------------------------------------
{{#each this}}
import "{{this.solidity_filepath}}" as _{{this.contract_name}};
import { {{this.contract_name}} } from "{{this.solidity_filepath}}";
{{/each}}
{{#each this}}
string constant Artifact_{{this.contract_name}} = "{{this.solidity_filename}}:{{this.contract_name}}";
{{/each}}
// --------------------------------------------------------------------------------------------
library DeployerFunctions{
// --------------------------------------------------------------------------------------------
// GENERATED
// --------------------------------------------------------------------------------------------
{{#each this}}
function deploy_{{this.contract_name}}(
Deployer deployer,
string memory name
{{#each this.constructor.args}},{{#if this.custom_type}}_{{../contract_name}}.{{/if}}{{this.type}} {{#if this.memory_type }}memory{{/if}} {{this.name}}{{/each}}
) internal returns ({{this.contract_name}}) {
bytes memory args = abi.encode({{#each this.constructor.args}}{{this.name}}{{#unless @last}},{{/unless}}{{/each}});
{{this.contract_name}} deployed = new {{this.contract_name}}(
{{#each this.constructor.args}}{{this.name}}{{#unless @last}},{{/unless}}{{/each}}
);
deployer.save(name, address(deployed), Artifact_{{this.contract_name}}, args);
return deployed;
}
{{/each}}
// --------------------------------------------------------------------------------------------
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment