Skip to content

Commit

Permalink
change types in custom transport template
Browse files Browse the repository at this point in the history
  • Loading branch information
karen-stepanyan committed Sep 22, 2023
1 parent 194f37a commit 26ccc29
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {
AdapterRequest,
AdapterResponse,
} from '@chainlink/external-adapter-framework/util'
import { TypeFromDefinition } from '@chainlink/external-adapter-framework/validation/input-params'
import { BaseEndpointTypes } from '../endpoint/<%= inputEndpointName %>'
import { BaseEndpointTypes, inputParameters } from '../endpoint/<%= inputEndpointName %>'

<% if (includeComments) { -%>
// CustomTransport extends base types from endpoint and adds additional, Provider-specific types (if needed).
Expand All @@ -23,15 +22,15 @@ export type CustomTransportTypes = BaseEndpointTypes & {
// different protocol, or you need custom functionality that built-in transports don't support. For example, custom, multistep authentication
// for requests, paginated requests, on-chain data retrieval using third party libraries, and so on.
<% } -%>
export class CustomTransport<T extends CustomTransportTypes> implements Transport<T> {
export class CustomTransport implements Transport<CustomTransportTypes> {
<% if (includeComments) { -%>
// name of the transport, used for logging
<% } -%>
name!: string
<% if (includeComments) { -%>
// cache instance for caching responses from provider
<% } -%>
responseCache!: ResponseCache<T>
responseCache!: ResponseCache<CustomTransportTypes>
<% if (includeComments) { -%>
// instance of Requester to be used for data fetching. Use this instance to perform http calls
<% } -%>
Expand All @@ -41,7 +40,7 @@ export class CustomTransport<T extends CustomTransportTypes> implements Transpor
// REQUIRED. Transport will be automatically initialized by the framework using this method. It will be called with transport
// dependencies, adapter settings, endpoint name, and transport name as arguments. Use this method to initialize transport state
<% } -%>
async initialize(dependencies: TransportDependencies<T>, _adapterSettings: CustomTransportTypes['Settings'], _endpointName: string, transportName: string): Promise<void> {
async initialize(dependencies: TransportDependencies<CustomTransportTypes>, _adapterSettings: CustomTransportTypes['Settings'], _endpointName: string, transportName: string): Promise<void> {
this.responseCache = dependencies.responseCache
this.requester = dependencies.requester
this.name = transportName
Expand All @@ -52,7 +51,7 @@ export class CustomTransport<T extends CustomTransportTypes> implements Transpor
// request, process it,save it in the cache and return to user.
<% } -%>
async foregroundExecute(
req: AdapterRequest<TypeFromDefinition<T['Parameters']>>,
req: AdapterRequest<typeof inputParameters.validated>
): Promise<AdapterResponse<CustomTransportTypes['Response']>> {

// Custom transport logic
Expand Down

0 comments on commit 26ccc29

Please sign in to comment.