prediction-market-agent-tooling 0.69.6.dev1095__py3-none-any.whl → 0.69.7.dev1098__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -909,84 +909,77 @@ def contract_implements_function(
909
909
 
910
910
  # If not found directly and we should check proxies
911
911
  if not implements and look_for_proxy_contract:
912
- # Case 1: Check if it's a standard proxy (has implementation() function)
913
- if contract_implements_function(
914
- contract_address, "implementation", web3, look_for_proxy_contract=False
915
- ):
916
- # Get the implementation address and check the function there
917
- implementation_address = ContractProxyOnGnosisChain(
918
- address=contract_address
919
- ).implementation()
912
+ imp_address = uni_implementation_address(contract_address, web3)
913
+ if imp_address is not None:
920
914
  implements = contract_implements_function(
921
- implementation_address,
915
+ imp_address,
922
916
  function_name=function_name,
923
917
  web3=web3,
924
918
  function_arg_types=function_arg_types,
925
919
  look_for_proxy_contract=False,
926
920
  )
927
- else:
928
- # Case 2: Check if it's a minimal proxy contract
929
- implements = minimal_proxy_implements_function(
930
- contract_address=contract_address,
931
- function_name=function_name,
932
- web3=web3,
933
- function_arg_types=function_arg_types,
934
- ) or seer_minimal_proxy_implements_function(
935
- contract_address=contract_address,
936
- function_name=function_name,
937
- web3=web3,
938
- function_arg_types=function_arg_types,
939
- )
940
921
 
941
922
  return implements
942
923
 
943
924
 
944
- def minimal_proxy_implements_function(
945
- contract_address: ChecksumAddress,
946
- function_name: str,
947
- web3: Web3,
948
- function_arg_types: list[str] | None = None,
949
- ) -> bool:
925
+ def uni_implementation_address(
926
+ contract_address: ChecksumAddress, web3: Web3
927
+ ) -> ChecksumAddress | None:
928
+ """
929
+ There are multiple ways how proxies can be implemented.
930
+ This function enumerates them and returns the one that succeeds, or None.
931
+ """
932
+ address = implementation_proxy_address(contract_address, web3)
933
+ if address is not None:
934
+ return address
935
+
936
+ address = minimal_proxy_address(contract_address, web3)
937
+ if address is not None:
938
+ return address
939
+
940
+ address = seer_minimal_proxy_address(contract_address, web3)
941
+ if address is not None:
942
+ return address
943
+
944
+ return None
945
+
946
+
947
+ def implementation_proxy_address(
948
+ contract_address: ChecksumAddress, web3: Web3
949
+ ) -> ChecksumAddress | None:
950
+ if not contract_implements_function(
951
+ contract_address, "implementation", web3, look_for_proxy_contract=False
952
+ ):
953
+ return None
954
+ return ContractProxyOnGnosisChain(address=contract_address).implementation()
955
+
956
+
957
+ def minimal_proxy_address(
958
+ contract_address: ChecksumAddress, web3: Web3
959
+ ) -> ChecksumAddress | None:
950
960
  try:
951
961
  # Read storage slot 0 which should contain the implementation address in minimal proxies
952
962
  raw_slot_0 = web3.eth.get_storage_at(contract_address, 0)
953
963
  singleton_address = eth_abi.decode(["address"], raw_slot_0)[0]
954
- # Recurse into singleton
955
- return contract_implements_function(
956
- Web3.to_checksum_address(singleton_address),
957
- function_name=function_name,
958
- web3=web3,
959
- function_arg_types=function_arg_types,
960
- look_for_proxy_contract=False,
961
- )
964
+ return Web3.to_checksum_address(singleton_address)
962
965
  except DecodingError:
963
966
  logger.info(f"Error decoding contract address for singleton")
964
- return False
967
+ return None
965
968
 
966
969
 
967
- def seer_minimal_proxy_implements_function(
968
- contract_address: ChecksumAddress,
969
- function_name: str,
970
- web3: Web3,
971
- function_arg_types: list[str] | None = None,
972
- ) -> bool:
970
+ def seer_minimal_proxy_address(
971
+ contract_address: ChecksumAddress, web3: Web3
972
+ ) -> ChecksumAddress | None:
973
973
  try:
974
974
  # Read address between specific indices to find logic contract
975
975
  bytecode = web3.eth.get_code(contract_address)
976
976
  logic_contract_address = bytecode[11:31]
977
977
  if not Web3.is_address(logic_contract_address):
978
- return False
979
-
980
- return contract_implements_function(
981
- Web3.to_checksum_address(logic_contract_address),
982
- function_name=function_name,
983
- web3=web3,
984
- function_arg_types=function_arg_types,
985
- look_for_proxy_contract=False,
986
- )
978
+ return None
979
+ return Web3.to_checksum_address(logic_contract_address)
987
980
  except DecodingError:
988
981
  logger.info("Error decoding contract address on seer minimal proxy")
989
- return False
982
+ return None
990
983
 
991
984
 
992
985
  def init_collateral_token_contract(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.69.6.dev1095
3
+ Version: 0.69.7.dev1098
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.13
@@ -91,7 +91,7 @@ prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=MpS3FOM
91
91
  prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=rZIGhgijquwwPtp_qncSAPR1SDF2XxIVZL1ir0fgzWw,12127
92
92
  prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=ZW5iI5rmjqeAebu5T7ftRnlkxiL02IC-MxCfDB80x7w,1506
93
93
  prediction_market_agent_tooling/tools/caches/serializers.py,sha256=vFDx4fsPxclXp2q0sv27j4al_M_Tj9aR2JJP-xNHQXA,2151
94
- prediction_market_agent_tooling/tools/contract.py,sha256=Agd3eNsr9PW6t2jtGUzcQlmudNKpjvQkSfGEcq28i8k,33813
94
+ prediction_market_agent_tooling/tools/contract.py,sha256=zZ4EDlTdKuPhUWDzwHJ1YrY3fIqVBTO3N2R99tFxPVQ,33293
95
95
  prediction_market_agent_tooling/tools/contract_utils.py,sha256=9X9raICUZkPDShilt02aYzS_ILZ62u0vG5081uWLdqk,2152
96
96
  prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
97
97
  prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=kdvhWVTb31oHVspQFowDNEIoDtx8hwGTlKsWYGRh3oQ,14050
@@ -136,8 +136,8 @@ prediction_market_agent_tooling/tools/tokens/usd.py,sha256=DPO-4HBTy1-TZHKL_9CnH
136
136
  prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
137
137
  prediction_market_agent_tooling/tools/utils.py,sha256=ruq6P5TFs8CBHxeBLj1Plpx7kuNFPpDgMsJGQgDiRNs,8785
138
138
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=CDbaidlLeQ4VHzSg150L7QNfHfGveljSePGuDVFEYqc,13963
139
- prediction_market_agent_tooling-0.69.6.dev1095.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
140
- prediction_market_agent_tooling-0.69.6.dev1095.dist-info/METADATA,sha256=HEwiOdV121R0GRKDNkEvg2oLNtk_krazGIiBrrOdgIQ,8876
141
- prediction_market_agent_tooling-0.69.6.dev1095.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
142
- prediction_market_agent_tooling-0.69.6.dev1095.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
143
- prediction_market_agent_tooling-0.69.6.dev1095.dist-info/RECORD,,
139
+ prediction_market_agent_tooling-0.69.7.dev1098.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
140
+ prediction_market_agent_tooling-0.69.7.dev1098.dist-info/METADATA,sha256=FsfzI3oDm18A9Kk4d4hYcXo43Xt3J4A-oX9kiwLtXYE,8876
141
+ prediction_market_agent_tooling-0.69.7.dev1098.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
142
+ prediction_market_agent_tooling-0.69.7.dev1098.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
143
+ prediction_market_agent_tooling-0.69.7.dev1098.dist-info/RECORD,,