@chainlink/cre-sdk 0.0.3-alpha → 0.0.4-alpha

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 (41) hide show
  1. package/README.md +78 -59
  2. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.d.ts +18 -3
  3. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.js +148 -41
  4. package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.d.ts +4 -3
  5. package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.js +26 -8
  6. package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.d.ts +1 -1
  7. package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.js +14 -4
  8. package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.js +2 -0
  9. package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.js +2 -0
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.js +2 -0
  12. package/dist/sdk/impl/runtime-impl.d.ts +5 -1
  13. package/dist/sdk/impl/runtime-impl.js +13 -2
  14. package/dist/sdk/index.d.ts +1 -0
  15. package/dist/sdk/index.js +1 -0
  16. package/dist/sdk/report.d.ts +6 -0
  17. package/dist/sdk/report.js +14 -0
  18. package/dist/sdk/runtime.d.ts +6 -0
  19. package/dist/sdk/utils/capabilities/blockchain/blockchain-helpers.d.ts +50 -0
  20. package/dist/sdk/utils/capabilities/blockchain/blockchain-helpers.js +48 -0
  21. package/dist/sdk/utils/capabilities/http/http-helpers.d.ts +112 -0
  22. package/dist/sdk/utils/capabilities/http/http-helpers.js +44 -0
  23. package/dist/sdk/utils/index.d.ts +2 -0
  24. package/dist/sdk/utils/index.js +2 -0
  25. package/dist/workflows/standard_tests/Makefile +19 -0
  26. package/dist/workflows/standard_tests/capability_calls_are_async/test.ts +39 -0
  27. package/dist/workflows/standard_tests/config/test.ts +23 -0
  28. package/dist/workflows/standard_tests/errors/test.ts +24 -0
  29. package/dist/workflows/standard_tests/logging/test.ts +25 -0
  30. package/dist/workflows/standard_tests/mode_switch/don_runtime_in_node_mode/test.ts +33 -0
  31. package/dist/workflows/standard_tests/mode_switch/node_runtime_in_don_mode/test.ts +41 -0
  32. package/dist/workflows/standard_tests/mode_switch/successful_mode_switch/test.ts +58 -0
  33. package/dist/workflows/standard_tests/multiple_triggers/test.ts +40 -0
  34. package/dist/workflows/standard_tests/random/test.ts +64 -0
  35. package/dist/workflows/standard_tests/secrets/test.ts +30 -0
  36. package/dist/workflows/standard_tests/secrets_fail_in_node_mode/test.ts +29 -0
  37. package/package.json +70 -69
  38. package/scripts/run-standard-tests.sh +0 -3
  39. package/scripts/src/cre-setup.ts +9 -0
  40. package/dist/sdk/utils/safeJsonStringify.d.ts +0 -6
  41. package/dist/sdk/utils/safeJsonStringify.js +0 -6
package/README.md CHANGED
@@ -1,19 +1,77 @@
1
1
  # @chainlink/cre-sdk
2
2
 
3
- The Chainlink Runtime Environment (CRE) SDK for TypeScript enables developers to build decentralized workflows that combine off-chain computation with on-chain execution. Create workflows that fetch data from APIs, interact with smart contracts, and coordinate complex multi-step operations across blockchain networks.
3
+ The Chainlink Runtime Environment (CRE) SDK for TypeScript enables developers to write decentralized [Chainlink Runtime Environment Workflows](https://docs.chain.link/cre/) in Typescript.
4
+
5
+ ## Table of Contents
6
+
7
+ - [How to use this SDK](#how-to-use-this-sdk)
8
+ - [Examples](#examples)
9
+ - [Simulate locally with CRE CLI](#simulate-locally-with-cre-cli)
10
+ - [Installation](#installation)
11
+ - [Core Concepts](#core-concepts)
12
+ - [Workflows](#workflows)
13
+ - [Runtime Modes](#runtime-modes)
14
+ - [Available Capabilities](#available-capabilities)
15
+ - [Scheduling](#scheduling)
16
+ - [HTTP Operations](#http-operations)
17
+ - [Blockchain Interactions](#blockchain-interactions)
18
+ - [Configuration & Type Safety](#configuration--type-safety)
19
+ - [Consensus & Aggregation](#consensus--aggregation)
20
+ - [Utility Functions](#utility-functions)
21
+ - [Hex Utilities](#hex-utilities)
22
+ - [Chain Selectors](#chain-selectors)
23
+ - [Example Workflows](#example-workflows)
24
+ - [1. Simple Scheduled Task](#1-simple-scheduled-task)
25
+ - [2. API Data Aggregation](#2-api-data-aggregation)
26
+ - [3. On-Chain Data Integration](#3-on-chain-data-integration)
27
+ - [API Reference](#api-reference)
28
+ - [Core Functions](#core-functions)
29
+ - [Capabilities](#capabilities)
30
+ - [Utilities](#utilities)
31
+ - [Building from Source](#building-from-source)
32
+ - [Protobuf Generation](#protobuf-generation)
33
+ - [Chain Selectors Generation](#chain-selectors-generation)
34
+ - [Requirements](#requirements)
35
+ - [License](#license)
36
+
37
+ ## How to use this SDK
38
+
39
+ This package exposes the APIs you use to write CRE Workflows in TypeScript, and then compile them to WASM.
40
+
41
+ This package must be used along with the [CRE CLI tool](https://github.com/smartcontractkit/cre-cli) to deploy your WASM-compiled workflows.
42
+
43
+ ## Prerequisites
44
+
45
+ 1. the [bun runtime](https://bun.com/). The wasm compilation currently is only supported by the bun runtime which has near-complete NodeJS compatibility.
46
+
47
+ 2. the [CRE CLI tool](https://github.com/smartcontractkit/cre-cli) installed.
48
+
49
+ ## Getting Started
50
+
51
+ We recommend you consult the [getting started docs](https://docs.chain.link/cre/getting-started/cli-installation) and install the CRE CLI.
52
+
53
+ Then run `cre init`, name your project and choose TypeScript as the language to define your workflows in.
4
54
 
5
55
  ## Examples
6
56
 
7
- Ready to clone repo with example workflows and cre-sdk set up: [cre-sdk-examples](https://github.com/smartcontractkit/cre-sdk-typescript/tree/main/packages/cre-sdk-examples).
57
+ This TypeScript CRE SDK also includes some reference examples - [cre-sdk-examples](https://github.com/smartcontractkit/cre-sdk-typescript/tree/main/packages/cre-sdk-examples). These can be copied and pasted into your project as needed.
58
+
59
+ ⚠️ Note however that these are refence TypeScript workflows and may require some additional steps (having the CRE CLI installed, running `bunx cre-setup` from inside a workflow example directory, etc) to get them to work within this repo.
60
+
61
+ **We recommend you setup your project using the CRE CLI and then copy and paste these examples into your project**
8
62
 
9
63
  ## Simulate locally with CRE CLI
10
64
 
11
- You can run and debug your TypeScript workflows locally using the CRE CLI simulation:
65
+ You can run and debug your TypeScript workflows locally using [the CRE CLI's](https://github.com/smartcontractkit/cre-cli) simulation functionality.
66
+
67
+ Make sure you `cd` into the directory that contain's your workflow's TypeScript file and the associated `config.json`. Then:
12
68
 
13
69
  ```bash
14
- cre workflow simulate --target local-simulation --config config.json your-workflow-file.ts
70
+ cre workflow simulate --target local-simulation --config config.json index.ts
15
71
  ```
16
72
 
73
+ When simulating workflows that write to the blockchain, remember to pass extra flag `--broadcast` to broadcast the transactions to the blockchain.
74
+
17
75
  See the CLI docs for additional flags (e.g. config file, secrets, HTTP payloads, EVM log params).
18
76
 
19
77
  ## Installation
@@ -22,33 +80,6 @@ See the CLI docs for additional flags (e.g. config file, secrets, HTTP payloads,
22
80
  bun add @chainlink/cre-sdk
23
81
  ```
24
82
 
25
- ## Quick Start
26
-
27
- ```typescript
28
- import { cre, Runner, type Runtime } from "@chainlink/cre-sdk";
29
-
30
- type Config = { schedule: string };
31
-
32
- const onCronTrigger = (runtime: Runtime<Config>) => {
33
- runtime.log("Hello, CRE!");
34
- return "Hello, CRE!";
35
- };
36
-
37
- const initWorkflow = (config: Config) => {
38
- const cron = new cre.capabilities.CronCapability();
39
- return [
40
- cre.handler(cron.trigger({ schedule: config.schedule }), onCronTrigger),
41
- ];
42
- };
43
-
44
- export async function main() {
45
- const runner = await Runner.newRunner<Config>();
46
- await runner.run(initWorkflow);
47
- }
48
-
49
- main();
50
- ```
51
-
52
83
  ## Core Concepts
53
84
 
54
85
  ### Workflows
@@ -56,7 +87,7 @@ main();
56
87
  Workflows are the fundamental building blocks of CRE applications. They define how your application responds to triggers and what actions to take. Each workflow consists of:
57
88
 
58
89
  - **Triggers**: Events that initiate workflow execution (cron schedules, HTTP requests, etc.)
59
- - **Handlers**: Functions that process trigger events and execute your business logic
90
+ - **Handlers**: Functions that process trigger events and execute your business logic as provided in a callback function.
60
91
  - **Capabilities**: Built-in services for interacting with external systems
61
92
 
62
93
  ### Runtime Modes
@@ -183,7 +214,11 @@ const onCronTrigger = async (runtime: Runtime<Config>) => {
183
214
 
184
215
  ## Configuration & Type Safety
185
216
 
186
- Use Zod schemas for type-safe configuration:
217
+ You, the developer, must declare config files in config.json files, co-located with your TypeScript workflow definition.
218
+
219
+ Use Zod schemas for type-safe configuration.
220
+
221
+ Here's an example of zod usage for the config specified in `../cre-sdk-examples/src/workflows/on-chain/config.json`
187
222
 
188
223
  ```typescript
189
224
  import { z } from "zod";
@@ -231,10 +266,17 @@ const aggregatedValue = await runtime.runInNodeMode(
231
266
 
232
267
  ### Hex Utilities
233
268
 
269
+ CRE capabilities (like EVM client) expect data in base64 format for serialization. You may need to convert a hex string to base64 format for CRE protocol communication.
270
+
271
+ Or you may need to convert binary data back to hex format for blockchain operations. This can be Useful for decoding responses from CRE capabilities and transforming data for libraries like viem (which expect hex format)
272
+
234
273
  ```typescript
235
274
  import { hexToBase64, bytesToHex } from "@chainlink/cre-sdk";
236
275
 
276
+ // Example: "0x1234567890abcdef" → "EjRWeJCrze8="
237
277
  const base64Data = hexToBase64("0x1234567890abcdef");
278
+
279
+ // Example: Uint8Array([18, 52, 86...]) → "0x1234567890abcdef"
238
280
  const hexData = bytesToHex(buffer);
239
281
  ```
240
282
 
@@ -253,36 +295,13 @@ const ethereumSepolia = getNetwork({
253
295
 
254
296
  ## Example Workflows
255
297
 
256
- ### 1. Simple Scheduled Task
257
-
258
- ```typescript
259
- import { cre, Runner, type Runtime } from "@chainlink/cre-sdk";
260
-
261
- type Config = { schedule: string };
262
-
263
- const onCronTrigger = (runtime: Runtime<Config>) => {
264
- runtime.log("Workflow executed!");
265
- return "Task completed";
266
- };
298
+ ### 1. Simple Cron-scheduled task
267
299
 
268
- const initWorkflow = (config: Config) => {
269
- const cron = new cre.capabilities.CronCapability();
270
- return [
271
- cre.handler(cron.trigger({ schedule: config.schedule }), onCronTrigger),
272
- ];
273
- };
274
-
275
- export async function main() {
276
- const runner = await Runner.newRunner<Config>();
277
- await runner.run(initWorkflow);
278
- }
279
-
280
- main();
281
- ```
300
+ See the [hello-world](https://github.com/smartcontractkit/cre-sdk-typescript/tree/main/packages/cre-sdk-examples/src/hello-world) example for a simple example that runs a cron-based operation on CRE at intervals you define in the `config.js` file.
282
301
 
283
302
  ### 2. API Data Aggregation
284
303
 
285
- See the [http-fetch example](https://github.com/smartcontractkit/cre-sdk-typescript/tree/main/packages/cre-sdk-examples/src/workflows/http-fetch) for a complete implementation that fetches data from external APIs with consensus aggregation.
304
+ See the [http-fetch example](https://github.com/smartcontractkit/cre-sdk-typescript/tree/main/packages/cre-sdk-examples/src/workflows/http-fetch) for a complete implementation that fetches data from external APIs, with Chainlink CRE consensus aggregation applied.
286
305
 
287
306
  ### 3. On-Chain Data Integration
288
307
 
@@ -1,7 +1,22 @@
1
1
  import { type Any, type Empty } from '@bufbuild/protobuf/wkt';
2
- import { type BalanceAtReply, type BalanceAtRequest, type BalanceAtRequestJson, type CallContractReply, type CallContractRequest, type CallContractRequestJson, type EstimateGasReply, type EstimateGasRequest, type EstimateGasRequestJson, type FilterLogsReply, type FilterLogsRequest, type FilterLogsRequestJson, type FilterLogTriggerRequest, type FilterLogTriggerRequestJson, type GetTransactionByHashReply, type GetTransactionByHashRequest, type GetTransactionByHashRequestJson, type GetTransactionReceiptReply, type GetTransactionReceiptRequest, type GetTransactionReceiptRequestJson, type HeaderByNumberReply, type HeaderByNumberRequest, type HeaderByNumberRequestJson, type Log, type RegisterLogTrackingRequest, type RegisterLogTrackingRequestJson, type UnregisterLogTrackingRequest, type UnregisterLogTrackingRequestJson, type WriteReportReply, type WriteReportRequest, type WriteReportRequestJson } from '../../../../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
3
- import type { Runtime } from '../../../../../sdk/runtime';
2
+ import { type BalanceAtReply, type BalanceAtRequest, type BalanceAtRequestJson, type CallContractReply, type CallContractRequest, type CallContractRequestJson, type EstimateGasReply, type EstimateGasRequest, type EstimateGasRequestJson, type FilterLogsReply, type FilterLogsRequest, type FilterLogsRequestJson, type FilterLogTriggerRequest, type FilterLogTriggerRequestJson, type GasConfig, type GasConfigJson, type GetTransactionByHashReply, type GetTransactionByHashRequest, type GetTransactionByHashRequestJson, type GetTransactionReceiptReply, type GetTransactionReceiptRequest, type GetTransactionReceiptRequestJson, type HeaderByNumberReply, type HeaderByNumberRequest, type HeaderByNumberRequestJson, type Log, type RegisterLogTrackingRequest, type RegisterLogTrackingRequestJson, type UnregisterLogTrackingRequest, type UnregisterLogTrackingRequestJson, type WriteReportReply, type WriteReportRequest } from '../../../../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
3
+ import { type Runtime } from '../../../../../sdk';
4
+ import { Report } from '../../../../../sdk/report';
4
5
  import { type Trigger } from '../../../../../sdk/utils/triggers/trigger-interface';
6
+ export type WriteCreReportRequest = {
7
+ receiver: Uint8Array;
8
+ report?: Report;
9
+ gasConfig?: GasConfig;
10
+ $report: true;
11
+ };
12
+ export type WriteCreReportRequestJson = {
13
+ receiver: string;
14
+ report?: Report;
15
+ gasConfig?: GasConfigJson;
16
+ };
17
+ export declare function x_generatedCodeOnly_wrap_WriteCreReportRequest(input: WriteReportRequest): WriteCreReportRequest;
18
+ export declare function createWriteCreReportRequest(input: WriteCreReportRequestJson): WriteCreReportRequest;
19
+ export declare function x_generatedCodeOnly_unwrap_WriteCreReportRequest(input: WriteCreReportRequest): WriteReportRequest;
5
20
  /**
6
21
  * Client Capability
7
22
  *
@@ -60,7 +75,7 @@ export declare class ClientCapability {
60
75
  result: () => Empty;
61
76
  };
62
77
  logTrigger(config: FilterLogTriggerRequestJson): ClientLogTrigger;
63
- writeReport(runtime: Runtime<unknown>, input: WriteReportRequest | WriteReportRequestJson): {
78
+ writeReport(runtime: Runtime<unknown>, input: WriteCreReportRequest | WriteCreReportRequestJson): {
64
79
  result: () => WriteReportReply;
65
80
  };
66
81
  }
@@ -1,7 +1,33 @@
1
1
  import { create, fromJson } from '@bufbuild/protobuf';
2
2
  import { AnySchema, anyPack, EmptySchema } from '@bufbuild/protobuf/wkt';
3
- import { BalanceAtReplySchema, BalanceAtRequestSchema, CallContractReplySchema, CallContractRequestSchema, EstimateGasReplySchema, EstimateGasRequestSchema, FilterLogsReplySchema, FilterLogsRequestSchema, FilterLogTriggerRequestSchema, GetTransactionByHashReplySchema, GetTransactionByHashRequestSchema, GetTransactionReceiptReplySchema, GetTransactionReceiptRequestSchema, HeaderByNumberReplySchema, HeaderByNumberRequestSchema, LogSchema, RegisterLogTrackingRequestSchema, UnregisterLogTrackingRequestSchema, WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
3
+ import { BalanceAtReplySchema, BalanceAtRequestSchema, CallContractReplySchema, CallContractRequestSchema, EstimateGasReplySchema, EstimateGasRequestSchema, FilterLogsReplySchema, FilterLogsRequestSchema, FilterLogTriggerRequestSchema, GasConfigSchema, GetTransactionByHashReplySchema, GetTransactionByHashRequestSchema, GetTransactionReceiptReplySchema, GetTransactionReceiptRequestSchema, HeaderByNumberReplySchema, HeaderByNumberRequestSchema, LogSchema, RegisterLogTrackingRequestSchema, UnregisterLogTrackingRequestSchema, WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
4
+ import { ReportResponseSchema, } from '../../../../../generated/sdk/v1alpha/sdk_pb';
5
+ import {} from '../../../../../sdk';
6
+ import { Report } from '../../../../../sdk/report';
4
7
  import {} from '../../../../../sdk/utils/triggers/trigger-interface';
8
+ export function x_generatedCodeOnly_wrap_WriteCreReportRequest(input) {
9
+ return {
10
+ receiver: input.receiver,
11
+ report: input.report !== undefined ? new Report(input.report) : undefined,
12
+ gasConfig: input.gasConfig,
13
+ $report: true,
14
+ };
15
+ }
16
+ export function createWriteCreReportRequest(input) {
17
+ return {
18
+ receiver: new Uint8Array(Buffer.from(input.receiver, 'base64')),
19
+ report: input.report,
20
+ gasConfig: input.gasConfig !== undefined ? fromJson(GasConfigSchema, input.gasConfig) : undefined,
21
+ $report: true,
22
+ };
23
+ }
24
+ export function x_generatedCodeOnly_unwrap_WriteCreReportRequest(input) {
25
+ return create(WriteReportRequestSchema, {
26
+ receiver: input.receiver,
27
+ report: input.report !== undefined ? input.report.x_generatedCodeOnly_unwrap() : undefined,
28
+ gasConfig: input.gasConfig,
29
+ });
30
+ }
5
31
  /**
6
32
  * Client Capability
7
33
  *
@@ -35,9 +61,16 @@ export class ClientCapability {
35
61
  this.chainSelector = chainSelector;
36
62
  }
37
63
  callContract(runtime, input) {
38
- const payload = input.$typeName
39
- ? input
40
- : fromJson(CallContractRequestSchema, input);
64
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
65
+ let payload;
66
+ if (input.$typeName) {
67
+ // It's the original protobuf type
68
+ payload = input;
69
+ }
70
+ else {
71
+ // It's regular JSON, convert using fromJson
72
+ payload = fromJson(CallContractRequestSchema, input);
73
+ }
41
74
  // Include chainSelector in capability ID for routing when specified
42
75
  const capabilityId = this.chainSelector
43
76
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
@@ -51,14 +84,22 @@ export class ClientCapability {
51
84
  });
52
85
  return {
53
86
  result: () => {
54
- return capabilityResponse.result();
87
+ const result = capabilityResponse.result();
88
+ return result;
55
89
  },
56
90
  };
57
91
  }
58
92
  filterLogs(runtime, input) {
59
- const payload = input.$typeName
60
- ? input
61
- : fromJson(FilterLogsRequestSchema, input);
93
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
94
+ let payload;
95
+ if (input.$typeName) {
96
+ // It's the original protobuf type
97
+ payload = input;
98
+ }
99
+ else {
100
+ // It's regular JSON, convert using fromJson
101
+ payload = fromJson(FilterLogsRequestSchema, input);
102
+ }
62
103
  // Include chainSelector in capability ID for routing when specified
63
104
  const capabilityId = this.chainSelector
64
105
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
@@ -72,14 +113,22 @@ export class ClientCapability {
72
113
  });
73
114
  return {
74
115
  result: () => {
75
- return capabilityResponse.result();
116
+ const result = capabilityResponse.result();
117
+ return result;
76
118
  },
77
119
  };
78
120
  }
79
121
  balanceAt(runtime, input) {
80
- const payload = input.$typeName
81
- ? input
82
- : fromJson(BalanceAtRequestSchema, input);
122
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
123
+ let payload;
124
+ if (input.$typeName) {
125
+ // It's the original protobuf type
126
+ payload = input;
127
+ }
128
+ else {
129
+ // It's regular JSON, convert using fromJson
130
+ payload = fromJson(BalanceAtRequestSchema, input);
131
+ }
83
132
  // Include chainSelector in capability ID for routing when specified
84
133
  const capabilityId = this.chainSelector
85
134
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
@@ -93,14 +142,22 @@ export class ClientCapability {
93
142
  });
94
143
  return {
95
144
  result: () => {
96
- return capabilityResponse.result();
145
+ const result = capabilityResponse.result();
146
+ return result;
97
147
  },
98
148
  };
99
149
  }
100
150
  estimateGas(runtime, input) {
101
- const payload = input.$typeName
102
- ? input
103
- : fromJson(EstimateGasRequestSchema, input);
151
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
152
+ let payload;
153
+ if (input.$typeName) {
154
+ // It's the original protobuf type
155
+ payload = input;
156
+ }
157
+ else {
158
+ // It's regular JSON, convert using fromJson
159
+ payload = fromJson(EstimateGasRequestSchema, input);
160
+ }
104
161
  // Include chainSelector in capability ID for routing when specified
105
162
  const capabilityId = this.chainSelector
106
163
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
@@ -114,14 +171,22 @@ export class ClientCapability {
114
171
  });
115
172
  return {
116
173
  result: () => {
117
- return capabilityResponse.result();
174
+ const result = capabilityResponse.result();
175
+ return result;
118
176
  },
119
177
  };
120
178
  }
121
179
  getTransactionByHash(runtime, input) {
122
- const payload = input.$typeName
123
- ? input
124
- : fromJson(GetTransactionByHashRequestSchema, input);
180
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
181
+ let payload;
182
+ if (input.$typeName) {
183
+ // It's the original protobuf type
184
+ payload = input;
185
+ }
186
+ else {
187
+ // It's regular JSON, convert using fromJson
188
+ payload = fromJson(GetTransactionByHashRequestSchema, input);
189
+ }
125
190
  // Include chainSelector in capability ID for routing when specified
126
191
  const capabilityId = this.chainSelector
127
192
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
@@ -135,14 +200,22 @@ export class ClientCapability {
135
200
  });
136
201
  return {
137
202
  result: () => {
138
- return capabilityResponse.result();
203
+ const result = capabilityResponse.result();
204
+ return result;
139
205
  },
140
206
  };
141
207
  }
142
208
  getTransactionReceipt(runtime, input) {
143
- const payload = input.$typeName
144
- ? input
145
- : fromJson(GetTransactionReceiptRequestSchema, input);
209
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
210
+ let payload;
211
+ if (input.$typeName) {
212
+ // It's the original protobuf type
213
+ payload = input;
214
+ }
215
+ else {
216
+ // It's regular JSON, convert using fromJson
217
+ payload = fromJson(GetTransactionReceiptRequestSchema, input);
218
+ }
146
219
  // Include chainSelector in capability ID for routing when specified
147
220
  const capabilityId = this.chainSelector
148
221
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
@@ -156,14 +229,22 @@ export class ClientCapability {
156
229
  });
157
230
  return {
158
231
  result: () => {
159
- return capabilityResponse.result();
232
+ const result = capabilityResponse.result();
233
+ return result;
160
234
  },
161
235
  };
162
236
  }
163
237
  headerByNumber(runtime, input) {
164
- const payload = input.$typeName
165
- ? input
166
- : fromJson(HeaderByNumberRequestSchema, input);
238
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
239
+ let payload;
240
+ if (input.$typeName) {
241
+ // It's the original protobuf type
242
+ payload = input;
243
+ }
244
+ else {
245
+ // It's regular JSON, convert using fromJson
246
+ payload = fromJson(HeaderByNumberRequestSchema, input);
247
+ }
167
248
  // Include chainSelector in capability ID for routing when specified
168
249
  const capabilityId = this.chainSelector
169
250
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
@@ -177,14 +258,22 @@ export class ClientCapability {
177
258
  });
178
259
  return {
179
260
  result: () => {
180
- return capabilityResponse.result();
261
+ const result = capabilityResponse.result();
262
+ return result;
181
263
  },
182
264
  };
183
265
  }
184
266
  registerLogTracking(runtime, input) {
185
- const payload = input.$typeName
186
- ? input
187
- : fromJson(RegisterLogTrackingRequestSchema, input);
267
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
268
+ let payload;
269
+ if (input.$typeName) {
270
+ // It's the original protobuf type
271
+ payload = input;
272
+ }
273
+ else {
274
+ // It's regular JSON, convert using fromJson
275
+ payload = fromJson(RegisterLogTrackingRequestSchema, input);
276
+ }
188
277
  // Include chainSelector in capability ID for routing when specified
189
278
  const capabilityId = this.chainSelector
190
279
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
@@ -198,14 +287,22 @@ export class ClientCapability {
198
287
  });
199
288
  return {
200
289
  result: () => {
201
- return capabilityResponse.result();
290
+ const result = capabilityResponse.result();
291
+ return result;
202
292
  },
203
293
  };
204
294
  }
205
295
  unregisterLogTracking(runtime, input) {
206
- const payload = input.$typeName
207
- ? input
208
- : fromJson(UnregisterLogTrackingRequestSchema, input);
296
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
297
+ let payload;
298
+ if (input.$typeName) {
299
+ // It's the original protobuf type
300
+ payload = input;
301
+ }
302
+ else {
303
+ // It's regular JSON, convert using fromJson
304
+ payload = fromJson(UnregisterLogTrackingRequestSchema, input);
305
+ }
209
306
  // Include chainSelector in capability ID for routing when specified
210
307
  const capabilityId = this.chainSelector
211
308
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
@@ -219,7 +316,8 @@ export class ClientCapability {
219
316
  });
220
317
  return {
221
318
  result: () => {
222
- return capabilityResponse.result();
319
+ const result = capabilityResponse.result();
320
+ return result;
223
321
  },
224
322
  };
225
323
  }
@@ -231,9 +329,17 @@ export class ClientCapability {
231
329
  return new ClientLogTrigger(config, capabilityId, 'LogTrigger');
232
330
  }
233
331
  writeReport(runtime, input) {
234
- const payload = input.$typeName
235
- ? input
236
- : fromJson(WriteReportRequestSchema, input);
332
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
333
+ let payload;
334
+ // Check if it's a wrapped type by looking for the $report property
335
+ if (input.$report) {
336
+ // It's a wrapped type, unwrap it
337
+ payload = x_generatedCodeOnly_unwrap_WriteCreReportRequest(input);
338
+ }
339
+ else {
340
+ // It's wrapped JSON, convert using create function
341
+ payload = x_generatedCodeOnly_unwrap_WriteCreReportRequest(createWriteCreReportRequest(input));
342
+ }
237
343
  // Include chainSelector in capability ID for routing when specified
238
344
  const capabilityId = this.chainSelector
239
345
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
@@ -247,7 +353,8 @@ export class ClientCapability {
247
353
  });
248
354
  return {
249
355
  result: () => {
250
- return capabilityResponse.result();
356
+ const result = capabilityResponse.result();
357
+ return result;
251
358
  },
252
359
  };
253
360
  }
@@ -1,6 +1,7 @@
1
- import { type ReportRequest, type ReportRequestJson, type ReportResponse, type SimpleConsensusInputs, type SimpleConsensusInputsJson } from '../../../../../generated/sdk/v1alpha/sdk_pb';
1
+ import { 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
- import type { Runtime } from '../../../../../sdk/runtime';
3
+ import { type Runtime } from '../../../../../sdk';
4
+ import { Report } from '../../../../../sdk/report';
4
5
  /**
5
6
  * Consensus Capability
6
7
  *
@@ -17,6 +18,6 @@ export declare class ConsensusCapability {
17
18
  result: () => Value;
18
19
  };
19
20
  report(runtime: Runtime<unknown>, input: ReportRequest | ReportRequestJson): {
20
- result: () => ReportResponse;
21
+ result: () => Report;
21
22
  };
22
23
  }
@@ -1,6 +1,8 @@
1
1
  import { fromJson } from '@bufbuild/protobuf';
2
2
  import { ReportRequestSchema, ReportResponseSchema, SimpleConsensusInputsSchema, } from '../../../../../generated/sdk/v1alpha/sdk_pb';
3
3
  import { ValueSchema } from '../../../../../generated/values/v1/values_pb';
4
+ import {} from '../../../../../sdk';
5
+ import { Report } from '../../../../../sdk/report';
4
6
  /**
5
7
  * Consensus Capability
6
8
  *
@@ -14,9 +16,16 @@ export class ConsensusCapability {
14
16
  static CAPABILITY_NAME = 'consensus';
15
17
  static CAPABILITY_VERSION = '1.0.0-alpha';
16
18
  simple(runtime, input) {
17
- const payload = input.$typeName
18
- ? input
19
- : fromJson(SimpleConsensusInputsSchema, input);
19
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
20
+ let payload;
21
+ if (input.$typeName) {
22
+ // It's the original protobuf type
23
+ payload = input;
24
+ }
25
+ else {
26
+ // It's regular JSON, convert using fromJson
27
+ payload = fromJson(SimpleConsensusInputsSchema, input);
28
+ }
20
29
  const capabilityId = ConsensusCapability.CAPABILITY_ID;
21
30
  const capabilityResponse = runtime.callCapability({
22
31
  capabilityId,
@@ -27,14 +36,22 @@ export class ConsensusCapability {
27
36
  });
28
37
  return {
29
38
  result: () => {
30
- return capabilityResponse.result();
39
+ const result = capabilityResponse.result();
40
+ return result;
31
41
  },
32
42
  };
33
43
  }
34
44
  report(runtime, input) {
35
- const payload = input.$typeName
36
- ? input
37
- : fromJson(ReportRequestSchema, input);
45
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
46
+ let payload;
47
+ if (input.$typeName) {
48
+ // It's the original protobuf type
49
+ payload = input;
50
+ }
51
+ else {
52
+ // It's regular JSON, convert using fromJson
53
+ payload = fromJson(ReportRequestSchema, input);
54
+ }
38
55
  const capabilityId = ConsensusCapability.CAPABILITY_ID;
39
56
  const capabilityResponse = runtime.callCapability({
40
57
  capabilityId,
@@ -45,7 +62,8 @@ export class ConsensusCapability {
45
62
  });
46
63
  return {
47
64
  result: () => {
48
- return capabilityResponse.result();
65
+ const result = capabilityResponse.result();
66
+ return new Report(result);
49
67
  },
50
68
  };
51
69
  }
@@ -1,5 +1,5 @@
1
1
  import { type Request, type RequestJson, type Response } from '../../../../../generated/capabilities/networking/http/v1alpha/client_pb';
2
- import type { NodeRuntime, Runtime } from '../../../../../sdk/runtime';
2
+ import { type NodeRuntime, type Runtime } from '../../../../../sdk';
3
3
  import type { ConsensusAggregation, PrimitiveTypes, UnwrapOptions } from '../../../../../sdk/utils';
4
4
  export declare class SendRequester {
5
5
  private readonly runtime;