Skip to content

Commit

Permalink
Merge branch 'master' of github.com:safe-global/safe-eth-py
Browse files Browse the repository at this point in the history
  • Loading branch information
datradito committed Apr 4, 2023
2 parents 8b20fdf + 8a80927 commit 0c74c01
Show file tree
Hide file tree
Showing 27 changed files with 12,821 additions and 552 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
# Beta Release
uses: cla-assistant/github-action@v2.2.1
uses: cla-assistant/github-action@v2.3.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
Expand Down
51 changes: 26 additions & 25 deletions gnosis/eth/clients/blockscout_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,46 @@ class BlockScoutConfigurationProblem(BlockscoutClientException):

class BlockscoutClient:
NETWORK_WITH_URL = {
EthereumNetwork.XDAI: "https://blockscout.com/poa/xdai/",
EthereumNetwork.MATIC: "https://polygon-explorer-mainnet.chainstacklabs.com/",
EthereumNetwork.GNOSIS: "https://blockscout.com/poa/xdai/",
EthereumNetwork.POLYGON: "https://polygon-explorer-mainnet.chainstacklabs.com/",
EthereumNetwork.MUMBAI: "https://polygon-explorer-mumbai.chainstacklabs.com/",
EthereumNetwork.ENERGY_WEB_CHAIN: "https://explorer.energyweb.org/",
EthereumNetwork.VOLTA: "https://volta-explorer.energyweb.org/",
EthereumNetwork.OLYMPUS: "https://explorer.polis.tech",
EthereumNetwork.BOBA_NETWORK_BOBABEAM: "https://blockexplorer.bobabeam.boba.network/",
EthereumNetwork.BOBA_RINKEBY: "https://blockexplorer.rinkeby.boba.network/",
EthereumNetwork.BOBA: "https://blockexplorer.boba.network/",
EthereumNetwork.GATHER_DEVNET: "https://devnet-explorer.gather.network/",
EthereumNetwork.GATHER_TESTNET: "https://testnet-explorer.gather.network/",
EthereumNetwork.GATHER_MAINNET: "https://explorer.gather.network/",
EthereumNetwork.METIS_TESTNET: "https://stardust-explorer.metis.io/",
EthereumNetwork.ENERGY_WEB_VOLTA_TESTNET: "https://volta-explorer.energyweb.org/",
EthereumNetwork.POLIS_MAINNET: "https://explorer.polis.tech",
EthereumNetwork.BOBABEAM: "https://blockexplorer.bobabeam.boba.network/",
EthereumNetwork.BOBA_NETWORK_RINKEBY_TESTNET: "https://blockexplorer.rinkeby.boba.network/",
EthereumNetwork.BOBA_NETWORK: "https://blockexplorer.boba.network/",
EthereumNetwork.GATHER_DEVNET_NETWORK: "https://devnet-explorer.gather.network/",
EthereumNetwork.GATHER_TESTNET_NETWORK: "https://testnet-explorer.gather.network/",
EthereumNetwork.GATHER_MAINNET_NETWORK: "https://explorer.gather.network/",
EthereumNetwork.METIS_STARDUST_TESTNET: "https://stardust-explorer.metis.io/",
EthereumNetwork.METIS_GOERLI_TESTNET: "https://goerli.explorer.metisdevops.link/",
EthereumNetwork.METIS: "https://andromeda-explorer.metis.io/",
EthereumNetwork.METIS_ANDROMEDA_MAINNET: "https://andromeda-explorer.metis.io/",
EthereumNetwork.FUSE_MAINNET: "https://explorer.fuse.io/",
EthereumNetwork.VELAS_MAINNET: "https://evmexplorer.velas.com/",
EthereumNetwork.REI_MAINNET: "https://scan.rei.network/",
EthereumNetwork.REI_TESTNET: "https://scan-test.rei.network/",
EthereumNetwork.METER: "https://scan.meter.io/",
EthereumNetwork.VELAS_EVM_MAINNET: "https://evmexplorer.velas.com/",
EthereumNetwork.REI_NETWORK: "https://scan.rei.network/",
EthereumNetwork.REI_CHAIN_TESTNET: "https://scan-test.rei.network/",
EthereumNetwork.METER_MAINNET: "https://scan.meter.io/",
EthereumNetwork.METER_TESTNET: "https://scan-warringstakes.meter.io/",
EthereumNetwork.GODWOKEN_TESTNET: "https://v1.betanet.gwscan.com/",
EthereumNetwork.GODWOKEN: "https://v1.gwscan.com/",
EthereumNetwork.GODWOKEN_TESTNET_V1: "https://v1.betanet.gwscan.com/",
EthereumNetwork.GODWOKEN_MAINNET: "https://v1.gwscan.com/",
EthereumNetwork.VENIDIUM_TESTNET: "https://evm-testnet.venidiumexplorer.com/",
EthereumNetwork.VENIDIUM: "https://evm.venidiumexplorer.com/",
EthereumNetwork.KLAY_BAOBAB: "https://baobab.scope.klaytn.com/",
EthereumNetwork.KLAY_CYPRESS: "https://scope.klaytn.com/",
EthereumNetwork.ACA: "https://blockscout.acala.network/",
EthereumNetwork.VENIDIUM_MAINNET: "https://evm.venidiumexplorer.com/",
EthereumNetwork.KLAYTN_TESTNET_BAOBAB: "https://baobab.scope.klaytn.com/",
EthereumNetwork.KLAYTN_MAINNET_CYPRESS: "https://scope.klaytn.com/",
EthereumNetwork.ACALA_NETWORK: "https://blockscout.acala.network/",
EthereumNetwork.KARURA_NETWORK_TESTNET: "https://blockscout.karura.network/",
EthereumNetwork.ACALA_NETWORK_TESTNET: "https://blockscout.mandala.acala.network/",
EthereumNetwork.ASTAR: "https://blockscout.com/astar/",
EthereumNetwork.EVMOS_MAINNET: "https://evm.evmos.org",
EthereumNetwork.EVMOS: "https://evm.evmos.org",
EthereumNetwork.EVMOS_TESTNET: "https://evm.evmos.dev",
EthereumNetwork.RABBIT: "https://rabbit.analogscan.com",
EthereumNetwork.RABBIT_ANALOG_TESTNET_CHAIN: "https://rabbit.analogscan.com",
EthereumNetwork.KCC_MAINNET: "https://scan.kcc.io/",
EthereumNetwork.KCC_TESTNET: "https://scan-testnet.kcc.network/",
EthereumNetwork.ARBITRUM: "https://explorer.arbitrum.io",
EthereumNetwork.ARBITRUM_ONE: "https://explorer.arbitrum.io",
EthereumNetwork.ARBITRUM_NOVA: "https://nova-explorer.arbitrum.io",
EthereumNetwork.ARBITRUM_GOERLI: "https://goerli-rollup-explorer.arbitrum.io",
EthereumNetwork.CROSSBELL: "https://scan.crossbell.io",
}

def __init__(self, network: EthereumNetwork):
Expand Down
46 changes: 25 additions & 21 deletions gnosis/eth/clients/etherscan_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,44 @@ class EtherscanClient:
EthereumNetwork.ROPSTEN: "https://ropsten.etherscan.io",
EthereumNetwork.GOERLI: "https://goerli.etherscan.io",
EthereumNetwork.KOVAN: "https://kovan.etherscan.io",
EthereumNetwork.BINANCE: "https://bscscan.com",
EthereumNetwork.MATIC: "https://polygonscan.com",
EthereumNetwork.OPTIMISTIC: "https://optimistic.etherscan.io",
EthereumNetwork.ARBITRUM: "https://arbiscan.io",
EthereumNetwork.BINANCE_SMART_CHAIN_MAINNET: "https://bscscan.com",
EthereumNetwork.POLYGON: "https://polygonscan.com",
EthereumNetwork.OPTIMISM: "https://optimistic.etherscan.io",
EthereumNetwork.ARBITRUM_ONE: "https://arbiscan.io",
EthereumNetwork.ARBITRUM_NOVA: "https://nova.arbiscan.io",
EthereumNetwork.ARBITRUM_GOERLI: "https://goerli.arbiscan.io",
EthereumNetwork.AVALANCHE: "https://snowtrace.io",
EthereumNetwork.MOON_MOONBEAM: "https://moonscan.io",
EthereumNetwork.MOON_MOONRIVER: "https://moonriver.moonscan.io",
EthereumNetwork.MOON_MOONBASE: "https://moonbase.moonscan.io",
EthereumNetwork.CRONOS_MAINNET: "https://cronoscan.com",
EthereumNetwork.AVALANCHE_C_CHAIN: "https://snowtrace.io",
EthereumNetwork.MOONBEAM: "https://moonscan.io",
EthereumNetwork.MOONRIVER: "https://moonriver.moonscan.io",
EthereumNetwork.MOONBASE_ALPHA: "https://moonbase.moonscan.io",
EthereumNetwork.CRONOS_MAINNET_BETA: "https://cronoscan.com",
EthereumNetwork.CRONOS_TESTNET: "https://testnet.cronoscan.com",
EthereumNetwork.CELO: "https://celoscan.io",
EthereumNetwork.CELO_MAINNET: "https://celoscan.io",
EthereumNetwork.BASE_GOERLI_TESTNET: "https://goerli.basescan.org",
EthereumNetwork.NEON_EVM_DEVNET: "https://neonscan.org",
}

NETWORK_WITH_API_URL = {
EthereumNetwork.MAINNET: "https://api.etherscan.io",
EthereumNetwork.RINKEBY: "https://api-rinkeby.etherscan.io",
EthereumNetwork.ROPSTEN: "https://api-ropsten.etherscan.io",
EthereumNetwork.GOERLI: "https://api-goerli.etherscan.io/",
EthereumNetwork.GOERLI: "https://api-goerli.etherscan.io",
EthereumNetwork.KOVAN: "https://api-kovan.etherscan.io",
EthereumNetwork.BINANCE: "https://api.bscscan.com",
EthereumNetwork.MATIC: "https://api.polygonscan.com",
EthereumNetwork.OPTIMISTIC: "https://api-optimistic.etherscan.io",
EthereumNetwork.ARBITRUM: "https://api.arbiscan.io",
EthereumNetwork.BINANCE_SMART_CHAIN_MAINNET: "https://api.bscscan.com",
EthereumNetwork.POLYGON: "https://api.polygonscan.com",
EthereumNetwork.OPTIMISM: "https://api-optimistic.etherscan.io",
EthereumNetwork.ARBITRUM_ONE: "https://api.arbiscan.io",
EthereumNetwork.ARBITRUM_NOVA: "https://api-nova.arbiscan.io",
EthereumNetwork.ARBITRUM_GOERLI: "https://api-goerli.arbiscan.io",
EthereumNetwork.AVALANCHE: "https://api.snowtrace.io",
EthereumNetwork.MOON_MOONBEAM: "https://api-moonbeam.moonscan.io",
EthereumNetwork.MOON_MOONRIVER: "https://api-moonriver.moonscan.io",
EthereumNetwork.MOON_MOONBASE: "https://api-moonbase.moonscan.io",
EthereumNetwork.CRONOS_MAINNET: "https://api.cronoscan.com",
EthereumNetwork.AVALANCHE_C_CHAIN: "https://api.snowtrace.io",
EthereumNetwork.MOONBEAM: "https://api-moonbeam.moonscan.io",
EthereumNetwork.MOONRIVER: "https://api-moonriver.moonscan.io",
EthereumNetwork.MOONBASE_ALPHA: "https://api-moonbase.moonscan.io",
EthereumNetwork.CRONOS_MAINNET_BETA: "https://api.cronoscan.com",
EthereumNetwork.CRONOS_TESTNET: "https://api-testnet.cronoscan.com",
EthereumNetwork.CELO: "https://api.celoscan.io",
EthereumNetwork.CELO_MAINNET: "https://api.celoscan.io",
EthereumNetwork.BASE_GOERLI_TESTNET: "https://api-goerli.basescan.org",
EthereumNetwork.NEON_EVM_DEVNET: "https://devnet-api.neonscan.org",
}
HTTP_HEADERS = {
"User-Agent": "curl/7.77.0",
Expand Down
20 changes: 11 additions & 9 deletions gnosis/eth/eip712/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Routines for EIP712 encoding and signing.
Copyright (C) 2022 Judd Vinet <[email protected]>
Uxío Fuentefría <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down Expand Up @@ -75,15 +76,16 @@ def _encode_field(name, typ, value):
return ["bytes32", fast_keccak(value)]

if typ.endswith("]"):
parsed_type = typ[:-2]
type_value_pairs = dict(
[_encode_field(name, parsed_type, v) for v in value]
)
h = fast_keccak(
encode_abi(
list(type_value_pairs.keys()), list(type_value_pairs.values())
)
)
# Array type
if value:
parsed_type = typ[: typ.rindex("[")]
type_value_pairs = [_encode_field(name, parsed_type, v) for v in value]
data_types, data_hashes = zip(*type_value_pairs)
else:
# Empty array
data_types, data_hashes = [], []

h = fast_keccak(encode_abi(data_types, data_hashes))
return ["bytes32", h]

return [typ, value]
Expand Down
7 changes: 5 additions & 2 deletions gnosis/eth/ethereum_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1407,10 +1407,11 @@ def get_client_version(self) -> str:

def get_network(self) -> EthereumNetwork:
"""
Get network name based on the chainId
Get network name based on the chainId. This method is not cached as the method for getting the
`chainId` already is.
:return: EthereumNetwork based on the chainId. If network is not
on our list, `EthereumNetwork.UNKOWN` is returned
on our list, `EthereumNetwork.UNKNOWN` is returned
"""
return EthereumNetwork(self.get_chain_id())

Expand Down Expand Up @@ -1533,6 +1534,7 @@ def deploy_and_initialize_contract(
"gasPrice": self.w3.eth.gas_price,
"value": Wei(0),
"to": contract_address if contract_address else "",
"chainId": self.get_chain_id(),
}
tx["gas"] = self.w3.eth.estimate_gas(tx)
tx_hash = self.send_unsigned_transaction(
Expand Down Expand Up @@ -1942,6 +1944,7 @@ def send_eth_to(
"value": value,
"gas": gas or Wei(self.estimate_gas(to, account.address, value)),
"gasPrice": Wei(gas_price),
"chainId": self.get_chain_id(),
}

if nonce is not None:
Expand Down
Loading

0 comments on commit 0c74c01

Please sign in to comment.