Skip to content

Instantly share code, notes, and snippets.

@jacqueswww
Last active December 11, 2018 11:29
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 jacqueswww/4f97c596c75ea91925ad033f5344a4d9 to your computer and use it in GitHub Desktop.
Save jacqueswww/4f97c596c75ea91925ad033f5344a4d9 to your computer and use it in GitHub Desktop.
Populus VyperBackend
import pprint
import os
from collections import OrderedDict
from populus.compilation.backends.base import BaseCompilerBackend
class VyperBackend(BaseCompilerBackend):
project_source_glob = ('*.v.py', '*.vy')
test_source_glob = ('test_*.v.py', 'test_*.vy')
def get_compiled_contracts(self, source_file_paths, import_remappings):
try:
from vyper import compile_codes
except ImportError:
raise ImportError(
'vyper > 0.1.0b5 needs to be installed to use VyperBackend' +
' as compiler backend.'
)
self.logger.debug("Compiler Settings: %s", pprint.pformat(self.compiler_settings))
codes = OrderedDict()
for contract_path in source_file_paths:
codes[contract_path] = open(contract_path).read()
compiled_contracts = []
formats = ['abi', 'bytecode', 'bytecode_runtime']
for contract_path, c_info in compile_codes(codes, formats, 'dict').items():
c_info.update({
'name': os.path.basename(contract_path).split('.')[0],
'linkrefs': [],
'linkrefs_runtime': [],
'source_path': contract_path
})
compiled_contracts.append(c_info)
return compiled_contracts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment