Skip to content

Commit 45ee43a

Browse files
authored
Merge pull request #277 from smartcontractkit/chore-sync-with-main-22-06-26
Chore sync with main 22 06 26
2 parents 0c2be45 + fa71681 commit 45ee43a

17 files changed

Lines changed: 593 additions & 72 deletions

File tree

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,23 +270,23 @@ bun generate:sdk # Generate all SDK types and code
270270

271271
The [`breaking-changes`](./.github/workflows/breaking-changes.yml) workflow blocks PRs that alter any of the three protected contracts. If your change is intentional, update the relevant baseline before pushing:
272272

273-
| Contract | What triggers the failure | How to update |
274-
|---|---|---|
275-
| Proto fields | Field deleted, renamed, renumbered, or type changed | No baseline file — CI runs `buf breaking` on `submodules/chainlink-protos` (`cre` module) against the submodule commit pinned on `main` |
276-
| TypeScript public API | An exported type/interface was removed or changed | Run `bun run update-api-baseline` inside `packages/cre-sdk` and commit `api-baseline.d.ts` |
277-
| JS host binding names | A binding was added, removed, or renamed in `host-bindings.ts` | Run `bun test --update-snapshots` inside `packages/cre-sdk` and commit the updated `__snapshots__` file |
278-
| Rust host imports | An `extern "C"` import was added or removed in `lib.rs` | Re-run the sed extraction (see `breaking-changes.yml`) and commit `host-imports-baseline.txt` |
273+
| Contract | What triggers the failure | How to update |
274+
| --------------------- | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
275+
| Proto fields | Field deleted, renamed, renumbered, or type changed | No baseline file — CI runs `buf breaking` on `submodules/chainlink-protos` (`cre` module) against the submodule commit pinned on `main` |
276+
| TypeScript public API | An exported type/interface was removed or changed | Run `bun run update-api-baseline` inside `packages/cre-sdk` and commit `api-baseline.d.ts` |
277+
| JS host binding names | A binding was added, removed, or renamed in `host-bindings.ts` | Run `bun test --update-snapshots` inside `packages/cre-sdk` and commit the updated `__snapshots__` file |
278+
| Rust host imports | An `extern "C"` import was added or removed in `lib.rs` | Re-run the sed extraction (see `breaking-changes.yml`) and commit `host-imports-baseline.txt` |
279279

280280
#### CI override labels
281281

282282
When a change is **intentionally** breaking and cannot be fixed by updating a baseline (e.g. a coordinated proto break before `main` catches up), a **maintainer** adds the matching label on the PR (this re-runs the workflow):
283283

284-
| Label | Skips |
285-
|-------|--------|
286-
| `breaking-change:proto` | `proto-breaking` (`buf breaking`) |
287-
| `breaking-change:typescript-api` | `ts-api-surface` |
288-
| `breaking-change:host-bindings` | `host-bindings` |
289-
| `breaking-change:approved` | All three jobs |
284+
| Label | Skips |
285+
| -------------------------------- | --------------------------------- |
286+
| `breaking-change:proto` | `proto-breaking` (`buf breaking`) |
287+
| `breaking-change:typescript-api` | `ts-api-surface` |
288+
| `breaking-change:host-bindings` | `host-bindings` |
289+
| `breaking-change:approved` | All three jobs |
290290

291291
Labels are an audit trail in the PR timeline, not a substitute for review. Prefer updating baselines (`api-baseline.d.ts`, snapshots, `host-imports-baseline.txt`) when the new contract is the new source of truth. For proto breaks, coordinate the `chainlink-protos` submodule bump and document migration notes in the PR.
292292

bun.lock

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

packages/cre-sdk-examples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@chainlink/cre-sdk-examples",
33
"private": true,
4-
"version": "1.11.0",
4+
"version": "1.13.0",
55
"type": "module",
66
"author": "Ernest Nowacki",
77
"license": "BUSL-1.1",

packages/cre-sdk/api-baseline.d.ts

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export * as CRON_TRIGGER_PB from '@cre/generated/capabilities/scheduler/cron/v1/
88
export * as SDK_PB from '@cre/generated/sdk/v1alpha/sdk_pb';
99
export * as VALUES_PB from '@cre/generated/values/v1/values_pb';
1010
export * as BUFBUILD_TYPES from '@cre/sdk/types/bufbuild-types';
11+
export * from '../capabilities/errors';
1112
export * from './cre';
1213
export * from './don-info';
1314
export * from './errors';
@@ -23,10 +24,11 @@ export * from './workflow';
2324
import type { Message } from '@bufbuild/protobuf';
2425
import type { GenMessage } from '@bufbuild/protobuf/codegenv2';
2526
import type { ReportRequest, ReportRequestJson } from '@cre/generated/sdk/v1alpha/sdk_pb';
27+
import type { MetricType } from '@cre/sdk/impl/runtime-impl';
2628
import type { Report } from '@cre/sdk/report';
2729
import type { ConsensusAggregation, PrimitiveTypes, UnwrapOptions } from '@cre/sdk/utils';
2830
import type { SecretsProvider } from '.';
29-
export type { ReportRequest, ReportRequestJson };
31+
export type { ReportRequest, ReportRequestJson, MetricType };
3032
export type CallCapabilityParams<I extends Message, O extends Message> = {
3133
capabilityId: string;
3234
method: string;
@@ -45,13 +47,34 @@ export interface BaseRuntime<C> {
4547
};
4648
now(): Date;
4749
log(message: string): void;
50+
emitMetric(name: string, value: number, type: MetricType, labels?: Record<string, string>): boolean;
4851
}
4952
/**
5053
* Runtime for Node mode execution.
5154
*/
5255
export interface NodeRuntime<C> extends BaseRuntime<C> {
5356
readonly _isNodeRuntime: true;
5457
}
58+
/**
59+
* Runtime for Tee mode execution.
60+
*/
61+
export interface TeeRuntime<C> extends BaseRuntime<C>, SecretsProvider {
62+
/**
63+
* Generates a report from the DON.
64+
* Data requestsed throught this method will be routed outside of the TEE.
65+
*
66+
* @param input - Report request to generate a report from the DON
67+
* @returns Report generated from the DON
68+
*/
69+
reportFromDon(input: ReportRequest | ReportRequestJson): {
70+
result: () => Report;
71+
};
72+
/**
73+
* Returns the runtime that makes requests to the CRE DONs.
74+
* Requests made through this runtime will therefore be routed outside of the TEE
75+
*/
76+
usingTheDons(): Runtime<C>;
77+
}
5578
/**
5679
* Runtime for DON mode execution.
5780
*/
@@ -72,23 +95,29 @@ export interface Runtime<C> extends BaseRuntime<C>, SecretsProvider {
7295
};
7396
}
7497
import type { Message } from '@bufbuild/protobuf';
75-
import type { Secret, SecretRequest, SecretRequestJson } from '@cre/generated/sdk/v1alpha/sdk_pb';
76-
import { type Runtime } from '@cre/sdk/runtime';
98+
import type { Requirements, Secret, SecretRequest, SecretRequestJson } from '@cre/generated/sdk/v1alpha/sdk_pb';
99+
import type { Runtime, TeeRuntime } from '@cre/sdk/runtime';
77100
import type { Trigger } from '@cre/sdk/utils/triggers/trigger-interface';
78101
import type { CreSerializable } from './utils';
79-
export type HandlerFn<TConfig, TTriggerOutput, TResult> = (runtime: Runtime<TConfig>, triggerOutput: TTriggerOutput) => Promise<CreSerializable<TResult>> | CreSerializable<TResult>;
80-
export interface HandlerEntry<TConfig, TRawTriggerOutput extends Message<string>, TTriggerOutput, TResult> {
102+
export type { AnyTeeConstraint, NitroBinding, NitroRegion, OneOfTees, Region, TeeBinding, TeeConstraint, } from './tee-constraints';
103+
export { buildTeeRequirements, NITRO_REGIONS, REGIONS, teeConstraintSchema, } from './tee-constraints';
104+
import type { TeeConstraint } from './tee-constraints';
105+
export type HandlerFn<TConfig, TTriggerOutput, TResult, TRuntime = Runtime<TConfig>> = (runtime: TRuntime, triggerOutput: TTriggerOutput) => Promise<CreSerializable<TResult>> | CreSerializable<TResult>;
106+
export interface HandlerEntry<TConfig, TRawTriggerOutput extends Message<string>, TTriggerOutput, TResult, TRuntime = Runtime<TConfig>> {
81107
trigger: Trigger<TRawTriggerOutput, TTriggerOutput>;
82-
fn: HandlerFn<TConfig, TTriggerOutput, TResult>;
108+
fn: HandlerFn<TConfig, TTriggerOutput, TResult, TRuntime>;
109+
requirements?: Requirements;
83110
}
84-
export type Workflow<TConfig> = ReadonlyArray<HandlerEntry<TConfig, any, any, any>>;
85-
export declare const handler: <TRawTriggerOutput extends Message<string>, TTriggerOutput, TConfig, TResult>(trigger: Trigger<TRawTriggerOutput, TTriggerOutput>, fn: HandlerFn<TConfig, TTriggerOutput, TResult>) => HandlerEntry<TConfig, TRawTriggerOutput, TTriggerOutput, TResult>;
111+
export type Workflow<TConfig> = ReadonlyArray<HandlerEntry<TConfig, any, any, any, any>>;
112+
export declare const handler: <TRawTriggerOutput extends Message<string>, TTriggerOutput, TConfig, TResult, TRuntime = Runtime<TConfig>>(trigger: Trigger<TRawTriggerOutput, TTriggerOutput>, fn: HandlerFn<TConfig, TTriggerOutput, TResult, TRuntime>) => HandlerEntry<TConfig, TRawTriggerOutput, TTriggerOutput, TResult, TRuntime>;
113+
export declare const handlerInTee: <TRawTriggerOutput extends Message<string>, TTriggerOutput, TConfig, TResult>(trigger: Trigger<TRawTriggerOutput, TTriggerOutput>, fn: HandlerFn<TConfig, TTriggerOutput, TResult, TeeRuntime<TConfig>>, tees: TeeConstraint) => HandlerEntry<TConfig, TRawTriggerOutput, TTriggerOutput, TResult, TeeRuntime<TConfig>>;
86114
export type SecretsProvider = {
87115
getSecret(request: SecretRequest | SecretRequestJson): {
88116
result: () => Secret;
89117
};
90118
};
91119
import type { SecretRequest } from '@cre/generated/sdk/v1alpha/sdk_pb';
120+
export { CapabilityError as CapabilityRuntimeError } from './utils/capabilities/capability-error';
92121
export declare class DonModeError extends Error {
93122
constructor();
94123
}

packages/cre-sdk/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@chainlink/cre-sdk",
3-
"version": "1.11.0",
3+
"version": "1.13.0",
44
"type": "module",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -70,7 +70,7 @@
7070
"@biomejs/biome": "2.3.14",
7171
"@bufbuild/buf": "1.56.0",
7272
"@types/bun": "1.3.8",
73-
"chain-selectors": "https://github.com/smartcontractkit/chain-selectors.git#116ebbce88b36d4e76a03c12b3437ed33a5f9860",
73+
"chain-selectors": "https://github.com/smartcontractkit/chain-selectors.git#c6379b1272aa41e6977f60799c82a49465a14b3f",
7474
"fast-glob": "3.3.3",
7575
"ts-proto": "2.7.5",
7676
"typescript": "5.9.3",

packages/cre-sdk/src/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export class ClientCapability {
172172
'polygon-mainnet': 4051577828743386545n,
173173
'polygon-testnet-amoy': 16281711391670634445n,
174174
'private-testnet-andesite': 6915682381028791124n,
175+
'private-testnet-pumice': 1564738277398880633n,
175176
'private-testnet-rhyolite': 604447335222770945n,
176177
'sonic-mainnet': 1673871237479749969n,
177178
'sonic-testnet': 1763698235108410440n,

packages/cre-sdk/src/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ import {
3535
type GetMultipleAccountsWithOptsRequest,
3636
type GetMultipleAccountsWithOptsRequestJson,
3737
GetMultipleAccountsWithOptsRequestSchema,
38+
type GetProgramAccountsReply,
39+
GetProgramAccountsReplySchema,
40+
type GetProgramAccountsRequest,
41+
type GetProgramAccountsRequestJson,
42+
GetProgramAccountsRequestSchema,
3843
type GetSignatureStatusesReply,
3944
GetSignatureStatusesReplySchema,
4045
type GetSignatureStatusesRequest,
@@ -139,6 +144,7 @@ export class ClientCapability {
139144
/** Available ChainSelector values */
140145
static readonly SUPPORTED_CHAIN_SELECTORS = {
141146
'solana-devnet': 16423721717087811551n,
147+
'solana-mainnet': 124615329519749607n,
142148
} as const
143149

144150
constructor(private readonly ChainSelector: bigint) {}
@@ -361,6 +367,48 @@ export class ClientCapability {
361367
}
362368
}
363369

370+
getProgramAccounts<TInput>(
371+
runtime: Runtime<unknown>,
372+
input: CapabilityInput<TInput, GetProgramAccountsRequest, GetProgramAccountsRequestJson>,
373+
): { result: () => GetProgramAccountsReply }
374+
getProgramAccounts(
375+
runtime: Runtime<unknown>,
376+
input: GetProgramAccountsRequest | GetProgramAccountsRequestJson,
377+
): { result: () => GetProgramAccountsReply } {
378+
// Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
379+
let payload: GetProgramAccountsRequest
380+
381+
if ((input as unknown as { $typeName?: string }).$typeName) {
382+
// It's the original protobuf type
383+
payload = input as GetProgramAccountsRequest
384+
} else {
385+
// It's regular JSON, convert using fromJson
386+
payload = fromJson(GetProgramAccountsRequestSchema, input as GetProgramAccountsRequestJson)
387+
}
388+
389+
// Include all labels in capability ID for routing when specified
390+
const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`
391+
392+
const capabilityResponse = runtime.callCapability<
393+
GetProgramAccountsRequest,
394+
GetProgramAccountsReply
395+
>({
396+
capabilityId,
397+
method: 'GetProgramAccounts',
398+
payload,
399+
inputSchema: GetProgramAccountsRequestSchema,
400+
outputSchema: GetProgramAccountsReplySchema,
401+
})
402+
403+
return {
404+
result: () => {
405+
const result = capabilityResponse.result()
406+
407+
return result
408+
},
409+
}
410+
}
411+
364412
getSignatureStatuses<TInput>(
365413
runtime: Runtime<unknown>,
366414
input: CapabilityInput<TInput, GetSignatureStatusesRequest, GetSignatureStatusesRequestJson>,

0 commit comments

Comments
 (0)