prediction-market-agent-tooling 0.69.6.dev1094__py3-none-any.whl → 0.69.7__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.
- prediction_market_agent_tooling/tools/contract_utils.py +61 -0
- prediction_market_agent_tooling/tools/web3_utils.py +0 -58
- {prediction_market_agent_tooling-0.69.6.dev1094.dist-info → prediction_market_agent_tooling-0.69.7.dist-info}/METADATA +2 -2
- {prediction_market_agent_tooling-0.69.6.dev1094.dist-info → prediction_market_agent_tooling-0.69.7.dist-info}/RECORD +7 -6
- {prediction_market_agent_tooling-0.69.6.dev1094.dist-info → prediction_market_agent_tooling-0.69.7.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.69.6.dev1094.dist-info → prediction_market_agent_tooling-0.69.7.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.69.6.dev1094.dist-info → prediction_market_agent_tooling-0.69.7.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
from web3 import Web3
|
2
|
+
|
3
|
+
from prediction_market_agent_tooling.config import RPCConfig
|
4
|
+
from prediction_market_agent_tooling.gtypes import ChecksumAddress
|
5
|
+
from prediction_market_agent_tooling.tools.contract import contract_implements_function
|
6
|
+
|
7
|
+
|
8
|
+
def is_erc20_contract(address: ChecksumAddress, web3: Web3 | None = None) -> bool:
|
9
|
+
"""
|
10
|
+
Checks if the given address is an ERC20-compatible contract.
|
11
|
+
|
12
|
+
It estimates it by looking if it implements symbol, name, decimals, totalSupply, balanceOf.
|
13
|
+
"""
|
14
|
+
web3 = web3 or RPCConfig().get_web3()
|
15
|
+
return (
|
16
|
+
contract_implements_function(address, "symbol", web3)
|
17
|
+
and contract_implements_function(address, "name", web3)
|
18
|
+
and contract_implements_function(address, "totalSupply", web3)
|
19
|
+
and contract_implements_function(
|
20
|
+
address, "balanceOf", web3, function_arg_types=["address"]
|
21
|
+
)
|
22
|
+
)
|
23
|
+
|
24
|
+
|
25
|
+
def is_nft_contract(address: ChecksumAddress, web3: Web3 | None = None) -> bool:
|
26
|
+
"""
|
27
|
+
Checks if the given address is an NFT-compatible contract (ERC721 or ERC1155).
|
28
|
+
|
29
|
+
For ERC721, checks for: ownerOf, balanceOf, transferFrom.
|
30
|
+
For ERC1155, checks for: balanceOf, safeTransferFrom.
|
31
|
+
|
32
|
+
Returns True if either ERC721 or ERC1155 interface is detected.
|
33
|
+
"""
|
34
|
+
web3 = web3 or RPCConfig().get_web3()
|
35
|
+
is_erc721 = (
|
36
|
+
contract_implements_function(
|
37
|
+
address, "ownerOf", web3, function_arg_types=["uint256"]
|
38
|
+
)
|
39
|
+
and contract_implements_function(
|
40
|
+
address, "balanceOf", web3, function_arg_types=["address"]
|
41
|
+
)
|
42
|
+
and contract_implements_function(
|
43
|
+
address,
|
44
|
+
"transferFrom",
|
45
|
+
web3,
|
46
|
+
function_arg_types=["address", "address", "uint256"],
|
47
|
+
)
|
48
|
+
)
|
49
|
+
if is_erc721:
|
50
|
+
return True
|
51
|
+
is_erc1155 = contract_implements_function(
|
52
|
+
address, "balanceOf", web3, function_arg_types=["address", "uint256"]
|
53
|
+
) and contract_implements_function(
|
54
|
+
address,
|
55
|
+
"safeTransferFrom",
|
56
|
+
web3,
|
57
|
+
function_arg_types=["address", "address", "uint256", "uint256", "bytes"],
|
58
|
+
)
|
59
|
+
if is_erc1155:
|
60
|
+
return True
|
61
|
+
return False
|
@@ -18,7 +18,6 @@ from web3.constants import HASH_ZERO
|
|
18
18
|
from web3.contract.contract import ContractFunction as Web3ContractFunction
|
19
19
|
from web3.types import AccessList, AccessListEntry, Nonce, TxParams, TxReceipt
|
20
20
|
|
21
|
-
from prediction_market_agent_tooling.config import RPCConfig
|
22
21
|
from prediction_market_agent_tooling.gtypes import (
|
23
22
|
ABI,
|
24
23
|
ChecksumAddress,
|
@@ -34,7 +33,6 @@ from prediction_market_agent_tooling.gtypes import (
|
|
34
33
|
)
|
35
34
|
from prediction_market_agent_tooling.loggers import logger
|
36
35
|
from prediction_market_agent_tooling.tools._generic_value import _GenericValue
|
37
|
-
from prediction_market_agent_tooling.tools.contract import contract_implements_function
|
38
36
|
|
39
37
|
ONE_NONCE = Nonce(1)
|
40
38
|
ONE_XDAI = xDai(1)
|
@@ -408,59 +406,3 @@ def get_receipt_block_timestamp(receipt_tx: TxReceipt, web3: Web3) -> int:
|
|
408
406
|
|
409
407
|
def is_valid_wei(value: Web3Wei) -> bool:
|
410
408
|
return MIN_WEI <= value <= MAX_WEI
|
411
|
-
|
412
|
-
|
413
|
-
def is_erc20_contract(address: ChecksumAddress, web3: Web3 | None = None) -> bool:
|
414
|
-
"""
|
415
|
-
Checks if the given address is an ERC20-compatible contract.
|
416
|
-
|
417
|
-
It estimates it by looking if it implements symbol, name, decimals, totalSupply, balanceOf.
|
418
|
-
"""
|
419
|
-
web3 = web3 or RPCConfig().get_web3()
|
420
|
-
return (
|
421
|
-
contract_implements_function(address, "symbol", web3)
|
422
|
-
and contract_implements_function(address, "name", web3)
|
423
|
-
and contract_implements_function(address, "totalSupply", web3)
|
424
|
-
and contract_implements_function(
|
425
|
-
address, "balanceOf", web3, function_arg_types=["address"]
|
426
|
-
)
|
427
|
-
)
|
428
|
-
|
429
|
-
|
430
|
-
def is_nft_contract(address: ChecksumAddress, web3: Web3 | None = None) -> bool:
|
431
|
-
"""
|
432
|
-
Checks if the given address is an NFT-compatible contract (ERC721 or ERC1155).
|
433
|
-
|
434
|
-
For ERC721, checks for: ownerOf, balanceOf, transferFrom.
|
435
|
-
For ERC1155, checks for: balanceOf, safeTransferFrom.
|
436
|
-
|
437
|
-
Returns True if either ERC721 or ERC1155 interface is detected.
|
438
|
-
"""
|
439
|
-
web3 = web3 or RPCConfig().get_web3()
|
440
|
-
is_erc721 = (
|
441
|
-
contract_implements_function(
|
442
|
-
address, "ownerOf", web3, function_arg_types=["uint256"]
|
443
|
-
)
|
444
|
-
and contract_implements_function(
|
445
|
-
address, "balanceOf", web3, function_arg_types=["address"]
|
446
|
-
)
|
447
|
-
and contract_implements_function(
|
448
|
-
address,
|
449
|
-
"transferFrom",
|
450
|
-
web3,
|
451
|
-
function_arg_types=["address", "address", "uint256"],
|
452
|
-
)
|
453
|
-
)
|
454
|
-
if is_erc721:
|
455
|
-
return True
|
456
|
-
is_erc1155 = contract_implements_function(
|
457
|
-
address, "balanceOf", web3, function_arg_types=["address", "uint256"]
|
458
|
-
) and contract_implements_function(
|
459
|
-
address,
|
460
|
-
"safeTransferFrom",
|
461
|
-
web3,
|
462
|
-
function_arg_types=["address", "address", "uint256", "uint256", "bytes"],
|
463
|
-
)
|
464
|
-
if is_erc1155:
|
465
|
-
return True
|
466
|
-
return False
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: prediction-market-agent-tooling
|
3
|
-
Version: 0.69.
|
3
|
+
Version: 0.69.7
|
4
4
|
Summary: Tools to benchmark, deploy and monitor prediction market agents.
|
5
5
|
Author: Gnosis
|
6
6
|
Requires-Python: >=3.10,<3.13
|
@@ -43,7 +43,7 @@ Requires-Dist: protobuf (>=5.0.0,<6.0.0)
|
|
43
43
|
Requires-Dist: psycopg2-binary (>=2.9.9,<3.0.0)
|
44
44
|
Requires-Dist: py-clob-client (>=0.24.0,<0.25.0)
|
45
45
|
Requires-Dist: pydantic (>=2.6.1,<3.0.0)
|
46
|
-
Requires-Dist: pydantic-ai (>=0.
|
46
|
+
Requires-Dist: pydantic-ai (>=1.0.3,<2.0.0)
|
47
47
|
Requires-Dist: pydantic-settings (>=2.4.0,<3.0.0)
|
48
48
|
Requires-Dist: pymongo (>=4.8.0,<5.0.0)
|
49
49
|
Requires-Dist: pytest-postgresql (>=6.1.1,<7.0.0)
|
@@ -92,6 +92,7 @@ prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=rZIGhgijquwwPtp_
|
|
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
94
|
prediction_market_agent_tooling/tools/contract.py,sha256=Agd3eNsr9PW6t2jtGUzcQlmudNKpjvQkSfGEcq28i8k,33813
|
95
|
+
prediction_market_agent_tooling/tools/contract_utils.py,sha256=9X9raICUZkPDShilt02aYzS_ILZ62u0vG5081uWLdqk,2152
|
95
96
|
prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
|
96
97
|
prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=kdvhWVTb31oHVspQFowDNEIoDtx8hwGTlKsWYGRh3oQ,14050
|
97
98
|
prediction_market_agent_tooling/tools/cow/models.py,sha256=2hTW-Ye6SamBBAO32nVo4f3vjAOOySw8ehECReRcA3o,756
|
@@ -134,9 +135,9 @@ prediction_market_agent_tooling/tools/tokens/token_utils.py,sha256=fhs-FH9m9IbzG
|
|
134
135
|
prediction_market_agent_tooling/tools/tokens/usd.py,sha256=DPO-4HBTy1-TZHKL_9CnHQ8p9W7ivPfcRlUkRO0nKJ8,3259
|
135
136
|
prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
|
136
137
|
prediction_market_agent_tooling/tools/utils.py,sha256=ruq6P5TFs8CBHxeBLj1Plpx7kuNFPpDgMsJGQgDiRNs,8785
|
137
|
-
prediction_market_agent_tooling/tools/web3_utils.py,sha256=
|
138
|
-
prediction_market_agent_tooling-0.69.
|
139
|
-
prediction_market_agent_tooling-0.69.
|
140
|
-
prediction_market_agent_tooling-0.69.
|
141
|
-
prediction_market_agent_tooling-0.69.
|
142
|
-
prediction_market_agent_tooling-0.69.
|
138
|
+
prediction_market_agent_tooling/tools/web3_utils.py,sha256=CDbaidlLeQ4VHzSg150L7QNfHfGveljSePGuDVFEYqc,13963
|
139
|
+
prediction_market_agent_tooling-0.69.7.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
140
|
+
prediction_market_agent_tooling-0.69.7.dist-info/METADATA,sha256=JBg7JR5x7QBjb1jDgg3Z9XRU2YPgkax5effooheYli4,8868
|
141
|
+
prediction_market_agent_tooling-0.69.7.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
142
|
+
prediction_market_agent_tooling-0.69.7.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
143
|
+
prediction_market_agent_tooling-0.69.7.dist-info/RECORD,,
|
File without changes
|
File without changes
|