From 7338a4769f2b9ab08024c9b1ad389cc238527a8e Mon Sep 17 00:00:00 2001 From: Michael Xiao Date: Mon, 13 Jan 2025 19:29:57 -0500 Subject: [PATCH] Allow custom endpoint for indexer (#3631) Co-authored-by: app-token-issuer-data-feeds[bot] <134377064+app-token-issuer-data-feeds[bot]@users.noreply.github.com> --- .changeset/fifty-insects-try.md | 5 +++++ .../composites/proof-of-reserves/src/endpoint/reserves.ts | 6 ++++++ packages/composites/proof-of-reserves/src/utils/balance.ts | 6 ++++++ 3 files changed, 17 insertions(+) create mode 100644 .changeset/fifty-insects-try.md diff --git a/.changeset/fifty-insects-try.md b/.changeset/fifty-insects-try.md new file mode 100644 index 0000000000..811702388b --- /dev/null +++ b/.changeset/fifty-insects-try.md @@ -0,0 +1,5 @@ +--- +'@chainlink/proof-of-reserves-adapter': patch +--- + +Allow custom endpoint for indexer diff --git a/packages/composites/proof-of-reserves/src/endpoint/reserves.ts b/packages/composites/proof-of-reserves/src/endpoint/reserves.ts index ad7bded361..7e1a005b59 100644 --- a/packages/composites/proof-of-reserves/src/endpoint/reserves.ts +++ b/packages/composites/proof-of-reserves/src/endpoint/reserves.ts @@ -20,6 +20,7 @@ export type TInputParameters = { protocol: string protocolEndpoint?: string indexer: string + indexerEndpoint?: string confirmations?: number addresses?: string[] disableAddressValidation?: boolean @@ -57,6 +58,10 @@ const inputParameters: InputParameters = { ...indexerAdaptersV3.map(({ name }) => name.toUpperCase()), ], }, + indexerEndpoint: { + type: 'string', + description: 'Optional endpoint for the indexer external adapter to use', + }, confirmations: { required: false, type: 'number', @@ -109,6 +114,7 @@ export const execute: ExecuteWithConfig = async (input, context, config) confirmations, config, validatedAddresses, + validator.validated.data.indexerEndpoint, ) const reduceOutput = await runReduceAdapter(indexer, context, balanceOutput) return reduceOutput diff --git a/packages/composites/proof-of-reserves/src/utils/balance.ts b/packages/composites/proof-of-reserves/src/utils/balance.ts index a4a2665b62..4c497eca8e 100644 --- a/packages/composites/proof-of-reserves/src/utils/balance.ts +++ b/packages/composites/proof-of-reserves/src/utils/balance.ts @@ -58,6 +58,7 @@ export const runBalanceAdapter = async ( confirmations: number, config: Config, input: AdapterResponse, + indexerEndpoint?: string, ): Promise => { const execute = makeRequestFactory(config, indexer) let next @@ -117,6 +118,11 @@ export const runBalanceAdapter = async ( }, } } + + if (indexerEndpoint) { + ;(next.data as any).endpoint = indexerEndpoint + } + return callAdapter(execute, context, next, '_onBalance') }