Skip to content

Commit

Permalink
feat: add search by delegation id (#1176)
Browse files Browse the repository at this point in the history
Co-authored-by: Begoña Álvarez de la Cruz <[email protected]>
  • Loading branch information
brancoder and begonaalvarezd authored Feb 26, 2024
1 parent a03f72a commit ae55f70
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
19 changes: 19 additions & 0 deletions api/src/services/nova/novaApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,25 @@ export class NovaApiService {
}
}

/**
* Get the delegation output details.
* @param delegationId The delegationId to get the output details for.
* @returns The delegation output details.
*/
public async delegationDetails(delegationId: string): Promise<IOutputDetailsResponse | undefined> {
try {
const delegationOutputId = await this.client.delegationOutputId(delegationId);

if (delegationOutputId) {
const outputResponse = await this.outputDetails(delegationOutputId);

return outputResponse.error ? { error: outputResponse.error } : { output: outputResponse.output };
}
} catch {
return { message: "Delegation output not found" };
}
}

/**
* Get controlled Foundry output id by controller Account address
* @param accountAddress The bech32 account address to get the controlled Foundries for.
Expand Down
15 changes: 15 additions & 0 deletions api/src/utils/nova/searchExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ export class SearchExecutor {
);
}

if (searchQuery.delegationId) {
promises.push(
this.executeQuery(
this.apiService.delegationDetails(searchQuery.delegationId),
(response) => {
promisesResult = {
output: response.output,
error: response.error || response.message,
};
},
"Delegation id fetch failed",
),
);
}

if (searchQuery.transactionId) {
promises.push(
this.executeQuery(
Expand Down

0 comments on commit ae55f70

Please sign in to comment.