From 60b16f5415e5cea9e1a4436e373b46e20fd68187 Mon Sep 17 00:00:00 2001 From: Ira <61128114+stackaccount1@users.noreply.github.com> Date: Mon, 25 Jul 2022 22:12:26 -0400 Subject: [PATCH 01/15] Update init.rst Add troubleshoot option - $ brownie init -f - to documentation (brownie has a common error on empty folders, this is used often) --- docs/init.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/init.rst b/docs/init.rst index fb90b2552..3723dc9f8 100644 --- a/docs/init.rst +++ b/docs/init.rst @@ -20,6 +20,12 @@ To initialize an empty project, start by creating a new folder. From within that An empty :ref:`project structure` is created within the folder. +To initialize an empty project inside a new empty or existing folder type: + +:: + + $ brownie init -f + Creating a Project from a Template ================================== From 8af48c454166104d7e69b7b6045ab93410eaa0e2 Mon Sep 17 00:00:00 2001 From: LiamBeenken <117235608+LIamB12@users.noreply.github.com> Date: Sat, 4 Mar 2023 20:36:25 -0500 Subject: [PATCH 02/15] Typo in docs --- docs/tests-coverage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tests-coverage.rst b/docs/tests-coverage.rst index 9b6033231..5a068567e 100644 --- a/docs/tests-coverage.rst +++ b/docs/tests-coverage.rst @@ -84,6 +84,6 @@ Some things to keep in mind that can help to reduce your test runtime when evalu 1. Coverage is analyzed on a per-transaction basis, and the results are cached. If you repeat an identical transaction, Brownie will not analyze it the 2nd time. Keep this in mind when designing and sequencing setup fixtures. 2. For tests that involve many calls to the same getter method, use the :func:`no_call_coverage ` marker to significantly speed execution. 3. Omit very complex tests altogether with the :func:`skip_coverage ` marker. - 4. If possible, always run your tests in parralel with :ref:`xdist`. + 4. If possible, always run your tests in parallel with :ref:`xdist`. You can use the ``--durations`` flag to view a profile of your slowest tests. You may find good candidates for optimization, or the use of the :func:`no_call_coverage ` and :func:`skip_coverage ` fixtures. From ca29a420d52c36b9f5245798b3d1ed3dcbbd241b Mon Sep 17 00:00:00 2001 From: Vladimir Smelov Date: Sun, 26 Mar 2023 01:04:10 +0700 Subject: [PATCH 03/15] fix verification for same named files --- brownie/project/flattener.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/brownie/project/flattener.py b/brownie/project/flattener.py index 1e12a09bc..a2b9eea2a 100644 --- a/brownie/project/flattener.py +++ b/brownie/project/flattener.py @@ -32,6 +32,15 @@ def __init__( license_search = LICENSE_PATTERN.search(self.sources[Path(primary_source_fp).name]) self.license = license_search.group(1) if license_search else "NONE" + @classmethod + def path_to_name(cls, pth: str) -> str: + """Turn the full-path of every Solidity file to a unique shorten name. + + Note, that sometimes there could be several different files with the same name in a project, + so these files should keep uniq name to correct verification. + """ + return 'contracts/' + pth.split('/contracts/')[1] + def traverse(self, fp: str) -> None: """Traverse a contract source files dependencies. @@ -42,8 +51,9 @@ def traverse(self, fp: str) -> None: fp: The contract source file to traverse, if it's already been traversed, return early. """ # if already traversed file, return early + name = self.path_to_name(fp) fp_obj = Path(fp) - if fp_obj.name in self.sources: + if name in self.sources: return # read in the source file @@ -56,18 +66,17 @@ def traverse(self, fp: str) -> None: # replacement function for re.sub, we just sanitize the path repl = ( # noqa: E731 lambda m: f'import{m.group("prefix")}' - + f'"{Path(sanitize(m.group("path"))).name}"' - + f'{m.group("suffix")}' + + f'"{self.path_to_name(sanitize(m.group("path")))}"' + + f'{m.group("suffix")}' ) - - self.sources[fp_obj.name] = IMPORT_PATTERN.sub(repl, source) + self.sources[name] = IMPORT_PATTERN.sub(repl, source) if fp_obj.name not in self.dependencies: - self.dependencies[fp_obj.name] = set() + self.dependencies[name] = set() # traverse dependency files - can circular imports happen? for m in IMPORT_PATTERN.finditer(source): import_path = sanitize(m.group("path")) - self.dependencies[fp_obj.name].add(Path(import_path).name) + self.dependencies[name].add(self.path_to_name(import_path)) self.traverse(import_path) @property From ead9723eec554a75033b61adae0592b4f145008d Mon Sep 17 00:00:00 2001 From: Vladimir Smelov Date: Sun, 26 Mar 2023 01:32:39 +0700 Subject: [PATCH 04/15] fix some attributes of flattener --- brownie/project/flattener.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/brownie/project/flattener.py b/brownie/project/flattener.py index a2b9eea2a..78cda2f10 100644 --- a/brownie/project/flattener.py +++ b/brownie/project/flattener.py @@ -24,12 +24,12 @@ def __init__( self.dependencies: DefaultDict[str, Set[str]] = defaultdict(set) self.compiler_settings = compiler_settings self.contract_name = contract_name - self.contract_file = Path(primary_source_fp).name + self.contract_file = self.path_to_name(primary_source_fp) self.remappings = remappings self.traverse(primary_source_fp) - license_search = LICENSE_PATTERN.search(self.sources[Path(primary_source_fp).name]) + license_search = LICENSE_PATTERN.search(self.path_to_name(primary_source_fp)) self.license = license_search.group(1) if license_search else "NONE" @classmethod From 568948ff600c1e3450aba08b60e7d332c102bc6c Mon Sep 17 00:00:00 2001 From: Vladimir Smelov Date: Sun, 26 Mar 2023 01:42:58 +0700 Subject: [PATCH 05/15] Add entry to CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81812d8a4..fdbf5844f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ This changelog format is based on [Keep a Changelog](https://keepachangelog.com/ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased](https://github.com/eth-brownie/brownie) +### Fixed +- Fix verification for same named files ([#1677](https://github.com/eth-brownie/brownie/pull/1677)) ## [1.19.3](https://github.com/eth-brownie/brownie/tree/v1.19.3) - 2023-01-29 ### Added From 6c8ad1be1cdfa34f0eac715602a86aa0b1427847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83lina=20Cenan?= Date: Wed, 10 May 2023 11:48:14 +0300 Subject: [PATCH 06/15] Ensure contract address exists in contract map before deleting Closes https://github.com/eth-brownie/brownie/issues/1144 --- brownie/network/state.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/brownie/network/state.py b/brownie/network/state.py index 1cbe810da..5433d1acc 100644 --- a/brownie/network/state.py +++ b/brownie/network/state.py @@ -583,7 +583,8 @@ def _add_contract(contract: Any) -> None: def _remove_contract(contract: Any) -> None: - del _contract_map[contract.address] + if contract.address in _contract_map: + del _contract_map[contract.address] def _get_deployment( From 5c02442c452f8bbe6c599edda690517510153c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C4=83lina=20Cenan?= Date: Tue, 13 Jun 2023 09:17:11 +0300 Subject: [PATCH 07/15] Update brownie/network/state.py Co-authored-by: Charles Cooper --- brownie/network/state.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/brownie/network/state.py b/brownie/network/state.py index 5433d1acc..1b5814336 100644 --- a/brownie/network/state.py +++ b/brownie/network/state.py @@ -583,8 +583,7 @@ def _add_contract(contract: Any) -> None: def _remove_contract(contract: Any) -> None: - if contract.address in _contract_map: - del _contract_map[contract.address] + _contract_map.pop(contract.address, None) def _get_deployment( From 8c8187095ad9edca1bd03a6103d4dff5372a897a Mon Sep 17 00:00:00 2001 From: BIP Bot Date: Sun, 30 Jul 2023 15:59:57 +0200 Subject: [PATCH 08/15] Add Base Chain --- brownie/data/network-config.yaml | 21 ++++++++++++++++++++- brownie/network/contract.py | 3 ++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/brownie/data/network-config.yaml b/brownie/data/network-config.yaml index 53daf97ee..7ec278033 100644 --- a/brownie/data/network-config.yaml +++ b/brownie/data/network-config.yaml @@ -207,6 +207,13 @@ live: host: https://zkevm-rpc.com id: zkevm-main name: Polygon zkEVM mainnet + - name: Base + networks: + - chainid: 8453 + explorer: https://api.basescan.org/api + host: https://mainnet.base.org + id: base-main + name: Base mainnet @@ -361,4 +368,16 @@ development: accounts: 10 evm_version: istanbul mnemonic: brownie - fork: zkevm-main \ No newline at end of file + fork: zkevm-main + - name: Ganache-CLI Base-Mainnet Fork) + id: base-main-fork + cmd: ganache-cli + host: http://127.0.0.1 + timeout: 120 + cmd_settings: + port: 8545 + gas_limit: 20000000 + accounts: 10 + evm_version: istanbul + mnemonic: brownie + fork: base-main \ No newline at end of file diff --git a/brownie/network/contract.py b/brownie/network/contract.py index 17e2a1fda..4917e1295 100644 --- a/brownie/network/contract.py +++ b/brownie/network/contract.py @@ -85,7 +85,8 @@ "snowtrace": "SNOWTRACE_TOKEN", "aurorascan": "AURORASCAN_TOKEN", "moonscan": "MOONSCAN_TOKEN", - "gnosisscan": "GNOSISSCAN_TOKEN" + "gnosisscan": "GNOSISSCAN_TOKEN", + "base": "BASESCAN_TOKEN" } From da0799cc9aec10d82318929801714b720a5495ff Mon Sep 17 00:00:00 2001 From: BIP Bot Date: Sun, 30 Jul 2023 16:00:31 +0200 Subject: [PATCH 09/15] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e804fa403..48cb85eb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Polygon zkEVM - Optimisim (fixed explorer support) - Gnosis Chain +- Base chain ## [1.19.3](https://github.com/eth-brownie/brownie/tree/v1.19.3) - 2023-01-29 ### Added From e055f24f083db87d54d6e8fabfb9b8302e2b19f1 Mon Sep 17 00:00:00 2001 From: Hecate2 <2474101468@qq.com> Date: Thu, 28 Sep 2023 12:02:53 +0800 Subject: [PATCH 10/15] Force using utf-8 for reading contracts --- CHANGELOG.md | 3 +++ brownie/project/main.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e804fa403..fabb37e63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Optimisim (fixed explorer support) - Gnosis Chain +### Fixed +- Force using utf-8 for reading contracts + ## [1.19.3](https://github.com/eth-brownie/brownie/tree/v1.19.3) - 2023-01-29 ### Added - Ganache 7.7.x support ([#1652](https://github.com/eth-brownie/brownie/pull/1652)) diff --git a/brownie/project/main.py b/brownie/project/main.py index e8f123611..3c3a9a0c6 100644 --- a/brownie/project/main.py +++ b/brownie/project/main.py @@ -1026,7 +1026,7 @@ def _load_sources(project_path: Path, subfolder: str, allow_json: bool) -> Dict: continue if next((i for i in path.relative_to(project_path).parts if i.startswith("_")), False): continue - with path.open() as fp: + with path.open(encoding='utf-8') as fp: source = fp.read() if hasattr(hooks, "brownie_load_source"): From 0714237d3b15d7dd6d5666516ff6258c7e90eb48 Mon Sep 17 00:00:00 2001 From: Domen Grabec Date: Tue, 19 Dec 2023 13:17:11 +0100 Subject: [PATCH 11/15] include return data in transaction trace even when the function signature is not available --- brownie/network/transaction.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/brownie/network/transaction.py b/brownie/network/transaction.py index 2f9738f45..73ac8e6c8 100644 --- a/brownie/network/transaction.py +++ b/brownie/network/transaction.py @@ -920,6 +920,20 @@ def _expand_trace(self) -> None: last["address"], trace[i]["stack"][-2][-40:], trace[i]["stack"][-3] ) + # If the function signature is not available for decoding return data attach + # the encoded data. + # If the function signature is available this will be overridden by setting + # `return_value` a few lines below. + if trace[i]["depth"] and opcode == "RETURN": + subcall: dict = next( + i for i in self._subcalls[::-1] if i["to"] == last["address"] # type: ignore + ) + + if opcode == "RETURN": + returndata = _get_memory(trace[i], -1) + if returndata.hex() not in ("", "0x"): + subcall["returndata"] = returndata.hex() + try: pc = last["pc_map"][trace[i]["pc"]] except (KeyError, TypeError): From bb1ac431280108e54cb563b2923e24df4b73531d Mon Sep 17 00:00:00 2001 From: Kevin Neilson Date: Mon, 8 Jan 2024 16:05:42 -0700 Subject: [PATCH 12/15] revise moonbeam rpc urls --- brownie/data/network-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/brownie/data/network-config.yaml b/brownie/data/network-config.yaml index 53daf97ee..98aa7eee8 100644 --- a/brownie/data/network-config.yaml +++ b/brownie/data/network-config.yaml @@ -136,13 +136,13 @@ live: - name: Mainnet chainid: 1284 id: moonbeam-main - host: https://moonbeam.api.onfinality.io/public + host: https://moonbeam.unitedbloc.com explorer: https://api-moonbeam.moonscan.io/api multicall2: "0x1337BedC9D22ecbe766dF105c9623922A27963EC" - name: Moonbase Alpha chainid: 1287 id: moonbeam-test - host: https://moonbeam-alpha.api.onfinality.io/public + host: https://moonbase.unitedbloc.com explorer: https://api-moonbase.moonscan.io/api multicall2: "0x37084d0158C68128d6Bc3E5db537Be996f7B6979" - name: Moonriver @@ -150,7 +150,7 @@ live: - name: Mainnet chainid: 1285 id: moonriver-main - host: https://moonriver.api.onfinality.io/public + host: https://moonriver.unitedbloc.com explorer: https://api-moonriver.moonscan.io/api multicall2: "0xaef00a0cf402d9dedd54092d9ca179be6f9e5ce3" - name: Optimistic Ethereum From b254a0dda20325a7e4d6cd3169d07b0391341a49 Mon Sep 17 00:00:00 2001 From: Kevin Neilson Date: Wed, 10 Jan 2024 09:31:42 -0800 Subject: [PATCH 13/15] Update brownie/data/network-config.yaml Co-authored-by: albertov19 <64150856+albertov19@users.noreply.github.com> --- brownie/data/network-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brownie/data/network-config.yaml b/brownie/data/network-config.yaml index 98aa7eee8..81e62af01 100644 --- a/brownie/data/network-config.yaml +++ b/brownie/data/network-config.yaml @@ -136,7 +136,7 @@ live: - name: Mainnet chainid: 1284 id: moonbeam-main - host: https://moonbeam.unitedbloc.com + host: https://rpc.api.moonbeam.network explorer: https://api-moonbeam.moonscan.io/api multicall2: "0x1337BedC9D22ecbe766dF105c9623922A27963EC" - name: Moonbase Alpha From 3a689bb064d5780fb1d26e9dd3312501295949ea Mon Sep 17 00:00:00 2001 From: Kevin Neilson Date: Wed, 10 Jan 2024 09:31:47 -0800 Subject: [PATCH 14/15] Update brownie/data/network-config.yaml Co-authored-by: albertov19 <64150856+albertov19@users.noreply.github.com> --- brownie/data/network-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brownie/data/network-config.yaml b/brownie/data/network-config.yaml index 81e62af01..00e6ae708 100644 --- a/brownie/data/network-config.yaml +++ b/brownie/data/network-config.yaml @@ -142,7 +142,7 @@ live: - name: Moonbase Alpha chainid: 1287 id: moonbeam-test - host: https://moonbase.unitedbloc.com + host: https://rpc.api.moonbase.moonbeam.network explorer: https://api-moonbase.moonscan.io/api multicall2: "0x37084d0158C68128d6Bc3E5db537Be996f7B6979" - name: Moonriver From 32cc96cfba548b451446cbe426c6a91f7e3e7445 Mon Sep 17 00:00:00 2001 From: Kevin Neilson Date: Wed, 10 Jan 2024 09:31:53 -0800 Subject: [PATCH 15/15] Update brownie/data/network-config.yaml Co-authored-by: albertov19 <64150856+albertov19@users.noreply.github.com> --- brownie/data/network-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brownie/data/network-config.yaml b/brownie/data/network-config.yaml index 00e6ae708..2a8164308 100644 --- a/brownie/data/network-config.yaml +++ b/brownie/data/network-config.yaml @@ -150,7 +150,7 @@ live: - name: Mainnet chainid: 1285 id: moonriver-main - host: https://moonriver.unitedbloc.com + host: https://rpc.api.moonriver.moonbeam.network explorer: https://api-moonriver.moonscan.io/api multicall2: "0xaef00a0cf402d9dedd54092d9ca179be6f9e5ce3" - name: Optimistic Ethereum