Skip to content

Commit

Permalink
Add indexer params to PoR (#3642)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxiao-cll authored Jan 21, 2025
1 parent 35c16f2 commit 38426f6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-starfishes-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/proof-of-reserves-adapter': patch
---

Allow additional params to indexer
1 change: 1 addition & 0 deletions packages/composites/proof-of-reserves/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ See the [Composite Adapter README](../README.md) for more information on how to
| | `protocolEndpoint` | Optional endpoint for the protocol external adapter to use | | |
|| `indexer` | The indexer external adapter to use | `ada_balance`, `amberdata`, `avalanche_platform`, `bitcoin_json_rpc`, `blockchain_com`. `blockchair`, `blockcypher`, `btc_com`, `cryptoapis`, `eth_balance`, `eth_beacon`, `lotus`, `polkadot_balance`, `por_indexer`, `sochain`, `stader_balance`, `token_balance`, `ceffu` | |
| | `indexerEndpoint` | Optional endpoint for the indexer external adapter to use | | |
| | `indexerParams` | Additional param for indexer external adapter to use | | |
| | `confirmations` | The number of confirmations required for a transaction to be counted when getting an address balance | | 6 |
| | `addresses` | An array of addresses to get the balance from, when "protocol" is set to `list` | | |
| | `disableAddressValidation` | if this parameter is set to `true` address validation will be turned off | `true`, `false` | `false` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type TInputParameters = {
protocolEndpoint?: string
indexer: string
indexerEndpoint?: string
indexerParams?: Record<string, string>
confirmations?: number
addresses?: string[]
disableAddressValidation?: boolean
Expand Down Expand Up @@ -63,6 +64,10 @@ const inputParameters: InputParameters<TInputParameters> = {
type: 'string',
description: 'Optional endpoint for the indexer external adapter to use',
},
indexerParams: {
type: 'object',
description: 'Additional param for indexer external adapter to use',
},
confirmations: {
required: false,
type: 'number',
Expand Down Expand Up @@ -121,6 +126,7 @@ export const execute: ExecuteWithConfig<Config> = async (input, context, config)
config,
validatedAddresses,
validator.validated.data.indexerEndpoint,
validator.validated.data.indexerParams,
)
const reduceOutput = await runReduceAdapter(indexer, context, balanceOutput)
reduceOutput.data.description = validator.validated.data.description
Expand Down
5 changes: 5 additions & 0 deletions packages/composites/proof-of-reserves/src/utils/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const runBalanceAdapter = async (
config: Config,
input: AdapterResponse,
indexerEndpoint?: string,
indexerParams?: Record<string, string>,
): Promise<AdapterResponse> => {
const execute = makeRequestFactory(config, indexer)
let next
Expand Down Expand Up @@ -128,6 +129,10 @@ export const runBalanceAdapter = async (
;(next.data as any).endpoint = indexerEndpoint
}

for (const [key, value] of Object.entries(indexerParams || {})) {
;(next.data as any)[key] = value
}

return callAdapter(execute, context, next, '_onBalance')
}

Expand Down

0 comments on commit 38426f6

Please sign in to comment.