Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add search by delegation id #1176

Merged
merged 5 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading