-
Notifications
You must be signed in to change notification settings - Fork 300
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
TS migrations #221
TS migrations #221
Conversation
I see that you haven't updated any CHANGELOG files. Would it make sense to do so? |
70a3152
to
b3fc300
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Added a few small tweaks.
One thing I am unsure of is what the endpoint
would be for some of these adapters. I know we want to keep similar endpoints conformed to the same name and params. Just thinking aloud that we need them documented somewhere.
kaiko/src/index.ts
Outdated
import { makeExecute } from './adapter' | ||
import { makeConfig } from './config' | ||
|
||
const NAME = 'EXAMPLE' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const NAME = 'EXAMPLE' | |
const NAME = 'KAIKO' |
@krebernisak Do we want this capitalized or lowercase? I've seen both ways, but let's pick a convention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was first used as an ENV prefix to avoid naming collisions when using two or more adapters in the same env. So for now it was a simple hardcoded uppercase string
What we should do now to make this more robust is this:
- Import the
name
frompackage.json
, remove the-adapter
suffix, and export that as NAME. - Create a
toEnvName
util function that will map it to a safe string to use as ENV name
Environment variable names used by the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore) from the characters defined in Portable Character Set and do not begin with a digit.
kaiko/src/config.ts
Outdated
import { Requester } from '@chainlink/external-adapter' | ||
import { Config } from '@chainlink/types' | ||
|
||
export const DEFAULT_ENDPOINT = 'example' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is currently an unused variable as there is only one endpoint
marketstack/package.json
Outdated
"test": "mocha --exit --timeout 0 -r ts-node/register 'test/**/*.test.ts'", | ||
"test:unit": "mocha --exit --grep @integration --invert -r ts-node/register 'test/**/*.test.ts'", | ||
"test:integration": "mocha --exit --timeout 0 --grep @integration -r ts-node/register 'test/**/*.test.ts'", | ||
"server": "node -e 'require(\"./index.js\").server()'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"server": "node -e 'require(\"./index.js\").server()'", |
Take these out of every TS migrated EA as ./index.js
is now gone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking it out of the example
as well.
marketstack/src/adapter.ts
Outdated
case eod.Name: { | ||
const data = await eod.execute(config, request) | ||
|
||
return Requester.success(jobRunID, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will quickly grow to be hard to read if say 10 other endpoints were added.
I think the best style would be how Jonas modified the example
adapter as seen here:
https://github.com/smartcontractkit/external-adapters-js/blob/develop/example/src/endpoint/example.ts#L32
Each endpoint handles its own return, which keeps adapter.ts
a lot cleaner.
|
||
export const Name = 'eod' | ||
|
||
const customError = (data: any) => data.Response === 'Error' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krebernisak Should we be adding typing for each API response shape? Seems like it might be hard to maintain, but could provide valuable debugging information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in this PR to keep it fast & simple.
But in the future, we should type anything that's useful, and I think that will become useful at one point. The further we go with composite adapters, the more we use the data provider adapters programmatically, the more useful we are going to find those types.
First, we should finish this migration, then focus on improvements to our internal framework data types, and then we can make another push like this where we add a bunch of underlying API data types in one push. At that point it could start being useful :)
@@ -1,15 +1,46 @@ | |||
{ | |||
"name": "@chainlink/metalsapi-adapter", | |||
"version": "0.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we be bumping versions for all of these TS migrations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think we should!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since all versions are now set to 0.0.1
, let's wait until everything is finished/merged, and batch-update all TS migrated ones, or all TS ones in general.
b3fc300
to
7236e27
Compare
945a5f9
to
319ea92
Compare
319ea92
to
159c760
Compare
Converted this to draft as it had been split to 3 smaller batches. To be closed after merging the migrations. |
Migrating the following adapters to Typescript:
google-finance
kaiko
marketstack
metalsapi
nikkei
nomics
openexchangerates
poa-gasprice
polygon