@chainlink/cre-sdk 1.17.0-alpha.3 → 1.17.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.d.ts +1035 -0
  2. package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.js +290 -0
  3. package/dist/generated/sdk/v1alpha/sdk_pb.d.ts +6 -2
  4. package/dist/generated/sdk/v1alpha/sdk_pb.js +5 -1
  5. package/dist/generated/workflows/v2/cre_info_pb.d.ts +123 -0
  6. package/dist/generated/workflows/v2/cre_info_pb.js +17 -0
  7. package/dist/generated/workflows/v2/workflow_key_pb.d.ts +55 -0
  8. package/dist/generated/workflows/v2/workflow_key_pb.js +17 -0
  9. package/dist/generated/workflows/v2/workflow_user_metric_pb.d.ts +118 -0
  10. package/dist/generated/workflows/v2/workflow_user_metric_pb.js +41 -0
  11. package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.d.ts +63 -0
  12. package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.js +247 -0
  13. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.d.ts +13 -0
  14. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.js +94 -0
  15. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.d.ts +15 -0
  16. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +116 -0
  17. package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.d.ts +5 -1
  18. package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.js +22 -0
  19. package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.d.ts +4 -0
  20. package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.js +12 -0
  21. package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.d.ts +12 -2
  22. package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.js +12 -0
  23. package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.d.ts +2 -0
  24. package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.js +2 -0
  25. package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.d.ts +2 -0
  26. package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.js +2 -0
  27. package/dist/sdk/cre/index.d.ts +30 -15
  28. package/dist/sdk/cre/index.js +29 -14
  29. package/dist/sdk/impl/runtime-impl.d.ts +29 -2
  30. package/dist/sdk/impl/runtime-impl.js +55 -6
  31. package/dist/sdk/runtime.d.ts +24 -2
  32. package/dist/sdk/tee-constraints.d.ts +68 -0
  33. package/dist/sdk/tee-constraints.js +59 -0
  34. package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.d.ts +25 -0
  35. package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.js +111 -0
  36. package/dist/sdk/test/generated/index.d.ts +1 -0
  37. package/dist/sdk/test/generated/index.js +1 -0
  38. package/dist/sdk/testutils/index.d.ts +1 -1
  39. package/dist/sdk/testutils/index.js +1 -1
  40. package/dist/sdk/testutils/test-runtime.d.ts +17 -4
  41. package/dist/sdk/testutils/test-runtime.js +31 -5
  42. package/dist/sdk/testutils/test-writer.d.ts +7 -1
  43. package/dist/sdk/testutils/test-writer.js +13 -1
  44. package/dist/sdk/types/global.d.ts +8 -0
  45. package/dist/sdk/utils/capabilities/blockchain/solana/solana-helpers.js +1 -1
  46. package/dist/sdk/utils/values/consensus_aggregators.d.ts +16 -8
  47. package/dist/sdk/utils/values/consensus_aggregators.js +20 -3
  48. package/dist/sdk/utils/values/serializer_types.d.ts +1 -1
  49. package/dist/sdk/wasm/host-bindings.d.ts +4 -0
  50. package/dist/sdk/wasm/host-bindings.js +4 -0
  51. package/dist/sdk/wasm/runner.d.ts +10 -4
  52. package/dist/sdk/wasm/runner.js +86 -13
  53. package/dist/sdk/wasm/runtime.d.ts +4 -1
  54. package/dist/sdk/wasm/runtime.js +9 -1
  55. package/dist/sdk/workflow.d.ts +16 -7
  56. package/dist/sdk/workflow.js +10 -2
  57. package/dist/workflows/standard_tests/frequency_list/test.ts +75 -0
  58. package/dist/workflows/standard_tests/restrictions/test.ts +41 -0
  59. package/dist/workflows/standard_tests/tee_runtime/test.ts +29 -0
  60. package/package.json +2 -2
  61. package/scripts/src/generate-sdks.ts +6 -0
@@ -367,3 +367,119 @@ class ClientLogTrigger {
367
367
  return rawOutput;
368
368
  }
369
369
  }
370
+ export class ClientRestrictor {
371
+ ChainSelector;
372
+ constructor(ChainSelector) {
373
+ this.ChainSelector = ChainSelector;
374
+ }
375
+ limitGetAccountInfoWithOpts(maxCalls) {
376
+ // Include all labels in capability ID for routing when specified
377
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
378
+ return {
379
+ method: {
380
+ id: capabilityId,
381
+ method: 'GetAccountInfoWithOpts',
382
+ maxCalls,
383
+ },
384
+ };
385
+ }
386
+ limitGetBalance(maxCalls) {
387
+ // Include all labels in capability ID for routing when specified
388
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
389
+ return {
390
+ method: {
391
+ id: capabilityId,
392
+ method: 'GetBalance',
393
+ maxCalls,
394
+ },
395
+ };
396
+ }
397
+ limitGetBlock(maxCalls) {
398
+ // Include all labels in capability ID for routing when specified
399
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
400
+ return {
401
+ method: {
402
+ id: capabilityId,
403
+ method: 'GetBlock',
404
+ maxCalls,
405
+ },
406
+ };
407
+ }
408
+ limitGetFeeForMessage(maxCalls) {
409
+ // Include all labels in capability ID for routing when specified
410
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
411
+ return {
412
+ method: {
413
+ id: capabilityId,
414
+ method: 'GetFeeForMessage',
415
+ maxCalls,
416
+ },
417
+ };
418
+ }
419
+ limitGetMultipleAccountsWithOpts(maxCalls) {
420
+ // Include all labels in capability ID for routing when specified
421
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
422
+ return {
423
+ method: {
424
+ id: capabilityId,
425
+ method: 'GetMultipleAccountsWithOpts',
426
+ maxCalls,
427
+ },
428
+ };
429
+ }
430
+ limitGetProgramAccounts(maxCalls) {
431
+ // Include all labels in capability ID for routing when specified
432
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
433
+ return {
434
+ method: {
435
+ id: capabilityId,
436
+ method: 'GetProgramAccounts',
437
+ maxCalls,
438
+ },
439
+ };
440
+ }
441
+ limitGetSignatureStatuses(maxCalls) {
442
+ // Include all labels in capability ID for routing when specified
443
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
444
+ return {
445
+ method: {
446
+ id: capabilityId,
447
+ method: 'GetSignatureStatuses',
448
+ maxCalls,
449
+ },
450
+ };
451
+ }
452
+ limitGetSlotHeight(maxCalls) {
453
+ // Include all labels in capability ID for routing when specified
454
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
455
+ return {
456
+ method: {
457
+ id: capabilityId,
458
+ method: 'GetSlotHeight',
459
+ maxCalls,
460
+ },
461
+ };
462
+ }
463
+ limitGetTransaction(maxCalls) {
464
+ // Include all labels in capability ID for routing when specified
465
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
466
+ return {
467
+ method: {
468
+ id: capabilityId,
469
+ method: 'GetTransaction',
470
+ maxCalls,
471
+ },
472
+ };
473
+ }
474
+ limitWriteReport(maxCalls) {
475
+ // Include all labels in capability ID for routing when specified
476
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
477
+ return {
478
+ method: {
479
+ id: capabilityId,
480
+ method: 'WriteReport',
481
+ maxCalls,
482
+ },
483
+ };
484
+ }
485
+ }
@@ -1,4 +1,4 @@
1
- import { type ReportRequest, type ReportRequestJson, type SimpleConsensusInputs, type SimpleConsensusInputsJson } from '../../../../../generated/sdk/v1alpha/sdk_pb';
1
+ import { type CapabilityRestrictionJson, type ReportRequest, type ReportRequestJson, type SimpleConsensusInputs, type SimpleConsensusInputsJson } from '../../../../../generated/sdk/v1alpha/sdk_pb';
2
2
  import { type Value } from '../../../../../generated/values/v1/values_pb';
3
3
  import type { Runtime } from '../../../../../sdk';
4
4
  import { Report } from '../../../../../sdk/report';
@@ -22,3 +22,7 @@ export declare class ConsensusCapability {
22
22
  result: () => Report;
23
23
  };
24
24
  }
25
+ export declare class ConsensusRestrictor {
26
+ limitSimple(maxCalls: number): CapabilityRestrictionJson;
27
+ limitReport(maxCalls: number): CapabilityRestrictionJson;
28
+ }
@@ -68,3 +68,25 @@ export class ConsensusCapability {
68
68
  };
69
69
  }
70
70
  }
71
+ export class ConsensusRestrictor {
72
+ limitSimple(maxCalls) {
73
+ const capabilityId = ConsensusCapability.CAPABILITY_ID;
74
+ return {
75
+ method: {
76
+ id: capabilityId,
77
+ method: 'Simple',
78
+ maxCalls,
79
+ },
80
+ };
81
+ }
82
+ limitReport(maxCalls) {
83
+ const capabilityId = ConsensusCapability.CAPABILITY_ID;
84
+ return {
85
+ method: {
86
+ id: capabilityId,
87
+ method: 'Report',
88
+ maxCalls,
89
+ },
90
+ };
91
+ }
92
+ }
@@ -1,4 +1,5 @@
1
1
  import { type ConfidentialHTTPRequest, type ConfidentialHTTPRequestJson, type HTTPResponse } from '../../../../../generated/capabilities/networking/confidentialhttp/v1alpha/client_pb';
2
+ import type { CapabilityRestrictionJson } from '../../../../../generated/sdk/v1alpha/sdk_pb';
2
3
  import type { Runtime } from '../../../../../sdk';
3
4
  import type { CapabilityInput } from '../../../../../sdk/utils/types/no-excess';
4
5
  /**
@@ -17,3 +18,6 @@ export declare class ClientCapability {
17
18
  result: () => HTTPResponse;
18
19
  };
19
20
  }
21
+ export declare class ClientRestrictor {
22
+ limitSendRequest(maxCalls: number): CapabilityRestrictionJson;
23
+ }
@@ -41,3 +41,15 @@ export class ClientCapability {
41
41
  };
42
42
  }
43
43
  }
44
+ export class ClientRestrictor {
45
+ limitSendRequest(maxCalls) {
46
+ const capabilityId = ClientCapability.CAPABILITY_ID;
47
+ return {
48
+ method: {
49
+ id: capabilityId,
50
+ method: 'SendRequest',
51
+ maxCalls,
52
+ },
53
+ };
54
+ }
55
+ }
@@ -1,5 +1,6 @@
1
1
  import { type Request, type RequestJson, type Response } from '../../../../../generated/capabilities/networking/http/v1alpha/client_pb';
2
- import type { NodeRuntime, Runtime } from '../../../../../sdk';
2
+ import type { CapabilityRestrictionJson } from '../../../../../generated/sdk/v1alpha/sdk_pb';
3
+ import type { NodeRuntime, Runtime, TeeRuntime } from '../../../../../sdk';
3
4
  import type { ConsensusAggregation, PrimitiveTypes, UnwrapOptions } from '../../../../../sdk/utils';
4
5
  import type { CapabilityInput } from '../../../../../sdk/utils/types/no-excess';
5
6
  export declare class SendRequester {
@@ -22,12 +23,21 @@ export declare class ClientCapability {
22
23
  static readonly CAPABILITY_ID = "http-actions@1.0.0-alpha";
23
24
  static readonly CAPABILITY_NAME = "http-actions";
24
25
  static readonly CAPABILITY_VERSION = "1.0.0-alpha";
26
+ sendRequest<TInput>(runtime: TeeRuntime<unknown>, input: CapabilityInput<TInput, Request, RequestJson>): {
27
+ result: () => Response;
28
+ };
25
29
  sendRequest<TInput>(runtime: NodeRuntime<unknown>, input: CapabilityInput<TInput, Request, RequestJson>): {
26
30
  result: () => Response;
27
31
  };
28
- sendRequest<TArgs extends unknown[], TOutput>(runtime: Runtime<unknown>, fn: (sendRequester: SendRequester, ...args: TArgs) => TOutput, consensusAggregation: ConsensusAggregation<TOutput, true>, unwrapOptions?: TOutput extends PrimitiveTypes ? never : UnwrapOptions<TOutput>): (...args: TArgs) => {
32
+ sendRequest<TInput>(runtime: NodeRuntime<unknown> | TeeRuntime<unknown>, input: CapabilityInput<TInput, Request, RequestJson>): {
33
+ result: () => Response;
34
+ };
35
+ sendRequest<TArgs extends unknown[], TInput, TOutput = TInput>(runtime: Runtime<unknown>, fn: (sendRequester: SendRequester, ...args: TArgs) => TInput, consensusAggregation: ConsensusAggregation<TInput, TOutput, true>, unwrapOptions?: TInput extends PrimitiveTypes ? never : UnwrapOptions<TInput>): (...args: TArgs) => {
29
36
  result: () => TOutput;
30
37
  };
31
38
  private sendRequestCallHelper;
32
39
  private sendRequestSugarHelper;
33
40
  }
41
+ export declare class ClientRestrictor {
42
+ limitSendRequest(maxCalls: number): CapabilityRestrictionJson;
43
+ }
@@ -68,3 +68,15 @@ export class ClientCapability {
68
68
  return runtime.runInNodeMode(wrappedFn, consensusAggregation, unwrapOptions);
69
69
  }
70
70
  }
71
+ export class ClientRestrictor {
72
+ limitSendRequest(maxCalls) {
73
+ const capabilityId = ClientCapability.CAPABILITY_ID;
74
+ return {
75
+ method: {
76
+ id: capabilityId,
77
+ method: 'SendRequest',
78
+ maxCalls,
79
+ },
80
+ };
81
+ }
82
+ }
@@ -36,4 +36,6 @@ declare class HTTPTrigger implements Trigger<Payload, Payload> {
36
36
  */
37
37
  adapt(rawOutput: Payload): Payload;
38
38
  }
39
+ export declare class HTTPRestrictor {
40
+ }
39
41
  export {};
@@ -53,3 +53,5 @@ class HTTPTrigger {
53
53
  return rawOutput;
54
54
  }
55
55
  }
56
+ export class HTTPRestrictor {
57
+ }
@@ -36,4 +36,6 @@ declare class CronTrigger implements Trigger<Payload, Payload> {
36
36
  */
37
37
  adapt(rawOutput: Payload): Payload;
38
38
  }
39
+ export declare class CronRestrictor {
40
+ }
39
41
  export {};
@@ -53,3 +53,5 @@ class CronTrigger {
53
53
  return rawOutput;
54
54
  }
55
55
  }
56
+ export class CronRestrictor {
57
+ }
@@ -1,12 +1,13 @@
1
1
  /**
2
2
  * Public API for the CRE SDK.
3
3
  */
4
- import { ClientCapability as EVMClient } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
5
- import { ClientCapability as SolanaClient } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
6
- import { ClientCapability as ConfidentialHTTPClient } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
7
- import { ClientCapability as HTTPClient } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
8
- import { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
9
- import { CronCapability } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
4
+ import { ClientCapability as AptosClient, ClientRestrictor as AptosRestrictor } from '../../generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen';
5
+ import { ClientCapability as EVMClient, ClientRestrictor as EVMRestrictor } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
6
+ import { ClientCapability as SolanaClient, ClientRestrictor as SolanaRestrictor } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
7
+ import { ClientCapability as ConfidentialHTTPClient, ClientRestrictor as ConfidentialHTTPRestrictor } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
8
+ import { ClientCapability as HTTPClient, ClientRestrictor as HTTPClientRestrictor } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
9
+ import { HTTPCapability, HTTPRestrictor } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
10
+ import { CronCapability, CronRestrictor } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
10
11
  /**
11
12
  * Public exports for the CRE SDK.
12
13
  */
@@ -14,14 +15,17 @@ export { type Log as EVMLog, TxStatus, } from '../../generated/capabilities/bloc
14
15
  export { ComparisonOperator as SolanaComparisonOperator, type CPIFilterConfigJson as SolanaCPIFilterConfigJson, type FilterLogTriggerRequestJson as SolanaFilterLogTriggerRequestJson, type Log as SolanaLog, ReceiverContractExecutionStatus as SolanaReceiverContractExecutionStatus, type SubkeyConfigJson as SolanaSubkeyConfigJson, TxStatus as SolanaTxStatus, type ValueComparatorJson as SolanaValueComparatorJson, } from '../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
15
16
  export type { Payload as HTTPPayload } from '../../generated/capabilities/networking/http/v1alpha/trigger_pb';
16
17
  export type { Payload as CronPayload } from '../../generated/capabilities/scheduler/cron/v1/trigger_pb';
17
- export { ClientCapability as EVMClient, type WriteCreReportRequest, type WriteCreReportRequestJson, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
18
- export { ClientCapability as SolanaClient, type WriteCreReportRequest as SolanaWriteCreReportRequest, type WriteCreReportRequestJson as SolanaWriteCreReportRequestJson, } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
19
- export { ClientCapability as ConfidentialHTTPClient } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
20
- export { ClientCapability as HTTPClient, type SendRequester as HTTPSendRequester, } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
21
- export { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
22
- export { CronCapability } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
23
- export type { NodeRuntime, Runtime } from '../runtime';
24
- export { handler } from '../workflow';
18
+ export { TeeType } from '../../generated/sdk/v1alpha/sdk_pb';
19
+ export { ClientCapability as AptosClient, ClientRestrictor as AptosRestrictor, type WriteCreReportRequest as AptosWriteCreReportRequest, type WriteCreReportRequestJson as AptosWriteCreReportRequestJson, } from '../../generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen';
20
+ export { ClientCapability as EVMClient, ClientRestrictor as EVMRestrictor, type WriteCreReportRequest, type WriteCreReportRequestJson, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
21
+ export { ClientCapability as SolanaClient, ClientRestrictor as SolanaRestrictor, type WriteCreReportRequest as SolanaWriteCreReportRequest, type WriteCreReportRequestJson as SolanaWriteCreReportRequestJson, } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
22
+ export { ClientCapability as ConfidentialHTTPClient, ClientRestrictor as ConfidentialHTTPRestrictor, } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
23
+ export { ClientCapability as HTTPClient, ClientRestrictor as HTTPClientRestrictor, type SendRequester as HTTPSendRequester, } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
24
+ export { HTTPCapability, HTTPRestrictor, } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
25
+ export { CronCapability, CronRestrictor, } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
26
+ export type { NodeRuntime, Runtime, TeeRuntime } from '../runtime';
27
+ export type { AnyTeeConstraint, NitroBinding, NitroRegion, OneOfTees, Region, TeeBinding, TeeConstraint, } from '../workflow';
28
+ export { handler, handlerInTee, NITRO_REGIONS, REGIONS } from '../workflow';
25
29
  export declare const cre: {
26
30
  capabilities: {
27
31
  CronCapability: typeof CronCapability;
@@ -29,7 +33,18 @@ export declare const cre: {
29
33
  ConfidentialHTTPClient: typeof ConfidentialHTTPClient;
30
34
  HTTPClient: typeof HTTPClient;
31
35
  EVMClient: typeof EVMClient;
36
+ AptosClient: typeof AptosClient;
32
37
  SolanaClient: typeof SolanaClient;
33
38
  };
34
- handler: <TRawTriggerOutput extends import("@bufbuild/protobuf").Message<string>, TTriggerOutput, TConfig, TResult>(trigger: import("..").Trigger<TRawTriggerOutput, TTriggerOutput>, fn: import("../workflow").HandlerFn<TConfig, TTriggerOutput, TResult>) => import("../workflow").HandlerEntry<TConfig, TRawTriggerOutput, TTriggerOutput, TResult>;
39
+ restrictors: {
40
+ CronRestrictor: typeof CronRestrictor;
41
+ HTTPRestrictor: typeof HTTPRestrictor;
42
+ ConfidentialHTTPRestrictor: typeof ConfidentialHTTPRestrictor;
43
+ HTTPClientRestrictor: typeof HTTPClientRestrictor;
44
+ EVMRestrictor: typeof EVMRestrictor;
45
+ SolanaRestrictor: typeof SolanaRestrictor;
46
+ AptosRestrictor: typeof AptosRestrictor;
47
+ };
48
+ handler: <TRawTriggerOutput extends import("@bufbuild/protobuf").Message<string>, TTriggerOutput, TConfig, TResult, TRuntime = import("../runtime").Runtime<TConfig>>(trigger: import("..").Trigger<TRawTriggerOutput, TTriggerOutput>, fn: import("../workflow").HandlerFn<TConfig, TTriggerOutput, TResult, TRuntime>, hooks?: import("../workflow").Hooks<TConfig, TTriggerOutput>) => import("../workflow").HandlerEntry<TConfig, TRawTriggerOutput, TTriggerOutput, TResult, TRuntime>;
49
+ handlerInTee: <TRawTriggerOutput extends import("@bufbuild/protobuf").Message<string>, TTriggerOutput, TConfig, TResult>(trigger: import("..").Trigger<TRawTriggerOutput, TTriggerOutput>, fn: import("../workflow").HandlerFn<TConfig, TTriggerOutput, TResult, import("../runtime").TeeRuntime<TConfig>>, tees: import("../workflow").TeeConstraint, hooks?: import("../workflow").Hooks<TConfig, TTriggerOutput>) => import("../workflow").HandlerEntry<TConfig, TRawTriggerOutput, TTriggerOutput, TResult, import("../runtime").TeeRuntime<TConfig>>;
35
50
  };
@@ -1,31 +1,35 @@
1
1
  /**
2
2
  * Public API for the CRE SDK.
3
3
  */
4
- import { ClientCapability as EVMClient } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
5
- import { ClientCapability as SolanaClient } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
6
- import { ClientCapability as ConfidentialHTTPClient } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
7
- import { ClientCapability as HTTPClient } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
8
- import { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
9
- import { CronCapability } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
4
+ import { ClientCapability as AptosClient, ClientRestrictor as AptosRestrictor, } from '../../generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen';
5
+ import { ClientCapability as EVMClient, ClientRestrictor as EVMRestrictor, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
6
+ import { ClientCapability as SolanaClient, ClientRestrictor as SolanaRestrictor, } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
7
+ import { ClientCapability as ConfidentialHTTPClient, ClientRestrictor as ConfidentialHTTPRestrictor, } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
8
+ import { ClientCapability as HTTPClient, ClientRestrictor as HTTPClientRestrictor, } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
9
+ import { HTTPCapability, HTTPRestrictor, } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
10
+ import { CronCapability, CronRestrictor, } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
10
11
  import { prepareRuntime } from '../utils/prepare-runtime';
11
- import { handler } from '../workflow';
12
+ import { handler, handlerInTee } from '../workflow';
12
13
  /**
13
14
  * Public exports for the CRE SDK.
14
15
  */
15
16
  export { TxStatus, } from '../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
16
17
  export { ComparisonOperator as SolanaComparisonOperator, ReceiverContractExecutionStatus as SolanaReceiverContractExecutionStatus, TxStatus as SolanaTxStatus, } from '../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
18
+ export { TeeType } from '../../generated/sdk/v1alpha/sdk_pb';
19
+ // Aptos Capability
20
+ export { ClientCapability as AptosClient, ClientRestrictor as AptosRestrictor, } from '../../generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen';
17
21
  // EVM Capability
18
- export { ClientCapability as EVMClient, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
22
+ export { ClientCapability as EVMClient, ClientRestrictor as EVMRestrictor, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
19
23
  // Solana Capability
20
- export { ClientCapability as SolanaClient, } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
24
+ export { ClientCapability as SolanaClient, ClientRestrictor as SolanaRestrictor, } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
21
25
  // Confidential HTTP Capability
22
- export { ClientCapability as ConfidentialHTTPClient } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
26
+ export { ClientCapability as ConfidentialHTTPClient, ClientRestrictor as ConfidentialHTTPRestrictor, } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
23
27
  // HTTP Capability
24
- export { ClientCapability as HTTPClient, } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
25
- export { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
28
+ export { ClientCapability as HTTPClient, ClientRestrictor as HTTPClientRestrictor, } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
29
+ export { HTTPCapability, HTTPRestrictor, } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
26
30
  // CRON Capability
27
- export { CronCapability } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
28
- export { handler } from '../workflow';
31
+ export { CronCapability, CronRestrictor, } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
32
+ export { handler, handlerInTee, NITRO_REGIONS, REGIONS } from '../workflow';
29
33
  prepareRuntime();
30
34
  export const cre = {
31
35
  capabilities: {
@@ -34,7 +38,18 @@ export const cre = {
34
38
  ConfidentialHTTPClient,
35
39
  HTTPClient,
36
40
  EVMClient,
41
+ AptosClient,
37
42
  SolanaClient,
38
43
  },
44
+ restrictors: {
45
+ CronRestrictor,
46
+ HTTPRestrictor,
47
+ ConfidentialHTTPRestrictor,
48
+ HTTPClientRestrictor,
49
+ EVMRestrictor,
50
+ SolanaRestrictor,
51
+ AptosRestrictor,
52
+ },
39
53
  handler,
54
+ handlerInTee,
40
55
  };
@@ -1,6 +1,6 @@
1
1
  import { type Message } from '@bufbuild/protobuf';
2
2
  import { type AwaitCapabilitiesRequest, type AwaitCapabilitiesResponse, type AwaitSecretsRequest, type AwaitSecretsResponse, type CapabilityRequest, type GetSecretsRequest, Mode, type Secret, type SecretRequest, type SecretRequestJson } from '../../generated/sdk/v1alpha/sdk_pb';
3
- import type { BaseRuntime, CallCapabilityParams, NodeRuntime, ReportRequest, ReportRequestJson, Runtime } from '..';
3
+ import type { BaseRuntime, CallCapabilityParams, NodeRuntime, ReportRequest, ReportRequestJson, Runtime, TeeRuntime } from '..';
4
4
  import type { Report } from '../report';
5
5
  import { type ConsensusAggregation, type PrimitiveTypes, type UnwrapOptions } from '../utils';
6
6
  /**
@@ -44,7 +44,10 @@ export declare class BaseRuntimeImpl<C> implements BaseRuntime<C> {
44
44
  now(): Date;
45
45
  sleep(ms: number): void;
46
46
  log(message: string): void;
47
+ emitMetric(name: string, value: number, type: MetricType, labels?: Record<string, string>): boolean;
47
48
  }
49
+ /** Ergonomic union for {@link BaseRuntimeImpl.emitMetric}. */
50
+ export type MetricType = 'counter' | 'gauge';
48
51
  /**
49
52
  * It is used when a BFT guarantee cannot be provided automatically (e.g. calling a standard API).
50
53
  * You tell each node to perform a task on its own.
@@ -75,7 +78,7 @@ export declare class RuntimeImpl<C> extends BaseRuntimeImpl<C> implements Runtim
75
78
  * 5. Runs consensus to aggregate observations
76
79
  * 6. Returns aggregated result
77
80
  */
78
- runInNodeMode<TArgs extends unknown[], TOutput>(fn: (nodeRuntime: NodeRuntime<C>, ...args: TArgs) => TOutput, consensusAggregation: ConsensusAggregation<TOutput, true>, unwrapOptions?: TOutput extends PrimitiveTypes ? never : UnwrapOptions<TOutput>): (...args: TArgs) => {
81
+ runInNodeMode<TArgs extends unknown[], TInput, TOutput = TInput>(fn: (nodeRuntime: NodeRuntime<C>, ...args: TArgs) => TInput, consensusAggregation: ConsensusAggregation<TInput, TOutput, true>, unwrapOptions?: TInput extends PrimitiveTypes ? never : UnwrapOptions<TInput>): (...args: TArgs) => {
79
82
  result: () => TOutput;
80
83
  };
81
84
  private prepareConsensusInput;
@@ -94,6 +97,25 @@ export declare class RuntimeImpl<C> extends BaseRuntimeImpl<C> implements Runtim
94
97
  result: () => Report;
95
98
  };
96
99
  }
100
+ export declare class TeeRuntimeImpl<C> implements TeeRuntime<C> {
101
+ config: C;
102
+ nextCallId: number;
103
+ private readonly runtime;
104
+ constructor(config: C, nextCallId: number, helpers: RuntimeHelpers, maxResponseSize: bigint);
105
+ getSecret(request: SecretRequest | SecretRequestJson): {
106
+ result: () => Secret;
107
+ };
108
+ now(): Date;
109
+ log(message: string): void;
110
+ emitMetric(name: string, value: number, type: MetricType, labels?: Record<string, string>): boolean;
111
+ callCapability<I extends Message, O extends Message>({ capabilityId, method, payload, inputSchema, outputSchema, }: CallCapabilityParams<I, O>): {
112
+ result: () => O;
113
+ };
114
+ reportFromDon(input: ReportRequest | ReportRequestJson): {
115
+ result: () => Report;
116
+ };
117
+ usingTheDons(): Runtime<C>;
118
+ }
97
119
  /**
98
120
  * Interface to the WASM host environment.
99
121
  * Provides low-level access to capabilities, secrets, and utilities.
@@ -115,4 +137,9 @@ export interface RuntimeHelpers {
115
137
  sleep(ms: number): void;
116
138
  /** Logs a message to the host environment. */
117
139
  log(message: string): void;
140
+ /**
141
+ * Emits a user metric to the host. Payload is a protobuf-encoded
142
+ * `workflows.v2.WorkflowUserMetric`. Returns false if the host rejected it.
143
+ */
144
+ emitMetric(payload: Uint8Array): boolean;
118
145
  }
@@ -1,7 +1,8 @@
1
- import { create } from '@bufbuild/protobuf';
1
+ import { create, toBinary } from '@bufbuild/protobuf';
2
2
  import { anyPack, anyUnpack } from '@bufbuild/protobuf/wkt';
3
3
  import { deserializeErrorFromString } from '../../capabilities/errors';
4
4
  import { AwaitCapabilitiesRequestSchema, AwaitSecretsRequestSchema, CapabilityRequestSchema, GetSecretsRequestSchema, Mode, SecretRequestSchema, SimpleConsensusInputsSchema, } from '../../generated/sdk/v1alpha/sdk_pb';
5
+ import { UserMetricType, WorkflowUserMetricSchema, } from '../../generated/workflows/v2/workflow_user_metric_pb';
5
6
  import { ConsensusCapability } from '../../generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen';
6
7
  import { Value, } from '../utils';
7
8
  import { CapabilityRuntimeError, DonModeError, NodeModeError, SecretsError } from '../errors';
@@ -139,7 +140,20 @@ export class BaseRuntimeImpl {
139
140
  log(message) {
140
141
  this.helpers.log(message);
141
142
  }
143
+ emitMetric(name, value, type, labels) {
144
+ const metric = create(WorkflowUserMetricSchema, {
145
+ name,
146
+ value,
147
+ type: METRIC_TYPE_TO_PROTO[type],
148
+ labels: labels ?? {},
149
+ });
150
+ return this.helpers.emitMetric(toBinary(WorkflowUserMetricSchema, metric));
151
+ }
142
152
  }
153
+ const METRIC_TYPE_TO_PROTO = {
154
+ counter: UserMetricType.COUNTER,
155
+ gauge: UserMetricType.GAUGE,
156
+ };
143
157
  /**
144
158
  * It is used when a BFT guarantee cannot be provided automatically (e.g. calling a standard API).
145
159
  * You tell each node to perform a task on its own.
@@ -204,7 +218,7 @@ export class RuntimeImpl extends BaseRuntimeImpl {
204
218
  descriptors: consensusAggregation.descriptor,
205
219
  });
206
220
  if (consensusAggregation.defaultValue) {
207
- // Safe cast: ConsensusAggregation<T, true> implies T extends CreSerializable
221
+ // Safe cast: ConsensusAggregation<TInput, TOutput, true> implies TInput extends CreSerializable
208
222
  const defaultValue = Value.from(consensusAggregation.defaultValue).proto();
209
223
  clearIgnoredFields(defaultValue, consensusAggregation.descriptor);
210
224
  consensusInput.default = defaultValue;
@@ -212,7 +226,7 @@ export class RuntimeImpl extends BaseRuntimeImpl {
212
226
  return consensusInput;
213
227
  }
214
228
  captureObservation(consensusInput, observation, descriptor) {
215
- // Safe cast: ConsensusAggregation<T, true> implies T extends CreSerializable
229
+ // Safe cast: ConsensusAggregation<TInput, TOutput, true> implies TInput extends CreSerializable
216
230
  const observationValue = Value.from(observation).proto();
217
231
  clearIgnoredFields(observationValue, descriptor);
218
232
  consensusInput.observation = {
@@ -239,9 +253,7 @@ export class RuntimeImpl extends BaseRuntimeImpl {
239
253
  result: () => {
240
254
  const result = call.result();
241
255
  const wrappedValue = Value.wrap(result);
242
- return unwrapOptions
243
- ? wrappedValue.unwrapToType(unwrapOptions)
244
- : wrappedValue.unwrap();
256
+ return (unwrapOptions ? wrappedValue.unwrapToType(unwrapOptions) : wrappedValue.unwrap());
245
257
  },
246
258
  };
247
259
  }
@@ -321,6 +333,43 @@ export class RuntimeImpl extends BaseRuntimeImpl {
321
333
  };
322
334
  }
323
335
  }
336
+ export class TeeRuntimeImpl {
337
+ config;
338
+ nextCallId;
339
+ runtime;
340
+ constructor(config, nextCallId, helpers, maxResponseSize) {
341
+ this.config = config;
342
+ this.nextCallId = nextCallId;
343
+ this.runtime = new RuntimeImpl(config, nextCallId, helpers, maxResponseSize);
344
+ }
345
+ getSecret(request) {
346
+ return this.runtime.getSecret(request);
347
+ }
348
+ now() {
349
+ return this.runtime.now();
350
+ }
351
+ log(message) {
352
+ this.runtime.log(message);
353
+ }
354
+ emitMetric(name, value, type, labels) {
355
+ return this.runtime.emitMetric(name, value, type, labels);
356
+ }
357
+ callCapability({ capabilityId, method, payload, inputSchema, outputSchema, }) {
358
+ return this.runtime.callCapability({
359
+ capabilityId,
360
+ method,
361
+ payload,
362
+ inputSchema,
363
+ outputSchema,
364
+ });
365
+ }
366
+ reportFromDon(input) {
367
+ return this.runtime.report(input);
368
+ }
369
+ usingTheDons() {
370
+ return this.runtime;
371
+ }
372
+ }
324
373
  function clearIgnoredFields(value, descriptor) {
325
374
  if (!descriptor || !value) {
326
375
  return;
@@ -1,10 +1,11 @@
1
1
  import type { Message } from '@bufbuild/protobuf';
2
2
  import type { GenMessage } from '@bufbuild/protobuf/codegenv2';
3
3
  import type { ReportRequest, ReportRequestJson } from '../generated/sdk/v1alpha/sdk_pb';
4
+ import type { MetricType } from './impl/runtime-impl';
4
5
  import type { Report } from './report';
5
6
  import type { ConsensusAggregation, PrimitiveTypes, UnwrapOptions } from './utils';
6
7
  import type { SecretsProvider } from '.';
7
- export type { ReportRequest, ReportRequestJson };
8
+ export type { ReportRequest, ReportRequestJson, MetricType };
8
9
  export type CallCapabilityParams<I extends Message, O extends Message> = {
9
10
  capabilityId: string;
10
11
  method: string;
@@ -23,6 +24,7 @@ export interface BaseRuntime<C> {
23
24
  };
24
25
  now(): Date;
25
26
  log(message: string): void;
27
+ emitMetric(name: string, value: number, type: MetricType, labels?: Record<string, string>): boolean;
26
28
  }
27
29
  /**
28
30
  * Runtime for Node mode execution.
@@ -30,6 +32,26 @@ export interface BaseRuntime<C> {
30
32
  export interface NodeRuntime<C> extends BaseRuntime<C> {
31
33
  readonly _isNodeRuntime: true;
32
34
  }
35
+ /**
36
+ * Runtime for Tee mode execution.
37
+ */
38
+ export interface TeeRuntime<C> extends BaseRuntime<C>, SecretsProvider {
39
+ /**
40
+ * Generates a report from the DON.
41
+ * Data requestsed throught this method will be routed outside of the TEE.
42
+ *
43
+ * @param input - Report request to generate a report from the DON
44
+ * @returns Report generated from the DON
45
+ */
46
+ reportFromDon(input: ReportRequest | ReportRequestJson): {
47
+ result: () => Report;
48
+ };
49
+ /**
50
+ * Returns the runtime that makes requests to the CRE DONs.
51
+ * Requests made through this runtime will therefore be routed outside of the TEE
52
+ */
53
+ usingTheDons(): Runtime<C>;
54
+ }
33
55
  /**
34
56
  * Runtime for DON mode execution.
35
57
  */
@@ -42,7 +64,7 @@ export interface Runtime<C> extends BaseRuntime<C>, SecretsProvider {
42
64
  * @param unwrapOptions - Optional unwrapping config for complex return types
43
65
  * @returns Wrapped function that returns aggregated result
44
66
  */
45
- runInNodeMode<TArgs extends unknown[], TOutput>(fn: (nodeRuntime: NodeRuntime<C>, ...args: TArgs) => TOutput, consensusAggregation: ConsensusAggregation<TOutput, true>, unwrapOptions?: TOutput extends PrimitiveTypes ? never : UnwrapOptions<TOutput>): (...args: TArgs) => {
67
+ runInNodeMode<TArgs extends unknown[], TInput, TOutput = TInput>(fn: (nodeRuntime: NodeRuntime<C>, ...args: TArgs) => TInput, consensusAggregation: ConsensusAggregation<TInput, TOutput, true>, unwrapOptions?: TInput extends PrimitiveTypes ? never : UnwrapOptions<TInput>): (...args: TArgs) => {
46
68
  result: () => TOutput;
47
69
  };
48
70
  report(input: ReportRequest | ReportRequestJson): {