prediction-market-agent-tooling 0.37.0__py3-none-any.whl → 0.38.0__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.
@@ -0,0 +1,52 @@
1
+ [
2
+ {
3
+ "type": "function",
4
+ "name": "get",
5
+ "inputs": [
6
+ {
7
+ "name": "marketAddress",
8
+ "type": "address",
9
+ "internalType": "address"
10
+ }
11
+ ],
12
+ "outputs": [
13
+ {
14
+ "name": "",
15
+ "type": "bytes32",
16
+ "internalType": "bytes32"
17
+ }
18
+ ],
19
+ "stateMutability": "view"
20
+ },
21
+ {
22
+ "type": "function",
23
+ "name": "remove",
24
+ "inputs": [
25
+ {
26
+ "name": "marketAddress",
27
+ "type": "address",
28
+ "internalType": "address"
29
+ }
30
+ ],
31
+ "outputs": [],
32
+ "stateMutability": "nonpayable"
33
+ },
34
+ {
35
+ "type": "function",
36
+ "name": "set",
37
+ "inputs": [
38
+ {
39
+ "name": "marketAddress",
40
+ "type": "address",
41
+ "internalType": "address"
42
+ },
43
+ {
44
+ "name": "image_hash",
45
+ "type": "bytes32",
46
+ "internalType": "bytes32"
47
+ }
48
+ ],
49
+ "outputs": [],
50
+ "stateMutability": "nonpayable"
51
+ }
52
+ ]
@@ -34,6 +34,7 @@ Mana = NewType("Mana", float) # Manifold's "currency"
34
34
  USDC = NewType("USDC", float)
35
35
  DatetimeWithTimezone = NewType("DatetimeWithTimezone", datetime)
36
36
  ChainID = NewType("ChainID", int)
37
+ IPFSCIDVersion0 = NewType("IPFSCIDVersion0", str)
37
38
 
38
39
 
39
40
  def usd_type(amount: Union[str, int, float]) -> USD:
@@ -13,6 +13,7 @@ from prediction_market_agent_tooling.gtypes import (
13
13
  HexAddress,
14
14
  HexBytes,
15
15
  HexStr,
16
+ IPFSCIDVersion0,
16
17
  OmenOutcomeToken,
17
18
  TxParams,
18
19
  TxReceipt,
@@ -26,7 +27,12 @@ from prediction_market_agent_tooling.tools.contract import (
26
27
  ContractOnGnosisChain,
27
28
  abi_field_validator,
28
29
  )
29
- from prediction_market_agent_tooling.tools.web3_utils import xdai_to_wei
30
+ from prediction_market_agent_tooling.tools.web3_utils import (
31
+ ZERO_BYTES,
32
+ byte32_to_ipfscidv0,
33
+ ipfscidv0_to_byte32,
34
+ xdai_to_wei,
35
+ )
30
36
 
31
37
 
32
38
  class OmenOracleContract(ContractOnGnosisChain):
@@ -610,3 +616,61 @@ class OmenRealitioContract(ContractOnGnosisChain):
610
616
  web3: Web3 | None = None,
611
617
  ) -> TxReceipt:
612
618
  return self.send(api_keys=api_keys, function_name="withdraw", web3=web3)
619
+
620
+
621
+ class OmenThumbnailMapping(ContractOnGnosisChain):
622
+ # Contract ABI taken from built https://github.com/gnosis/labs-contracts.
623
+ abi: ABI = abi_field_validator(
624
+ os.path.join(
625
+ os.path.dirname(os.path.realpath(__file__)),
626
+ "../../abis/omen_thumbnailmapping.abi.json",
627
+ )
628
+ )
629
+ address: ChecksumAddress = Web3.to_checksum_address(
630
+ "0x5D8B7B619EcdE05B8A94C0a0E99E0A0727A0e2e7"
631
+ )
632
+
633
+ def get(
634
+ self,
635
+ market_address: ChecksumAddress,
636
+ web3: Web3 | None = None,
637
+ ) -> IPFSCIDVersion0 | None:
638
+ hash_bytes = HexBytes(
639
+ self.call("get", function_params=[market_address], web3=web3)
640
+ )
641
+ return byte32_to_ipfscidv0(hash_bytes) if hash_bytes != ZERO_BYTES else None
642
+
643
+ def get_url(
644
+ self,
645
+ market_address: ChecksumAddress,
646
+ web3: Web3 | None = None,
647
+ ) -> str | None:
648
+ hash_ = self.get(market_address, web3)
649
+ return f"https://ipfs.io/ipfs/{hash_}" if hash_ is not None else None
650
+
651
+ def set(
652
+ self,
653
+ api_keys: APIKeys,
654
+ market_address: ChecksumAddress,
655
+ image_hash: IPFSCIDVersion0,
656
+ web3: Web3 | None = None,
657
+ ) -> TxReceipt:
658
+ return self.send(
659
+ api_keys=api_keys,
660
+ function_name="set",
661
+ function_params=[market_address, ipfscidv0_to_byte32(image_hash)],
662
+ web3=web3,
663
+ )
664
+
665
+ def remove(
666
+ self,
667
+ api_keys: APIKeys,
668
+ market_address: ChecksumAddress,
669
+ web3: Web3 | None = None,
670
+ ) -> TxReceipt:
671
+ return self.send(
672
+ api_keys=api_keys,
673
+ function_name="remove",
674
+ function_params=[market_address],
675
+ web3=web3,
676
+ )
@@ -1,5 +1,7 @@
1
+ import binascii
1
2
  from typing import Any, Optional, TypeVar
2
3
 
4
+ import base58
3
5
  import tenacity
4
6
  from eth_account import Account
5
7
  from eth_typing import URI
@@ -16,6 +18,7 @@ from prediction_market_agent_tooling.gtypes import (
16
18
  HexAddress,
17
19
  HexBytes,
18
20
  HexStr,
21
+ IPFSCIDVersion0,
19
22
  PrivateKey,
20
23
  xDai,
21
24
  xdai_type,
@@ -287,3 +290,22 @@ def send_xdai_to(
287
290
  web3, tx_params_new, from_private_key, timeout
288
291
  )
289
292
  return receipt_tx
293
+
294
+
295
+ def ipfscidv0_to_byte32(cid: IPFSCIDVersion0) -> HexBytes:
296
+ """
297
+ Convert ipfscidv0 to 32 bytes.
298
+ Modified from https://github.com/emg110/ipfs2bytes32/blob/main/python/ipfs2bytes32.py
299
+ """
300
+ decoded = base58.b58decode(cid)
301
+ sliced_decoded = decoded[2:]
302
+ return HexBytes(binascii.b2a_hex(sliced_decoded).decode("utf-8"))
303
+
304
+
305
+ def byte32_to_ipfscidv0(hex: HexBytes) -> IPFSCIDVersion0:
306
+ """
307
+ Convert 32 bytes hex to ipfscidv0.
308
+ Modified from https://github.com/emg110/ipfs2bytes32/blob/main/python/ipfs2bytes32.py
309
+ """
310
+ completed_binary_str = b"\x12 " + hex
311
+ return IPFSCIDVersion0(base58.b58encode(completed_binary_str).decode("utf-8"))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.37.0
3
+ Version: 0.38.0
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.12
@@ -11,6 +11,7 @@ Provides-Extra: google
11
11
  Provides-Extra: langchain
12
12
  Provides-Extra: openai
13
13
  Requires-Dist: autoflake (>=2.2.1,<3.0.0)
14
+ Requires-Dist: base58 (>=2.1.1,<3.0.0)
14
15
  Requires-Dist: cron-validator (>=1.0.8,<2.0.0)
15
16
  Requires-Dist: eth-account (>=0.8.0,<0.9.0)
16
17
  Requires-Dist: eth-typing (>=3.0.0,<4.0.0)
@@ -6,6 +6,7 @@ prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json,sha256=KBEb-COXM
6
6
  prediction_market_agent_tooling/abis/omen_kleros.abi.json,sha256=QPMXrYA5UCo_wVUqmzwCxes1bfvfzqzif3L_mJcx6j4,7315
7
7
  prediction_market_agent_tooling/abis/omen_oracle.abi.json,sha256=YPZ-FLvd4PA9pYd6d5mQI1TD11JnsE0LGxH4XcZZFCA,1775
8
8
  prediction_market_agent_tooling/abis/omen_realitio.abi.json,sha256=7HmFkBF_rq83UTaH2kRRsEfc_WZuf4n-qvkB4nhvweo,15953
9
+ prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json,sha256=u1-3B8FB3Ys9KVJCH-lw9ArkicdxbNMf34dV-VEGMMU,930
9
10
  prediction_market_agent_tooling/abis/wxdai.abi.json,sha256=m3qC06Yug-pToI0lSFe1f8e6gKMIulnV3MA2K0X51hI,6055
10
11
  prediction_market_agent_tooling/benchmark/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
12
  prediction_market_agent_tooling/benchmark/agents.py,sha256=HPIFJvackW110ch3UkktbxhU48gMRVo4gQse84Klhdc,4000
@@ -18,7 +19,7 @@ prediction_market_agent_tooling/deploy/constants.py,sha256=M5ty8URipYMGe_G-RzxRy
18
19
  prediction_market_agent_tooling/deploy/gcp/deploy.py,sha256=CYUgnfy-9XVk04kkxA_5yp0GE9Mw5caYqlFUZQ2j3ks,3739
19
20
  prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py,sha256=qYIHRxQLac3yxtZ8ChikiPG9O1aUQucHW0muTSm1nto,2627
20
21
  prediction_market_agent_tooling/deploy/gcp/utils.py,sha256=oyW0jgrUT2Tr49c7GlpcMsYNQjoCSOcWis3q-MmVAhU,6089
21
- prediction_market_agent_tooling/gtypes.py,sha256=xGSJXw12hzp8LwvQ956l01GiZMWd07MZTYqo8CXVeLY,2417
22
+ prediction_market_agent_tooling/gtypes.py,sha256=lbV2nsPyhMIRI9olx0_6A06jwTWKYBPGMxyiGVFysag,2467
22
23
  prediction_market_agent_tooling/loggers.py,sha256=ua9rynYmsbOJZjxPIFxRBooomeN08zuLSJ7lxZMDS7w,3133
23
24
  prediction_market_agent_tooling/markets/agent_market.py,sha256=SMvkXct_RgHXqF-fVq3ooTIQ_99MG77kVlvS3rM8Ozo,7019
24
25
  prediction_market_agent_tooling/markets/categorize.py,sha256=yTd-lDMPW4ESDSzmxeLLBuzLX0FggOF7Vbswh7295o0,941
@@ -32,7 +33,7 @@ prediction_market_agent_tooling/markets/markets.py,sha256=w05Oo7yCA2axpCw69Q9y4i
32
33
  prediction_market_agent_tooling/markets/omen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
34
  prediction_market_agent_tooling/markets/omen/data_models.py,sha256=EXtjmcujx68Xu50BVkYXvLuf_Asx5o65RvFS3ZS6HGs,14405
34
35
  prediction_market_agent_tooling/markets/omen/omen.py,sha256=fS19WoDG_N8WIa5FY-YRF21Np46y6d93QBJOpNKXi7Q,33939
35
- prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=eDS8vN4Klv_-Y1wwfIeLDt3twhl9U_AJjPQov0JScb0,19888
36
+ prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=-EEmN4vA8Fn52ewqQ7ZXZAFnfP4EQ4YISkeDHb9oeLk,21722
36
37
  prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=g77QsQ5WnSI2rzBlX87L_EhWMwobkyXyfRhHQmpAdzo,9012
37
38
  prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=2y89FJlDrJ_hpeNTFZU1W30xCpt8QXjssEW8bNZnEpU,23596
38
39
  prediction_market_agent_tooling/markets/polymarket/api.py,sha256=HXmA1akA0qDj0m3e-GEvWG8x75pm6BX4H7YJPQcST7I,4767
@@ -67,9 +68,9 @@ prediction_market_agent_tooling/tools/safe.py,sha256=h0xOO0eNtitClf0fPkn-0oTc6A_
67
68
  prediction_market_agent_tooling/tools/singleton.py,sha256=CiIELUiI-OeS7U7eeHEt0rnVhtQGzwoUdAgn_7u_GBM,729
68
69
  prediction_market_agent_tooling/tools/streamlit_user_login.py,sha256=NXEqfjT9Lc9QtliwSGRASIz1opjQ7Btme43H4qJbzgE,3010
69
70
  prediction_market_agent_tooling/tools/utils.py,sha256=-G22UEbCRm59bm1RWFdeF55hRsaxgwZVAHvK32-Ye1g,6190
70
- prediction_market_agent_tooling/tools/web3_utils.py,sha256=cboATXNmEdn5RmPbVblHOwOdUMKBYrUK3GiI6i6Vzxo,9855
71
- prediction_market_agent_tooling-0.37.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
72
- prediction_market_agent_tooling-0.37.0.dist-info/METADATA,sha256=CaelrPuw-JpZ4VVfKQTy8v8pdKTeWPLrqnEfhqRFHJg,7595
73
- prediction_market_agent_tooling-0.37.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
74
- prediction_market_agent_tooling-0.37.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
75
- prediction_market_agent_tooling-0.37.0.dist-info/RECORD,,
71
+ prediction_market_agent_tooling/tools/web3_utils.py,sha256=nKRHmdLnWSKd3wpo-cysXGvhhrJ2Yf69sN2FFQfSt6s,10578
72
+ prediction_market_agent_tooling-0.38.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
73
+ prediction_market_agent_tooling-0.38.0.dist-info/METADATA,sha256=BCdK9YuigO1Rdphbyjb_MfbI1HgJJkQsnH53ZAF6opg,7634
74
+ prediction_market_agent_tooling-0.38.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
75
+ prediction_market_agent_tooling-0.38.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
76
+ prediction_market_agent_tooling-0.38.0.dist-info/RECORD,,