def make_project(db, configuration: Config): rmtree(brownie_project_folder, ignore_errors=True) # init brownie project structure project.new(brownie_project_folder) brownie_contracts_folder = os.path.join(brownie_project_folder, 'contracts') multisig_contract = os.path.join(contracts_folder, 'MultiSigSwapWallet.sol') copy(multisig_contract, os.path.join(brownie_contracts_folder, 'MultiSigSwapWallet.sol')) # load and compile contracts to project try: brownie_project = project.load(brownie_project_folder, name="IntegrationTests") brownie_project.load_config() except ProjectAlreadyLoaded: pass # noinspection PyUnresolvedReferences network.connect('development') # connect to ganache cli yield # cleanup del brownie_project sleep(1) rmtree(brownie_project_folder, ignore_errors=True)
def main(): args = docopt(__doc__) path = Path(args['<path>'] or '.').resolve() if CONFIG['folders']['brownie'] in str(path): sys.exit( "ERROR: Cannot init inside the main brownie installation folder.\n" "Create a new folder for your project and run brownie init there.") project.new(path, config.ARGV['force']) print("Brownie environment has been initiated at {}".format(path)) sys.exit()
def test_verification_info(tmp_path_factory, version): header = f""" // SPDX-License-Identifier: MIT pragma solidity {version}; """ # setup directory dir: Path = tmp_path_factory.mktemp("verify-project") # initialize brownie project new(dir.as_posix()) modded_sources = {} for fp, src in sources: with dir.joinpath(fp).open("w") as f: f.write(header + src) modded_sources[fp] = header + src find_best_solc_version(modded_sources, install_needed=True) project = load(dir, "TestImportProject") for contract_name in ("Foo", "Bar", "Baz"): contract = getattr(project, contract_name) input_data = contract.get_verification_info()["standard_json_input"] # output selection isn't included in the verification info because # etherscan replaces it regardless. Here we just replicate with what they # would include input_data["settings"]["outputSelection"] = { "*": {"*": ["evm.bytecode", "evm.deployedBytecode", "abi"]} } compiler_version, _ = contract._build["compiler"]["version"].split("+") output_data = solcx.compile_standard(input_data, solc_version=compiler_version) # keccak256 = 0xd61b13a841b15bc814760b36086983db80788946ca38aa90a06bebf287a67205 build_info = output_data["contracts"][f"{contract_name}.sol"][contract_name] assert build_info["abi"] == contract.abi # ignore the metadata at the end of the bytecode, etherscan does the same assert build_info["evm"]["bytecode"]["object"][:-96] == contract.bytecode[:-96] assert ( build_info["evm"]["deployedBytecode"]["object"][:-96] == contract._build["deployedBytecode"][:-96] ) project.close()
def test_new_raises(noload, tmpdir): project.new(tmpdir) project.load(tmpdir) with pytest.raises(ProjectAlreadyLoaded): project.new(tmpdir) project.close() with pytest.raises(SystemError): project.new(tmpdir+"/contracts")
def main(): args = docopt(__doc__) path = project.new(args["<path>"] or ".", args["--force"]) notify("SUCCESS", f"Brownie environment has been initiated at {path}")
def test_pull_raises(noload, testpath): project.new(testpath+'/token') with pytest.raises(FileExistsError): project.pull('token') with pytest.raises(SystemError): project.pull(testpath+"/token/contracts")
def test_new(noload, tmpdir): assert tmpdir == project.new(tmpdir) assert config['folders']['project'] is None assert Path(tmpdir).joinpath('brownie-config.json').exists()
def main(): args = docopt(__doc__) path = project.new(args["<path>"] or ".", args["--force"], args["--force"]) notify("SUCCESS", f"A new Brownie project has been initialized at {path}")
def main(): args = docopt(__doc__) path = project.new(args['<path>'] or '.', args['--force']) notify("SUCCESS", f"Brownie environment has been initiated at {path}")