From 05e0ccd0d4470d885682a3443fe5daaa995cf86d Mon Sep 17 00:00:00 2001 From: Alfonso Bribiesca Date: Wed, 4 Mar 2026 12:14:51 -0600 Subject: [PATCH 1/2] feat: add wallet token endpoints --- client/api/wallets.py | 15 ++++++++ tests/api/test_wallets.py | 72 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) diff --git a/client/api/wallets.py b/client/api/wallets.py index 81ecf02..b72fba3 100644 --- a/client/api/wallets.py +++ b/client/api/wallets.py @@ -49,3 +49,18 @@ def votes(self, wallet_id, page=None, limit=100): 'limit': limit, } return self.with_endpoint('api').request_get(f'wallets/{wallet_id}/votes', params) + + def tokens(self, wallet_id, page=None, limit=100): + params = { + 'page': page, + 'limit': limit, + } + return self.with_endpoint('api').request_get(f'wallets/{wallet_id}/tokens', params) + + def token_addresses(self, addresses, page=None, limit=100): + params = { + 'addresses': addresses, + 'page': page, + 'limit': limit, + } + return self.with_endpoint('api').request_get('wallets/tokens', params) diff --git a/tests/api/test_wallets.py b/tests/api/test_wallets.py index ca164ec..8ee82fe 100644 --- a/tests/api/test_wallets.py +++ b/tests/api/test_wallets.py @@ -240,3 +240,75 @@ def test_votes_calls_correct_url_with_passed_in_params(): ) assert 'page=5' in responses.calls[0].request.url assert 'limit=69' in responses.calls[0].request.url + + +def test_tokens_calls_correct_url_with_default_params(): + wallet_id = '12345' + responses.add( + responses.GET, + 'http://127.0.0.1:4002/api/wallets/{}/tokens'.format(wallet_id), + json={'success': True}, + status=200 + ) + + client = ArkClient('http://127.0.0.1:4002/api') + client.wallets.tokens(wallet_id) + assert len(responses.calls) == 1 + assert responses.calls[0].request.url == ( + 'http://127.0.0.1:4002/api/wallets/12345/tokens?limit=100' + ) + + +def test_tokens_calls_correct_url_with_passed_in_params(): + wallet_id = '12345' + responses.add( + responses.GET, + 'http://127.0.0.1:4002/api/wallets/{}/tokens'.format(wallet_id), + json={'success': True}, + status=200 + ) + + client = ArkClient('http://127.0.0.1:4002/api') + client.wallets.tokens(wallet_id, page=5, limit=69) + assert len(responses.calls) == 1 + assert responses.calls[0].request.url.startswith( + 'http://127.0.0.1:4002/api/wallets/12345/tokens?' + ) + assert 'page=5' in responses.calls[0].request.url + assert 'limit=69' in responses.calls[0].request.url + + +def test_token_addresses_calls_correct_url_with_default_params(): + responses.add( + responses.GET, + 'http://127.0.0.1:4002/api/wallets/tokens', + json={'success': True}, + status=200 + ) + + client = ArkClient('http://127.0.0.1:4002/api') + client.wallets.token_addresses('0xabc,0xdef') + assert len(responses.calls) == 1 + assert responses.calls[0].request.url.startswith( + 'http://127.0.0.1:4002/api/wallets/tokens?' + ) + assert 'addresses=0xabc%2C0xdef' in responses.calls[0].request.url + assert 'limit=100' in responses.calls[0].request.url + + +def test_token_addresses_calls_correct_url_with_passed_in_params(): + responses.add( + responses.GET, + 'http://127.0.0.1:4002/api/wallets/tokens', + json={'success': True}, + status=200 + ) + + client = ArkClient('http://127.0.0.1:4002/api') + client.wallets.token_addresses('0xabc,0xdef', page=2, limit=50) + assert len(responses.calls) == 1 + assert responses.calls[0].request.url.startswith( + 'http://127.0.0.1:4002/api/wallets/tokens?' + ) + assert 'page=2' in responses.calls[0].request.url + assert 'limit=50' in responses.calls[0].request.url From 6ec965edda991fac339388f256481d96bd841497 Mon Sep 17 00:00:00 2001 From: Alfonso Bribiesca Date: Tue, 10 Mar 2026 08:46:44 -0600 Subject: [PATCH 2/2] refactor: rename token_addresses to tokens_for --- client/api/wallets.py | 2 +- tests/api/test_wallets.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/api/wallets.py b/client/api/wallets.py index b72fba3..8e83e35 100644 --- a/client/api/wallets.py +++ b/client/api/wallets.py @@ -57,7 +57,7 @@ def tokens(self, wallet_id, page=None, limit=100): } return self.with_endpoint('api').request_get(f'wallets/{wallet_id}/tokens', params) - def token_addresses(self, addresses, page=None, limit=100): + def tokens_for(self, addresses, page=None, limit=100): params = { 'addresses': addresses, 'page': page, diff --git a/tests/api/test_wallets.py b/tests/api/test_wallets.py index 8ee82fe..f3e5b2e 100644 --- a/tests/api/test_wallets.py +++ b/tests/api/test_wallets.py @@ -278,7 +278,7 @@ def test_tokens_calls_correct_url_with_passed_in_params(): assert 'limit=69' in responses.calls[0].request.url -def test_token_addresses_calls_correct_url_with_default_params(): +def test_tokens_for_calls_correct_url_with_default_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/wallets/tokens', @@ -287,7 +287,7 @@ def test_token_addresses_calls_correct_url_with_default_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.wallets.token_addresses('0xabc,0xdef') + client.wallets.tokens_for('0xabc,0xdef') assert len(responses.calls) == 1 assert responses.calls[0].request.url.startswith( 'http://127.0.0.1:4002/api/wallets/tokens?' @@ -296,7 +296,7 @@ def test_token_addresses_calls_correct_url_with_default_params(): assert 'limit=100' in responses.calls[0].request.url -def test_token_addresses_calls_correct_url_with_passed_in_params(): +def test_tokens_for_calls_correct_url_with_passed_in_params(): responses.add( responses.GET, 'http://127.0.0.1:4002/api/wallets/tokens', @@ -305,7 +305,7 @@ def test_token_addresses_calls_correct_url_with_passed_in_params(): ) client = ArkClient('http://127.0.0.1:4002/api') - client.wallets.token_addresses('0xabc,0xdef', page=2, limit=50) + client.wallets.tokens_for('0xabc,0xdef', page=2, limit=50) assert len(responses.calls) == 1 assert responses.calls[0].request.url.startswith( 'http://127.0.0.1:4002/api/wallets/tokens?'