Skip to content

Commit bb1c816

Browse files
cl-mayowaapp-token-issuer-data-feeds[bot]Fletch153
authored
Add Canton EA to read from Canton participant node (#4103)
* add canton ea endpoint and transport * add changeset * update contract query and input params * remove unsued functions and refactor code * update integration tests for new changes * refactor adapter settings and tests * add custom return handler with tests * refactor canton to be extensible and added tests * update dependencies lock * remove outdated snapshots * update external adapter framework version * remove useless read me * Add canton-functions path to tsconfig * add README for canton EA * upgrade EA version * update yarn --------- Co-authored-by: app-token-issuer-data-feeds[bot] <134377064+app-token-issuer-data-feeds[bot]@users.noreply.github.com> Co-authored-by: Michael Fletcher <michael.fletcher@smartcontract.com>
1 parent bdb27c1 commit bb1c816

25 files changed

+1092
-0
lines changed

.changeset/fair-geese-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@chainlink/canton-functions-adapter': major
3+
---
4+
5+
This EA enables us to read data from Canton participant nodes via the Ledger API

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
7+
[*.{js,json,yml}]
8+
charset = utf-8
9+
indent_style = space
10+
indent_size = 2

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/.yarn/** linguist-vendored
2+
/.yarn/releases/* binary
3+
/.yarn/plugins/**/* binary
4+
/.pnp.* binary linguist-generated

.pnp.cjs

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sources/canton-functions/CHANGELOG.md

Whitespace-only changes.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# CANTON_FUNCTIONS
2+
3+
![1.0.0](https://img.shields.io/github/package-json/v/smartcontractkit/external-adapters-js?filename=packages/sources/canton-functions/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+
|| AUTH_TOKEN | JWT token for Canton JSON API authentication | string | | |
12+
| | BACKGROUND_EXECUTE_MS | The amount of time the background execute should sleep before performing the next request | number | | `1000` |
13+
|| URL | The Canton JSON API URL | string | | |
14+
|| TEMPLATE_ID | The template ID to query contracts for (format: packageId:Module:Template) | string | | |
15+
|| CHOICE | The non-consuming choice to exercise on the contract | string | | |
16+
| | ARGUMENT | The argument for the choice (JSON string) | string | | |
17+
| | CONTRACT_FILTER | Filter to query contracts when contractId is not provided (JSON string) | string | | |
18+
19+
---
20+
21+
## Data Provider Rate Limits
22+
23+
There are no rate limits for this adapter.
24+
25+
---
26+
27+
## Input Parameters
28+
29+
| Required? | Name | Description | Type | Options | Default |
30+
| :-------: | :------: | :-----------------: | :----: | :----------------------------------: | :-----------: |
31+
| | endpoint | The endpoint to use | string | [canton-data](#canton-data-endpoint) | `canton-data` |
32+
33+
## Canton-data Endpoint
34+
35+
`canton-data` is the only supported name for this endpoint.
36+
37+
### Input Params
38+
39+
| Required? | Name | Aliases | Description | Type | Options | Default | Depends On | Not Valid With |
40+
| :-------: | :--------: | :-----: | :-----------------------------------: | :----: | :-----: | :-----: | :--------: | :------------: |
41+
| | contractId | | The contract ID to exercise choice on | string | | | | |
42+
43+
### Example
44+
45+
Request:
46+
47+
```json
48+
{
49+
"data": {
50+
"endpoint": "canton-data",
51+
"contractId": "00e1f5c6d8b9a7f4e3c2d1a0b9c8d7e6f5a4b3c2d1e0f9a8b7c6d5e4f3a2b1c0"
52+
}
53+
}
54+
```
55+
56+
---
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "@chainlink/canton-functions-adapter",
3+
"version": "1.0.0",
4+
"description": "Chainlink canton-functions adapter.",
5+
"keywords": [
6+
"Chainlink",
7+
"LINK",
8+
"blockchain",
9+
"oracle",
10+
"canton-functions"
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+
"@sinonjs/fake-timers": "9.1.2",
32+
"@types/jest": "^29.5.14",
33+
"@types/node": "22.14.1",
34+
"@types/sinonjs__fake-timers": "8.1.5",
35+
"nock": "13.5.6",
36+
"typescript": "5.8.3"
37+
},
38+
"dependencies": {
39+
"@chainlink/external-adapter-framework": "2.11.5",
40+
"tslib": "2.4.1"
41+
}
42+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { AdapterConfig } from '@chainlink/external-adapter-framework/config'
2+
3+
export const config = new AdapterConfig({
4+
AUTH_TOKEN: {
5+
description: 'JWT token for Canton JSON API authentication',
6+
type: 'string',
7+
required: true,
8+
sensitive: true,
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: 1_000,
15+
},
16+
URL: {
17+
description: 'The Canton JSON API URL',
18+
type: 'string',
19+
required: true,
20+
},
21+
TEMPLATE_ID: {
22+
description: 'The template ID to query contracts for (format: packageId:Module:Template)',
23+
type: 'string',
24+
required: true,
25+
},
26+
CHOICE: {
27+
description: 'The non-consuming choice to exercise on the contract',
28+
type: 'string',
29+
required: true,
30+
},
31+
ARGUMENT: {
32+
description: 'The argument for the choice (JSON string)',
33+
type: 'string',
34+
required: false,
35+
},
36+
CONTRACT_FILTER: {
37+
description: 'Filter to query contracts when contractId is not provided (JSON string)',
38+
type: 'string',
39+
required: false,
40+
},
41+
})
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { AdapterEndpoint } from '@chainlink/external-adapter-framework/adapter'
2+
import { InputParameters } from '@chainlink/external-adapter-framework/validation'
3+
import { config } from '../config'
4+
import { cantonDataTransport } from '../transport/canton-data'
5+
6+
export const inputParameters = new InputParameters(
7+
{
8+
contractId: {
9+
description: 'The contract ID to exercise choice on',
10+
type: 'string',
11+
required: false,
12+
},
13+
},
14+
[
15+
{
16+
contractId: '00e1f5c6d8b9a7f4e3c2d1a0b9c8d7e6f5a4b3c2d1e0f9a8b7c6d5e4f3a2b1c0',
17+
},
18+
],
19+
)
20+
21+
export type BaseEndpointTypes = {
22+
Parameters: typeof inputParameters.definition
23+
Response: {
24+
Data: {
25+
result: string
26+
exerciseResult: any
27+
contract?: any
28+
}
29+
Result: string
30+
}
31+
Settings: typeof config.settings
32+
}
33+
34+
export const endpoint = new AdapterEndpoint({
35+
name: 'canton-data',
36+
aliases: [],
37+
transport: cantonDataTransport,
38+
inputParameters,
39+
})
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { endpoint as cantonData } from './canton-data'

0 commit comments

Comments
 (0)