Skip to content

Commit 2dddcbb

Browse files
authored
Merge pull request #20 from TransposeData/dev
refactor: rename swaps_by_token to swaps_by_contract_address
2 parents d6274e7 + 6db164d commit 2dddcbb

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

docs/token.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ The **Token Transfer Model** represents a single token transfer. The **Token Tra
137137
| ----------------------------------------------------------------------------------------------- | -------------------------------- | ------------ |
138138
| `token.swaps(occurred_after, occurred_before, order, limit)` | `GET /v0/token/swaps` | `List[Swap]` |
139139
| `token.swaps_by_account(account_address, occurred_after, occurred_before, order, limit)` | `GET /v0/token/swaps-by-account` | `List[Swap]` |
140-
| `token.swaps_by_token(token_address, direction, occurred_after, occurred_before, order, limit)` | `GET /v0/token/swaps-by-token` | `List[Swap]` |
140+
| `token.swaps_by_contract_address(token_address, direction, occurred_after, occurred_before, order, limit)` | `GET /v0/token/swaps-by-token` | `List[Swap]` |
141141
| `token.swaps_by_pair(token_one, token_two occurred_after, occurred_before, order, limit)` | `GET /v0/token/swaps-by-pair` | `List[Swap]` |
142142

143143
### Token Swap Model

tests/test_token_swaps_by_token.py renamed to tests/test_token_swaps_by_contract_address.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def test_basic():
44
try:
55
api = Transpose(api_key)
66

7-
swaps = api.token.swaps_by_token(token_address='0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
7+
swaps = api.token.swaps_by_contract_address(contract_address='0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2')
88

99
assert len(swaps) >= 1
1010

@@ -15,7 +15,7 @@ def test_cursor():
1515
try:
1616
api = Transpose(api_key)
1717

18-
swaps = api.token.swaps_by_token(token_address='0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', occurred_after='2019-01-01 00:00:00')
18+
swaps = api.token.swaps_by_contract_address(contract_address='0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', occurred_after='2019-01-01 00:00:00')
1919

2020
assert len(swaps) >= 1
2121
assert api._next != None
@@ -31,7 +31,7 @@ def test_range():
3131
try:
3232
api = Transpose(api_key)
3333

34-
swaps = api.token.swaps_by_token(token_address='0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', occurred_after='2019-01-01 00:00:00', occurred_before='2023-01-01 00:00:00')
34+
swaps = api.token.swaps_by_contract_address(contract_address='0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', occurred_after='2019-01-01 00:00:00', occurred_before='2023-01-01 00:00:00')
3535

3636
assert len(swaps) >= 1
3737
assert all(swap.from_token == '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' or swap.to_token == '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' for swap in swaps)

transpose/src/api/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,6 @@
9494
# Swap Endpoints
9595
'swaps': 'https://api.transpose.io/v0/token/swaps',
9696
'swaps_by_account': 'https://api.transpose.io/v0/token/swaps-by-account',
97-
'swaps_by_token': 'https://api.transpose.io/v0/token/swaps-by-token',
97+
'swaps_by_contract_address': 'https://api.transpose.io/v0/token/swaps-by-contract-address',
9898
'swaps_by_pair': 'https://api.transpose.io/v0/token/swaps-by-pair',
9999
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
from ..constants import TOKEN_API_ENDPOINTS
22

3-
def _swaps_by_token (token_address: str,
3+
def _swaps_by_contract_address (contract_address: str,
44
direction: str='all',
55
occurred_after: int or str='1970-01-01T00:00:00',
66
occurred_before: int or str='2050-01-01T00:00:00',
77
order: str='asc',
88
limit: int=10) -> str:
99

10-
base_url = '{}?token_address={}&direction={}&occurred_after={}&occurred_before={}&order={}&limit={}'.format(TOKEN_API_ENDPOINTS['swaps_by_token'], token_address, direction, occurred_after, occurred_before, order, limit)
10+
base_url = '{}?contract_address={}&direction={}&occurred_after={}&occurred_before={}&order={}&limit={}'.format(TOKEN_API_ENDPOINTS['swaps_by_contract_address'], contract_address, direction, occurred_after, occurred_before, order, limit)
1111

1212
return base_url

transpose/src/api/token/base.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
from ._transfers import _transfers
44
from ._swaps_by_pair import _swaps_by_pair
55
from ._tokens_by_name import _tokens_by_name
6-
from ._swaps_by_token import _swaps_by_token
76
from ._tokens_by_owner import _tokens_by_owner
87
from ._swaps_by_account import _swaps_by_account
98
from ._tokens_by_symbol import _tokens_by_symbol
109
from ._transfers_by_account import _transfers_by_account
1110
from ._tokens_by_date_created import _tokens_by_date_created
1211
from ._native_token_transfers import _native_token_transfers
12+
from ._swaps_by_contract_address import _swaps_by_contract_address
1313
from ._tokens_by_contract_address import _tokens_by_contract_address
1414
from ._owners_by_contract_address import _owners_by_contract_address
1515
from ._transfers_by_contract_address import _transfers_by_contract_address
@@ -151,16 +151,16 @@ def swaps_by_account(self,
151151
limit: int=10) -> List[Swap]:
152152
return self.super.perform_authorized_request(Swap, _swaps_by_account(account_address, occurred_after, occurred_before, order, limit))
153153

154-
# Get Swaps by Token
155-
# https://api.transpose.io/v0/token/swaps-by-token
156-
def swaps_by_token (self,
157-
token_address: str = None,
158-
direction: str = 'all',
159-
occurred_after: int or str='1970-01-01T00:00:00',
160-
occurred_before: int or str='2050-01-01T00:00:00',
161-
order: str='asc',
162-
limit: int=10) -> List[Swap]:
163-
return self.super.perform_authorized_request(Swap, _swaps_by_token(token_address, direction, occurred_after, occurred_before, order, limit))
154+
# Get Swaps by Contract Address
155+
# https://api.transpose.io/v0/token/swaps-by-contract-address
156+
def swaps_by_contract_address (self,
157+
contract_address: str = None,
158+
direction: str = 'all',
159+
occurred_after: int or str='1970-01-01T00:00:00',
160+
occurred_before: int or str='2050-01-01T00:00:00',
161+
order: str='asc',
162+
limit: int=10) -> List[Swap]:
163+
return self.super.perform_authorized_request(Swap, _swaps_by_contract_address(contract_address, direction, occurred_after, occurred_before, order, limit))
164164

165165
# Get Swaps by Pair
166166
# https://api.transpose.io/v0/token/swaps-by-pair

0 commit comments

Comments
 (0)