Introduce hardcoded default RPC endpoint; localize chain IDs, blockchain names to constants.py

pull/3496/head
Kieran 2024-05-07 13:42:18 +02:00 committed by KPrasch
parent 11a0b26c82
commit 2ac0aba53f
No known key found for this signature in database
6 changed files with 55 additions and 30 deletions

View File

@ -37,8 +37,7 @@ from nucypher.blockchain.eth.agents import (
TACoApplicationAgent,
TACoChildApplicationAgent,
)
from nucypher.blockchain.eth.clients import PUBLIC_CHAINS
from nucypher.blockchain.eth.constants import NULL_ADDRESS
from nucypher.blockchain.eth.constants import NULL_ADDRESS, DEFAULT_RPC_ENDPOINTS, PUBLIC_CHAINS
from nucypher.blockchain.eth.decorators import validate_checksum_address
from nucypher.blockchain.eth.domains import TACoDomain
from nucypher.blockchain.eth.interfaces import (

View File

@ -33,28 +33,6 @@ class Web3ClientUnexpectedVersionString(Web3ClientError):
pass
PUBLIC_CHAINS = {
1: "Mainnet",
137: "Polygon/Mainnet",
11155111: "Sepolia",
80002: "Polygon/Amoy",
}
# This list is not exhaustive,
# but is sufficient for the current needs of the project.
POA_CHAINS = {
4, # Rinkeby
5, # Goerli
42, # Kovan
77, # Sokol
100, # xDAI
10200, # gnosis/chiado,
137, # Polygon/Mainnet
80001, # "Polygon/Mumbai"
80002, # "Polygon/Amoy"
}
class EthereumClient:
BLOCK_CONFIRMATIONS_POLLING_TIME = 3 # seconds
TRANSACTION_POLLING_TIME = 0.5 # seconds

View File

@ -1,5 +1,3 @@
#
# Contract Names
#
@ -15,7 +13,6 @@ TACO_CHILD_APPLICATION_CONTRACT_NAME = "TACoChildApplication"
COORDINATOR_CONTRACT_NAME = "Coordinator"
SUBSCRIPTION_MANAGER_CONTRACT_NAME = "SubscriptionManager"
TACO_CONTRACT_NAMES = (
TACO_APPLICATION_CONTRACT_NAME,
TACO_CHILD_APPLICATION_CONTRACT_NAME,
@ -23,7 +20,6 @@ TACO_CONTRACT_NAMES = (
SUBSCRIPTION_MANAGER_CONTRACT_NAME
)
# Ethereum
AVERAGE_BLOCK_TIME_IN_SECONDS = 14
@ -37,3 +33,52 @@ NULL_ADDRESS = '0x' + '0' * 40
# NuCypher
# TODO: this is equal to HRAC.SIZE.
POLICY_ID_LENGTH = 16
PUBLIC_CHAINS = {
1: "Mainnet",
137: "Polygon/Mainnet",
11155111: "Sepolia",
80002: "Polygon/Amoy",
}
POA_CHAINS = {
4, # Rinkeby
5, # Goerli
42, # Kovan
77, # Sokol
100, # xDAI
10200, # gnosis/chiado,
137, # Polygon/Mainnet
80001, # "Polygon/Mumbai"
80002, # "Polygon/Amoy"
}
# TODO: This may be dynamic in the future, perhaps using a 3rd party API
DEFAULT_RPC_ENDPOINTS = {
1: [
"https://cloudflare-eth.com",
"https://ethereum-rpc.publicnode.com",
"https://mainnet.gateway.tenderly.co",
"https://rpc.flashbots.net",
"https://rpc.mevblocker.io"
],
11155111: [
"https://rpc.sepolia.org",
"https://rpc2.sepolia.org",
"https://rpc-sepolia.rockx.com",
"https://rpc.sepolia.ethpandaops.io",
"https://sepolia.gateway.tenderly.co",
"https://ethereum-sepolia-rpc.publicnode.com",
"https://sepolia.drpc.org"
],
137: [
"https://polygon-rpc.com",
"https://polygon-bor-rpc.publicnode.com",
"https://polygon.gateway.tenderly.co",
"https://polygon.drpc.org"
],
80002: [
"https://rpc-amoy.polygon.technology",
"https://polygon-amoy-bor-rpc.publicnode.com",
]
}

View File

@ -21,7 +21,8 @@ from web3.middleware import geth_poa_middleware, simple_cache_middleware
from web3.providers import BaseProvider
from web3.types import TxParams, TxReceipt
from nucypher.blockchain.eth.clients import POA_CHAINS, EthereumClient
from nucypher.blockchain.eth.clients import EthereumClient
from nucypher.blockchain.eth.constants import POA_CHAINS
from nucypher.blockchain.eth.decorators import validate_checksum_address
from nucypher.blockchain.eth.providers import (
_get_http_provider,

View File

@ -6,6 +6,8 @@ from web3 import Web3
from web3.contract.contract import ContractConstructor, ContractFunction
from web3.types import TxParams
from nucypher.blockchain.eth.constants import DEFAULT_RPC_ENDPOINTS
def prettify_eth_amount(amount, original_denomination: str = 'wei') -> str:
"""

View File

@ -18,7 +18,7 @@ from web3.middleware import geth_poa_middleware
from web3.providers import BaseProvider
from web3.types import ABIFunction
from nucypher.blockchain.eth.clients import POA_CHAINS
from nucypher.blockchain.eth.constants import POA_CHAINS
from nucypher.policy.conditions import STANDARD_ABI_CONTRACT_TYPES, STANDARD_ABIS
from nucypher.policy.conditions.base import AccessControlCondition
from nucypher.policy.conditions.context import (