def compile_source(source): result = [] for name, build in compiler.compile_source(source).items(): if build['type'] == "interface": continue result.append(ContractContainer(build)) return result
def load(path=None): if CONFIG['folders']['project']: raise SystemError("Project has already been loaded") if path is None: path = check_for_project('.') if not path or not Path(path).joinpath("brownie-config.json").exists(): raise SystemError("Could not find brownie project") path = Path(path).resolve() CONFIG['folders']['project'] = str(path) sys.path.insert(0, str(path)) brownie._config.update_config() _create_build_folders(path) result = [] for name, build in compiler.compile_contracts( path.joinpath('contracts')).items(): if build['type'] == "interface": continue container = ContractContainer(build) globals()[name] = container __all__.append(name) result.append(container) # if running via interpreter, add to main namespace if package was imported via from if '__project' in sys.modules['__main__'].__dict__: sys.modules['__main__'].__dict__[name] = container return result
def _create_containers(self) -> None: # create container objects self._containers: Dict = {} for key, data in self._build.items(): if data["bytecode"]: container = ContractContainer(self, data) self._containers[key] = container setattr(self, container._name, container)
def _create_containers(self): # create container objects self._containers = {} for key, data in self._build.items(): if data['bytecode']: container = ContractContainer(self, data) self._containers[key] = container setattr(self, container._name, container)
def compile_source(source): '''Compiles the given source code string and returns a list of ContractContainer instances.''' result = [] for name, build_json in sources.compile_source(source).items(): if build_json['type'] == "interface": continue result.append(ContractContainer(build_json)) return result
def _create_containers(self) -> None: # create container objects self.interface = InterfaceContainer(self) self._containers: Dict = {} for key, data in self._build.items(): if data["type"] == "interface": self.interface._add(data["contractName"], data["abi"]) if data.get("bytecode"): container = ContractContainer(self, data) self._containers[key] = container setattr(self, container._name, container)
def _create_objects(): result = [] for name, data in build.items(): if not data['bytecode']: continue container = ContractContainer(data) result.append(container) sys.modules['brownie.project'].__dict__[name] = container sys.modules['brownie.project'].__all__.append(name) # if running via brownie cli, add to brownie namespace if ARGV['cli']: sys.modules['brownie'].__dict__[name] = container sys.modules['brownie'].__all__.append(name) # if running via interpreter, add to main namespace if package was imported via from elif '__brownie_import_all__' in sys.modules['__main__'].__dict__: sys.modules['__main__'].__dict__[name] = container return result