opinion-clob-sdk 0.2.3__tar.gz → 0.2.5__tar.gz
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 opinion-clob-sdk might be problematic. Click here for more details.
- {opinion_clob_sdk-0.2.3/opinion_clob_sdk.egg-info → opinion_clob_sdk-0.2.5}/PKG-INFO +2 -2
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/README.md +2 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/__init__.py +1 -1
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/contract_caller.py +10 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5/opinion_clob_sdk.egg-info}/PKG-INFO +2 -2
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/opinion_clob_sdk.egg-info/SOURCES.txt +1 -43
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/opinion_clob_sdk.egg-info/requires.txt +1 -1
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/setup.py +2 -2
- opinion_clob_sdk-0.2.5/tests/test_poa_middleware.py +77 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/MANIFEST.in +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/__init__.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/contracts/__init__.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/contracts/conditional_tokens.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/contracts/erc20.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/exception.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/__init__.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/builders/__init__.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/builders/base_builder.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/builders/exception.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/builders/order_builder.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/builders/order_builder_test.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/constants.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/model/__init__.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/model/order.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/model/order_type.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/model/sides.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/model/signatures.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/signer.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/utils.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/__init__.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/constants.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/eip712/__init__.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/enums.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/exceptions.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/multisend.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/safe.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/safe_contracts/__init__.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/safe_contracts/compatibility_fallback_handler_v1_3_0.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/safe_contracts/multisend_v1_3_0.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/safe_contracts/safe_v1_3_0.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/safe_contracts/utils.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/safe_signature.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/safe_test.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/safe_tx.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/signatures.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/typing.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/utils.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/config.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/model.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/opinion_clob_sdk.egg-info/dependency_links.txt +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/opinion_clob_sdk.egg-info/top_level.txt +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/sdk.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/setup.cfg +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/tests/test_integration.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/tests/test_model.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/tests/test_order_calculations.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/tests/test_precision.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/tests/test_sdk.py +0 -0
- {opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/verify_api_calls.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opinion_clob_sdk
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Opinion CLOB SDK (Tech Preview) - Python SDK for Opinion Prediction Market Central Limit Order Book API
|
|
5
5
|
Home-page: https://opinion.trade
|
|
6
6
|
Author: Opinion Labs
|
|
@@ -26,7 +26,7 @@ Requires-Dist: hexbytes>=1.2.1
|
|
|
26
26
|
Requires-Dist: web3>=7.6.1
|
|
27
27
|
Requires-Dist: eth_account>=0.13.0
|
|
28
28
|
Requires-Dist: poly_eip712_structs>=0.0.1
|
|
29
|
-
Requires-Dist: opinion_api>=0.1.
|
|
29
|
+
Requires-Dist: opinion_api>=0.1.2
|
|
30
30
|
Requires-Dist: pytest>=7.0.0
|
|
31
31
|
Dynamic: author
|
|
32
32
|
Dynamic: author-email
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
Python SDK for interacting with Opinion prediction markets via the CLOB (Central Limit Order Book) API.
|
|
6
6
|
|
|
7
|
+
**Latest Version: 0.2.5** - Fixed POA chain compatibility for BNB Chain operations
|
|
8
|
+
|
|
7
9
|
## Overview
|
|
8
10
|
|
|
9
11
|
The Opinion CLOB SDK provides a Python interface for:
|
|
@@ -8,6 +8,13 @@ from web3 import Web3
|
|
|
8
8
|
from web3.contract import Contract
|
|
9
9
|
from web3.providers import HTTPProvider
|
|
10
10
|
|
|
11
|
+
# Handle both old and new web3.py versions
|
|
12
|
+
try:
|
|
13
|
+
from web3.middleware import ExtraDataToPOAMiddleware
|
|
14
|
+
geth_poa_middleware = ExtraDataToPOAMiddleware
|
|
15
|
+
except ImportError:
|
|
16
|
+
from web3.middleware import geth_poa_middleware
|
|
17
|
+
|
|
11
18
|
from .exception import BalanceNotEnough, NoPositionsToRedeem, InsufficientGasBalance
|
|
12
19
|
from .safe.constants import NULL_HASH
|
|
13
20
|
from .safe.multisend import MultiSendTx, MultiSendOperation
|
|
@@ -40,6 +47,9 @@ class ContractCaller:
|
|
|
40
47
|
self.conditional_tokens_addr = conditional_tokens_addr
|
|
41
48
|
self.multisend_addr = multisend_addr
|
|
42
49
|
w3 = Web3(HTTPProvider(rpc_url))
|
|
50
|
+
# Inject POA middleware to handle BNB Chain (BSC) which is a Proof of Authority chain
|
|
51
|
+
# BNB Chain includes extra validator data in block headers (280 bytes instead of 32)
|
|
52
|
+
w3.middleware_onion.inject(geth_poa_middleware, layer=0)
|
|
43
53
|
self.w3 = w3
|
|
44
54
|
self.safe = Safe(w3, private_key, multi_sig_addr, multisend_addr)
|
|
45
55
|
self.__enable_trading_check_interval: int = enable_trading_check_interval
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: opinion_clob_sdk
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.5
|
|
4
4
|
Summary: Opinion CLOB SDK (Tech Preview) - Python SDK for Opinion Prediction Market Central Limit Order Book API
|
|
5
5
|
Home-page: https://opinion.trade
|
|
6
6
|
Author: Opinion Labs
|
|
@@ -26,7 +26,7 @@ Requires-Dist: hexbytes>=1.2.1
|
|
|
26
26
|
Requires-Dist: web3>=7.6.1
|
|
27
27
|
Requires-Dist: eth_account>=0.13.0
|
|
28
28
|
Requires-Dist: poly_eip712_structs>=0.0.1
|
|
29
|
-
Requires-Dist: opinion_api>=0.1.
|
|
29
|
+
Requires-Dist: opinion_api>=0.1.2
|
|
30
30
|
Requires-Dist: pytest>=7.0.0
|
|
31
31
|
Dynamic: author
|
|
32
32
|
Dynamic: author-email
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
MANIFEST.in
|
|
2
2
|
README.md
|
|
3
|
-
__init__.py
|
|
4
|
-
config.py
|
|
5
|
-
model.py
|
|
6
|
-
sdk.py
|
|
7
3
|
setup.py
|
|
8
|
-
verify_api_calls.py
|
|
9
4
|
./__init__.py
|
|
10
5
|
./config.py
|
|
11
6
|
./model.py
|
|
@@ -49,44 +44,6 @@ verify_api_calls.py
|
|
|
49
44
|
./chain/safe/safe_contracts/multisend_v1_3_0.py
|
|
50
45
|
./chain/safe/safe_contracts/safe_v1_3_0.py
|
|
51
46
|
./chain/safe/safe_contracts/utils.py
|
|
52
|
-
chain/__init__.py
|
|
53
|
-
chain/contract_caller.py
|
|
54
|
-
chain/exception.py
|
|
55
|
-
chain/contracts/__init__.py
|
|
56
|
-
chain/contracts/conditional_tokens.py
|
|
57
|
-
chain/contracts/erc20.py
|
|
58
|
-
chain/py_order_utils/__init__.py
|
|
59
|
-
chain/py_order_utils/constants.py
|
|
60
|
-
chain/py_order_utils/signer.py
|
|
61
|
-
chain/py_order_utils/utils.py
|
|
62
|
-
chain/py_order_utils/builders/__init__.py
|
|
63
|
-
chain/py_order_utils/builders/base_builder.py
|
|
64
|
-
chain/py_order_utils/builders/exception.py
|
|
65
|
-
chain/py_order_utils/builders/order_builder.py
|
|
66
|
-
chain/py_order_utils/builders/order_builder_test.py
|
|
67
|
-
chain/py_order_utils/model/__init__.py
|
|
68
|
-
chain/py_order_utils/model/order.py
|
|
69
|
-
chain/py_order_utils/model/order_type.py
|
|
70
|
-
chain/py_order_utils/model/sides.py
|
|
71
|
-
chain/py_order_utils/model/signatures.py
|
|
72
|
-
chain/safe/__init__.py
|
|
73
|
-
chain/safe/constants.py
|
|
74
|
-
chain/safe/enums.py
|
|
75
|
-
chain/safe/exceptions.py
|
|
76
|
-
chain/safe/multisend.py
|
|
77
|
-
chain/safe/safe.py
|
|
78
|
-
chain/safe/safe_signature.py
|
|
79
|
-
chain/safe/safe_test.py
|
|
80
|
-
chain/safe/safe_tx.py
|
|
81
|
-
chain/safe/signatures.py
|
|
82
|
-
chain/safe/typing.py
|
|
83
|
-
chain/safe/utils.py
|
|
84
|
-
chain/safe/eip712/__init__.py
|
|
85
|
-
chain/safe/safe_contracts/__init__.py
|
|
86
|
-
chain/safe/safe_contracts/compatibility_fallback_handler_v1_3_0.py
|
|
87
|
-
chain/safe/safe_contracts/multisend_v1_3_0.py
|
|
88
|
-
chain/safe/safe_contracts/safe_v1_3_0.py
|
|
89
|
-
chain/safe/safe_contracts/utils.py
|
|
90
47
|
opinion_clob_sdk.egg-info/PKG-INFO
|
|
91
48
|
opinion_clob_sdk.egg-info/SOURCES.txt
|
|
92
49
|
opinion_clob_sdk.egg-info/dependency_links.txt
|
|
@@ -95,5 +52,6 @@ opinion_clob_sdk.egg-info/top_level.txt
|
|
|
95
52
|
tests/test_integration.py
|
|
96
53
|
tests/test_model.py
|
|
97
54
|
tests/test_order_calculations.py
|
|
55
|
+
tests/test_poa_middleware.py
|
|
98
56
|
tests/test_precision.py
|
|
99
57
|
tests/test_sdk.py
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from setuptools import setup, find_packages
|
|
2
2
|
|
|
3
3
|
NAME = "opinion_clob_sdk"
|
|
4
|
-
VERSION = "0.2.
|
|
4
|
+
VERSION = "0.2.5"
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name=NAME,
|
|
@@ -79,7 +79,7 @@ result = client.place_order(order_data)
|
|
|
79
79
|
"web3 >= 7.6.1",
|
|
80
80
|
"eth_account >= 0.13.0",
|
|
81
81
|
"poly_eip712_structs >= 0.0.1",
|
|
82
|
-
"opinion_api >= 0.1.
|
|
82
|
+
"opinion_api >= 0.1.2",
|
|
83
83
|
"pytest >= 7.0.0",
|
|
84
84
|
],
|
|
85
85
|
packages=[
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test POA middleware integration for BNB Chain compatibility
|
|
3
|
+
|
|
4
|
+
This test verifies that the POA middleware is properly injected to handle
|
|
5
|
+
BNB Chain's extra block header data (280 bytes instead of 32).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import pytest
|
|
9
|
+
from unittest.mock import Mock, patch
|
|
10
|
+
from web3 import Web3
|
|
11
|
+
|
|
12
|
+
# Handle both old and new web3.py versions
|
|
13
|
+
try:
|
|
14
|
+
from web3.middleware import ExtraDataToPOAMiddleware
|
|
15
|
+
geth_poa_middleware = ExtraDataToPOAMiddleware
|
|
16
|
+
except ImportError:
|
|
17
|
+
from web3.middleware import geth_poa_middleware
|
|
18
|
+
|
|
19
|
+
from eth_typing import HexStr, ChecksumAddress
|
|
20
|
+
|
|
21
|
+
from opinion_clob_sdk.chain.contract_caller import ContractCaller
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class TestPOAMiddleware:
|
|
25
|
+
"""Test POA middleware is properly configured for BNB Chain"""
|
|
26
|
+
|
|
27
|
+
def test_poa_middleware_injected_on_init(self):
|
|
28
|
+
"""Test that POA middleware is injected during ContractCaller initialization"""
|
|
29
|
+
|
|
30
|
+
# Mock Web3 instance
|
|
31
|
+
mock_w3 = Mock(spec=Web3)
|
|
32
|
+
mock_middleware_onion = Mock()
|
|
33
|
+
mock_w3.middleware_onion = mock_middleware_onion
|
|
34
|
+
|
|
35
|
+
with patch('opinion_clob_sdk.chain.contract_caller.Web3') as MockWeb3, \
|
|
36
|
+
patch('opinion_clob_sdk.chain.contract_caller.Safe'):
|
|
37
|
+
|
|
38
|
+
MockWeb3.return_value = mock_w3
|
|
39
|
+
|
|
40
|
+
# Initialize ContractCaller
|
|
41
|
+
caller = ContractCaller(
|
|
42
|
+
rpc_url='https://bsc-dataseed.binance.org',
|
|
43
|
+
private_key=HexStr('0x' + '1' * 64),
|
|
44
|
+
multi_sig_addr=ChecksumAddress('0x' + '1' * 40),
|
|
45
|
+
conditional_tokens_addr=ChecksumAddress('0x' + '2' * 40),
|
|
46
|
+
multisend_addr=ChecksumAddress('0x' + '3' * 40)
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
# Verify POA middleware was injected at layer 0
|
|
50
|
+
mock_middleware_onion.inject.assert_called()
|
|
51
|
+
call_args = mock_middleware_onion.inject.call_args_list
|
|
52
|
+
|
|
53
|
+
# Check that geth_poa_middleware was injected
|
|
54
|
+
poa_injected = False
|
|
55
|
+
for call in call_args:
|
|
56
|
+
args, kwargs = call
|
|
57
|
+
if len(args) > 0 and (args[0] == geth_poa_middleware or
|
|
58
|
+
args[0].__name__ == geth_poa_middleware.__name__):
|
|
59
|
+
poa_injected = True
|
|
60
|
+
assert kwargs.get('layer') == 0, "POA middleware should be injected at layer 0"
|
|
61
|
+
break
|
|
62
|
+
|
|
63
|
+
assert poa_injected, "POA middleware should be injected"
|
|
64
|
+
|
|
65
|
+
def test_poa_middleware_import(self):
|
|
66
|
+
"""Test that POA middleware can be imported correctly"""
|
|
67
|
+
# This verifies the import fallback works
|
|
68
|
+
from opinion_clob_sdk.chain import contract_caller
|
|
69
|
+
|
|
70
|
+
# Should have geth_poa_middleware defined
|
|
71
|
+
assert hasattr(contract_caller, 'geth_poa_middleware')
|
|
72
|
+
assert contract_caller.geth_poa_middleware is not None
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
if __name__ == '__main__':
|
|
76
|
+
pytest.main([__file__, '-v'])
|
|
77
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/builders/base_builder.py
RENAMED
|
File without changes
|
{opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/builders/exception.py
RENAMED
|
File without changes
|
{opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/py_order_utils/builders/order_builder.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/chain/safe/safe_contracts/multisend_v1_3_0.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opinion_clob_sdk-0.2.3 → opinion_clob_sdk-0.2.5}/opinion_clob_sdk.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|