Skip to content
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

Feat/DF-20625 apex #3672

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilled-shrimps-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/apex-adapter': major
---

Apex EA Initial Commit
21 changes: 21 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
3 changes: 3 additions & 0 deletions packages/sources/apex/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Chainlink External Adapter for apex

This README will be generated automatically when code is merged to `main`. If you would like to generate a preview of the README, please run `yarn generate:readme apex`.
41 changes: 41 additions & 0 deletions packages/sources/apex/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "@chainlink/apex-adapter",
"version": "0.0.0",
"description": "Chainlink apex adapter.",
"keywords": [
"Chainlink",
"LINK",
"blockchain",
"oracle",
"apex"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"repository": {
"url": "https://github.com/smartcontractkit/external-adapters-js",
"type": "git"
},
"license": "MIT",
"scripts": {
"clean": "rm -rf dist && rm -f tsconfig.tsbuildinfo",
"prepack": "yarn build",
"build": "tsc -b",
"server": "node -e 'require(\"./index.js\").server()'",
"server:dist": "node -e 'require(\"./dist/index.js\").server()'",
"start": "yarn server:dist"
},
"devDependencies": {
"@types/jest": "27.5.2",
"@types/node": "22.12.0",
"nock": "13.5.6",
"typescript": "5.6.3"
},
"dependencies": {
"@chainlink/external-adapter-framework": "2.0.0",
"axios": "1.7.9",
"tslib": "2.4.1"
}
}
45 changes: 45 additions & 0 deletions packages/sources/apex/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { AdapterConfig } from '@chainlink/external-adapter-framework/config'

export const config = new AdapterConfig({
CLIENT_ID: {
description: 'Data Provider client ID',
type: 'string',
required: true,
sensitive: true,
},
CLIENT_SECRET: {
description: 'Data Provider client secret',
type: 'string',
required: true,
sensitive: true,
},
SCOPE: {
description: 'Scope of credentials',
type: 'string',
required: true,
sensitive: true,
},
GRANT_TYPE: {
description: 'Grant type for credentials',
type: 'string',
required: true,
sensitive: true,
},
NAV_API_ENDPOINT: {
description: 'An API endpoint for Data Provider',
type: 'string',
default: 'https://api.apexgroup.com/v1/reports/NAV',
},
AUTH_API_ENDPOINT: {
description: 'An auth API endpoint for Data Provider',
type: 'string',
required: true,
sensitive: true,
},
BACKGROUND_EXECUTE_MS: {
description:
'The amount of time the background execute should sleep before performing the next request',
type: 'number',
default: 10_000,
},
})
1 change: 1 addition & 0 deletions packages/sources/apex/src/endpoint/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { endpoint as nav } from './nav'
32 changes: 32 additions & 0 deletions packages/sources/apex/src/endpoint/nav.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { AdapterEndpoint } from '@chainlink/external-adapter-framework/adapter'
import { InputParameters } from '@chainlink/external-adapter-framework/validation'
import { SingleNumberResultResponse } from '@chainlink/external-adapter-framework/util'
import { config } from '../config'
import { navTransport } from '../transport/nav'

export const inputParameters = new InputParameters(
{
accountName: {
required: true,
type: 'string',
description: 'The account name to query',
},
},
[
{
accountName: 'EXAMPLE',
},
],
)

export type BaseEndpointTypes = {
Parameters: typeof inputParameters.definition
Response: SingleNumberResultResponse
Settings: typeof config.settings
}

export const endpoint = new AdapterEndpoint({
name: 'nav',
transport: navTransport,
inputParameters,
})
21 changes: 21 additions & 0 deletions packages/sources/apex/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { expose, ServerInstance } from '@chainlink/external-adapter-framework'
import { Adapter } from '@chainlink/external-adapter-framework/adapter'
import { config } from './config'
import { nav } from './endpoint'

export const adapter = new Adapter({
defaultEndpoint: nav.name,
name: 'APEX',
config,
endpoints: [nav],
rateLimiting: {
tiers: {
default: {
rateLimit1m: 6,
note: 'Setting reasonable default limits',
},
},
},
})

export const server = (): Promise<ServerInstance | undefined> => expose(adapter)
Loading
Loading