""" Create a project template with an ERC20 contract and accompanying tests """
from ...template import Template
from ....common.logging import getLogger
log = getLogger(__name__)
[docs]class ERC20Template(Template):
[docs] def __init__(self, *args, **kwargs):
super(ERC20Template, self).__init__(*args, **kwargs)
[docs] def initialize(self):
""" Create a project structure for an ERC20 token """
self.create_dirs()
self.create_tests()
self.create_contracts()
self.create_deployment()
self.create_networks()
[docs] def create_tests(self):
""" Create the test files """
self.copy_template_file(self.pwd, 'tests', 'test_erc20.py')
[docs] def create_contracts(self):
""" Create the contract source files """
log.info("Creating contract templates...")
self.copy_template_file(self.pwd, 'contracts', 'MyERC20.sol')
self.copy_template_file(self.pwd, 'contracts', 'ERC20.sol')
self.copy_template_file(self.pwd, 'contracts', 'IERC20.sol')
self.copy_template_file(self.pwd, 'contracts', 'SafeMath.sol')
[docs] def create_deployment(self):
""" Create the deploy module and script """
log.info("Creating contract deploy scripts...")
self.copy_template_file(self.pwd, 'deploy', '__init__.py')
self.copy_template_file(self.pwd, 'deploy', 'deploy_main.py')
[docs] def create_networks(self):
""" Create the networks.yml file """
log.info("Creating networks.yml...")
self.copy_template_file(self.pwd, '', 'networks.yml')
[docs]def get_template_instance(*args, **kwargs):
""" Return an ERC20 template """
return ERC20Template(*args, **kwargs)