Skip to content

Commit

Permalink
Feat/DF-20625 apex (#3672)
Browse files Browse the repository at this point in the history
* DF-20625 apex EA initial commit

* add changeset

* review fixes
  • Loading branch information
mmcallister-cll authored Feb 5, 2025
1 parent 29cf6c0 commit 805468b
Show file tree
Hide file tree
Showing 19 changed files with 549 additions and 0 deletions.
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

0 comments on commit 805468b

Please sign in to comment.