From b7cfacd9a12c01d0a3843a938d591b7809beed1f Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 28 Jun 2022 16:35:33 -0400 Subject: [PATCH 01/13] Fix minor value error When incorrectly adding network, 'ValueError: Network is missing required field(s): chainid' is printed, but requires 'chain_id' from DEV_CMD_SETTINGS --- brownie/_cli/networks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/brownie/_cli/networks.py b/brownie/_cli/networks.py index 0ec393e42..117644a54 100644 --- a/brownie/_cli/networks.py +++ b/brownie/_cli/networks.py @@ -35,14 +35,14 @@ To add a network you must specify an environment and id, as well as required fields. For example, to add a network "mainnet" to the "Ethereum" environment: - brownie networks add Ethereum mainnet host=https://mainnet.infura.io/ chainid=1 + brownie networks add Ethereum mainnet host=https://mainnet.infura.io/ chain_id=1 Use `brownie networks list true` to see a detailed view of available networks as well as possible data fields when declaring new networks.""" DEV_REQUIRED = ("id", "host", "cmd", "cmd_settings") -PROD_REQUIRED = ("id", "host", "chainid") +PROD_REQUIRED = ("id", "host", "chain_id") OPTIONAL = ("name", "explorer", "timeout", "multicall2", "provider") DEV_CMD_SETTINGS = ( From e714b59bc093eff4c322a019f74caf15cc1c7836 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 12 Jul 2022 11:55:39 -0400 Subject: [PATCH 02/13] fix chain_id consistency --- tests/cli/test_cli_networks.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/cli/test_cli_networks.py b/tests/cli/test_cli_networks.py index 1863c0eb2..78db5129f 100644 --- a/tests/cli/test_cli_networks.py +++ b/tests/cli/test_cli_networks.py @@ -20,7 +20,7 @@ def test_list(config, capfd): cli_networks._list(verbose=False) output = capfd.readouterr()[0] - assert "chainid" not in output + assert "chain_id" not in output for key in config.networks: assert key in output @@ -29,48 +29,48 @@ def test_list_verbose(config, capfd): cli_networks._list(verbose=True) output = capfd.readouterr()[0] - assert "chainid" in output + assert "chain_id" in output for key in config.networks: assert key in output def test_add(): - cli_networks._add("ethereum", "tester", "host=127.0.0.1", "chainid=42") + cli_networks._add("ethereum", "tester", "host=127.0.0.1", "chain_id=42") with _get_data_folder().joinpath("network-config.yaml").open() as fp: networks = yaml.safe_load(fp) assert networks["live"][0]["networks"][-1] == { "id": "tester", "host": "127.0.0.1", - "chainid": 42, + "chain_id": 42, "name": "tester", } def test_add_new_env(): - cli_networks._add("FooChain", "tester", "host=127.0.0.1", "chainid=42") + cli_networks._add("FooChain", "tester", "host=127.0.0.1", "chain_id=42") with _get_data_folder().joinpath("network-config.yaml").open() as fp: networks = yaml.safe_load(fp) assert networks["live"][-1] == { "name": "FooChain", - "networks": [{"id": "tester", "host": "127.0.0.1", "chainid": 42, "name": "tester"}], + "networks": [{"id": "tester", "host": "127.0.0.1", "chain_id": 42, "name": "tester"}], } def test_add_exists(): with pytest.raises(ValueError): - cli_networks._add("FooChain", "development", "host=127.0.0.1", "chainid=42") + cli_networks._add("FooChain", "development", "host=127.0.0.1", "chain_id=42") def test_add_missing_field(): with pytest.raises(ValueError): - cli_networks._add("FooChain", "tester", "chainid=42") + cli_networks._add("FooChain", "tester", "chain_id=42") def test_add_unknown_field(): with pytest.raises(ValueError): - cli_networks._add("FooChain", "tester", "host=127.0.0.1", "chainid=42", "foo=bar") + cli_networks._add("FooChain", "tester", "host=127.0.0.1", "chain_id=42", "foo=bar") def test_add_dev(): @@ -94,15 +94,15 @@ def test_add_dev_missing_field(): def test_add_dev_unknown_field(): with pytest.raises(ValueError): - cli_networks._add("development", "tester", "cmd=foo", "host=127.0.0.1", "chainid=411") + cli_networks._add("development", "tester", "cmd=foo", "host=127.0.0.1", "chain_id=411") def test_modify(): - cli_networks._modify("mainnet", "chainid=3") + cli_networks._modify("mainnet", "chain_id=3") with _get_data_folder().joinpath("network-config.yaml").open() as fp: networks = yaml.safe_load(fp) - assert networks["live"][0]["networks"][0]["chainid"] == 3 + assert networks["live"][0]["networks"][0]["chain_id"] == 3 def test_modify_id(): @@ -219,7 +219,7 @@ def test_import(tmp_path): { "name": "FooChain", "networks": [ - {"id": "tester", "host": "127.0.0.1", "chainid": 42, "name": "tester"} + {"id": "tester", "host": "127.0.0.1", "chain_id": 42, "name": "tester"} ], } ] @@ -234,7 +234,7 @@ def test_import(tmp_path): assert networks["live"][-1] == { "name": "FooChain", - "networks": [{"id": "tester", "host": "127.0.0.1", "chainid": 42, "name": "tester"}], + "networks": [{"id": "tester", "host": "127.0.0.1", "chain_id": 42, "name": "tester"}], } @@ -246,7 +246,7 @@ def test_import_id_exists(tmp_path): "live": [ { "name": "FooChain", - "networks": [{"id": "mainnet", "host": "127.0.0.1", "chainid": 42}], + "networks": [{"id": "mainnet", "host": "127.0.0.1", "chain_id": 42}], } ] }, From 2d2b612970b36345c3bfdad95e74da5550012cc3 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 12 Jul 2022 11:59:17 -0400 Subject: [PATCH 03/13] Update network-config.yaml --- brownie/data/network-config.yaml | 56 ++++++++++++++++---------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/brownie/data/network-config.yaml b/brownie/data/network-config.yaml index dbb3a5bb1..50285dae2 100644 --- a/brownie/data/network-config.yaml +++ b/brownie/data/network-config.yaml @@ -2,35 +2,35 @@ live: - name: Ethereum networks: - name: Mainnet (Infura) - chainid: 1 + chain_id: 1 id: mainnet host: https://mainnet.infura.io/v3/$WEB3_INFURA_PROJECT_ID explorer: https://api.etherscan.io/api multicall2: "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696" provider: infura - name: Ropsten (Infura) - chainid: 3 + chain_id: 3 id: ropsten host: https://ropsten.infura.io/v3/$WEB3_INFURA_PROJECT_ID explorer: https://api-ropsten.etherscan.io/api multicall2: "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696" provider: infura - name: Rinkeby (Infura) - chainid: 4 + chain_id: 4 id: rinkeby host: https://rinkeby.infura.io/v3/$WEB3_INFURA_PROJECT_ID explorer: https://api-rinkeby.etherscan.io/api multicall2: "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696" provider: infura - name: Goerli (Infura) - chainid: 5 + chain_id: 5 id: goerli host: https://goerli.infura.io/v3/$WEB3_INFURA_PROJECT_ID explorer: https://api-goerli.etherscan.io/api multicall2: "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696" provider: infura - name: Kovan (Infura) - chainid: 42 + chain_id: 42 id: kovan host: https://kovan.infura.io/v3/$WEB3_INFURA_PROJECT_ID explorer: https://api-kovan.etherscan.io/api @@ -39,69 +39,69 @@ live: - name: Ethereum Classic networks: - name: Mainnet - chainid: 61 + chain_id: 61 id: etc host: https://www.ethercluster.com/etc explorer: https://blockscout.com/etc/mainnet/api - name: Kotti - chainid: 6 + chain_id: 6 id: kotti host: https://www.ethercluster.com/kotti explorer: https://blockscout.com/etc/kotti/api - name: Arbitrum networks: - name: Mainnet - chainid: 42161 + chain_id: 42161 id: arbitrum-main host: https://arb1.arbitrum.io/rpc explorer: https://api.arbiscan.io/api multicall2: "0x5B5CFE992AdAC0C9D48E05854B2d91C73a003858" - name: Avalanche networks: - - chainid: 43114 + - chain_id: 43114 explorer: https://api.snowtrace.io/api host: https://api.avax.network/ext/bc/C/rpc id: avax-main name: Mainnet - - chainid: 43113 + - chain_id: 43113 host: https://api.avax-test.network/ext/bc/C/rpc id: avax-test name: Testnet - name: Aurora networks: - name: Mainnet - chainid: 1313161554 + chain_id: 1313161554 id: aurora-main host: https://mainnet.aurora.dev explorer: https://api.aurorascan.dev/api multicall2: "0xace58a26b8Db90498eF0330fDC9C2655db0C45E2" - name: Testnet - chainid: 1313161555 + chain_id: 1313161555 id: aurora-test host: https://testnet.aurora.dev explorer: https://testnet.aurorascan.dev/api - name: Binance Smart Chain networks: - name: Testnet - chainid: 97 + chain_id: 97 id: bsc-test host: https://data-seed-prebsc-1-s1.binance.org:8545 explorer: https://api-testnet.bscscan.com/api - name: Mainnet - chainid: 56 + chain_id: 56 id: bsc-main host: https://bsc-dataseed.binance.org explorer: https://api.bscscan.com/api - name: Boba networks: - name: Testnet - chainid: 28 + chain_id: 28 id: boba-test host: https://rinkeby.boba.network explorer: https://blockexplorer.rinkeby.boba.network/api multicall2: "0xeD188A73c442Df375b19b7b8f394a15a2b851BB5" - name: Mainnet - chainid: 288 + chain_id: 288 id: boba-main host: https://mainnet.boba.network explorer: https://blockexplorer.boba.network/api @@ -109,32 +109,32 @@ live: - name: Fantom Opera networks: - name: Testnet - chainid: 0xfa2 + chain_id: 0xfa2 id: ftm-test host: https://rpc.testnet.fantom.network explorer: https://explorer.testnet.fantom.network - name: Mainnet - chainid: 250 + chain_id: 250 id: ftm-main host: https://rpc.ftm.tools explorer: https://api.ftmscan.com/api - name: Harmony networks: - name: Mainnet (Shard 0) - chainid: 1666600000 + chain_id: 1666600000 host: https://api.harmony.one id: harmony-main multicall2: "0x3E01dD8a5E1fb3481F0F589056b428Fc308AF0Fb" - name: Moonbeam networks: - name: Mainnet - chainid: 1284 + chain_id: 1284 id: moonbeam-main host: https://moonbeam.api.onfinality.io/public explorer: https://api-moonbeam.moonscan.io/api multicall2: "0x1337BedC9D22ecbe766dF105c9623922A27963EC" - name: Moonbase Alpha - chainid: 1287 + chain_id: 1287 id: moonbeam-test host: https://moonbeam-alpha.api.onfinality.io/public explorer: https://api-moonbeam.moonscan.io/api @@ -142,7 +142,7 @@ live: - name: Moonriver networks: - name: Mainnet - chainid: 1285 + chain_id: 1285 id: moonriver-main host: https://moonriver.api.onfinality.io/public explorer: https://api-moonriver.moonscan.io/api @@ -150,13 +150,13 @@ live: - name: Optimistic Ethereum networks: - name: Mainnet - chainid: 10 + chain_id: 10 id: optimism-main host: https://mainnet.optimism.io explorer: https://api-optimistic.etherscan.io/api multicall2: "0x2DC0E2aa608532Da689e89e237dF582B783E552C" - name: Kovan - chainid: 69 + chain_id: 69 id: optimism-test host: https://kovan.optimism.io explorer: https://api-kovan-optimistic.etherscan.io/api @@ -164,13 +164,13 @@ live: - name: Polygon networks: - name: Mainnet (Infura) - chainid: 137 + chain_id: 137 id: polygon-main host: https://polygon-mainnet.infura.io/v3/$WEB3_INFURA_PROJECT_ID explorer: https://api.polygonscan.com/api multicall2: "0xc8E51042792d7405184DfCa245F2d27B94D013b6" - name: Mumbai Testnet (Infura) - chainid: 80001 + chain_id: 80001 id: polygon-test host: https://polygon-mumbai.infura.io/v3/$WEB3_INFURA_PROJECT_ID explorer: https://api-testnet.polygonscan.com/api @@ -178,12 +178,12 @@ live: - name: XDai networks: - name: Mainnet - chainid: 100 + chain_id: 100 id: xdai-main host: https://xdai.poanetwork.dev explorer: https://blockscout.com/xdai/mainnet/api - name: Testnet - chainid: 77 + chain_id: 77 id: xdai-test host: https://sokol.poa.network explorer: https://blockscout.com/poa/sokol/api From 230a45fdd93dddc5706b1e11c891dc8e66a3c51a Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 12 Jul 2022 12:01:10 -0400 Subject: [PATCH 04/13] Update state.py --- brownie/network/state.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/brownie/network/state.py b/brownie/network/state.py index 1cbe810da..bfdc3dd59 100644 --- a/brownie/network/state.py +++ b/brownie/network/state.py @@ -201,13 +201,13 @@ def __init__(self) -> None: self._undo_lock = threading.Lock() self._undo_buffer: List = [] self._redo_buffer: List = [] - self._chainid: Optional[int] = None + self._chain_id: Optional[int] = None self._block_gas_time: int = -1 self._block_gas_limit: int = 0 def __repr__(self) -> str: try: - return f"" + return f"" except Exception: return "" @@ -284,9 +284,9 @@ def height(self) -> int: @property def id(self) -> int: - if self._chainid is None: - self._chainid = web3.eth.chain_id - return self._chainid + if self._chain_id is None: + self._chain_id = web3.eth.chain_id + return self._chain_id @property def block_gas_limit(self) -> Wei: @@ -345,7 +345,7 @@ def _network_disconnected(self) -> None: self._snapshot_id = None self._reset_id = None self._current_id = None - self._chainid = None + self._chain_id = None _notify_registry(0) def get_transaction(self, txid: Union[str, bytes]) -> TransactionReceipt: @@ -562,7 +562,7 @@ def _find_contract(address: Any) -> Any: address = _resolve_address(address) if address in _contract_map: return _contract_map[address] - if "chainid" in CONFIG.active_network: + if "chain_id" in CONFIG.active_network: try: from brownie.network.contract import Contract @@ -598,7 +598,7 @@ def _get_deployment( query = f"alias='{alias}'" try: - name = f"chain{CONFIG.active_network['chainid']}" + name = f"chain{CONFIG.active_network['chain_id']}" except KeyError: raise BrownieEnvironmentError("Functionality not available in local environment") from None try: @@ -623,11 +623,11 @@ def _get_deployment( def _add_deployment(contract: Any, alias: Optional[str] = None) -> None: - if "chainid" not in CONFIG.active_network: + if "chain_id" not in CONFIG.active_network: return address = _resolve_address(contract.address) - name = f"chain{CONFIG.active_network['chainid']}" + name = f"chain{CONFIG.active_network['chain_id']}" cur.execute( f"CREATE TABLE IF NOT EXISTS {name} " @@ -659,7 +659,7 @@ def _remove_deployment( query = f"alias='{alias}'" try: - name = f"chain{CONFIG.active_network['chainid']}" + name = f"chain{CONFIG.active_network['chain_id']}" except KeyError: raise BrownieEnvironmentError("Functionality not available in local environment") from None From 3e6b4bd4489815ea7e1ee7565605880fb9497873 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 12 Jul 2022 12:02:33 -0400 Subject: [PATCH 05/13] Update _config.py --- brownie/_config.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/brownie/_config.py b/brownie/_config.py index 28367cff6..c5fd3120b 100644 --- a/brownie/_config.py +++ b/brownie/_config.py @@ -56,10 +56,10 @@ def __init__(self): raise ValueError(f"Multiple networks using ID '{key}'") self.networks[key] = value - # make sure chainids are always strings + # make sure chain_ids are always strings for network, values in self.networks.items(): - if "chainid" in values: - self.networks[network]["chainid"] = str(values["chainid"]) + if "chain_id" in values: + self.networks[network]["chain_id"] = str(values["chain_id"]) self.argv = defaultdict(lambda: None) self.settings = _Singleton("settings", (ConfigDict,), {})(base_config) @@ -86,9 +86,9 @@ def set_active_network(self, id_: str = None) -> Dict: fork = network["cmd_settings"]["fork"] if fork in self.networks: network["cmd_settings"]["fork"] = self.networks[fork]["host"] - network["chainid"] = self.networks[fork]["chainid"] + network["chain_id"] = self.networks[fork]["chain_id"] if "chain_id" not in network["cmd_settings"]: - network["cmd_settings"]["chain_id"] = int(self.networks[fork]["chainid"]) + network["cmd_settings"]["chain_id"] = int(self.networks[fork]["chain_id"]) if "explorer" in self.networks[fork]: network["explorer"] = self.networks[fork]["explorer"] From 1ffb41e63fd8b4a74ea7adaf1aba58ada838d9ac Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 12 Jul 2022 12:03:47 -0400 Subject: [PATCH 06/13] Update main.py --- brownie/project/main.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/brownie/project/main.py b/brownie/project/main.py index 163006e37..518f11d1e 100644 --- a/brownie/project/main.py +++ b/brownie/project/main.py @@ -352,8 +352,8 @@ def _load_dependency_artifacts(self) -> None: def _load_deployments(self) -> None: if CONFIG.network_type != "live" and not CONFIG.settings["dev_deployment_artifacts"]: return - chainid = CONFIG.active_network["chainid"] if CONFIG.network_type == "live" else "dev" - path = self._build_path.joinpath(f"deployments/{chainid}") + chain_id = CONFIG.active_network["chain_id"] if CONFIG.network_type == "live" else "dev" + path = self._build_path.joinpath(f"deployments/{chain_id}") path.mkdir(exist_ok=True) deployments = list(path.glob("*.json")) deployments.sort(key=lambda k: k.stat().st_mtime) @@ -378,7 +378,7 @@ def _load_deployments(self) -> None: container._contracts.append(contract) # update deployment map for the current chain - instances = deployment_map.setdefault(chainid, {}).setdefault(contract_name, []) + instances = deployment_map.setdefault(chain_id, {}).setdefault(contract_name, []) if build_json.stem in instances: instances.remove(build_json.stem) instances.insert(0, build_json.stem) @@ -400,14 +400,14 @@ def _save_deployment_map(self, deployment_map: Dict) -> None: def _remove_from_deployment_map(self, contract: ProjectContract) -> None: if CONFIG.network_type != "live" and not CONFIG.settings["dev_deployment_artifacts"]: return - chainid = CONFIG.active_network["chainid"] if CONFIG.network_type == "live" else "dev" + chain_id = CONFIG.active_network["chain_id"] if CONFIG.network_type == "live" else "dev" deployment_map = self._load_deployment_map() try: - deployment_map[chainid][contract._name].remove(contract.address) - if not deployment_map[chainid][contract._name]: - del deployment_map[chainid][contract._name] - if not deployment_map[chainid]: - del deployment_map[chainid] + deployment_map[chain_id][contract._name].remove(contract.address) + if not deployment_map[chain_id][contract._name]: + del deployment_map[chain_id][contract._name] + if not deployment_map[chain_id]: + del deployment_map[chain_id] except (KeyError, ValueError): pass @@ -417,13 +417,13 @@ def _add_to_deployment_map(self, contract: ProjectContract) -> None: if CONFIG.network_type != "live" and not CONFIG.settings["dev_deployment_artifacts"]: return - chainid = CONFIG.active_network["chainid"] if CONFIG.network_type == "live" else "dev" + chain_id = CONFIG.active_network["chain_id"] if CONFIG.network_type == "live" else "dev" deployment_map = self._load_deployment_map() try: - deployment_map[chainid][contract._name].remove(contract.address) + deployment_map[chain_id][contract._name].remove(contract.address) except (ValueError, KeyError): pass - deployment_map.setdefault(chainid, {}).setdefault(contract._name, []).insert( + deployment_map.setdefault(chain_id, {}).setdefault(contract._name, []).insert( 0, contract.address ) self._save_deployment_map(deployment_map) From 6df4a58c7cec94bd999a4724a1ac389e0a5b8e2c Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 12 Jul 2022 12:04:48 -0400 Subject: [PATCH 07/13] Update network-management.rst --- docs/network-management.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/network-management.rst b/docs/network-management.rst index b613c03d7..4fdcabe66 100644 --- a/docs/network-management.rst +++ b/docs/network-management.rst @@ -75,7 +75,7 @@ Live Networks Live networks **must** include the following fields: - * ``chainid``: The chain ID for a network. Live networks with the same chain ID share local data about :ref:`contract deployments `. See `chainid.network `_ for a list of chain IDs. + * ``chain_id``: The chain ID for a network. Live networks with the same chain ID share local data about :ref:`contract deployments `. See `chainid.network `_ for a list of chain IDs. The following fields are optional for live networks: From 54e1d6c3104c9da5fb709fdb5b41bdd52174a92f Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 12 Jul 2022 12:05:25 -0400 Subject: [PATCH 08/13] Update networks.py --- brownie/_cli/networks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/brownie/_cli/networks.py b/brownie/_cli/networks.py index 0ec393e42..117644a54 100644 --- a/brownie/_cli/networks.py +++ b/brownie/_cli/networks.py @@ -35,14 +35,14 @@ To add a network you must specify an environment and id, as well as required fields. For example, to add a network "mainnet" to the "Ethereum" environment: - brownie networks add Ethereum mainnet host=https://mainnet.infura.io/ chainid=1 + brownie networks add Ethereum mainnet host=https://mainnet.infura.io/ chain_id=1 Use `brownie networks list true` to see a detailed view of available networks as well as possible data fields when declaring new networks.""" DEV_REQUIRED = ("id", "host", "cmd", "cmd_settings") -PROD_REQUIRED = ("id", "host", "chainid") +PROD_REQUIRED = ("id", "host", "chain_id") OPTIONAL = ("name", "explorer", "timeout", "multicall2", "provider") DEV_CMD_SETTINGS = ( From 4fb92f37deefbba04fcedd78c1b9326728188b92 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 12 Jul 2022 12:05:58 -0400 Subject: [PATCH 09/13] Update core-chain.rst --- docs/core-chain.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core-chain.rst b/docs/core-chain.rst index 4249dbd78..372b366de 100644 --- a/docs/core-chain.rst +++ b/docs/core-chain.rst @@ -12,7 +12,7 @@ The :func:`Chain ` object, available as ``chain``, .. code-block:: python >>> chain - + >>> chain[12965000] AttributeDict({ From 0a2c4dac07da4283032a0a60df3decf2ab692ed5 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 12 Jul 2022 12:07:07 -0400 Subject: [PATCH 10/13] Update contract.py --- brownie/network/contract.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/brownie/network/contract.py b/brownie/network/contract.py index 9b0035809..65d7db1d5 100644 --- a/brownie/network/contract.py +++ b/brownie/network/contract.py @@ -813,19 +813,19 @@ def _deployment_path(self) -> Optional[Path]: ): return None - chainid = CONFIG.active_network["chainid"] if CONFIG.network_type == "live" else "dev" - path = self._project._build_path.joinpath(f"deployments/{chainid}") + chain_id = CONFIG.active_network["chain_id"] if CONFIG.network_type == "live" else "dev" + path = self._project._build_path.joinpath(f"deployments/{chain_id}") path.mkdir(exist_ok=True) return path.joinpath(f"{self.address}.json") def _save_deployment(self) -> None: path = self._deployment_path() - chainid = CONFIG.active_network["chainid"] if CONFIG.network_type == "live" else "dev" + chain_id = CONFIG.active_network["chain_id"] if CONFIG.network_type == "live" else "dev" deployment_build = self._build.copy() deployment_build["deployment"] = { "address": self.address, - "chainid": chainid, + "chain_id": chain_id, "blockHeight": web3.eth.block_number, } if path: @@ -1268,7 +1268,7 @@ def set_alias(self, alias: Optional[str], persist: bool = True) -> None: alias: str | None An alias to apply. If `None`, any existing alias is removed. """ - if "chainid" not in CONFIG.active_network: + if "chain_id" not in CONFIG.active_network: raise ValueError("Cannot set aliases in a development environment") if alias is not None: From 1cfacfe9854a53453095b8d851ca79e097de39e7 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 12 Jul 2022 12:07:49 -0400 Subject: [PATCH 11/13] Update caching.py --- brownie/network/middlewares/caching.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brownie/network/middlewares/caching.py b/brownie/network/middlewares/caching.py index 002da555e..07a14970b 100644 --- a/brownie/network/middlewares/caching.py +++ b/brownie/network/middlewares/caching.py @@ -102,7 +102,7 @@ class RequestCachingMiddleware(BrownieMiddlewareABC): def __init__(self, w3: Web3) -> None: self.w3 = w3 - self.table_key = f"chain{CONFIG.active_network['chainid']}" + self.table_key = f"chain{CONFIG.active_network['chain_id']}" self.cur = Cursor(_get_data_folder().joinpath("cache.db")) self.cur.execute(f"CREATE TABLE IF NOT EXISTS {self.table_key} (method, params, result)") From ed29d017c0f313d1acdf8038f78bf50103b38c0a Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 12 Jul 2022 12:09:07 -0400 Subject: [PATCH 12/13] Update api-network.rst --- docs/api-network.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api-network.rst b/docs/api-network.rst index 3bc9d79ec..b0a03bf53 100644 --- a/docs/api-network.rst +++ b/docs/api-network.rst @@ -2094,7 +2094,7 @@ Chain >>> from brownie.network.state import Chain >>> chain = Chain() >>> chain - + You can use list indexing the access specific blocks. For negative index values, the block returned is relative to the most recently mined block. For example, ``chain[-1]`` returns the most recently mined block. From c713a01cf48cece9db486b52549510c24e2166b5 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 12 Jul 2022 12:18:06 -0400 Subject: [PATCH 13/13] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b4462976..bf1bb3961 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased](https://github.com/eth-brownie/brownie) +### Fixed +- `chainid` updated to consistent `chain_id` + ## [1.19.0](https://github.com/eth-brownie/brownie/tree/v1.19.0) - 2022-05-29 ### Added - Initial support for [Anvil](https://github.com/foundry-rs/foundry/tree/master/anvil), a blazing-fast local testnet node implementation in Rust ([#1541](https://github.com/eth-brownie/brownie/pull/1541))