Skip to content

Commit 0ddb09b

Browse files
committed
Fix compilation issues
1 parent aa3635a commit 0ddb09b

3 files changed

Lines changed: 17 additions & 42 deletions

File tree

scripts/generator-adapter/generators/app/templates/src/transport/custombg.ts.ejs

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { TransportDependencies } from '@chainlink/external-adapter-framework/transports'
22
import { calculateHttpRequestKey } from '@chainlink/external-adapter-framework/cache'
3-
import { ResponseCache } from '@chainlink/external-adapter-framework/cache/response'
43
import { Requester } from '@chainlink/external-adapter-framework/util/requester'
54
import {
65
AdapterResponse, sleep, makeLogger
@@ -20,26 +19,13 @@ type PriceResponse = {
2019
}
2120
}
2221

23-
<% if (includeComments) { -%>
24-
// <%= normalizedEndpointNameCap %>Transport extends base types from endpoint and adds additional, Provider-specific types (if needed).
25-
<% } -%>
26-
export type <%= normalizedEndpointNameCap %>TransportTypes = BaseEndpointTypes & {
27-
Provider: {
28-
RequestBody: never
29-
ResponseBody: any
30-
}
31-
}
3222
<% if (includeComments) { -%>
3323
// <%= normalizedEndpointNameCap %>Transport is used to perform custom data fetching and processing from a Provider. The framework provides built-in transports to
3424
// fetch data from a Provider using several protocols, including `http`, `websocket`, and `sse`. Use <%= normalizedEndpointNameCap %>Transport when the Provider uses
3525
// different protocol, or you need custom functionality that built-in transports don't support. For example, custom, multistep authentication
3626
// for requests, paginated requests, on-chain data retrieval using third party libraries, and so on.
3727
<% } -%>
38-
export class <%= normalizedEndpointNameCap %>Transport extends SubscriptionTransport<<%= normalizedEndpointNameCap %>TransportTypes> {
39-
<% if (includeComments) { -%>
40-
// name of the transport, used for logging
41-
<% } -%>
42-
name!: string
28+
export class <%= normalizedEndpointNameCap %>Transport extends SubscriptionTransport<BaseEndpointTypes> {
4329
<% if (includeComments) { -%>
4430
// name of the endpoint, used to calculate the request key
4531
<% } -%>
@@ -48,10 +34,6 @@ export class <%= normalizedEndpointNameCap %>Transport extends SubscriptionTrans
4834
// instance of adapter config
4935
<% } -%>
5036
config!: BaseEndpointTypes['Settings']
51-
<% if (includeComments) { -%>
52-
// cache instance for caching responses from provider
53-
<% } -%>
54-
responseCache!: ResponseCache<<%= normalizedEndpointNameCap %>TransportTypes>
5537
<% if (includeComments) { -%>
5638
// instance of Requester to be used for data fetching. Use this instance to perform http calls
5739
<% } -%>
@@ -61,7 +43,12 @@ export class <%= normalizedEndpointNameCap %>Transport extends SubscriptionTrans
6143
// REQUIRED. Transport will be automatically initialized by the framework using this method. It will be called with transport
6244
// dependencies, adapter settings, endpoint name, and transport name as arguments. Use this method to initialize transport state
6345
<% } -%>
64-
async initialize(dependencies: TransportDependencies<<%= normalizedEndpointNameCap %>TransportTypes>, adapterSettings: <%= normalizedEndpointNameCap %>TransportTypes['Settings'], endpointName: string, transportName: string): Promise<void> {
46+
async initialize(
47+
dependencies: TransportDependencies<BaseEndpointTypes>,
48+
adapterSettings: BaseEndpointTypes['Settings'],
49+
endpointName: string,
50+
transportName: string
51+
): Promise<void> {
6552
await super.initialize(dependencies, adapterSettings, endpointName, transportName)
6653
this.config = adapterSettings
6754
this.endpointName = endpointName
@@ -72,13 +59,13 @@ export class <%= normalizedEndpointNameCap %>Transport extends SubscriptionTrans
7259
// and an array of all the entries in the subscription set as second argument. Use this method to handle the incoming
7360
// request, process it and save it in the cache.
7461
<% } -%>
75-
async backgroundHandler(context: EndpointContext<<%= normalizedEndpointNameCap %>TransportTypes>, entries: RequestParams[]) {
62+
async backgroundHandler(context: EndpointContext<BaseEndpointTypes>, entries: RequestParams[]) {
7663
await Promise.all(entries.map(async (param) => this.handleRequest(param)))
7764
await sleep(context.adapterSettings.BACKGROUND_EXECUTE_MS)
7865
}
7966

8067
async handleRequest(param: RequestParams) {
81-
let response: AdapterResponse<<%= normalizedEndpointNameCap %>TransportTypes['Response']>
68+
let response: AdapterResponse<BaseEndpointTypes['Response']>
8269
try {
8370
response = await this._handleRequest(param)
8471
} catch (e) {
@@ -99,7 +86,7 @@ export class <%= normalizedEndpointNameCap %>Transport extends SubscriptionTrans
9986

10087
async _handleRequest(
10188
params: RequestParams,
102-
): Promise<AdapterResponse<<%= normalizedEndpointNameCap %>TransportTypes['Response']>> {
89+
): Promise<AdapterResponse<BaseEndpointTypes['Response']>> {
10390

10491
const providerDataRequestedUnixMs = Date.now()
10592

@@ -156,7 +143,7 @@ export class <%= normalizedEndpointNameCap %>Transport extends SubscriptionTrans
156143
}
157144
}
158145

159-
getSubscriptionTtlFromConfig(adapterSettings: <%= normalizedEndpointNameCap %>TransportTypes['Settings']): number {
146+
getSubscriptionTtlFromConfig(adapterSettings: BaseEndpointTypes['Settings']): number {
160147
return adapterSettings.WARMUP_SUBSCRIPTION_TTL
161148
}
162149
}

scripts/generator-adapter/generators/app/templates/test/integration/adapter.test.ts.ejs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import {
33
setEnvVariables,
44
} from '@chainlink/external-adapter-framework/util/testing-utils'
55
import * as nock from 'nock'
6-
<% if (mockPostResponse) { %>
7-
import { mockPostResponseSuccess } from './fixtures'
8-
<% } else { %>
9-
import { mockResponseSuccess } from './fixtures'
10-
<% } %>
6+
import { <% if (mockPostResponse) { %>mockPostResponseSuccess<% } else { %>mockResponseSuccess<% } %> } from './fixtures'
117

128
describe('execute', () => {
139
let spy: jest.SpyInstance

scripts/generator-adapter/generators/app/templates/test/unit/custombg.test.ts.ejs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,12 @@ describe('<%= normalizedEndpointNameCap %>Transport', () => {
6161

6262
type RequestConfig = {
6363
baseURL: string
64+
url: string
6465
method: 'POST'
66+
headers: Record<string, string>
6567
data: {
66-
method: 'account_info'
67-
params: [
68-
{
69-
account: string
70-
ledger_index: 'validated'
71-
},
72-
]
68+
symbol: string
69+
convert: string
7370
}
7471
}
7572

@@ -102,11 +99,6 @@ describe('<%= normalizedEndpointNameCap %>Transport', () => {
10299
data: requestConfig.data,
103100
transportName,
104101
})
105-
/*
106-
expect(log).toBeCalledWith(`Generated HTTP request queue key: "${requestKey}"`)
107-
expect(log).toBeCalledTimes(1)
108-
log.mockClear()
109-
*/
110102
return requestKey
111103
}
112104

@@ -228,7 +220,7 @@ describe('<%= normalizedEndpointNameCap %>Transport', () => {
228220
it('should throw if response does not include price', async () => {
229221
const from = 'ETH'
230222
const to = 'USD'
231-
const price = undefined
223+
const price = undefined as unknown as number
232224

233225
const params = makeStub('params', {
234226
base: from,

0 commit comments

Comments
 (0)