opinion-clob-sdk 0.1.3__py3-none-any.whl → 0.1.5__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 opinion-clob-sdk might be problematic. Click here for more details.
- opinion_clob_sdk/__init__.py +1 -1
- opinion_clob_sdk/opinion_clob_sdk/__init__.py +1 -1
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/__init__.py +1 -1
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/__init__.py +26 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/contract_caller.py +390 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/contracts/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/contracts/conditional_tokens.py +707 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/contracts/erc20.py +111 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/exception.py +11 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/builders/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/builders/base_builder.py +41 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/builders/exception.py +2 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/builders/order_builder.py +90 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/builders/order_builder_test.py +40 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/constants.py +2 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/model/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/model/order.py +254 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/model/order_type.py +9 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/model/sides.py +8 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/model/signatures.py +8 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/signer.py +20 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/utils.py +109 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/constants.py +19 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/eip712/__init__.py +176 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/enums.py +6 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/exceptions.py +94 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/multisend.py +347 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe.py +141 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_contracts/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_contracts/compatibility_fallback_handler_v1_3_0.py +327 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_contracts/multisend_v1_3_0.py +22 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_contracts/safe_v1_3_0.py +1035 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_contracts/utils.py +26 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_signature.py +364 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_test.py +37 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_tx.py +437 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/signatures.py +63 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/typing.py +17 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/utils.py +218 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/config.py +4 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/model.py +19 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/__init__.py +26 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/contract_caller.py +390 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/contracts/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/contracts/conditional_tokens.py +707 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/contracts/erc20.py +111 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/exception.py +11 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/builders/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/builders/base_builder.py +41 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/builders/exception.py +2 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/builders/order_builder.py +90 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/builders/order_builder_test.py +40 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/constants.py +2 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/model/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/model/order.py +254 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/model/order_type.py +9 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/model/sides.py +8 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/model/signatures.py +8 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/signer.py +20 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/py_order_utils/utils.py +109 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/constants.py +19 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/eip712/__init__.py +176 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/enums.py +6 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/exceptions.py +94 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/multisend.py +347 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe.py +141 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_contracts/__init__.py +0 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_contracts/compatibility_fallback_handler_v1_3_0.py +327 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_contracts/multisend_v1_3_0.py +22 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_contracts/safe_v1_3_0.py +1035 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_contracts/utils.py +26 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_signature.py +364 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_test.py +37 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/safe_tx.py +437 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/signatures.py +63 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/typing.py +17 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/chain/safe/utils.py +218 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/config.py +4 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/model.py +19 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/sdk.py +947 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/sdk.py +947 -0
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/sdk.py +11 -11
- opinion_clob_sdk/opinion_clob_sdk/opinion_clob_sdk/verify_api_calls.py +135 -0
- opinion_clob_sdk/opinion_clob_sdk/sdk.py +11 -11
- opinion_clob_sdk/opinion_clob_sdk/verify_api_calls.py +135 -0
- opinion_clob_sdk/sdk.py +11 -11
- opinion_clob_sdk/verify_api_calls.py +135 -0
- {opinion_clob_sdk-0.1.3.dist-info → opinion_clob_sdk-0.1.5.dist-info}/METADATA +1 -1
- opinion_clob_sdk-0.1.5.dist-info/RECORD +217 -0
- opinion_clob_sdk-0.1.3.dist-info/RECORD +0 -130
- {opinion_clob_sdk-0.1.3.dist-info → opinion_clob_sdk-0.1.5.dist-info}/WHEEL +0 -0
- {opinion_clob_sdk-0.1.3.dist-info → opinion_clob_sdk-0.1.5.dist-info}/top_level.txt +0 -0
|
@@ -159,8 +159,8 @@ class Client:
|
|
|
159
159
|
|
|
160
160
|
# for each quote token, check if the chain_id is the same as the chain_id in the contract_caller
|
|
161
161
|
for quote_token in quote_token_list:
|
|
162
|
-
quote_token_address = fast_to_checksum_address(quote_token.
|
|
163
|
-
ctf_exchange_address = fast_to_checksum_address(quote_token.
|
|
162
|
+
quote_token_address = fast_to_checksum_address(quote_token.quote_token_address)
|
|
163
|
+
ctf_exchange_address = fast_to_checksum_address(quote_token.ctf_exchange_address)
|
|
164
164
|
supported_quote_tokens[quote_token_address] = ctf_exchange_address
|
|
165
165
|
|
|
166
166
|
logging.info(f'Supported quote tokens: {supported_quote_tokens}')
|
|
@@ -194,7 +194,7 @@ class Client:
|
|
|
194
194
|
status = market_data.status
|
|
195
195
|
if not (status == TopicStatus.ACTIVATED.value or status == TopicStatus.RESOLVED.value or status == TopicStatus.RESOLVING.value):
|
|
196
196
|
raise OpenApiError('Cannot split on non-activated/resolving/resolved market')
|
|
197
|
-
collateral = fast_to_checksum_address(market_data.
|
|
197
|
+
collateral = fast_to_checksum_address(market_data.quote_token)
|
|
198
198
|
condition_id = market_data.condition_id
|
|
199
199
|
|
|
200
200
|
return self.contract_caller.split(collateral_token=collateral, condition_id=bytes.fromhex(condition_id), amount=amount)
|
|
@@ -225,7 +225,7 @@ class Client:
|
|
|
225
225
|
status = market_data.status
|
|
226
226
|
if not (status == TopicStatus.ACTIVATED.value or status == TopicStatus.RESOLVED.value or status == TopicStatus.RESOLVING.value):
|
|
227
227
|
raise OpenApiError('Cannot merge on non-activated/resolving/resolved market')
|
|
228
|
-
collateral = fast_to_checksum_address(market_data.
|
|
228
|
+
collateral = fast_to_checksum_address(market_data.quote_token)
|
|
229
229
|
condition_id = market_data.condition_id
|
|
230
230
|
|
|
231
231
|
return self.contract_caller.merge(collateral_token=collateral, condition_id=bytes.fromhex(condition_id),
|
|
@@ -254,7 +254,7 @@ class Client:
|
|
|
254
254
|
status = market_data.status
|
|
255
255
|
if not status == TopicStatus.RESOLVED.value:
|
|
256
256
|
raise OpenApiError('Cannot redeem on non-resolved market')
|
|
257
|
-
collateral = market_data.
|
|
257
|
+
collateral = market_data.quote_token
|
|
258
258
|
condition_id = market_data.condition_id
|
|
259
259
|
logging.info(f'Redeem: collateral={collateral}, condition_id={condition_id}')
|
|
260
260
|
return self.contract_caller.redeem(collateral_token=collateral, condition_id=bytes.fromhex(condition_id))
|
|
@@ -521,7 +521,7 @@ class Client:
|
|
|
521
521
|
order_exp_time='0'
|
|
522
522
|
)
|
|
523
523
|
|
|
524
|
-
result = self.market_api.openapi_order_post(apikey=self.api_key,
|
|
524
|
+
result = self.market_api.openapi_order_post(apikey=self.api_key, add_order_req=v2_add_order_req)
|
|
525
525
|
return result
|
|
526
526
|
except InvalidParamError as e:
|
|
527
527
|
logging.error(f"Validation error: {e}")
|
|
@@ -541,14 +541,14 @@ class Client:
|
|
|
541
541
|
if int(market.chain_id) != self.chain_id:
|
|
542
542
|
raise OpenApiError('Cannot place order on different chain')
|
|
543
543
|
|
|
544
|
-
quote_token_addr = market.
|
|
544
|
+
quote_token_addr = market.quote_token
|
|
545
545
|
|
|
546
|
-
# find quote token from quote_token_list by
|
|
547
|
-
quote_token = next((item for item in quote_token_list if str.lower(item.
|
|
546
|
+
# find quote token from quote_token_list by quote_token_address
|
|
547
|
+
quote_token = next((item for item in quote_token_list if str.lower(item.quote_token_address) == str.lower(quote_token_addr)), None)
|
|
548
548
|
if not quote_token:
|
|
549
549
|
raise OpenApiError('Quote token not found for this market')
|
|
550
550
|
|
|
551
|
-
exchange_addr = quote_token.
|
|
551
|
+
exchange_addr = quote_token.ctf_exchange_address
|
|
552
552
|
chain_id = quote_token.chain_id
|
|
553
553
|
|
|
554
554
|
makerAmount = 0
|
|
@@ -647,7 +647,7 @@ class Client:
|
|
|
647
647
|
|
|
648
648
|
# Internally use trans_no for API compatibility
|
|
649
649
|
request_body = OpenapiCancelOrderRequestOpenAPI(trans_no=order_id)
|
|
650
|
-
result = self.market_api.openapi_order_cancel_post(apikey=self.api_key,
|
|
650
|
+
result = self.market_api.openapi_order_cancel_post(apikey=self.api_key, cancel_order_req=request_body)
|
|
651
651
|
return result
|
|
652
652
|
|
|
653
653
|
def place_orders_batch(self, orders: List[PlaceOrderDataInput], check_approval: bool = False) -> List[Any]:
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Verification script to check all API method signatures in opinion_clob_sdk
|
|
3
|
+
This script validates that all API calls pass the correct parameters to opinion_api
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import inspect
|
|
7
|
+
from opinion_api.api.prediction_market_api import PredictionMarketApi
|
|
8
|
+
from opinion_api.api.user_api import UserApi
|
|
9
|
+
|
|
10
|
+
# Expected API calls with required parameters
|
|
11
|
+
EXPECTED_API_CALLS = {
|
|
12
|
+
# Market API calls
|
|
13
|
+
'openapi_quote_token_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
14
|
+
'openapi_market_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
15
|
+
'openapi_market_market_id_get': ['apikey', 'market_id'],
|
|
16
|
+
'openapi_market_categorical_market_id_get': ['apikey', 'market_id'],
|
|
17
|
+
'openapi_token_price_history_get': ['apikey', 'token_id', 'interval', 'start_time', 'bars'],
|
|
18
|
+
'openapi_token_orderbook_get': ['apikey', 'token_id'],
|
|
19
|
+
'openapi_token_latest_price_get': ['apikey', 'token_id'],
|
|
20
|
+
'openapi_token_fee_rates_get': ['apikey', 'token_id'],
|
|
21
|
+
'openapi_order_post': ['apikey', 'v2_add_order_req'],
|
|
22
|
+
'openapi_order_cancel_post': ['apikey', 'openapi_cancel_order_request_open_api'],
|
|
23
|
+
'openapi_order_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
24
|
+
'openapi_order_order_id_get': ['apikey', 'order_id'],
|
|
25
|
+
'openapi_positions_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
26
|
+
'openapi_user_balance_get': ['apikey', 'wallet_address', 'chain_id'], # chain_id should be str
|
|
27
|
+
'openapi_trade_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
28
|
+
|
|
29
|
+
# User API calls
|
|
30
|
+
'openapi_user_auth_get': ['apikey'],
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
def verify_api_signatures():
|
|
34
|
+
"""Verify that all API methods have the expected signatures"""
|
|
35
|
+
errors = []
|
|
36
|
+
|
|
37
|
+
# Check PredictionMarketApi methods
|
|
38
|
+
for method_name, expected_params in EXPECTED_API_CALLS.items():
|
|
39
|
+
if method_name == 'openapi_user_auth_get':
|
|
40
|
+
continue # This is in UserApi
|
|
41
|
+
|
|
42
|
+
if not hasattr(PredictionMarketApi, method_name):
|
|
43
|
+
errors.append(f"❌ Method {method_name} not found in PredictionMarketApi")
|
|
44
|
+
continue
|
|
45
|
+
|
|
46
|
+
method = getattr(PredictionMarketApi, method_name)
|
|
47
|
+
sig = inspect.signature(method)
|
|
48
|
+
params = list(sig.parameters.keys())
|
|
49
|
+
|
|
50
|
+
# Remove 'self' from params
|
|
51
|
+
if 'self' in params:
|
|
52
|
+
params.remove('self')
|
|
53
|
+
|
|
54
|
+
# Check if all expected params are in the signature
|
|
55
|
+
for expected_param in expected_params:
|
|
56
|
+
if expected_param not in params:
|
|
57
|
+
errors.append(f"❌ {method_name}: missing parameter '{expected_param}'")
|
|
58
|
+
|
|
59
|
+
# Check UserApi methods
|
|
60
|
+
if hasattr(UserApi, 'openapi_user_auth_get'):
|
|
61
|
+
method = getattr(UserApi, 'openapi_user_auth_get')
|
|
62
|
+
sig = inspect.signature(method)
|
|
63
|
+
params = list(sig.parameters.keys())
|
|
64
|
+
|
|
65
|
+
if 'self' in params:
|
|
66
|
+
params.remove('self')
|
|
67
|
+
|
|
68
|
+
if 'apikey' not in params:
|
|
69
|
+
errors.append("❌ openapi_user_auth_get: missing parameter 'apikey'")
|
|
70
|
+
else:
|
|
71
|
+
errors.append("❌ Method openapi_user_auth_get not found in UserApi")
|
|
72
|
+
|
|
73
|
+
return errors
|
|
74
|
+
|
|
75
|
+
def check_sdk_calls():
|
|
76
|
+
"""Check that SDK methods call the API with correct parameters"""
|
|
77
|
+
import re
|
|
78
|
+
|
|
79
|
+
# Read sdk.py
|
|
80
|
+
with open('/Users/nikli/Work/openapi/openapi/python_sdk/opinion_clob_sdk/sdk.py', 'r') as f:
|
|
81
|
+
sdk_content = f.read()
|
|
82
|
+
|
|
83
|
+
issues = []
|
|
84
|
+
|
|
85
|
+
# Find all API calls in SDK
|
|
86
|
+
api_call_pattern = r'self\.(market_api|user_api)\.(\w+)\((.*?)\)'
|
|
87
|
+
matches = re.finditer(api_call_pattern, sdk_content, re.MULTILINE | re.DOTALL)
|
|
88
|
+
|
|
89
|
+
for match in matches:
|
|
90
|
+
api_type = match.group(1)
|
|
91
|
+
method_name = match.group(2)
|
|
92
|
+
params_str = match.group(3)
|
|
93
|
+
|
|
94
|
+
# Check for apikey parameter
|
|
95
|
+
if 'apikey=' not in params_str:
|
|
96
|
+
issues.append(f"⚠️ {method_name}: missing apikey parameter")
|
|
97
|
+
elif 'apikey=self.api_key' not in params_str:
|
|
98
|
+
issues.append(f"⚠️ {method_name}: apikey should be self.api_key")
|
|
99
|
+
|
|
100
|
+
# Check for chain_id parameter (should be str)
|
|
101
|
+
if 'chain_id=' in params_str:
|
|
102
|
+
if 'chain_id=str(self.chain_id)' not in params_str:
|
|
103
|
+
issues.append(f"⚠️ {method_name}: chain_id should be str(self.chain_id)")
|
|
104
|
+
|
|
105
|
+
return issues
|
|
106
|
+
|
|
107
|
+
if __name__ == '__main__':
|
|
108
|
+
print("=" * 70)
|
|
109
|
+
print("Verifying API Signatures in opinion_api")
|
|
110
|
+
print("=" * 70)
|
|
111
|
+
|
|
112
|
+
errors = verify_api_signatures()
|
|
113
|
+
if errors:
|
|
114
|
+
for error in errors:
|
|
115
|
+
print(error)
|
|
116
|
+
print(f"\n❌ Found {len(errors)} signature issues")
|
|
117
|
+
else:
|
|
118
|
+
print("✅ All API signatures verified successfully")
|
|
119
|
+
|
|
120
|
+
print("\n" + "=" * 70)
|
|
121
|
+
print("Checking SDK API Calls")
|
|
122
|
+
print("=" * 70)
|
|
123
|
+
|
|
124
|
+
issues = check_sdk_calls()
|
|
125
|
+
if issues:
|
|
126
|
+
for issue in issues:
|
|
127
|
+
print(issue)
|
|
128
|
+
print(f"\n⚠️ Found {len(issues)} potential issues in SDK calls")
|
|
129
|
+
else:
|
|
130
|
+
print("✅ All SDK API calls verified successfully")
|
|
131
|
+
|
|
132
|
+
if not errors and not issues:
|
|
133
|
+
print("\n" + "=" * 70)
|
|
134
|
+
print("🎉 All verifications passed!")
|
|
135
|
+
print("=" * 70)
|
|
@@ -159,8 +159,8 @@ class Client:
|
|
|
159
159
|
|
|
160
160
|
# for each quote token, check if the chain_id is the same as the chain_id in the contract_caller
|
|
161
161
|
for quote_token in quote_token_list:
|
|
162
|
-
quote_token_address = fast_to_checksum_address(quote_token.
|
|
163
|
-
ctf_exchange_address = fast_to_checksum_address(quote_token.
|
|
162
|
+
quote_token_address = fast_to_checksum_address(quote_token.quote_token_address)
|
|
163
|
+
ctf_exchange_address = fast_to_checksum_address(quote_token.ctf_exchange_address)
|
|
164
164
|
supported_quote_tokens[quote_token_address] = ctf_exchange_address
|
|
165
165
|
|
|
166
166
|
logging.info(f'Supported quote tokens: {supported_quote_tokens}')
|
|
@@ -194,7 +194,7 @@ class Client:
|
|
|
194
194
|
status = market_data.status
|
|
195
195
|
if not (status == TopicStatus.ACTIVATED.value or status == TopicStatus.RESOLVED.value or status == TopicStatus.RESOLVING.value):
|
|
196
196
|
raise OpenApiError('Cannot split on non-activated/resolving/resolved market')
|
|
197
|
-
collateral = fast_to_checksum_address(market_data.
|
|
197
|
+
collateral = fast_to_checksum_address(market_data.quote_token)
|
|
198
198
|
condition_id = market_data.condition_id
|
|
199
199
|
|
|
200
200
|
return self.contract_caller.split(collateral_token=collateral, condition_id=bytes.fromhex(condition_id), amount=amount)
|
|
@@ -225,7 +225,7 @@ class Client:
|
|
|
225
225
|
status = market_data.status
|
|
226
226
|
if not (status == TopicStatus.ACTIVATED.value or status == TopicStatus.RESOLVED.value or status == TopicStatus.RESOLVING.value):
|
|
227
227
|
raise OpenApiError('Cannot merge on non-activated/resolving/resolved market')
|
|
228
|
-
collateral = fast_to_checksum_address(market_data.
|
|
228
|
+
collateral = fast_to_checksum_address(market_data.quote_token)
|
|
229
229
|
condition_id = market_data.condition_id
|
|
230
230
|
|
|
231
231
|
return self.contract_caller.merge(collateral_token=collateral, condition_id=bytes.fromhex(condition_id),
|
|
@@ -254,7 +254,7 @@ class Client:
|
|
|
254
254
|
status = market_data.status
|
|
255
255
|
if not status == TopicStatus.RESOLVED.value:
|
|
256
256
|
raise OpenApiError('Cannot redeem on non-resolved market')
|
|
257
|
-
collateral = market_data.
|
|
257
|
+
collateral = market_data.quote_token
|
|
258
258
|
condition_id = market_data.condition_id
|
|
259
259
|
logging.info(f'Redeem: collateral={collateral}, condition_id={condition_id}')
|
|
260
260
|
return self.contract_caller.redeem(collateral_token=collateral, condition_id=bytes.fromhex(condition_id))
|
|
@@ -521,7 +521,7 @@ class Client:
|
|
|
521
521
|
order_exp_time='0'
|
|
522
522
|
)
|
|
523
523
|
|
|
524
|
-
result = self.market_api.openapi_order_post(apikey=self.api_key,
|
|
524
|
+
result = self.market_api.openapi_order_post(apikey=self.api_key, add_order_req=v2_add_order_req)
|
|
525
525
|
return result
|
|
526
526
|
except InvalidParamError as e:
|
|
527
527
|
logging.error(f"Validation error: {e}")
|
|
@@ -541,14 +541,14 @@ class Client:
|
|
|
541
541
|
if int(market.chain_id) != self.chain_id:
|
|
542
542
|
raise OpenApiError('Cannot place order on different chain')
|
|
543
543
|
|
|
544
|
-
quote_token_addr = market.
|
|
544
|
+
quote_token_addr = market.quote_token
|
|
545
545
|
|
|
546
|
-
# find quote token from quote_token_list by
|
|
547
|
-
quote_token = next((item for item in quote_token_list if str.lower(item.
|
|
546
|
+
# find quote token from quote_token_list by quote_token_address
|
|
547
|
+
quote_token = next((item for item in quote_token_list if str.lower(item.quote_token_address) == str.lower(quote_token_addr)), None)
|
|
548
548
|
if not quote_token:
|
|
549
549
|
raise OpenApiError('Quote token not found for this market')
|
|
550
550
|
|
|
551
|
-
exchange_addr = quote_token.
|
|
551
|
+
exchange_addr = quote_token.ctf_exchange_address
|
|
552
552
|
chain_id = quote_token.chain_id
|
|
553
553
|
|
|
554
554
|
makerAmount = 0
|
|
@@ -647,7 +647,7 @@ class Client:
|
|
|
647
647
|
|
|
648
648
|
# Internally use trans_no for API compatibility
|
|
649
649
|
request_body = OpenapiCancelOrderRequestOpenAPI(trans_no=order_id)
|
|
650
|
-
result = self.market_api.openapi_order_cancel_post(apikey=self.api_key,
|
|
650
|
+
result = self.market_api.openapi_order_cancel_post(apikey=self.api_key, cancel_order_req=request_body)
|
|
651
651
|
return result
|
|
652
652
|
|
|
653
653
|
def place_orders_batch(self, orders: List[PlaceOrderDataInput], check_approval: bool = False) -> List[Any]:
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Verification script to check all API method signatures in opinion_clob_sdk
|
|
3
|
+
This script validates that all API calls pass the correct parameters to opinion_api
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import inspect
|
|
7
|
+
from opinion_api.api.prediction_market_api import PredictionMarketApi
|
|
8
|
+
from opinion_api.api.user_api import UserApi
|
|
9
|
+
|
|
10
|
+
# Expected API calls with required parameters
|
|
11
|
+
EXPECTED_API_CALLS = {
|
|
12
|
+
# Market API calls
|
|
13
|
+
'openapi_quote_token_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
14
|
+
'openapi_market_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
15
|
+
'openapi_market_market_id_get': ['apikey', 'market_id'],
|
|
16
|
+
'openapi_market_categorical_market_id_get': ['apikey', 'market_id'],
|
|
17
|
+
'openapi_token_price_history_get': ['apikey', 'token_id', 'interval', 'start_time', 'bars'],
|
|
18
|
+
'openapi_token_orderbook_get': ['apikey', 'token_id'],
|
|
19
|
+
'openapi_token_latest_price_get': ['apikey', 'token_id'],
|
|
20
|
+
'openapi_token_fee_rates_get': ['apikey', 'token_id'],
|
|
21
|
+
'openapi_order_post': ['apikey', 'v2_add_order_req'],
|
|
22
|
+
'openapi_order_cancel_post': ['apikey', 'openapi_cancel_order_request_open_api'],
|
|
23
|
+
'openapi_order_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
24
|
+
'openapi_order_order_id_get': ['apikey', 'order_id'],
|
|
25
|
+
'openapi_positions_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
26
|
+
'openapi_user_balance_get': ['apikey', 'wallet_address', 'chain_id'], # chain_id should be str
|
|
27
|
+
'openapi_trade_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
28
|
+
|
|
29
|
+
# User API calls
|
|
30
|
+
'openapi_user_auth_get': ['apikey'],
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
def verify_api_signatures():
|
|
34
|
+
"""Verify that all API methods have the expected signatures"""
|
|
35
|
+
errors = []
|
|
36
|
+
|
|
37
|
+
# Check PredictionMarketApi methods
|
|
38
|
+
for method_name, expected_params in EXPECTED_API_CALLS.items():
|
|
39
|
+
if method_name == 'openapi_user_auth_get':
|
|
40
|
+
continue # This is in UserApi
|
|
41
|
+
|
|
42
|
+
if not hasattr(PredictionMarketApi, method_name):
|
|
43
|
+
errors.append(f"❌ Method {method_name} not found in PredictionMarketApi")
|
|
44
|
+
continue
|
|
45
|
+
|
|
46
|
+
method = getattr(PredictionMarketApi, method_name)
|
|
47
|
+
sig = inspect.signature(method)
|
|
48
|
+
params = list(sig.parameters.keys())
|
|
49
|
+
|
|
50
|
+
# Remove 'self' from params
|
|
51
|
+
if 'self' in params:
|
|
52
|
+
params.remove('self')
|
|
53
|
+
|
|
54
|
+
# Check if all expected params are in the signature
|
|
55
|
+
for expected_param in expected_params:
|
|
56
|
+
if expected_param not in params:
|
|
57
|
+
errors.append(f"❌ {method_name}: missing parameter '{expected_param}'")
|
|
58
|
+
|
|
59
|
+
# Check UserApi methods
|
|
60
|
+
if hasattr(UserApi, 'openapi_user_auth_get'):
|
|
61
|
+
method = getattr(UserApi, 'openapi_user_auth_get')
|
|
62
|
+
sig = inspect.signature(method)
|
|
63
|
+
params = list(sig.parameters.keys())
|
|
64
|
+
|
|
65
|
+
if 'self' in params:
|
|
66
|
+
params.remove('self')
|
|
67
|
+
|
|
68
|
+
if 'apikey' not in params:
|
|
69
|
+
errors.append("❌ openapi_user_auth_get: missing parameter 'apikey'")
|
|
70
|
+
else:
|
|
71
|
+
errors.append("❌ Method openapi_user_auth_get not found in UserApi")
|
|
72
|
+
|
|
73
|
+
return errors
|
|
74
|
+
|
|
75
|
+
def check_sdk_calls():
|
|
76
|
+
"""Check that SDK methods call the API with correct parameters"""
|
|
77
|
+
import re
|
|
78
|
+
|
|
79
|
+
# Read sdk.py
|
|
80
|
+
with open('/Users/nikli/Work/openapi/openapi/python_sdk/opinion_clob_sdk/sdk.py', 'r') as f:
|
|
81
|
+
sdk_content = f.read()
|
|
82
|
+
|
|
83
|
+
issues = []
|
|
84
|
+
|
|
85
|
+
# Find all API calls in SDK
|
|
86
|
+
api_call_pattern = r'self\.(market_api|user_api)\.(\w+)\((.*?)\)'
|
|
87
|
+
matches = re.finditer(api_call_pattern, sdk_content, re.MULTILINE | re.DOTALL)
|
|
88
|
+
|
|
89
|
+
for match in matches:
|
|
90
|
+
api_type = match.group(1)
|
|
91
|
+
method_name = match.group(2)
|
|
92
|
+
params_str = match.group(3)
|
|
93
|
+
|
|
94
|
+
# Check for apikey parameter
|
|
95
|
+
if 'apikey=' not in params_str:
|
|
96
|
+
issues.append(f"⚠️ {method_name}: missing apikey parameter")
|
|
97
|
+
elif 'apikey=self.api_key' not in params_str:
|
|
98
|
+
issues.append(f"⚠️ {method_name}: apikey should be self.api_key")
|
|
99
|
+
|
|
100
|
+
# Check for chain_id parameter (should be str)
|
|
101
|
+
if 'chain_id=' in params_str:
|
|
102
|
+
if 'chain_id=str(self.chain_id)' not in params_str:
|
|
103
|
+
issues.append(f"⚠️ {method_name}: chain_id should be str(self.chain_id)")
|
|
104
|
+
|
|
105
|
+
return issues
|
|
106
|
+
|
|
107
|
+
if __name__ == '__main__':
|
|
108
|
+
print("=" * 70)
|
|
109
|
+
print("Verifying API Signatures in opinion_api")
|
|
110
|
+
print("=" * 70)
|
|
111
|
+
|
|
112
|
+
errors = verify_api_signatures()
|
|
113
|
+
if errors:
|
|
114
|
+
for error in errors:
|
|
115
|
+
print(error)
|
|
116
|
+
print(f"\n❌ Found {len(errors)} signature issues")
|
|
117
|
+
else:
|
|
118
|
+
print("✅ All API signatures verified successfully")
|
|
119
|
+
|
|
120
|
+
print("\n" + "=" * 70)
|
|
121
|
+
print("Checking SDK API Calls")
|
|
122
|
+
print("=" * 70)
|
|
123
|
+
|
|
124
|
+
issues = check_sdk_calls()
|
|
125
|
+
if issues:
|
|
126
|
+
for issue in issues:
|
|
127
|
+
print(issue)
|
|
128
|
+
print(f"\n⚠️ Found {len(issues)} potential issues in SDK calls")
|
|
129
|
+
else:
|
|
130
|
+
print("✅ All SDK API calls verified successfully")
|
|
131
|
+
|
|
132
|
+
if not errors and not issues:
|
|
133
|
+
print("\n" + "=" * 70)
|
|
134
|
+
print("🎉 All verifications passed!")
|
|
135
|
+
print("=" * 70)
|
opinion_clob_sdk/sdk.py
CHANGED
|
@@ -159,8 +159,8 @@ class Client:
|
|
|
159
159
|
|
|
160
160
|
# for each quote token, check if the chain_id is the same as the chain_id in the contract_caller
|
|
161
161
|
for quote_token in quote_token_list:
|
|
162
|
-
quote_token_address = fast_to_checksum_address(quote_token.
|
|
163
|
-
ctf_exchange_address = fast_to_checksum_address(quote_token.
|
|
162
|
+
quote_token_address = fast_to_checksum_address(quote_token.quote_token_address)
|
|
163
|
+
ctf_exchange_address = fast_to_checksum_address(quote_token.ctf_exchange_address)
|
|
164
164
|
supported_quote_tokens[quote_token_address] = ctf_exchange_address
|
|
165
165
|
|
|
166
166
|
logging.info(f'Supported quote tokens: {supported_quote_tokens}')
|
|
@@ -194,7 +194,7 @@ class Client:
|
|
|
194
194
|
status = market_data.status
|
|
195
195
|
if not (status == TopicStatus.ACTIVATED.value or status == TopicStatus.RESOLVED.value or status == TopicStatus.RESOLVING.value):
|
|
196
196
|
raise OpenApiError('Cannot split on non-activated/resolving/resolved market')
|
|
197
|
-
collateral = fast_to_checksum_address(market_data.
|
|
197
|
+
collateral = fast_to_checksum_address(market_data.quote_token)
|
|
198
198
|
condition_id = market_data.condition_id
|
|
199
199
|
|
|
200
200
|
return self.contract_caller.split(collateral_token=collateral, condition_id=bytes.fromhex(condition_id), amount=amount)
|
|
@@ -225,7 +225,7 @@ class Client:
|
|
|
225
225
|
status = market_data.status
|
|
226
226
|
if not (status == TopicStatus.ACTIVATED.value or status == TopicStatus.RESOLVED.value or status == TopicStatus.RESOLVING.value):
|
|
227
227
|
raise OpenApiError('Cannot merge on non-activated/resolving/resolved market')
|
|
228
|
-
collateral = fast_to_checksum_address(market_data.
|
|
228
|
+
collateral = fast_to_checksum_address(market_data.quote_token)
|
|
229
229
|
condition_id = market_data.condition_id
|
|
230
230
|
|
|
231
231
|
return self.contract_caller.merge(collateral_token=collateral, condition_id=bytes.fromhex(condition_id),
|
|
@@ -254,7 +254,7 @@ class Client:
|
|
|
254
254
|
status = market_data.status
|
|
255
255
|
if not status == TopicStatus.RESOLVED.value:
|
|
256
256
|
raise OpenApiError('Cannot redeem on non-resolved market')
|
|
257
|
-
collateral = market_data.
|
|
257
|
+
collateral = market_data.quote_token
|
|
258
258
|
condition_id = market_data.condition_id
|
|
259
259
|
logging.info(f'Redeem: collateral={collateral}, condition_id={condition_id}')
|
|
260
260
|
return self.contract_caller.redeem(collateral_token=collateral, condition_id=bytes.fromhex(condition_id))
|
|
@@ -521,7 +521,7 @@ class Client:
|
|
|
521
521
|
order_exp_time='0'
|
|
522
522
|
)
|
|
523
523
|
|
|
524
|
-
result = self.market_api.openapi_order_post(apikey=self.api_key,
|
|
524
|
+
result = self.market_api.openapi_order_post(apikey=self.api_key, add_order_req=v2_add_order_req)
|
|
525
525
|
return result
|
|
526
526
|
except InvalidParamError as e:
|
|
527
527
|
logging.error(f"Validation error: {e}")
|
|
@@ -541,14 +541,14 @@ class Client:
|
|
|
541
541
|
if int(market.chain_id) != self.chain_id:
|
|
542
542
|
raise OpenApiError('Cannot place order on different chain')
|
|
543
543
|
|
|
544
|
-
quote_token_addr = market.
|
|
544
|
+
quote_token_addr = market.quote_token
|
|
545
545
|
|
|
546
|
-
# find quote token from quote_token_list by
|
|
547
|
-
quote_token = next((item for item in quote_token_list if str.lower(item.
|
|
546
|
+
# find quote token from quote_token_list by quote_token_address
|
|
547
|
+
quote_token = next((item for item in quote_token_list if str.lower(item.quote_token_address) == str.lower(quote_token_addr)), None)
|
|
548
548
|
if not quote_token:
|
|
549
549
|
raise OpenApiError('Quote token not found for this market')
|
|
550
550
|
|
|
551
|
-
exchange_addr = quote_token.
|
|
551
|
+
exchange_addr = quote_token.ctf_exchange_address
|
|
552
552
|
chain_id = quote_token.chain_id
|
|
553
553
|
|
|
554
554
|
makerAmount = 0
|
|
@@ -647,7 +647,7 @@ class Client:
|
|
|
647
647
|
|
|
648
648
|
# Internally use trans_no for API compatibility
|
|
649
649
|
request_body = OpenapiCancelOrderRequestOpenAPI(trans_no=order_id)
|
|
650
|
-
result = self.market_api.openapi_order_cancel_post(apikey=self.api_key,
|
|
650
|
+
result = self.market_api.openapi_order_cancel_post(apikey=self.api_key, cancel_order_req=request_body)
|
|
651
651
|
return result
|
|
652
652
|
|
|
653
653
|
def place_orders_batch(self, orders: List[PlaceOrderDataInput], check_approval: bool = False) -> List[Any]:
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Verification script to check all API method signatures in opinion_clob_sdk
|
|
3
|
+
This script validates that all API calls pass the correct parameters to opinion_api
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import inspect
|
|
7
|
+
from opinion_api.api.prediction_market_api import PredictionMarketApi
|
|
8
|
+
from opinion_api.api.user_api import UserApi
|
|
9
|
+
|
|
10
|
+
# Expected API calls with required parameters
|
|
11
|
+
EXPECTED_API_CALLS = {
|
|
12
|
+
# Market API calls
|
|
13
|
+
'openapi_quote_token_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
14
|
+
'openapi_market_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
15
|
+
'openapi_market_market_id_get': ['apikey', 'market_id'],
|
|
16
|
+
'openapi_market_categorical_market_id_get': ['apikey', 'market_id'],
|
|
17
|
+
'openapi_token_price_history_get': ['apikey', 'token_id', 'interval', 'start_time', 'bars'],
|
|
18
|
+
'openapi_token_orderbook_get': ['apikey', 'token_id'],
|
|
19
|
+
'openapi_token_latest_price_get': ['apikey', 'token_id'],
|
|
20
|
+
'openapi_token_fee_rates_get': ['apikey', 'token_id'],
|
|
21
|
+
'openapi_order_post': ['apikey', 'v2_add_order_req'],
|
|
22
|
+
'openapi_order_cancel_post': ['apikey', 'openapi_cancel_order_request_open_api'],
|
|
23
|
+
'openapi_order_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
24
|
+
'openapi_order_order_id_get': ['apikey', 'order_id'],
|
|
25
|
+
'openapi_positions_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
26
|
+
'openapi_user_balance_get': ['apikey', 'wallet_address', 'chain_id'], # chain_id should be str
|
|
27
|
+
'openapi_trade_get': ['apikey', 'chain_id'], # chain_id should be str
|
|
28
|
+
|
|
29
|
+
# User API calls
|
|
30
|
+
'openapi_user_auth_get': ['apikey'],
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
def verify_api_signatures():
|
|
34
|
+
"""Verify that all API methods have the expected signatures"""
|
|
35
|
+
errors = []
|
|
36
|
+
|
|
37
|
+
# Check PredictionMarketApi methods
|
|
38
|
+
for method_name, expected_params in EXPECTED_API_CALLS.items():
|
|
39
|
+
if method_name == 'openapi_user_auth_get':
|
|
40
|
+
continue # This is in UserApi
|
|
41
|
+
|
|
42
|
+
if not hasattr(PredictionMarketApi, method_name):
|
|
43
|
+
errors.append(f"❌ Method {method_name} not found in PredictionMarketApi")
|
|
44
|
+
continue
|
|
45
|
+
|
|
46
|
+
method = getattr(PredictionMarketApi, method_name)
|
|
47
|
+
sig = inspect.signature(method)
|
|
48
|
+
params = list(sig.parameters.keys())
|
|
49
|
+
|
|
50
|
+
# Remove 'self' from params
|
|
51
|
+
if 'self' in params:
|
|
52
|
+
params.remove('self')
|
|
53
|
+
|
|
54
|
+
# Check if all expected params are in the signature
|
|
55
|
+
for expected_param in expected_params:
|
|
56
|
+
if expected_param not in params:
|
|
57
|
+
errors.append(f"❌ {method_name}: missing parameter '{expected_param}'")
|
|
58
|
+
|
|
59
|
+
# Check UserApi methods
|
|
60
|
+
if hasattr(UserApi, 'openapi_user_auth_get'):
|
|
61
|
+
method = getattr(UserApi, 'openapi_user_auth_get')
|
|
62
|
+
sig = inspect.signature(method)
|
|
63
|
+
params = list(sig.parameters.keys())
|
|
64
|
+
|
|
65
|
+
if 'self' in params:
|
|
66
|
+
params.remove('self')
|
|
67
|
+
|
|
68
|
+
if 'apikey' not in params:
|
|
69
|
+
errors.append("❌ openapi_user_auth_get: missing parameter 'apikey'")
|
|
70
|
+
else:
|
|
71
|
+
errors.append("❌ Method openapi_user_auth_get not found in UserApi")
|
|
72
|
+
|
|
73
|
+
return errors
|
|
74
|
+
|
|
75
|
+
def check_sdk_calls():
|
|
76
|
+
"""Check that SDK methods call the API with correct parameters"""
|
|
77
|
+
import re
|
|
78
|
+
|
|
79
|
+
# Read sdk.py
|
|
80
|
+
with open('/Users/nikli/Work/openapi/openapi/python_sdk/opinion_clob_sdk/sdk.py', 'r') as f:
|
|
81
|
+
sdk_content = f.read()
|
|
82
|
+
|
|
83
|
+
issues = []
|
|
84
|
+
|
|
85
|
+
# Find all API calls in SDK
|
|
86
|
+
api_call_pattern = r'self\.(market_api|user_api)\.(\w+)\((.*?)\)'
|
|
87
|
+
matches = re.finditer(api_call_pattern, sdk_content, re.MULTILINE | re.DOTALL)
|
|
88
|
+
|
|
89
|
+
for match in matches:
|
|
90
|
+
api_type = match.group(1)
|
|
91
|
+
method_name = match.group(2)
|
|
92
|
+
params_str = match.group(3)
|
|
93
|
+
|
|
94
|
+
# Check for apikey parameter
|
|
95
|
+
if 'apikey=' not in params_str:
|
|
96
|
+
issues.append(f"⚠️ {method_name}: missing apikey parameter")
|
|
97
|
+
elif 'apikey=self.api_key' not in params_str:
|
|
98
|
+
issues.append(f"⚠️ {method_name}: apikey should be self.api_key")
|
|
99
|
+
|
|
100
|
+
# Check for chain_id parameter (should be str)
|
|
101
|
+
if 'chain_id=' in params_str:
|
|
102
|
+
if 'chain_id=str(self.chain_id)' not in params_str:
|
|
103
|
+
issues.append(f"⚠️ {method_name}: chain_id should be str(self.chain_id)")
|
|
104
|
+
|
|
105
|
+
return issues
|
|
106
|
+
|
|
107
|
+
if __name__ == '__main__':
|
|
108
|
+
print("=" * 70)
|
|
109
|
+
print("Verifying API Signatures in opinion_api")
|
|
110
|
+
print("=" * 70)
|
|
111
|
+
|
|
112
|
+
errors = verify_api_signatures()
|
|
113
|
+
if errors:
|
|
114
|
+
for error in errors:
|
|
115
|
+
print(error)
|
|
116
|
+
print(f"\n❌ Found {len(errors)} signature issues")
|
|
117
|
+
else:
|
|
118
|
+
print("✅ All API signatures verified successfully")
|
|
119
|
+
|
|
120
|
+
print("\n" + "=" * 70)
|
|
121
|
+
print("Checking SDK API Calls")
|
|
122
|
+
print("=" * 70)
|
|
123
|
+
|
|
124
|
+
issues = check_sdk_calls()
|
|
125
|
+
if issues:
|
|
126
|
+
for issue in issues:
|
|
127
|
+
print(issue)
|
|
128
|
+
print(f"\n⚠️ Found {len(issues)} potential issues in SDK calls")
|
|
129
|
+
else:
|
|
130
|
+
print("✅ All SDK API calls verified successfully")
|
|
131
|
+
|
|
132
|
+
if not errors and not issues:
|
|
133
|
+
print("\n" + "=" * 70)
|
|
134
|
+
print("🎉 All verifications passed!")
|
|
135
|
+
print("=" * 70)
|