From 1b5554eab5b426dfe95c1640d47042b89e27a5b6 Mon Sep 17 00:00:00 2001 From: SushantF1 Date: Mon, 23 Mar 2026 21:43:49 +0000 Subject: [PATCH] fix: add None guard for params in get_balance_allowance and update_balance_allowance --- py_clob_client/client.py | 4 ++++ tests/test_balance_allowance.py | 35 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 tests/test_balance_allowance.py diff --git a/py_clob_client/client.py b/py_clob_client/client.py index e6be3c56..559804a2 100644 --- a/py_clob_client/client.py +++ b/py_clob_client/client.py @@ -934,6 +934,8 @@ def get_balance_allowance(self, params: BalanceAllowanceParams = None): Requires Level 2 authentication """ self.assert_level_2_auth() + if params is None: + raise ValueError("params is required for get_balance_allowance") request_args = RequestArgs(method="GET", request_path=GET_BALANCE_ALLOWANCE) headers = create_level_2_headers(self.signer, self.creds, request_args) if params.signature_type == -1: @@ -949,6 +951,8 @@ def update_balance_allowance(self, params: BalanceAllowanceParams = None): Requires Level 2 authentication """ self.assert_level_2_auth() + if params is None: + raise ValueError("params is required for update_balance_allowance") request_args = RequestArgs(method="GET", request_path=UPDATE_BALANCE_ALLOWANCE) headers = create_level_2_headers(self.signer, self.creds, request_args) if params.signature_type == -1: diff --git a/tests/test_balance_allowance.py b/tests/test_balance_allowance.py new file mode 100644 index 00000000..c4a823ad --- /dev/null +++ b/tests/test_balance_allowance.py @@ -0,0 +1,35 @@ +from unittest import TestCase + +from py_clob_client.client import ClobClient +from py_clob_client.clob_types import ApiCreds +from py_clob_client.constants import AMOY + +# publicly known private key +private_key = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" +creds = ApiCreds( + api_key="test-api-key", + api_secret="test-api-secret", + api_passphrase="test-api-passphrase", +) + + +class TestBalanceAllowance(TestCase): + def test_get_balance_allowance_requires_params(self): + client = ClobClient( + "https://clob.polymarket.com", + key=private_key, + chain_id=AMOY, + creds=creds, + ) + with self.assertRaises(ValueError): + client.get_balance_allowance() + + def test_update_balance_allowance_requires_params(self): + client = ClobClient( + "https://clob.polymarket.com", + key=private_key, + chain_id=AMOY, + creds=creds, + ) + with self.assertRaises(ValueError): + client.update_balance_allowance()