Skip to content

Commit

Permalink
include order parameter for links
Browse files Browse the repository at this point in the history
  • Loading branch information
soad003 committed Apr 4, 2024
1 parent 3c153ab commit f9d0e70
Show file tree
Hide file tree
Showing 5 changed files with 294 additions and 6 deletions.
2 changes: 2 additions & 0 deletions gsrest/service/addresses_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ async def list_address_links(request,
neighbor,
min_height=None,
max_height=None,
order='desc',
page=None,
pagesize=None):
address = cannonicalize_address(currency, address)
Expand All @@ -120,6 +121,7 @@ async def list_address_links(request,
neighbor,
min_height=min_height,
max_height=max_height,
order=order,
page=page,
pagesize=pagesize)

Expand Down
2 changes: 2 additions & 0 deletions gsrest/service/entities_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ async def list_entity_links(request,
neighbor,
min_height=None,
max_height=None,
order='desc',
page=None,
pagesize=None):
db = request.app['db']
Expand All @@ -611,6 +612,7 @@ async def list_entity_links(request,
neighbor,
min_height=min_height,
max_height=max_height,
order=order,
page=page,
pagesize=pagesize)

Expand Down
8 changes: 5 additions & 3 deletions openapi_server/controllers/addresses_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async def get_address_entity(request: web.Request, currency, address) -> web.Res
raise web.HTTPInternalServerError()


async def list_address_links(request: web.Request, currency, address, neighbor, min_height=None, max_height=None, page=None, pagesize=None) -> web.Response:
async def list_address_links(request: web.Request, currency, address, neighbor, min_height=None, max_height=None, order=None, page=None, pagesize=None) -> web.Response:
"""Get outgoing transactions between two addresses
Expand All @@ -172,6 +172,8 @@ async def list_address_links(request: web.Request, currency, address, neighbor,
:type min_height: int
:param max_height: Return transactions up to (including) given height
:type max_height: int
:param order: Sorting order
:type order: str
:param page: Resumption token for retrieving the next page
:type page: str
:param pagesize: Number of items returned in a single page
Expand Down Expand Up @@ -200,11 +202,11 @@ async def list_address_links(request: web.Request, currency, address, neighbor,
request.app['request_config']['show_private_tags'] = show_private_tags

try:
if 'currency' in ['','currency','address','neighbor','min_height','max_height','page','pagesize']:
if 'currency' in ['','currency','address','neighbor','min_height','max_height','order','page','pagesize']:
if currency is not None:
currency = currency.lower()
result = service.list_address_links(request
,currency=currency,address=address,neighbor=neighbor,min_height=min_height,max_height=max_height,page=page,pagesize=pagesize)
,currency=currency,address=address,neighbor=neighbor,min_height=min_height,max_height=max_height,order=order,page=page,pagesize=pagesize)
result = await result

for plugin in request.app['plugins']:
Expand Down
8 changes: 5 additions & 3 deletions openapi_server/controllers/entities_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ async def list_entity_addresses(request: web.Request, currency, entity, page=Non
raise web.HTTPInternalServerError()


async def list_entity_links(request: web.Request, currency, entity, neighbor, min_height=None, max_height=None, page=None, pagesize=None) -> web.Response:
async def list_entity_links(request: web.Request, currency, entity, neighbor, min_height=None, max_height=None, order=None, page=None, pagesize=None) -> web.Response:
"""Get transactions between two entities
Expand All @@ -255,6 +255,8 @@ async def list_entity_links(request: web.Request, currency, entity, neighbor, mi
:type min_height: int
:param max_height: Return transactions up to (including) given height
:type max_height: int
:param order: Sorting order
:type order: str
:param page: Resumption token for retrieving the next page
:type page: str
:param pagesize: Number of items returned in a single page
Expand Down Expand Up @@ -283,11 +285,11 @@ async def list_entity_links(request: web.Request, currency, entity, neighbor, mi
request.app['request_config']['show_private_tags'] = show_private_tags

try:
if 'currency' in ['','currency','entity','neighbor','min_height','max_height','page','pagesize']:
if 'currency' in ['','currency','entity','neighbor','min_height','max_height','order','page','pagesize']:
if currency is not None:
currency = currency.lower()
result = service.list_entity_links(request
,currency=currency,entity=entity,neighbor=neighbor,min_height=min_height,max_height=max_height,page=page,pagesize=pagesize)
,currency=currency,entity=entity,neighbor=neighbor,min_height=min_height,max_height=max_height,order=order,page=page,pagesize=pagesize)
result = await result

for plugin in request.app['plugins']:
Expand Down
280 changes: 280 additions & 0 deletions openapi_server/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,19 @@ paths:
schema:
$ref: '#/components/schemas/height'
style: form
- description: Sorting order
example: desc
explode: true
in: query
name: order
required: false
schema:
default: desc
enum:
- asc
- desc
type: string
style: form
- description: Resumption token for retrieving the next page
explode: true
in: query
Expand Down Expand Up @@ -1046,6 +1059,19 @@ paths:
schema:
$ref: '#/components/schemas/height'
style: form
- description: Sorting order
example: desc
explode: true
in: query
name: order
required: false
schema:
default: desc
enum:
- asc
- desc
type: string
style: form
- description: Resumption token for retrieving the next page
explode: true
in: query
Expand Down Expand Up @@ -4685,6 +4711,260 @@ components:
title: search_result_level6
type: object
search_result_leaf:
example:
neighbor:
token_values:
usdt:
fiat_values:
- 0.2
- 0.3
value: 0.2
weth:
fiat_values:
- 0.2
- 0.3
value: 200000000000000
value:
fiat_values:
- code: code
value: 0.8008282
- code: code
value: 0.8008282
value: 6
entity:
total_spent:
fiat_values:
- code: code
value: 0.8008282
- code: code
value: 0.8008282
value: 6
in_degree: 0
no_addresses: 1
out_degree: 6
first_tx:
tx_hash: cb0baba9617e18c90b1014614b19e4101593c233ce5b58d91033173d2c7244fd
height: 47
timestamp: 123456789
total_tokens_received:
usdt:
fiat_values:
- 0.2
- 0.3
value: 0.2
weth:
fiat_values:
- 0.2
- 0.3
value: 200000000000000
no_address_tags: 2
root_address: addressA
actors:
- id: id
label: example
- id: id
label: example
balance:
fiat_values:
- code: code
value: 0.8008282
- code: code
value: 0.8008282
value: 6
no_incoming_txs: 5
no_outgoing_txs: 5
currency: btc
last_tx:
tx_hash: cb0baba9617e18c90b1014614b19e4101593c233ce5b58d91033173d2c7244fd
height: 47
timestamp: 123456789
entity: 123456
token_balances:
usdt:
fiat_values:
- 0.2
- 0.3
value: 0.2
weth:
fiat_values:
- 0.2
- 0.3
value: 200000000000000
total_received:
fiat_values:
- code: code
value: 0.8008282
- code: code
value: 0.8008282
value: 6
total_tokens_spent:
usdt:
fiat_values:
- 0.2
- 0.3
value: 0.2
weth:
fiat_values:
- 0.2
- 0.3
value: 200000000000000
labels:
- labels
- labels
no_txs: 11
matching_addresses:
- total_spent:
fiat_values:
- code: code
value: 0.8008282
- code: code
value: 0.8008282
value: 6
in_degree: 1
is_contract: true
address: addressA
out_degree: 5
first_tx:
tx_hash: cb0baba9617e18c90b1014614b19e4101593c233ce5b58d91033173d2c7244fd
height: 47
timestamp: 123456789
total_tokens_received:
usdt:
fiat_values:
- 0.2
- 0.3
value: 0.2
weth:
fiat_values:
- 0.2
- 0.3
value: 200000000000000
actors:
- id: id
label: example
- id: id
label: example
balance:
fiat_values:
- code: code
value: 0.8008282
- code: code
value: 0.8008282
value: 6
no_incoming_txs: 5
no_outgoing_txs: 2
currency: btc
last_tx:
tx_hash: cb0baba9617e18c90b1014614b19e4101593c233ce5b58d91033173d2c7244fd
height: 47
timestamp: 123456789
entity: 123456
token_balances:
usdt:
fiat_values:
- 0.2
- 0.3
value: 0.2
weth:
fiat_values:
- 0.2
- 0.3
value: 200000000000000
total_received:
fiat_values:
- code: code
value: 0.8008282
- code: code
value: 0.8008282
value: 6
total_tokens_spent:
usdt:
fiat_values:
- 0.2
- 0.3
value: 0.2
weth:
fiat_values:
- 0.2
- 0.3
value: 200000000000000
status: clean
- total_spent:
fiat_values:
- code: code
value: 0.8008282
- code: code
value: 0.8008282
value: 6
in_degree: 1
is_contract: true
address: addressA
out_degree: 5
first_tx:
tx_hash: cb0baba9617e18c90b1014614b19e4101593c233ce5b58d91033173d2c7244fd
height: 47
timestamp: 123456789
total_tokens_received:
usdt:
fiat_values:
- 0.2
- 0.3
value: 0.2
weth:
fiat_values:
- 0.2
- 0.3
value: 200000000000000
actors:
- id: id
label: example
- id: id
label: example
balance:
fiat_values:
- code: code
value: 0.8008282
- code: code
value: 0.8008282
value: 6
no_incoming_txs: 5
no_outgoing_txs: 2
currency: btc
last_tx:
tx_hash: cb0baba9617e18c90b1014614b19e4101593c233ce5b58d91033173d2c7244fd
height: 47
timestamp: 123456789
entity: 123456
token_balances:
usdt:
fiat_values:
- 0.2
- 0.3
value: 0.2
weth:
fiat_values:
- 0.2
- 0.3
value: 200000000000000
total_received:
fiat_values:
- code: code
value: 0.8008282
- code: code
value: 0.8008282
value: 6
total_tokens_spent:
usdt:
fiat_values:
- 0.2
- 0.3
value: 0.2
weth:
fiat_values:
- 0.2
- 0.3
value: 200000000000000
status: clean
properties:
neighbor:
$ref: '#/components/schemas/neighbor_entity'
Expand Down

0 comments on commit f9d0e70

Please sign in to comment.