Closed reedsa closed 10 months ago
Hello @reedsa! I'd like to try to contribute and solve this issue. Could you please provide me with further instructions and assign this task to me?
@DavidRomanovizc sounds great! The network utility can be added to a new python file network.py
under eth_utils
.
There should be a new class for the Network
that will store the chainId
, symbol
, name
, shortName
from the chain list.
network_names = {
1: "Ethereum Mainnet",
...
}
network_short_names = {
1: "eth",
}
class Network:
chain_id: int
name: str
shortName: str
The method for this class could look like:
def network_from_chain_id(chain_id: int) -> Network:
try:
return network_names_by_id[chain_id]
except KeyError:
raise ValidationError(f"chain_id not recognized: {chain_id}")
The same pattern applies for the short names. Parameterized tests should be added as well to make sure the new functions are returning what is expected.
Again, appreciate your help on this. If you have any questions feel free to reach out!
What feature should we add?
It would be convenient to retrieve the network name by using
w3.network
, which could just call the utility withw3.eth.chain_id
.A
name_from_chain_id
function is needed that will return the full name of the network. (example: "Ethereum Mainnet") Ashort_name_from_chain_id
function would return the short name. (example: "eth")List of networks in json: https://chainid.network/chains_mini.json
A script was written to parse the list json and create a list of enums: https://gist.github.com/reedsa/addafe9eb852db3267c0e90f1ce9867e An adaptation of the script could make it easy to update the list chain ids and names in our code.