-
Couldn't load subscription status.
- Fork 325
Add Canton EA to read from Canton participant node #4103
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: d652378 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| required: true, | ||
| sensitive: true, | ||
| }, | ||
| BACKGROUND_EXECUTE_MS: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to override the default here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we can always export a different BACKGROUND_EXECUTE_MS env variable. But if we want to do that programmatically, we might need to create in input param for it.
| throw new Error(`Failed to query contracts: ${response.response?.statusText}`) | ||
| } | ||
|
|
||
| const contracts = response.response.data.result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this actually return multiple contracts? i thought contractIds were unique
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the query did not factor in the contract Id. But the function has been removed now because there is no use case for it in the code any longer
| } | ||
|
|
||
| // Find the latest contract by createdAt | ||
| contract = this.findLatestContract(contracts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think each eturned contract may have a flag associated with it, which says where it's "ACTIVE" or "ARCHIVED" - it might be useful to check this and log an error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The doc for this query is actually for active contracts. So all the contracts returned are active by default.
| } | ||
|
|
||
| // Sort by createdAt in descending order (latest first) | ||
| return contracts.sort((a, b) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does Canton not have an API to return the latest contract? And also perhaps even filter by flag ACTIVE as i mentioned above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Canton does not have the API for that. The only thing that comes close to this is the created_at property that is attached to a query response from a gRPC call. However, when you query active contracts via the JSON api, it returns the active contracts in order of creation. So the first contract In the list is the latest, while the last contract in the list is the oldest.
| import { cantonDataTransport } from '../transport/canton-data' | ||
|
|
||
| export const inputParameters = new InputParameters( | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted: these should be ENV variables specified in the implementing project, most of these are fixed and do not need to be in the request
| templateIds: request.templateIds, | ||
| } | ||
|
|
||
| if (request.filter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can either
- Return an error if duplicates are found
- We could also return the full response (all the contracts) and pass this down to the implementing project to handle the return values. This might be preferable
| import { config } from './config' | ||
| import { cantonData } from './endpoint' | ||
|
|
||
| export const adapter = new Adapter({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Base contract should not have an instance, instance should be configured within implementing contracts as discussed
Closes #DS-1113
https://smartcontract-it.atlassian.net/browse/DS-1113
Description
This is a general-purpose Chainlink External Adapter that enables smart contracts to read data from Canton participant nodes via the Ledger API. The adapter should be pluggable and configurable to support application-specific queries while maintaining a standard interface.
We should prioritise using the JSON Ledger API interface, although there is an alternative gRPC interface. The ledger API is the interface to the participant node.
This can be used in a more specific way to read from individual DPs, who may have contracts with different getter functions.
......
Changes
Steps to Test
Quality Assurance
infra-k8sconfiguration file.adapter-secretsconfiguration file or update the soak testing blacklist.test-payload.jsonfile with relevant requests.feature/x,chore/x,release/x,hotfix/x,fix/x) or is created from Jira.