Skip to content

Commit

Permalink
add missing endpoint level docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Mar 4, 2024
1 parent 346c48c commit 44a1510
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
9 changes: 6 additions & 3 deletions docs/bin/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@
"type": "string"
},
"amount": {
"type": "string"
"type": "string",
"description": "If the utxo is created, this has the amount. It's undefined if the utxo\nis spent."
}
},
"required": [
Expand All @@ -209,8 +210,7 @@
],
"type": "object"
},
"type": "array",
"description": "If the utxo is created, this has the amount. It's undefined if the utxo\nis spent."
"type": "array"
}
},
"required": [
Expand Down Expand Up @@ -1362,6 +1362,7 @@
}
}
},
"description": "Returns utxo entries filtered either by cip 14 fingerprint or by policy id.\n\nThis is useful to keep track of the utxo set of a particular asset.",
"security": [],
"parameters": [],
"requestBody": {
Expand Down Expand Up @@ -1521,6 +1522,7 @@
}
}
},
"description": "Returns the pool of the last delegation for this address.\n\nNote: the tx can be in the current epoch, so the delegation may not be in\neffect yet.",
"security": [],
"parameters": [],
"requestBody": {
Expand Down Expand Up @@ -1580,6 +1582,7 @@
}
}
},
"description": "Returns the list of delegations for the provided pools. The pool field in\nthe response will be null when the address was previously delegating to a\npool in the input, but now the delegation is moved to a pool outside the\nlist, or when the staking key is unregistered.\n\nThis is useful to keep track of the delegators for a particular pool.",
"security": [],
"parameters": [],
"requestBody": {
Expand Down
20 changes: 17 additions & 3 deletions webserver/server/app/controllers/AssetUtxosController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,23 @@ import type { IAssetUtxosResult } from '../models/asset/assetUtxos.queries';
import { bech32 } from 'bech32';
import { ASSET_UTXOS_LIMIT } from '../../../shared/constants';
import { Address } from '@dcspark/cardano-multiplatform-lib-nodejs';
import { adjustToSlotLimits, resolvePageStart, resolveUntilTransaction } from '../services/PaginationService';
import {
adjustToSlotLimits,
resolvePageStart,
resolveUntilTransaction,
} from '../services/PaginationService';
import { slotBoundsPagination } from '../models/pagination/slotBoundsPagination.queries';
import { expectType } from 'tsd';

const route = Routes.assetUtxos;

@Route('asset/utxos')
export class AssetUtxosController extends Controller {
/**
* Returns utxo entries filtered either by cip 14 fingerprint or by policy id.
*
* This is useful to keep track of the utxo set of a particular asset.
*/
@SuccessResponse(`${StatusCodes.OK}`)
@Post()
public async assetUtxos(
Expand Down Expand Up @@ -76,7 +85,12 @@ export class AssetUtxosController extends Controller {
});
}

const pageStartWithSlot = adjustToSlotLimits(pageStart, until, requestBody.slotLimits, slotBounds);
const pageStartWithSlot = adjustToSlotLimits(
pageStart,
until,
requestBody.slotLimits,
slotBounds
);

const data = await getAssetUtxos({
after: pageStartWithSlot?.tx_id || 0,
Expand Down Expand Up @@ -135,4 +149,4 @@ export class AssetUtxosController extends Controller {

return response;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const route = Routes.delegationForAddress;

@Route('delegation/address')
export class DelegationForAddressController extends Controller {
/**
* Returns the pool of the last delegation for this address.
*
* Note: the tx can be in the current epoch, so the delegation may not be in
* effect yet.
*/
@SuccessResponse(`${StatusCodes.OK}`)
@Post()
public async delegationForAddress(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ const route = Routes.delegationForPool;

@Route('delegation/pool')
export class DelegationForPoolController extends Controller {
/**
* Returns the list of delegations for the provided pools. The pool field in
* the response will be null when the address was previously delegating to a
* pool in the input, but now the delegation is moved to a pool outside the
* list, or when the staking key is unregistered.
*
* This is useful to keep track of the delegators for a particular pool.
*/
@SuccessResponse(`${StatusCodes.OK}`)
@Post()
public async delegationForPool(
Expand Down
12 changes: 6 additions & 6 deletions webserver/shared/models/AssetUtxos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ export type AssetUtxosRequest = {
} & Pagination;

export type AssetUtxosResponse = {
/**
* If the utxo is created, this has the amount. It's undefined if the utxo
* is spent.
*
* @example '1031423725351'
*/
payload: {
/**
* If the utxo is created, this has the amount. It's undefined if the utxo
* is spent.
*
* @example '1031423725351'
*/
amount: string | undefined;
cip14Fingerprint: string;
policyId: string;
Expand Down

0 comments on commit 44a1510

Please sign in to comment.