Skip to content

Commit

Permalink
fix getCardanoAssetUtxosBy signature
Browse files Browse the repository at this point in the history
  • Loading branch information
ecioppettini committed Dec 29, 2023
1 parent cd59a04 commit 5a1323a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import {
cdeCardanoPoolGetAddressDelegation,
cdeCardanoAssetUtxosByAddress,
} from '@paima/db';
import type { OwnedNftsResponse, GenericCdeDataUnit, TokenIdPair } from './types.js';
import type {
OwnedNftsResponse,
GenericCdeDataUnit,
TokenIdPair,
CardanoAssetUtxo,
} from './types.js';

/* Functions to retrieve CDE ID: */

Expand Down Expand Up @@ -197,7 +202,7 @@ export async function internalGetCardanoAssetUtxos(
address: string,
filterBy: string,
value: string
): Promise<{ txId: string; outputIndex: number; amount: string }[]> {
): Promise<CardanoAssetUtxo[]> {
const arg = { address, [filterBy]: value };

const results = await cdeCardanoAssetUtxosByAddress.run(arg, readonlyDBConn);
Expand Down
11 changes: 8 additions & 3 deletions packages/node-sdk/paima-utils-backend/src/cde-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ import {
internalGetCardanoAddressDelegation,
internalGetCardanoAssetUtxos,
} from './cde-access-internals.js';
import type { OwnedNftsResponse, GenericCdeDataUnit, TokenIdPair } from './types.js';
import type {
OwnedNftsResponse,
GenericCdeDataUnit,
TokenIdPair,
CardanoAssetUtxo,
} from './types.js';

/**
* Fetch the owner of the NFT from the database
Expand Down Expand Up @@ -173,7 +178,7 @@ export async function getCardanoAssetUtxosByFingerprint(
readonlyDBConn: Pool,
address: string,
cip14Fingerprint: string
): Promise<{ txId: string; outputIndex: number; amount: string }[]> {
): Promise<CardanoAssetUtxo[]> {
return await internalGetCardanoAssetUtxos(
readonlyDBConn,
address,
Expand All @@ -186,6 +191,6 @@ export async function getCardanoAssetUtxosByPolicyId(
readonlyDBConn: Pool,
address: string,
policyId: string
): Promise<{ txId: string; outputIndex: number; amount: string }[]> {
): Promise<CardanoAssetUtxo[]> {
return await internalGetCardanoAssetUtxos(readonlyDBConn, address, 'policy_id', policyId);
}
8 changes: 8 additions & 0 deletions packages/node-sdk/paima-utils-backend/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ export interface GenericCdeDataUnit {
blockHeight: number;
payload: any;
}

export interface CardanoAssetUtxo {
txId: string;
outputIndex: number;
amount: string;
policyId: string;
assetName: string;
}

0 comments on commit 5a1323a

Please sign in to comment.