Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed minor value error #1569

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions brownie/_cli/networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
10 changes: 5 additions & 5 deletions brownie/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"]

Expand Down
56 changes: 28 additions & 28 deletions brownie/data/network-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -39,151 +39,151 @@ 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
multicall2: "0xbe2Be647F8aC42808E67431B4E1D6c19796bF586"
- 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
multicall2: "0x37084d0158C68128d6Bc3E5db537Be996f7B6979"
- 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
multicall2: "0xaef00a0cf402d9dedd54092d9ca179be6f9e5ce3"
- 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
multicall2: "0x2DC0E2aa608532Da689e89e237dF582B783E552C"
- 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
multicall2: "0x6842E0412AC1c00464dc48961330156a07268d14"
- 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
Expand Down
10 changes: 5 additions & 5 deletions brownie/network/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion brownie/network/middlewares/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)")

Expand Down
22 changes: 11 additions & 11 deletions brownie/network/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"<Chain object (chainid={self.id}, height={self.height})>"
return f"<Chain object (chain_id={self.id}, height={self.height})>"
except Exception:
return "<Chain object (disconnected)>"

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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} "
Expand Down Expand Up @@ -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

Expand Down
Loading