prediction-market-agent-tooling 0.69.15.dev1135__py3-none-any.whl → 0.69.15.dev1137__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.

Potentially problematic release.


This version of prediction-market-agent-tooling might be problematic. Click here for more details.

@@ -0,0 +1,16 @@
1
+ [
2
+ {
3
+ "constant": true,
4
+ "inputs": [],
5
+ "name": "processor",
6
+ "outputs": [
7
+ {
8
+ "name": "impl",
9
+ "type": "address"
10
+ }
11
+ ],
12
+ "payable": false,
13
+ "stateMutability": "view",
14
+ "type": "function"
15
+ }
16
+ ]
@@ -12,6 +12,7 @@ from web3 import Web3
12
12
  from web3.constants import CHECKSUM_ADDRESSS_ZERO, HASH_ZERO
13
13
  from web3.contract.contract import Contract as Web3Contract
14
14
  from web3.exceptions import ContractCustomError, ContractLogicError
15
+ from web3.types import BlockIdentifier
15
16
 
16
17
  from prediction_market_agent_tooling.chains import POLYGON_CHAIN_ID
17
18
  from prediction_market_agent_tooling.config import APIKeys, RPCConfig
@@ -97,6 +98,7 @@ class ContractBaseClass(BaseModel):
97
98
  function_name: str,
98
99
  function_params: t.Optional[list[t.Any] | dict[str, t.Any]] = None,
99
100
  web3: Web3 | None = None,
101
+ block_identifier: BlockIdentifier | None = None,
100
102
  ) -> t.Any:
101
103
  """
102
104
  Used for reading from the contract.
@@ -108,6 +110,7 @@ class ContractBaseClass(BaseModel):
108
110
  contract_abi=self.abi,
109
111
  function_name=function_name,
110
112
  function_params=function_params,
113
+ block_identifier=block_identifier,
111
114
  )
112
115
 
113
116
  def send(
@@ -196,6 +199,22 @@ class ContractProxyBaseClass(ContractBaseClass):
196
199
  return Web3.to_checksum_address(address)
197
200
 
198
201
 
202
+ class ContractProcessorBaseClass(ContractBaseClass):
203
+ """
204
+ Contract base class for processor contracts.
205
+ """
206
+
207
+ abi: ABI = abi_field_validator(
208
+ os.path.join(
209
+ os.path.dirname(os.path.realpath(__file__)), "../abis/processor.abi.json"
210
+ )
211
+ )
212
+
213
+ def processor(self, web3: Web3 | None = None) -> ChecksumAddress:
214
+ address = self.call("processor", web3=web3)
215
+ return Web3.to_checksum_address(address)
216
+
217
+
199
218
  class ContractERC20BaseClass(ContractBaseClass):
200
219
  """
201
220
  Contract base class extended by ERC-20 standard methods.
@@ -274,8 +293,17 @@ class ContractERC20BaseClass(ContractBaseClass):
274
293
  web3=web3,
275
294
  )
276
295
 
277
- def balanceOf(self, for_address: ChecksumAddress, web3: Web3 | None = None) -> Wei:
278
- balance = Wei(self.call("balanceOf", [for_address], web3=web3))
296
+ def balanceOf(
297
+ self,
298
+ for_address: ChecksumAddress,
299
+ web3: Web3 | None = None,
300
+ block_identifier: BlockIdentifier | None = None,
301
+ ) -> Wei:
302
+ balance = Wei(
303
+ self.call(
304
+ "balanceOf", [for_address], web3=web3, block_identifier=block_identifier
305
+ )
306
+ )
279
307
  return balance
280
308
 
281
309
  def balance_of_in_tokens(
@@ -948,6 +976,7 @@ def uni_implementation_address(
948
976
  # TODO: Fix the above, and afterwards assert that only 1 imp address is returned from this function. Or prove that this could indeed happen (although we are very pretty sure it shouldn't).
949
977
  addresses = [
950
978
  implementation_proxy_address(contract_address, web3),
979
+ processor_proxy_address(contract_address, web3),
951
980
  minimal_proxy_address(contract_address, web3),
952
981
  seer_minimal_proxy_address(contract_address, web3),
953
982
  eip_1967_proxy_address(contract_address, web3),
@@ -979,6 +1008,29 @@ def implementation_proxy_address(
979
1008
  return None
980
1009
 
981
1010
 
1011
+ def processor_proxy_address(
1012
+ contract_address: ChecksumAddress, web3: Web3
1013
+ ) -> ChecksumAddress | None:
1014
+ if not contract_implements_function(
1015
+ contract_address, "processor", web3, look_for_proxy_contract=False
1016
+ ):
1017
+ return None
1018
+ try:
1019
+ return ContractProcessorBaseClass(address=contract_address).processor(web3)
1020
+ except (ContractCustomError, ContractLogicError, tenacity.RetryError) as e:
1021
+ if isinstance(e, tenacity.RetryError) and not isinstance(
1022
+ e.last_attempt.exception(), (ContractCustomError, ContractLogicError)
1023
+ ):
1024
+ raise
1025
+
1026
+ # For example https://gnosisscan.io/address/0x3221a28ed2b2e955da64d1d299956f277562c95c#code,
1027
+ # it has the processor method, but it's only for admins.
1028
+ logger.warning(
1029
+ f"Failed to get processor for {contract_address=} even though it has the method: {e}"
1030
+ )
1031
+ return None
1032
+
1033
+
982
1034
  def minimal_proxy_address(
983
1035
  contract_address: ChecksumAddress, web3: Web3
984
1036
  ) -> ChecksumAddress | None:
@@ -16,7 +16,14 @@ from safe_eth.safe.safe import SafeV141
16
16
  from web3 import Web3
17
17
  from web3.constants import HASH_ZERO
18
18
  from web3.contract.contract import ContractFunction as Web3ContractFunction
19
- from web3.types import AccessList, AccessListEntry, Nonce, TxParams, TxReceipt
19
+ from web3.types import (
20
+ AccessList,
21
+ AccessListEntry,
22
+ BlockIdentifier,
23
+ Nonce,
24
+ TxParams,
25
+ TxReceipt,
26
+ )
20
27
 
21
28
  from prediction_market_agent_tooling.gtypes import (
22
29
  ABI,
@@ -106,11 +113,12 @@ def call_function_on_contract(
106
113
  contract_abi: ABI,
107
114
  function_name: str,
108
115
  function_params: Optional[list[Any] | dict[str, Any]] = None,
116
+ block_identifier: Optional[BlockIdentifier] = None,
109
117
  ) -> Any:
110
118
  contract = web3.eth.contract(address=contract_address, abi=contract_abi)
111
119
  output = contract.functions[function_name](
112
120
  *parse_function_params(function_params)
113
- ).call()
121
+ ).call(block_identifier=block_identifier)
114
122
  return output
115
123
 
116
124
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.69.15.dev1135
3
+ Version: 0.69.15.dev1137
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  License-File: LICENSE
6
6
  Author: Gnosis
@@ -16,6 +16,7 @@ prediction_market_agent_tooling/abis/omen_realitio.abi.json,sha256=7HmFkBF_rq83U
16
16
  prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json,sha256=u1-3B8FB3Ys9KVJCH-lw9ArkicdxbNMf34dV-VEGMMU,930
17
17
  prediction_market_agent_tooling/abis/ownable.abi.json,sha256=DeTy_7VmsMhFl7jwI8MIlmjy2jORauYxrGm7wC_Alxw,1528
18
18
  prediction_market_agent_tooling/abis/ownable_erc721.abi.json,sha256=9sxm588MAQmqCV_S0D3eYC7l9grbeALsd0Da_AHxdEI,8506
19
+ prediction_market_agent_tooling/abis/processor.abi.json,sha256=VGMyBblTPO3I6AoKQFMgTylgJLl6-6FquUbejICDEAw,242
19
20
  prediction_market_agent_tooling/abis/proxy.abi.json,sha256=h24GXZ6Q0bSZlwh7zOv0EiDvbqUz_PHtWfKHTyPJ1w4,644
20
21
  prediction_market_agent_tooling/abis/seer_gnosis_router.abi.json,sha256=DyADzOXhy9MDS31ReVrG7ibpWbw1jVy19nExZ80xfRY,6839
21
22
  prediction_market_agent_tooling/abis/seer_market_factory.abi.json,sha256=g7RVxZVUWlTXIgTV2W6kO4twQM909Qv58zAr7Dk4XIc,13553
@@ -92,7 +93,7 @@ prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=MpS3FOM
92
93
  prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=V6o6UdesjkKzSJMhqkUtD76cJGPaNhuwA4OL2chIYSI,13801
93
94
  prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=ZW5iI5rmjqeAebu5T7ftRnlkxiL02IC-MxCfDB80x7w,1506
94
95
  prediction_market_agent_tooling/tools/caches/serializers.py,sha256=fwyIHUsL7u9NY7ZihTcUdqsvl2psatcbTfgWHTSez3U,2427
95
- prediction_market_agent_tooling/tools/contract.py,sha256=ZPQT3Kk9-q-ns7DO3MjQ_OLPUgeDjUTFwKP7L0vKKqc,36035
96
+ prediction_market_agent_tooling/tools/contract.py,sha256=XbdegY4dVdiJkNbtXLKtR2GsqGLMYbvc5lTpIIOcWLw,37785
96
97
  prediction_market_agent_tooling/tools/contract_utils.py,sha256=9X9raICUZkPDShilt02aYzS_ILZ62u0vG5081uWLdqk,2152
97
98
  prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
98
99
  prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=DN_8cPrr4jWVpXdS4D0j1QB19nB8fxDoSheo2BFMc8M,14523
@@ -136,9 +137,9 @@ prediction_market_agent_tooling/tools/tokens/token_utils.py,sha256=fhs-FH9m9IbzG
136
137
  prediction_market_agent_tooling/tools/tokens/usd.py,sha256=DPO-4HBTy1-TZHKL_9CnHQ8p9W7ivPfcRlUkRO0nKJ8,3259
137
138
  prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
138
139
  prediction_market_agent_tooling/tools/utils.py,sha256=ruq6P5TFs8CBHxeBLj1Plpx7kuNFPpDgMsJGQgDiRNs,8785
139
- prediction_market_agent_tooling/tools/web3_utils.py,sha256=CDbaidlLeQ4VHzSg150L7QNfHfGveljSePGuDVFEYqc,13963
140
- prediction_market_agent_tooling-0.69.15.dev1135.dist-info/METADATA,sha256=1H0d5JE8lKB6PgIB_tlN93PQHxM1fcPdnTtINOj2_Rg,8899
141
- prediction_market_agent_tooling-0.69.15.dev1135.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
142
- prediction_market_agent_tooling-0.69.15.dev1135.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
143
- prediction_market_agent_tooling-0.69.15.dev1135.dist-info/licenses/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
144
- prediction_market_agent_tooling-0.69.15.dev1135.dist-info/RECORD,,
140
+ prediction_market_agent_tooling/tools/web3_utils.py,sha256=1G8uu33p4zNhGKSiyyueROtMau4YoMR3N1QDRFQ3TjE,14098
141
+ prediction_market_agent_tooling-0.69.15.dev1137.dist-info/METADATA,sha256=0p53RdWnPkbg0lmhBEQ0YaxRvqLGQXWZVhoSJHkhQbs,8899
142
+ prediction_market_agent_tooling-0.69.15.dev1137.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
143
+ prediction_market_agent_tooling-0.69.15.dev1137.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
144
+ prediction_market_agent_tooling-0.69.15.dev1137.dist-info/licenses/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
145
+ prediction_market_agent_tooling-0.69.15.dev1137.dist-info/RECORD,,