@chainlink/cre-sdk 1.17.0-alpha.1 → 1.17.0-alpha.2

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 (80) hide show
  1. package/README.md +62 -2
  2. package/dist/generated/chain-selectors/testnet/evm/glamsterdam-devnet-6.d.ts +3 -0
  3. package/dist/generated/chain-selectors/testnet/evm/glamsterdam-devnet-6.js +12 -0
  4. package/dist/generated/chain-selectors/testnet/evm/t-rex-testnet.d.ts +3 -0
  5. package/dist/generated/chain-selectors/testnet/evm/t-rex-testnet.js +12 -0
  6. package/dist/generated/networks.d.ts +1 -1
  7. package/dist/generated/networks.js +14 -0
  8. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.d.ts +0 -13
  9. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.js +0 -94
  10. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.d.ts +0 -15
  11. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +0 -116
  12. package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.d.ts +1 -5
  13. package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.js +0 -22
  14. package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.d.ts +0 -4
  15. package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.js +0 -12
  16. package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.d.ts +1 -11
  17. package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.js +0 -12
  18. package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.d.ts +0 -2
  19. package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.js +0 -2
  20. package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.d.ts +0 -2
  21. package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.js +0 -2
  22. package/dist/sdk/cre/index.d.ts +16 -31
  23. package/dist/sdk/cre/index.js +15 -30
  24. package/dist/sdk/impl/runtime-impl.d.ts +1 -28
  25. package/dist/sdk/impl/runtime-impl.js +1 -52
  26. package/dist/sdk/runtime.d.ts +1 -23
  27. package/dist/sdk/test/contract-mock-core.d.ts +16 -0
  28. package/dist/sdk/test/contract-mock-core.js +21 -0
  29. package/dist/sdk/test/evm-contract-mock.js +60 -58
  30. package/dist/sdk/test/generated/index.d.ts +0 -1
  31. package/dist/sdk/test/generated/index.js +0 -1
  32. package/dist/sdk/test/index.d.ts +1 -0
  33. package/dist/sdk/test/index.js +1 -0
  34. package/dist/sdk/test/solana-contract-mock.d.ts +54 -0
  35. package/dist/sdk/test/solana-contract-mock.js +63 -0
  36. package/dist/sdk/testutils/index.d.ts +1 -1
  37. package/dist/sdk/testutils/index.js +1 -1
  38. package/dist/sdk/testutils/test-runtime.d.ts +4 -17
  39. package/dist/sdk/testutils/test-runtime.js +5 -31
  40. package/dist/sdk/testutils/test-writer.d.ts +1 -7
  41. package/dist/sdk/testutils/test-writer.js +1 -13
  42. package/dist/sdk/types/global.d.ts +0 -8
  43. package/dist/sdk/utils/capabilities/blockchain/{blockchain-helpers.d.ts → evm/evm-helpers.d.ts} +7 -6
  44. package/dist/sdk/utils/capabilities/blockchain/{blockchain-helpers.js → evm/evm-helpers.js} +6 -8
  45. package/dist/sdk/utils/capabilities/blockchain/report-helpers.d.ts +19 -0
  46. package/dist/sdk/utils/capabilities/blockchain/report-helpers.js +16 -0
  47. package/dist/sdk/utils/capabilities/blockchain/solana/solana-helpers.d.ts +165 -0
  48. package/dist/sdk/utils/capabilities/blockchain/solana/solana-helpers.js +176 -0
  49. package/dist/sdk/utils/hex-utils.d.ts +6 -0
  50. package/dist/sdk/utils/hex-utils.js +8 -0
  51. package/dist/sdk/utils/index.d.ts +4 -1
  52. package/dist/sdk/utils/index.js +3 -1
  53. package/dist/sdk/utils/triggers/trigger-interface.d.ts +7 -0
  54. package/dist/sdk/utils/triggers/trigger-interface.js +13 -1
  55. package/dist/sdk/wasm/host-bindings.d.ts +0 -4
  56. package/dist/sdk/wasm/host-bindings.js +0 -4
  57. package/dist/sdk/wasm/runner.d.ts +4 -10
  58. package/dist/sdk/wasm/runner.js +13 -86
  59. package/dist/sdk/wasm/runtime.d.ts +1 -4
  60. package/dist/sdk/wasm/runtime.js +1 -9
  61. package/dist/sdk/workflow.d.ts +7 -16
  62. package/dist/sdk/workflow.js +2 -10
  63. package/package.json +7 -4
  64. package/scripts/src/generate-sdks.ts +0 -6
  65. package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.d.ts +0 -1035
  66. package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.js +0 -290
  67. package/dist/generated/workflows/v2/cre_info_pb.d.ts +0 -123
  68. package/dist/generated/workflows/v2/cre_info_pb.js +0 -17
  69. package/dist/generated/workflows/v2/workflow_key_pb.d.ts +0 -55
  70. package/dist/generated/workflows/v2/workflow_key_pb.js +0 -17
  71. package/dist/generated/workflows/v2/workflow_user_metric_pb.d.ts +0 -118
  72. package/dist/generated/workflows/v2/workflow_user_metric_pb.js +0 -41
  73. package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.d.ts +0 -63
  74. package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.js +0 -247
  75. package/dist/sdk/tee-constraints.d.ts +0 -68
  76. package/dist/sdk/tee-constraints.js +0 -59
  77. package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.d.ts +0 -25
  78. package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.js +0 -111
  79. package/dist/workflows/standard_tests/restrictions/test.ts +0 -41
  80. package/dist/workflows/standard_tests/tee_runtime/test.ts +0 -29
@@ -53,5 +53,3 @@ class CronTrigger {
53
53
  return rawOutput;
54
54
  }
55
55
  }
56
- export class CronRestrictor {
57
- }
@@ -1,31 +1,27 @@
1
1
  /**
2
2
  * Public API for the CRE SDK.
3
3
  */
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';
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';
11
10
  /**
12
11
  * Public exports for the CRE SDK.
13
12
  */
14
13
  export { type Log as EVMLog, TxStatus, } from '../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
15
- export { ReceiverContractExecutionStatus as SolanaReceiverContractExecutionStatus, TxStatus as SolanaTxStatus, } from '../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
14
+ 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';
16
15
  export type { Payload as HTTPPayload } from '../../generated/capabilities/networking/http/v1alpha/trigger_pb';
17
16
  export type { Payload as CronPayload } from '../../generated/capabilities/scheduler/cron/v1/trigger_pb';
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';
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';
29
25
  export declare const cre: {
30
26
  capabilities: {
31
27
  CronCapability: typeof CronCapability;
@@ -33,18 +29,7 @@ export declare const cre: {
33
29
  ConfidentialHTTPClient: typeof ConfidentialHTTPClient;
34
30
  HTTPClient: typeof HTTPClient;
35
31
  EVMClient: typeof EVMClient;
36
- AptosClient: typeof AptosClient;
37
32
  SolanaClient: typeof SolanaClient;
38
33
  };
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("../utils/triggers/trigger-interface").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("../utils/triggers/trigger-interface").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>>;
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>;
50
35
  };
@@ -1,35 +1,31 @@
1
1
  /**
2
2
  * Public API for the CRE SDK.
3
3
  */
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';
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';
11
10
  import { prepareRuntime } from '../utils/prepare-runtime';
12
- import { handler, handlerInTee } from '../workflow';
11
+ import { handler } from '../workflow';
13
12
  /**
14
13
  * Public exports for the CRE SDK.
15
14
  */
16
15
  export { TxStatus, } from '../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
17
- export { 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';
16
+ export { ComparisonOperator as SolanaComparisonOperator, ReceiverContractExecutionStatus as SolanaReceiverContractExecutionStatus, TxStatus as SolanaTxStatus, } from '../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
21
17
  // EVM Capability
22
- export { ClientCapability as EVMClient, ClientRestrictor as EVMRestrictor, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
18
+ export { ClientCapability as EVMClient, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
23
19
  // Solana Capability
24
- export { ClientCapability as SolanaClient, ClientRestrictor as SolanaRestrictor, } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
20
+ export { ClientCapability as SolanaClient, } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
25
21
  // Confidential HTTP Capability
26
- export { ClientCapability as ConfidentialHTTPClient, ClientRestrictor as ConfidentialHTTPRestrictor, } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
22
+ export { ClientCapability as ConfidentialHTTPClient } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
27
23
  // HTTP Capability
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';
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';
30
26
  // CRON Capability
31
- export { CronCapability, CronRestrictor, } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
32
- export { handler, handlerInTee, NITRO_REGIONS, REGIONS } from '../workflow';
27
+ export { CronCapability } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
28
+ export { handler } from '../workflow';
33
29
  prepareRuntime();
34
30
  export const cre = {
35
31
  capabilities: {
@@ -38,18 +34,7 @@ export const cre = {
38
34
  ConfidentialHTTPClient,
39
35
  HTTPClient,
40
36
  EVMClient,
41
- AptosClient,
42
37
  SolanaClient,
43
38
  },
44
- restrictors: {
45
- CronRestrictor,
46
- HTTPRestrictor,
47
- ConfidentialHTTPRestrictor,
48
- HTTPClientRestrictor,
49
- EVMRestrictor,
50
- SolanaRestrictor,
51
- AptosRestrictor,
52
- },
53
39
  handler,
54
- handlerInTee,
55
40
  };
@@ -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, TeeRuntime } from '..';
3
+ import type { BaseRuntime, CallCapabilityParams, NodeRuntime, ReportRequest, ReportRequestJson, Runtime } from '..';
4
4
  import type { Report } from '../report';
5
5
  import { type ConsensusAggregation, type PrimitiveTypes, type UnwrapOptions } from '../utils';
6
6
  /**
@@ -44,10 +44,7 @@ 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;
48
47
  }
49
- /** Ergonomic union for {@link BaseRuntimeImpl.emitMetric}. */
50
- export type MetricType = 'counter' | 'gauge';
51
48
  /**
52
49
  * It is used when a BFT guarantee cannot be provided automatically (e.g. calling a standard API).
53
50
  * You tell each node to perform a task on its own.
@@ -97,25 +94,6 @@ export declare class RuntimeImpl<C> extends BaseRuntimeImpl<C> implements Runtim
97
94
  result: () => Report;
98
95
  };
99
96
  }
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
- }
119
97
  /**
120
98
  * Interface to the WASM host environment.
121
99
  * Provides low-level access to capabilities, secrets, and utilities.
@@ -137,9 +115,4 @@ export interface RuntimeHelpers {
137
115
  sleep(ms: number): void;
138
116
  /** Logs a message to the host environment. */
139
117
  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;
145
118
  }
@@ -1,8 +1,7 @@
1
- import { create, toBinary } from '@bufbuild/protobuf';
1
+ import { create } 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';
6
5
  import { ConsensusCapability } from '../../generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen';
7
6
  import { Value, } from '../utils';
8
7
  import { CapabilityRuntimeError, DonModeError, NodeModeError, SecretsError } from '../errors';
@@ -140,20 +139,7 @@ export class BaseRuntimeImpl {
140
139
  log(message) {
141
140
  this.helpers.log(message);
142
141
  }
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
- }
152
142
  }
153
- const METRIC_TYPE_TO_PROTO = {
154
- counter: UserMetricType.COUNTER,
155
- gauge: UserMetricType.GAUGE,
156
- };
157
143
  /**
158
144
  * It is used when a BFT guarantee cannot be provided automatically (e.g. calling a standard API).
159
145
  * You tell each node to perform a task on its own.
@@ -335,43 +321,6 @@ export class RuntimeImpl extends BaseRuntimeImpl {
335
321
  };
336
322
  }
337
323
  }
338
- export class TeeRuntimeImpl {
339
- config;
340
- nextCallId;
341
- runtime;
342
- constructor(config, nextCallId, helpers, maxResponseSize) {
343
- this.config = config;
344
- this.nextCallId = nextCallId;
345
- this.runtime = new RuntimeImpl(config, nextCallId, helpers, maxResponseSize);
346
- }
347
- getSecret(request) {
348
- return this.runtime.getSecret(request);
349
- }
350
- now() {
351
- return this.runtime.now();
352
- }
353
- log(message) {
354
- this.runtime.log(message);
355
- }
356
- emitMetric(name, value, type, labels) {
357
- return this.runtime.emitMetric(name, value, type, labels);
358
- }
359
- callCapability({ capabilityId, method, payload, inputSchema, outputSchema, }) {
360
- return this.runtime.callCapability({
361
- capabilityId,
362
- method,
363
- payload,
364
- inputSchema,
365
- outputSchema,
366
- });
367
- }
368
- reportFromDon(input) {
369
- return this.runtime.report(input);
370
- }
371
- usingTheDons() {
372
- return this.runtime;
373
- }
374
- }
375
324
  function clearIgnoredFields(value, descriptor) {
376
325
  if (!descriptor || !value) {
377
326
  return;
@@ -1,11 +1,10 @@
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';
5
4
  import type { Report } from './report';
6
5
  import type { ConsensusAggregation, PrimitiveTypes, UnwrapOptions } from './utils';
7
6
  import type { SecretsProvider } from '.';
8
- export type { ReportRequest, ReportRequestJson, MetricType };
7
+ export type { ReportRequest, ReportRequestJson };
9
8
  export type CallCapabilityParams<I extends Message, O extends Message> = {
10
9
  capabilityId: string;
11
10
  method: string;
@@ -24,7 +23,6 @@ export interface BaseRuntime<C> {
24
23
  };
25
24
  now(): Date;
26
25
  log(message: string): void;
27
- emitMetric(name: string, value: number, type: MetricType, labels?: Record<string, string>): boolean;
28
26
  }
29
27
  /**
30
28
  * Runtime for Node mode execution.
@@ -32,26 +30,6 @@ export interface BaseRuntime<C> {
32
30
  export interface NodeRuntime<C> extends BaseRuntime<C> {
33
31
  readonly _isNodeRuntime: true;
34
32
  }
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
- }
55
33
  /**
56
34
  * Runtime for DON mode execution.
57
35
  */
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Chain-agnostic core of the per-contract mock routing used by
3
+ * `addContractMock` (EVM) and `addSolanaContractMock` (Solana).
4
+ *
5
+ * Builds a handler that routes a request to `handle` when `matches` returns
6
+ * true, falls through to the previously installed handler otherwise, and
7
+ * throws `noMatchError` when there is nothing to fall through to. Installing
8
+ * the returned handler over the previous one is what lets multiple contract
9
+ * mocks chain on the same capability mock.
10
+ */
11
+ export declare function chainContractHandler<TReq, TReply>(options: {
12
+ previous: ((req: TReq) => TReply) | undefined;
13
+ matches: (req: TReq) => boolean;
14
+ handle: (req: TReq) => TReply;
15
+ noMatchError: (req: TReq) => string;
16
+ }): (req: TReq) => TReply;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Chain-agnostic core of the per-contract mock routing used by
3
+ * `addContractMock` (EVM) and `addSolanaContractMock` (Solana).
4
+ *
5
+ * Builds a handler that routes a request to `handle` when `matches` returns
6
+ * true, falls through to the previously installed handler otherwise, and
7
+ * throws `noMatchError` when there is nothing to fall through to. Installing
8
+ * the returned handler over the previous one is what lets multiple contract
9
+ * mocks chain on the same capability mock.
10
+ */
11
+ export function chainContractHandler(options) {
12
+ const { previous, matches, handle, noMatchError } = options;
13
+ return (req) => {
14
+ if (!matches(req)) {
15
+ if (previous)
16
+ return previous(req);
17
+ throw new Error(noMatchError(req));
18
+ }
19
+ return handle(req);
20
+ };
21
+ }
@@ -1,4 +1,5 @@
1
1
  import { decodeFunctionData, encodeFunctionResult, } from 'viem';
2
+ import { chainContractHandler } from './contract-mock-core';
2
3
  function bytesToHexAddress(bytes) {
3
4
  return `0x${Array.from(bytes)
4
5
  .map((b) => b.toString(16).padStart(2, '0'))
@@ -49,66 +50,67 @@ export function addContractMock(evmMock, options) {
49
50
  const mock = {};
50
51
  const normalizedAddress = options.address.toLowerCase();
51
52
  const previousCallContract = evmMock.callContract;
52
- evmMock.callContract = (req) => {
53
- const toBytes = req.call?.to;
54
- if (!toBytes || bytesToHexAddress(toBytes) !== normalizedAddress) {
55
- if (previousCallContract)
56
- return previousCallContract(req);
57
- throw new Error(`addContractMock: no mock registered for address ${toBytes ? bytesToHexAddress(toBytes) : '(empty)'}`);
58
- }
59
- const dataBytes = req.call?.data;
60
- if (!dataBytes || dataBytes.length < 4) {
61
- throw new Error('addContractMock: call data too short (need at least 4 bytes for selector)');
62
- }
63
- const callDataHex = bytesToHex(dataBytes);
64
- let decoded;
65
- try {
66
- decoded = decodeFunctionData({
53
+ evmMock.callContract = chainContractHandler({
54
+ previous: previousCallContract,
55
+ matches: (req) => {
56
+ const toBytes = req.call?.to;
57
+ return !!toBytes && bytesToHexAddress(toBytes) === normalizedAddress;
58
+ },
59
+ noMatchError: (req) => `addContractMock: no mock registered for address ${req.call?.to ? bytesToHexAddress(req.call.to) : '(empty)'}`,
60
+ handle: (req) => {
61
+ const dataBytes = req.call?.data;
62
+ if (!dataBytes || dataBytes.length < 4) {
63
+ throw new Error('addContractMock: call data too short (need at least 4 bytes for selector)');
64
+ }
65
+ const callDataHex = bytesToHex(dataBytes);
66
+ let decoded;
67
+ try {
68
+ decoded = decodeFunctionData({
69
+ abi: options.abi,
70
+ data: callDataHex,
71
+ });
72
+ }
73
+ catch (e) {
74
+ if (previousCallContract)
75
+ return previousCallContract(req);
76
+ throw new Error(`addContractMock: failed to decode function data for ${options.address}: ${e instanceof Error ? e.message : e}`);
77
+ }
78
+ const handler = mock[decoded.functionName];
79
+ if (typeof handler !== 'function') {
80
+ throw new Error(`addContractMock: no handler set for ${decoded.functionName} on ${options.address}`);
81
+ }
82
+ const result = handler(...(decoded.args ?? []));
83
+ const encoded = encodeFunctionResult({
67
84
  abi: options.abi,
68
- data: callDataHex,
85
+ functionName: decoded.functionName,
86
+ result: result,
69
87
  });
70
- }
71
- catch (e) {
72
- if (previousCallContract)
73
- return previousCallContract(req);
74
- throw new Error(`addContractMock: failed to decode function data for ${options.address}: ${e instanceof Error ? e.message : e}`);
75
- }
76
- const handler = mock[decoded.functionName];
77
- if (typeof handler !== 'function') {
78
- throw new Error(`addContractMock: no handler set for ${decoded.functionName} on ${options.address}`);
79
- }
80
- const result = handler(...(decoded.args ?? []));
81
- const encoded = encodeFunctionResult({
82
- abi: options.abi,
83
- functionName: decoded.functionName,
84
- result: result,
85
- });
86
- return {
87
- data: hexToUint8Array(encoded),
88
- };
89
- };
88
+ return {
89
+ data: hexToUint8Array(encoded),
90
+ };
91
+ },
92
+ });
90
93
  const previousWriteReport = evmMock.writeReport;
91
- evmMock.writeReport = (req) => {
92
- const receiverBytes = req.receiver;
93
- if (!receiverBytes || bytesToHexAddress(receiverBytes) !== normalizedAddress) {
94
- if (previousWriteReport)
95
- return previousWriteReport(req);
96
- throw new Error(`addContractMock: no writeReport mock registered for receiver ${receiverBytes ? bytesToHexAddress(receiverBytes) : '(empty)'}`);
97
- }
98
- if (typeof mock.writeReport !== 'function') {
99
- throw new Error(`addContractMock: no writeReport handler set for ${options.address}`);
100
- }
101
- if (!req.report) {
102
- throw new Error(`addContractMock: writeReport called without report for ${options.address}`);
103
- }
104
- if (!req.gasConfig) {
105
- throw new Error(`addContractMock: writeReport called without gasConfig for ${options.address}`);
106
- }
107
- return mock.writeReport({
108
- receiver: req.receiver,
109
- report: req.report,
110
- gasConfig: req.gasConfig,
111
- });
112
- };
94
+ evmMock.writeReport = chainContractHandler({
95
+ previous: previousWriteReport,
96
+ matches: (req) => !!req.receiver && bytesToHexAddress(req.receiver) === normalizedAddress,
97
+ noMatchError: (req) => `addContractMock: no writeReport mock registered for receiver ${req.receiver ? bytesToHexAddress(req.receiver) : '(empty)'}`,
98
+ handle: (req) => {
99
+ if (typeof mock.writeReport !== 'function') {
100
+ throw new Error(`addContractMock: no writeReport handler set for ${options.address}`);
101
+ }
102
+ if (!req.report) {
103
+ throw new Error(`addContractMock: writeReport called without report for ${options.address}`);
104
+ }
105
+ if (!req.gasConfig) {
106
+ throw new Error(`addContractMock: writeReport called without gasConfig for ${options.address}`);
107
+ }
108
+ return mock.writeReport({
109
+ receiver: req.receiver,
110
+ report: req.report,
111
+ gasConfig: req.gasConfig,
112
+ });
113
+ },
114
+ });
113
115
  return mock;
114
116
  }
@@ -1,5 +1,4 @@
1
1
  /** Auto-generated barrel of capability mocks. Do not edit. */
2
- export { AptosMock } from './capabilities/blockchain/aptos/v1alpha/aptos_mock_gen';
3
2
  export { EvmMock } from './capabilities/blockchain/evm/v1alpha/evm_mock_gen';
4
3
  export { SolanaMock } from './capabilities/blockchain/solana/v1alpha/solana_mock_gen';
5
4
  export { BasicTestActionTriggerMock } from './capabilities/internal/actionandtrigger/v1/basic_test_action_trigger_mock_gen';
@@ -1,5 +1,4 @@
1
1
  /** Auto-generated barrel of capability mocks. Do not edit. */
2
- export { AptosMock } from './capabilities/blockchain/aptos/v1alpha/aptos_mock_gen';
3
2
  export { EvmMock } from './capabilities/blockchain/evm/v1alpha/evm_mock_gen';
4
3
  export { SolanaMock } from './capabilities/blockchain/solana/v1alpha/solana_mock_gen';
5
4
  export { BasicTestActionTriggerMock } from './capabilities/internal/actionandtrigger/v1/basic_test_action_trigger_mock_gen';
@@ -6,3 +6,4 @@ export { type CapabilityHandler, DEFAULT_MAX_RESPONSE_SIZE_BYTES, getTestCapabil
6
6
  export { TestWriter } from '../testutils/test-writer';
7
7
  export { type AddContractMockOptions, addContractMock, type ContractMock, type WriteReportMockInput, } from './evm-contract-mock';
8
8
  export * from './generated';
9
+ export { type AddSolanaContractMockOptions, addSolanaContractMock, type SolanaContractMock, type SolanaWriteReportMockInput, } from './solana-contract-mock';
@@ -6,3 +6,4 @@ export { DEFAULT_MAX_RESPONSE_SIZE_BYTES, getTestCapabilityHandler, newTestRunti
6
6
  export { TestWriter } from '../testutils/test-writer';
7
7
  export { addContractMock, } from './evm-contract-mock';
8
8
  export * from './generated';
9
+ export { addSolanaContractMock, } from './solana-contract-mock';
@@ -0,0 +1,54 @@
1
+ import type { AccountMeta, ComputeConfig, WriteReportReply, WriteReportReplyJson } from '../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
2
+ import type { ReportResponse } from '../../generated/sdk/v1alpha/sdk_pb';
3
+ import type { SolanaMock } from './generated';
4
+ /**
5
+ * Strict version of {@link WriteReportRequest} where `report` is guaranteed
6
+ * to be present. Used by mock handlers so tests don't need to check for
7
+ * undefined.
8
+ */
9
+ export interface SolanaWriteReportMockInput {
10
+ receiver: Uint8Array;
11
+ report: ReportResponse;
12
+ remainingAccounts: AccountMeta[];
13
+ computeConfig?: ComputeConfig;
14
+ }
15
+ /**
16
+ * A program mock returned by {@link addSolanaContractMock}.
17
+ *
18
+ * The Solana CRE capability is write-only, so the only routable handler is
19
+ * `writeReport`. When set, write-report calls targeting this program's ID are
20
+ * routed here; calls for other receivers chain to previously registered mocks.
21
+ */
22
+ export interface SolanaContractMock {
23
+ writeReport?: (input: SolanaWriteReportMockInput) => WriteReportReply | WriteReportReplyJson;
24
+ }
25
+ export interface AddSolanaContractMockOptions {
26
+ /** The receiver program ID — base58 string or 32 raw bytes. */
27
+ programId: string | Uint8Array;
28
+ }
29
+ /**
30
+ * Registers a typed program mock on a {@link SolanaMock} instance.
31
+ *
32
+ * This is the Solana counterpart of {@link addContractMock}: it intercepts
33
+ * `writeReport` on the provided mock, routing calls by receiver program ID.
34
+ * Multiple programs can be mocked on the same `SolanaMock` — each call to
35
+ * `addSolanaContractMock` chains with the previous handler.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * const solanaMock = SolanaMock.testInstance(chainSelector);
40
+ *
41
+ * const dataStorage = addSolanaContractMock(solanaMock, {
42
+ * programId: 'ECL8142j2YQAvs9R9geSsRnkVH2wLEi7soJCRyJ74cfL',
43
+ * });
44
+ *
45
+ * dataStorage.writeReport = ({ report, remainingAccounts }) => {
46
+ * return { txSignature: new Uint8Array(64) };
47
+ * };
48
+ * ```
49
+ *
50
+ * @param solanaMock - The `SolanaMock` instance to attach to.
51
+ * @param options - The receiver program ID to route on.
52
+ * @returns A mock object with a settable `writeReport` handler.
53
+ */
54
+ export declare function addSolanaContractMock(solanaMock: SolanaMock, options: AddSolanaContractMockOptions): SolanaContractMock;