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

Create clear-bank adapter #3100

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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/poor-dingos-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chainlink/clear-bank-adapter': major
---

Initial version of the adapter
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/clear-bank/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Chainlink External Adapter for clear-bank

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 clear-bank`.
41 changes: 41 additions & 0 deletions packages/sources/clear-bank/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "@chainlink/clear-bank-adapter",
"version": "0.0.0",
"description": "Chainlink clear-bank adapter.",
"keywords": [
"Chainlink",
"LINK",
"blockchain",
"oracle",
"clear-bank"
],
"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": "16.11.51",
"axios": "1.3.4",
"nock": "13.2.9",
"typescript": "5.0.4"
},
"dependencies": {
"@chainlink/external-adapter-framework": "0.33.1",
"tslib": "2.4.1"
}
}
29 changes: 29 additions & 0 deletions packages/sources/clear-bank/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { AdapterConfig } from '@chainlink/external-adapter-framework/config'
import { validator } from '@chainlink/external-adapter-framework/validation/utils'

export const config = new AdapterConfig({
API_KEY: {
description: 'An API key for Data Provider',
type: 'string',
required: true,
sensitive: true,
},
API_ENDPOINT: {
description: 'An API endpoint for Data Provider',
type: 'string',
default: 'https://institution-api.clearbank.co.uk/',
},
BACKGROUND_EXECUTE_MS: {
description:
'The amount of time the background execute should sleep before performing the next request',
type: 'number',
default: 10_000,
},
PAGE_SIZE: {
description: 'The number of accounts to fetch per call to /accounts. Must be >= 1 and <= 50.',
type: 'number',
required: false,
default: 50,
validate: validator.integer({ min: 1, max: 50 }),
},
})
41 changes: 41 additions & 0 deletions packages/sources/clear-bank/src/endpoint/accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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 { accountsTransport } from '../transport/accounts'

export const inputParameters = new InputParameters(
{
accountIDs: {
aliases: ['ibanIDs'],
required: true,
type: 'string',
description: 'The account ID that balances',
array: true,
},
currency: {
type: 'string',
description: 'The currency the balance should be aggregated for',
default: 'GBP',
},
},
[
{
accountIDs: ['GB44CLRB04084000000010'],
currency: 'GBP',
},
],
)

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

export const endpoint = new AdapterEndpoint({
name: 'accounts',
aliases: [],
transport: accountsTransport,
inputParameters,
})
1 change: 1 addition & 0 deletions packages/sources/clear-bank/src/endpoint/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { endpoint as accounts } from './accounts'
21 changes: 21 additions & 0 deletions packages/sources/clear-bank/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 { accounts } from './endpoint'

export const adapter = new Adapter({
defaultEndpoint: accounts.name,
name: 'CLEAR_BANK',
config,
endpoints: [accounts],
rateLimiting: {
tiers: {
default: {
rateLimit1s: 1,
note: 'Reasonable rate limit set by default to avoid overwhelming the endpoint',
},
},
},
})

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