Skip to content

Commit c4f3faa

Browse files
Nav consulting EA (#3508)
* Nav consulting EA * Comment * Comments * update test payload for harris and trotter --------- Co-authored-by: Matthew McAllister <[email protected]>
1 parent e56219b commit c4f3faa

34 files changed

+645
-12
lines changed

.changeset/cuddly-bikes-flow.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@chainlink/nav-consulting-adapter': major
3+
---
4+
5+
New Nav Consulting EA

.changeset/fair-apes-travel.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@chainlink/harris-and-trotter-adapter': patch
3+
'@chainlink/coinbase-prime-adapter': patch
4+
'@chainlink/anchorage-adapter': patch
5+
---
6+
7+
Update comments

.pnp.cjs

+40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.

packages/scripts/src/ephemeral-adapters/lib.ts

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export const deployAdapter = (config: Inputs): void => {
171171
const deployHelm = new Shell().exec(
172172
`helm ${config.helmSecrets ? 'secrets' : ''} upgrade ${config.name} ${config.helmChartDir} \
173173
--install \
174+
--debug \
174175
--namespace ${NAMESPACE} \
175176
--create-namespace \
176177
${config.helmValuesOverride} \

packages/scripts/src/generate-readme/readmeBlacklist.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"view-function-multi-chain",
6464
"xsushi-price",
6565
"coinbase-prime",
66-
"harris-and-trotter"
66+
"harris-and-trotter",
67+
"nav-consulting"
6768
]
6869
}

packages/sources/anchorage/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ There are no rate limits for this adapter.
3434
| Required? | Name | Aliases | Description | Type | Options | Default | Depends On | Not Valid With |
3535
| :-------: | :-----: | :-------: | :-------------------------------------------------------------------------: | :----: | :------------------: | :-------: | :--------: | :------------: |
3636
|| vaultId | `vaultID` | Id of the vault | string | | | | |
37-
|| coin | | Asset ticker name. Used to select {$coin}\_API_KEY in environment variables | string | | | | |
37+
|| coin | | Asset ticker name. Used to select ${coin}\_API_KEY in environment variables | string | | | | |
3838
| | chainId | | The ID of the chain to return | string | `mainnet`, `testnet` | `mainnet` | | |
3939
| | network | | The network to return | string | | `bitcoin` | | |
4040

packages/sources/coinbase-prime/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ This document was generated automatically. Please see [README Generator](../../s
3939

4040
### Input Params
4141

42-
| Required? | Name | Aliases | Description | Type | Options | Default | Depends On | Not Valid With |
43-
| :-------: | :-------: | :-----: | :-----------------------------------------------------------------------------------------------------------------------------------------------: | :----: | :-------------------------: | :-----: | :--------: | :------------: |
44-
|| portfolio | | The portfolio ID to query the balance of | string | | | | |
45-
|| symbol | | The symbol to return the balance for | string | | | | |
46-
| | type | | The balance type to return | string | `total`, `trading`, `vault` | `total` | | |
47-
| | apiKey | | Alternative api keys to use for this request, {$apiKey}_ACCESS_KEY {$apiKey}\_PASSPHRASE {$apiKey}\_SIGNING_KEY required in environment variables | string | | | | |
42+
| Required? | Name | Aliases | Description | Type | Options | Default | Depends On | Not Valid With |
43+
| :-------: | :-------: | :-----: | :------------------------------------------------------------------------------------------------------------------------------------------------: | :----: | :-------------------------: | :-----: | :--------: | :------------: |
44+
|| portfolio | | The portfolio ID to query the balance of | string | | | | |
45+
|| symbol | | The symbol to return the balance for | string | | | | |
46+
| | type | | The balance type to return | string | `total`, `trading`, `vault` | `total` | | |
47+
| | apiKey | | Alternative api keys to use for this request, ${apiKey}\_ACCESS_KEY ${apiKey}\_PASSPHRASE ${apiKey}\_SIGNING_KEY required in environment variables | string | | | | |
4848

4949
### Example
5050

packages/sources/coinbase-prime/src/endpoint/balance.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const inputParameters = new InputParameters(
2727
apiKey: {
2828
type: 'string',
2929
description:
30-
'Alternative api keys to use for this request, {$apiKey}_ACCESS_KEY {$apiKey}_PASSPHRASE {$apiKey}_SIGNING_KEY required in environment variables',
30+
'Alternative api keys to use for this request, ${apiKey}_ACCESS_KEY ${apiKey}_PASSPHRASE ${apiKey}_SIGNING_KEY required in environment variables',
3131
default: '',
3232
},
3333
},

packages/sources/harris-and-trotter/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ This document was generated automatically. Please see [README Generator](../../s
3737
| Required? | Name | Aliases | Description | Type | Options | Default | Depends On | Not Valid With |
3838
| :-------: | :--------: | :-----: | :------------------------------------------------------------------------------------------------: | :----: | :-----: | :-----: | :--------: | :------------: |
3939
|| clientName | | The name of the client to retrieve balances for. | string | | | | |
40-
| | apiKey | | Alternative api keys to use for this request, {$apiKey}\_API_KEY required in environment variables | string | | | | |
40+
| | apiKey | | Alternative api keys to use for this request, ${apiKey}\_API_KEY required in environment variables | string | | | | |
4141

4242
### Example
4343

packages/sources/harris-and-trotter/src/endpoint/balance.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const inputParameters = new InputParameters(
1818
apiKey: {
1919
type: 'string',
2020
description:
21-
'Alternative api keys to use for this request, {$apiKey}_API_KEY required in environment variables',
21+
'Alternative api keys to use for this request, ${apiKey}_API_KEY required in environment variables',
2222
default: '',
2323
},
2424
},

packages/sources/harris-and-trotter/test-payload.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"requests": [
33
{
4-
"clientName": "TUSD",
4+
"clientName": "wenia",
55
"endpoint": "balance"
66
}
77
]

packages/sources/nav-consulting/CHANGELOG.md

Whitespace-only changes.
+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# NAV_CONSULTING
2+
3+
![0.0.0](https://img.shields.io/github/package-json/v/smartcontractkit/external-adapters-js?filename=packages/sources/nav-consulting/package.json) ![v3](https://img.shields.io/badge/framework%20version-v3-blueviolet)
4+
5+
This document was generated automatically. Please see [README Generator](../../scripts#readme-generator) for more info.
6+
7+
## Environment Variables
8+
9+
| Required? | Name | Description | Type | Options | Default |
10+
| :-------: | :-------------------: | :---------------------------------------------------------------------------------------: | :----: | :-----: | :-----------------------------: |
11+
| | {FUND}\_API_KEY | API key, use fund in input to select | string | | |
12+
| | {FUND}\_SECRET_KEY | Secret key, use fund in input to select | string | | |
13+
| | API_ENDPOINT | An API endpoint for Data Provider | string | | `https://api.navconsulting.net` |
14+
| | BACKGROUND_EXECUTE_MS | The amount of time the background execute should sleep before performing the next request | number | | `10000` |
15+
16+
---
17+
18+
## Data Provider Rate Limits
19+
20+
There are no rate limits for this adapter.
21+
22+
---
23+
24+
## Input Parameters
25+
26+
| Required? | Name | Description | Type | Options | Default |
27+
| :-------: | :------: | :-----------------: | :----: | :--------------------------: | :-------: |
28+
| | endpoint | The endpoint to use | string | [reserve](#reserve-endpoint) | `reserve` |
29+
30+
## Reserve Endpoint
31+
32+
`reserve` is the only supported name for this endpoint.
33+
34+
### Input Params
35+
36+
| Required? | Name | Aliases | Description | Type | Options | Default | Depends On | Not Valid With |
37+
| :-------: | :--: | :-----: | :--------------------------------------------------------------------------------------: | :----: | :-----: | :-----: | :--------: | :------------: |
38+
|| fund | | Name of the fund, used to select ${fund}\_API_KEY ${fund}\_SECRET_KEY from env variables | string | | | | |
39+
40+
### Example
41+
42+
Request:
43+
44+
```json
45+
{
46+
"data": {
47+
"endpoint": "reserve",
48+
"fund": "Adapt3r"
49+
}
50+
}
51+
```
52+
53+
---
54+
55+
MIT License
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "@chainlink/nav-consulting-adapter",
3+
"version": "0.0.0",
4+
"description": "Chainlink nav-consulting adapter.",
5+
"keywords": [
6+
"Chainlink",
7+
"LINK",
8+
"blockchain",
9+
"oracle",
10+
"nav-consulting"
11+
],
12+
"main": "dist/index.js",
13+
"types": "dist/index.d.ts",
14+
"files": [
15+
"dist"
16+
],
17+
"repository": {
18+
"url": "https://github.com/smartcontractkit/external-adapters-js",
19+
"type": "git"
20+
},
21+
"license": "MIT",
22+
"scripts": {
23+
"clean": "rm -rf dist && rm -f tsconfig.tsbuildinfo",
24+
"prepack": "yarn build",
25+
"build": "tsc -b",
26+
"server": "node -e 'require(\"./index.js\").server()'",
27+
"server:dist": "node -e 'require(\"./dist/index.js\").server()'",
28+
"start": "yarn server:dist"
29+
},
30+
"devDependencies": {
31+
"@date-fns/utc": "2.1.0",
32+
"@types/crypto-js": "4.2.2",
33+
"@types/jest": "27.5.2",
34+
"@types/node": "16.18.115",
35+
"crypto-js": "4.2.0",
36+
"date-fns": "4.1.0",
37+
"nock": "13.5.4",
38+
"typescript": "5.5.4"
39+
},
40+
"dependencies": {
41+
"@chainlink/external-adapter-framework": "1.5.0",
42+
"tslib": "2.4.1"
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { AdapterConfig } from '@chainlink/external-adapter-framework/config'
2+
3+
export const config = new AdapterConfig({
4+
API_ENDPOINT: {
5+
description: 'An API endpoint for Data Provider',
6+
type: 'string',
7+
default: 'https://api.navconsulting.net',
8+
},
9+
10+
BACKGROUND_EXECUTE_MS: {
11+
description:
12+
'The amount of time the background execute should sleep before performing the next request',
13+
type: 'number',
14+
default: 10_000,
15+
},
16+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { endpoint as reserve } from './reserve'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { AdapterEndpoint } from '@chainlink/external-adapter-framework/adapter'
2+
import { InputParameters } from '@chainlink/external-adapter-framework/validation'
3+
import { SingleNumberResultResponse } from '@chainlink/external-adapter-framework/util'
4+
import { config } from '../config'
5+
import { navConsultingTransport } from '../transport/reserve'
6+
7+
export const inputParameters = new InputParameters(
8+
{
9+
fund: {
10+
required: true,
11+
type: 'string',
12+
description:
13+
'Name of the fund, used to select ${fund}_API_KEY ${fund}_SECRET_KEY from env variables',
14+
},
15+
},
16+
[
17+
{
18+
fund: 'Adapt3r',
19+
},
20+
],
21+
)
22+
23+
export type BaseEndpointTypes = {
24+
Parameters: typeof inputParameters.definition
25+
Response: SingleNumberResultResponse
26+
Settings: typeof config.settings
27+
}
28+
29+
export const endpoint = new AdapterEndpoint({
30+
name: 'reserve',
31+
transport: navConsultingTransport,
32+
inputParameters,
33+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { expose, ServerInstance } from '@chainlink/external-adapter-framework'
2+
import { Adapter } from '@chainlink/external-adapter-framework/adapter'
3+
import { config } from './config'
4+
import { reserve } from './endpoint'
5+
6+
export const adapter = new Adapter({
7+
defaultEndpoint: reserve.name,
8+
name: 'NAV_CONSULTING',
9+
config,
10+
endpoints: [reserve],
11+
})
12+
13+
export const server = (): Promise<ServerInstance | undefined> => expose(adapter)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import CryptoJS from 'crypto-js'
2+
3+
export const getValidatorIds = (
4+
method: string,
5+
path: string,
6+
body: string,
7+
apiKey: string,
8+
secret: string,
9+
) => {
10+
const nonce = createGuid()
11+
const utcNow = new Date().toUTCString()
12+
const contentHash = CryptoJS.SHA256(body).toString(CryptoJS.enc.Base64)
13+
14+
const stringToSign =
15+
apiKey + ';' + path + ';' + method + ';' + utcNow + ';' + nonce + ';' + contentHash
16+
17+
const signature = CryptoJS.HmacSHA256(stringToSign, secret).toString(CryptoJS.enc.Base64)
18+
19+
return {
20+
'x-date': utcNow,
21+
'x-content-sha256': contentHash,
22+
'x-hmac256-signature': apiKey + ';' + nonce + ';' + signature,
23+
}
24+
}
25+
26+
// Copied from Nav Consulting's API guide
27+
const createGuid = () => {
28+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
29+
const r = (Math.random() * 16) | 0
30+
const v = c === 'x' ? r : (r & 0x3) | 0x8
31+
return v.toString(16)
32+
})
33+
}

0 commit comments

Comments
 (0)