@chainlink/cre-sdk 0.0.1-alpha → 0.0.2-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 (114) hide show
  1. package/dist/generated/capabilities/internal/nodeaction/v1/node_action_pb.d.ts +69 -0
  2. package/dist/generated/capabilities/internal/nodeaction/v1/node_action_pb.js +29 -0
  3. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.d.ts +13 -18
  4. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.js +71 -260
  5. package/dist/generated-sdk/capabilities/internal/actionandtrigger/v1/basic_sdk_gen.d.ts +4 -9
  6. package/dist/generated-sdk/capabilities/internal/actionandtrigger/v1/basic_sdk_gen.js +14 -45
  7. package/dist/generated-sdk/capabilities/internal/basicaction/v1/basicaction_sdk_gen.d.ts +3 -7
  8. package/dist/generated-sdk/capabilities/internal/basicaction/v1/basicaction_sdk_gen.js +9 -36
  9. package/dist/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen.d.ts +2 -8
  10. package/dist/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen.js +8 -21
  11. package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.d.ts +5 -8
  12. package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.js +16 -60
  13. package/dist/generated-sdk/capabilities/internal/nodeaction/v1/basicaction_sdk_gen.d.ts +19 -0
  14. package/dist/generated-sdk/capabilities/internal/nodeaction/v1/basicaction_sdk_gen.js +36 -0
  15. package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.d.ts +3 -7
  16. package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.js +9 -36
  17. package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.d.ts +2 -8
  18. package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.js +8 -21
  19. package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.d.ts +2 -8
  20. package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.js +8 -21
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.js +1 -0
  23. package/dist/sdk/cre/index.d.ts +5 -19
  24. package/dist/sdk/cre/index.js +1 -17
  25. package/dist/sdk/errors.d.ts +12 -0
  26. package/dist/sdk/errors.js +21 -0
  27. package/dist/sdk/impl/runtime-impl.d.ts +38 -0
  28. package/dist/sdk/impl/runtime-impl.js +190 -0
  29. package/dist/sdk/impl/runtime-impl.test.js +334 -0
  30. package/dist/sdk/index.d.ts +3 -0
  31. package/dist/sdk/index.js +2 -0
  32. package/dist/sdk/runtime.d.ts +24 -0
  33. package/dist/sdk/utils/capabilities/capability-error.d.ts +0 -3
  34. package/dist/sdk/utils/capabilities/capability-error.js +0 -2
  35. package/dist/sdk/utils/config/configHandler.test.d.ts +1 -0
  36. package/dist/sdk/utils/config/configHandler.test.js +193 -0
  37. package/dist/sdk/utils/config/index.d.ts +4 -6
  38. package/dist/sdk/utils/config/index.js +10 -34
  39. package/dist/sdk/utils/index.d.ts +0 -3
  40. package/dist/sdk/utils/index.js +0 -3
  41. package/dist/sdk/utils/values/consensus_aggregators.d.ts +1 -1
  42. package/dist/sdk/{runtime → wasm}/host-bindings.d.ts +0 -1
  43. package/dist/sdk/{runtime → wasm}/host-bindings.js +0 -4
  44. package/dist/sdk/wasm/index.d.ts +1 -0
  45. package/dist/sdk/wasm/index.js +1 -0
  46. package/dist/sdk/wasm/runner.d.ts +14 -0
  47. package/dist/sdk/wasm/runner.js +114 -0
  48. package/dist/sdk/wasm/runner.test.d.ts +1 -0
  49. package/dist/sdk/wasm/runner.test.js +270 -0
  50. package/dist/sdk/wasm/runtime.d.ts +7 -0
  51. package/dist/sdk/wasm/runtime.js +55 -0
  52. package/dist/sdk/workflow.d.ts +13 -15
  53. package/dist/sdk/workflow.js +1 -21
  54. package/package.json +2 -2
  55. package/dist/sdk/engine/execute.d.ts +0 -4
  56. package/dist/sdk/engine/execute.js +0 -12
  57. package/dist/sdk/engine/execute.test.js +0 -129
  58. package/dist/sdk/engine/handleExecutionPhase.d.ts +0 -4
  59. package/dist/sdk/engine/handleExecutionPhase.js +0 -34
  60. package/dist/sdk/engine/handleSubscribePhase.d.ts +0 -3
  61. package/dist/sdk/engine/handleSubscribePhase.js +0 -23
  62. package/dist/sdk/logger.d.ts +0 -7
  63. package/dist/sdk/logger.js +0 -18
  64. package/dist/sdk/runtime/errors.d.ts +0 -23
  65. package/dist/sdk/runtime/errors.js +0 -30
  66. package/dist/sdk/runtime/index.d.ts +0 -3
  67. package/dist/sdk/runtime/index.js +0 -2
  68. package/dist/sdk/runtime/run-in-node-mode.d.ts +0 -12
  69. package/dist/sdk/runtime/run-in-node-mode.js +0 -47
  70. package/dist/sdk/runtime/run-in-node-mode.test.js +0 -116
  71. package/dist/sdk/runtime/runtime.d.ts +0 -36
  72. package/dist/sdk/runtime/runtime.js +0 -84
  73. package/dist/sdk/runtime/runtime.test.d.ts +0 -1
  74. package/dist/sdk/runtime/runtime.test.js +0 -58
  75. package/dist/sdk/testhelpers/dangerously-call-capability.d.ts +0 -10
  76. package/dist/sdk/testhelpers/dangerously-call-capability.js +0 -26
  77. package/dist/sdk/testhelpers/mock-host-bindings.d.ts +0 -15
  78. package/dist/sdk/testhelpers/mock-host-bindings.js +0 -25
  79. package/dist/sdk/testhelpers/mock-runtime.d.ts +0 -2
  80. package/dist/sdk/testhelpers/mock-runtime.js +0 -16
  81. package/dist/sdk/utils/await-async-request.d.ts +0 -9
  82. package/dist/sdk/utils/await-async-request.js +0 -27
  83. package/dist/sdk/utils/capabilities/call-capability.d.ts +0 -22
  84. package/dist/sdk/utils/capabilities/call-capability.js +0 -33
  85. package/dist/sdk/utils/capabilities/callback-id.d.ts +0 -3
  86. package/dist/sdk/utils/capabilities/callback-id.js +0 -22
  87. package/dist/sdk/utils/capabilities/http/fetch.d.ts +0 -44
  88. package/dist/sdk/utils/capabilities/http/fetch.js +0 -63
  89. package/dist/sdk/utils/do-request-async.d.ts +0 -12
  90. package/dist/sdk/utils/do-request-async.js +0 -17
  91. package/dist/sdk/utils/error-boundary.d.ts +0 -2
  92. package/dist/sdk/utils/error-boundary.js +0 -30
  93. package/dist/sdk/utils/get-request.d.ts +0 -1
  94. package/dist/sdk/utils/get-request.js +0 -15
  95. package/dist/sdk/utils/lazy-promise.d.ts +0 -59
  96. package/dist/sdk/utils/lazy-promise.js +0 -81
  97. package/dist/sdk/utils/random/get-rand.d.ts +0 -3
  98. package/dist/sdk/utils/random/get-rand.js +0 -6
  99. package/dist/sdk/utils/random/random.d.ts +0 -35
  100. package/dist/sdk/utils/random/random.js +0 -123
  101. package/dist/sdk/utils/secrets/await-async-secret.d.ts +0 -1
  102. package/dist/sdk/utils/secrets/await-async-secret.js +0 -29
  103. package/dist/sdk/utils/secrets/do-get-secret.d.ts +0 -1
  104. package/dist/sdk/utils/secrets/do-get-secret.js +0 -14
  105. package/dist/sdk/utils/secrets/get-secret.d.ts +0 -1
  106. package/dist/sdk/utils/secrets/get-secret.js +0 -10
  107. package/dist/sdk/utils/send-error.d.ts +0 -1
  108. package/dist/sdk/utils/send-error.js +0 -16
  109. package/dist/sdk/utils/send-response-value.d.ts +0 -2
  110. package/dist/sdk/utils/send-response-value.js +0 -15
  111. package/dist/sdk/utils/time/get-time.d.ts +0 -16
  112. package/dist/sdk/utils/time/get-time.js +0 -21
  113. /package/dist/sdk/{engine/execute.test.d.ts → impl/runtime-impl.test.d.ts} +0 -0
  114. /package/dist/sdk/{runtime/run-in-node-mode.test.d.ts → runtime.js} +0 -0
@@ -1,26 +1,19 @@
1
- import { create, fromBinary, fromJson, toBinary } from '@bufbuild/protobuf';
2
- import { AnySchema, EmptySchema } from '@bufbuild/protobuf/wkt';
1
+ import { create, fromJson } from '@bufbuild/protobuf';
2
+ import { AnySchema, anyPack, EmptySchema } from '@bufbuild/protobuf/wkt';
3
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';
4
- import { Mode } from '../../../../../generated/sdk/v1alpha/sdk_pb';
5
- import { callCapability } from '../../../../../sdk/utils/capabilities/call-capability';
6
- import { CapabilityError } from '../../../../../sdk/utils/capabilities/capability-error';
4
+ import {} from '../../../../../sdk/runtime';
7
5
  import {} from '../../../../../sdk/utils/triggers/trigger-interface';
8
- import { getTypeUrl } from '../../../../../sdk/utils/typeurl';
9
6
  /**
10
7
  * Client Capability
11
8
  *
12
9
  * Capability ID: evm@1.0.0
13
- * Default Mode: Mode.DON
14
10
  * Capability Name: evm
15
11
  * Capability Version: 1.0.0
16
12
  */
17
13
  export class ClientCapability {
18
- mode;
19
14
  chainSelector;
20
15
  /** The capability ID for this service */
21
16
  static CAPABILITY_ID = 'evm@1.0.0';
22
- /** The default execution mode for this capability */
23
- static DEFAULT_MODE = Mode.DON;
24
17
  static CAPABILITY_NAME = 'evm';
25
18
  static CAPABILITY_VERSION = '1.0.0';
26
19
  /** Available chain selectors */
@@ -39,410 +32,233 @@ export class ClientCapability {
39
32
  'polygon-mainnet': 4051577828743386545n,
40
33
  'polygon-testnet-amoy': 16281711391670634445n,
41
34
  };
42
- constructor(mode = ClientCapability.DEFAULT_MODE, chainSelector) {
43
- this.mode = mode;
35
+ constructor(chainSelector) {
44
36
  this.chainSelector = chainSelector;
45
37
  }
46
- callContract(input) {
38
+ callContract(runtime, input) {
47
39
  // biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
48
- const value = input.$typeName
40
+ const payload = input.$typeName
49
41
  ? input
50
42
  : fromJson(CallContractRequestSchema, input);
51
- const payload = {
52
- typeUrl: getTypeUrl(CallContractRequestSchema),
53
- value: toBinary(CallContractRequestSchema, value),
54
- };
55
43
  // Include chainSelector in capability ID for routing when specified
56
44
  const capabilityId = this.chainSelector
57
45
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
58
46
  : ClientCapability.CAPABILITY_ID;
59
- const capabilityResponse = callCapability({
47
+ const capabilityResponse = runtime.callCapability({
60
48
  capabilityId,
61
49
  method: 'CallContract',
62
- mode: this.mode,
63
50
  payload,
51
+ inputSchema: CallContractRequestSchema,
52
+ outputSchema: CallContractReplySchema,
64
53
  });
65
54
  return {
66
55
  result: async () => {
67
- const { response } = await capabilityResponse.result();
68
- if (response.case === 'error') {
69
- throw new CapabilityError(response.value, {
70
- capabilityId,
71
- method: 'CallContract',
72
- mode: this.mode,
73
- });
74
- }
75
- if (response.case !== 'payload') {
76
- throw new CapabilityError('No payload in response', {
77
- capabilityId,
78
- method: 'CallContract',
79
- mode: this.mode,
80
- });
81
- }
82
- return fromBinary(CallContractReplySchema, response.value.value);
56
+ return capabilityResponse.result();
83
57
  },
84
58
  };
85
59
  }
86
- filterLogs(input) {
60
+ filterLogs(runtime, input) {
87
61
  // biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
88
- const value = input.$typeName
62
+ const payload = input.$typeName
89
63
  ? input
90
64
  : fromJson(FilterLogsRequestSchema, input);
91
- const payload = {
92
- typeUrl: getTypeUrl(FilterLogsRequestSchema),
93
- value: toBinary(FilterLogsRequestSchema, value),
94
- };
95
65
  // Include chainSelector in capability ID for routing when specified
96
66
  const capabilityId = this.chainSelector
97
67
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
98
68
  : ClientCapability.CAPABILITY_ID;
99
- const capabilityResponse = callCapability({
69
+ const capabilityResponse = runtime.callCapability({
100
70
  capabilityId,
101
71
  method: 'FilterLogs',
102
- mode: this.mode,
103
72
  payload,
73
+ inputSchema: FilterLogsRequestSchema,
74
+ outputSchema: FilterLogsReplySchema,
104
75
  });
105
76
  return {
106
77
  result: async () => {
107
- const { response } = await capabilityResponse.result();
108
- if (response.case === 'error') {
109
- throw new CapabilityError(response.value, {
110
- capabilityId,
111
- method: 'FilterLogs',
112
- mode: this.mode,
113
- });
114
- }
115
- if (response.case !== 'payload') {
116
- throw new CapabilityError('No payload in response', {
117
- capabilityId,
118
- method: 'FilterLogs',
119
- mode: this.mode,
120
- });
121
- }
122
- return fromBinary(FilterLogsReplySchema, response.value.value);
78
+ return capabilityResponse.result();
123
79
  },
124
80
  };
125
81
  }
126
- balanceAt(input) {
82
+ balanceAt(runtime, input) {
127
83
  // biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
128
- const value = input.$typeName
84
+ const payload = input.$typeName
129
85
  ? input
130
86
  : fromJson(BalanceAtRequestSchema, input);
131
- const payload = {
132
- typeUrl: getTypeUrl(BalanceAtRequestSchema),
133
- value: toBinary(BalanceAtRequestSchema, value),
134
- };
135
87
  // Include chainSelector in capability ID for routing when specified
136
88
  const capabilityId = this.chainSelector
137
89
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
138
90
  : ClientCapability.CAPABILITY_ID;
139
- const capabilityResponse = callCapability({
91
+ const capabilityResponse = runtime.callCapability({
140
92
  capabilityId,
141
93
  method: 'BalanceAt',
142
- mode: this.mode,
143
94
  payload,
95
+ inputSchema: BalanceAtRequestSchema,
96
+ outputSchema: BalanceAtReplySchema,
144
97
  });
145
98
  return {
146
99
  result: async () => {
147
- const { response } = await capabilityResponse.result();
148
- if (response.case === 'error') {
149
- throw new CapabilityError(response.value, {
150
- capabilityId,
151
- method: 'BalanceAt',
152
- mode: this.mode,
153
- });
154
- }
155
- if (response.case !== 'payload') {
156
- throw new CapabilityError('No payload in response', {
157
- capabilityId,
158
- method: 'BalanceAt',
159
- mode: this.mode,
160
- });
161
- }
162
- return fromBinary(BalanceAtReplySchema, response.value.value);
100
+ return capabilityResponse.result();
163
101
  },
164
102
  };
165
103
  }
166
- estimateGas(input) {
104
+ estimateGas(runtime, input) {
167
105
  // biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
168
- const value = input.$typeName
106
+ const payload = input.$typeName
169
107
  ? input
170
108
  : fromJson(EstimateGasRequestSchema, input);
171
- const payload = {
172
- typeUrl: getTypeUrl(EstimateGasRequestSchema),
173
- value: toBinary(EstimateGasRequestSchema, value),
174
- };
175
109
  // Include chainSelector in capability ID for routing when specified
176
110
  const capabilityId = this.chainSelector
177
111
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
178
112
  : ClientCapability.CAPABILITY_ID;
179
- const capabilityResponse = callCapability({
113
+ const capabilityResponse = runtime.callCapability({
180
114
  capabilityId,
181
115
  method: 'EstimateGas',
182
- mode: this.mode,
183
116
  payload,
117
+ inputSchema: EstimateGasRequestSchema,
118
+ outputSchema: EstimateGasReplySchema,
184
119
  });
185
120
  return {
186
121
  result: async () => {
187
- const { response } = await capabilityResponse.result();
188
- if (response.case === 'error') {
189
- throw new CapabilityError(response.value, {
190
- capabilityId,
191
- method: 'EstimateGas',
192
- mode: this.mode,
193
- });
194
- }
195
- if (response.case !== 'payload') {
196
- throw new CapabilityError('No payload in response', {
197
- capabilityId,
198
- method: 'EstimateGas',
199
- mode: this.mode,
200
- });
201
- }
202
- return fromBinary(EstimateGasReplySchema, response.value.value);
122
+ return capabilityResponse.result();
203
123
  },
204
124
  };
205
125
  }
206
- getTransactionByHash(input) {
126
+ getTransactionByHash(runtime, input) {
207
127
  // biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
208
- const value = input.$typeName
128
+ const payload = input.$typeName
209
129
  ? input
210
130
  : fromJson(GetTransactionByHashRequestSchema, input);
211
- const payload = {
212
- typeUrl: getTypeUrl(GetTransactionByHashRequestSchema),
213
- value: toBinary(GetTransactionByHashRequestSchema, value),
214
- };
215
131
  // Include chainSelector in capability ID for routing when specified
216
132
  const capabilityId = this.chainSelector
217
133
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
218
134
  : ClientCapability.CAPABILITY_ID;
219
- const capabilityResponse = callCapability({
135
+ const capabilityResponse = runtime.callCapability({
220
136
  capabilityId,
221
137
  method: 'GetTransactionByHash',
222
- mode: this.mode,
223
138
  payload,
139
+ inputSchema: GetTransactionByHashRequestSchema,
140
+ outputSchema: GetTransactionByHashReplySchema,
224
141
  });
225
142
  return {
226
143
  result: async () => {
227
- const { response } = await capabilityResponse.result();
228
- if (response.case === 'error') {
229
- throw new CapabilityError(response.value, {
230
- capabilityId,
231
- method: 'GetTransactionByHash',
232
- mode: this.mode,
233
- });
234
- }
235
- if (response.case !== 'payload') {
236
- throw new CapabilityError('No payload in response', {
237
- capabilityId,
238
- method: 'GetTransactionByHash',
239
- mode: this.mode,
240
- });
241
- }
242
- return fromBinary(GetTransactionByHashReplySchema, response.value.value);
144
+ return capabilityResponse.result();
243
145
  },
244
146
  };
245
147
  }
246
- getTransactionReceipt(input) {
148
+ getTransactionReceipt(runtime, input) {
247
149
  // biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
248
- const value = input.$typeName
150
+ const payload = input.$typeName
249
151
  ? input
250
152
  : fromJson(GetTransactionReceiptRequestSchema, input);
251
- const payload = {
252
- typeUrl: getTypeUrl(GetTransactionReceiptRequestSchema),
253
- value: toBinary(GetTransactionReceiptRequestSchema, value),
254
- };
255
153
  // Include chainSelector in capability ID for routing when specified
256
154
  const capabilityId = this.chainSelector
257
155
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
258
156
  : ClientCapability.CAPABILITY_ID;
259
- const capabilityResponse = callCapability({
157
+ const capabilityResponse = runtime.callCapability({
260
158
  capabilityId,
261
159
  method: 'GetTransactionReceipt',
262
- mode: this.mode,
263
160
  payload,
161
+ inputSchema: GetTransactionReceiptRequestSchema,
162
+ outputSchema: GetTransactionReceiptReplySchema,
264
163
  });
265
164
  return {
266
165
  result: async () => {
267
- const { response } = await capabilityResponse.result();
268
- if (response.case === 'error') {
269
- throw new CapabilityError(response.value, {
270
- capabilityId,
271
- method: 'GetTransactionReceipt',
272
- mode: this.mode,
273
- });
274
- }
275
- if (response.case !== 'payload') {
276
- throw new CapabilityError('No payload in response', {
277
- capabilityId,
278
- method: 'GetTransactionReceipt',
279
- mode: this.mode,
280
- });
281
- }
282
- return fromBinary(GetTransactionReceiptReplySchema, response.value.value);
166
+ return capabilityResponse.result();
283
167
  },
284
168
  };
285
169
  }
286
- headerByNumber(input) {
170
+ headerByNumber(runtime, input) {
287
171
  // biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
288
- const value = input.$typeName
172
+ const payload = input.$typeName
289
173
  ? input
290
174
  : fromJson(HeaderByNumberRequestSchema, input);
291
- const payload = {
292
- typeUrl: getTypeUrl(HeaderByNumberRequestSchema),
293
- value: toBinary(HeaderByNumberRequestSchema, value),
294
- };
295
175
  // Include chainSelector in capability ID for routing when specified
296
176
  const capabilityId = this.chainSelector
297
177
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
298
178
  : ClientCapability.CAPABILITY_ID;
299
- const capabilityResponse = callCapability({
179
+ const capabilityResponse = runtime.callCapability({
300
180
  capabilityId,
301
181
  method: 'HeaderByNumber',
302
- mode: this.mode,
303
182
  payload,
183
+ inputSchema: HeaderByNumberRequestSchema,
184
+ outputSchema: HeaderByNumberReplySchema,
304
185
  });
305
186
  return {
306
187
  result: async () => {
307
- const { response } = await capabilityResponse.result();
308
- if (response.case === 'error') {
309
- throw new CapabilityError(response.value, {
310
- capabilityId,
311
- method: 'HeaderByNumber',
312
- mode: this.mode,
313
- });
314
- }
315
- if (response.case !== 'payload') {
316
- throw new CapabilityError('No payload in response', {
317
- capabilityId,
318
- method: 'HeaderByNumber',
319
- mode: this.mode,
320
- });
321
- }
322
- return fromBinary(HeaderByNumberReplySchema, response.value.value);
188
+ return capabilityResponse.result();
323
189
  },
324
190
  };
325
191
  }
326
- registerLogTracking(input) {
192
+ registerLogTracking(runtime, input) {
327
193
  // biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
328
- const value = input.$typeName
194
+ const payload = input.$typeName
329
195
  ? input
330
196
  : fromJson(RegisterLogTrackingRequestSchema, input);
331
- const payload = {
332
- typeUrl: getTypeUrl(RegisterLogTrackingRequestSchema),
333
- value: toBinary(RegisterLogTrackingRequestSchema, value),
334
- };
335
197
  // Include chainSelector in capability ID for routing when specified
336
198
  const capabilityId = this.chainSelector
337
199
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
338
200
  : ClientCapability.CAPABILITY_ID;
339
- const capabilityResponse = callCapability({
201
+ const capabilityResponse = runtime.callCapability({
340
202
  capabilityId,
341
203
  method: 'RegisterLogTracking',
342
- mode: this.mode,
343
204
  payload,
205
+ inputSchema: RegisterLogTrackingRequestSchema,
206
+ outputSchema: EmptySchema,
344
207
  });
345
208
  return {
346
209
  result: async () => {
347
- const { response } = await capabilityResponse.result();
348
- if (response.case === 'error') {
349
- throw new CapabilityError(response.value, {
350
- capabilityId,
351
- method: 'RegisterLogTracking',
352
- mode: this.mode,
353
- });
354
- }
355
- if (response.case !== 'payload') {
356
- throw new CapabilityError('No payload in response', {
357
- capabilityId,
358
- method: 'RegisterLogTracking',
359
- mode: this.mode,
360
- });
361
- }
362
- return fromBinary(EmptySchema, response.value.value);
210
+ return capabilityResponse.result();
363
211
  },
364
212
  };
365
213
  }
366
- unregisterLogTracking(input) {
214
+ unregisterLogTracking(runtime, input) {
367
215
  // biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
368
- const value = input.$typeName
216
+ const payload = input.$typeName
369
217
  ? input
370
218
  : fromJson(UnregisterLogTrackingRequestSchema, input);
371
- const payload = {
372
- typeUrl: getTypeUrl(UnregisterLogTrackingRequestSchema),
373
- value: toBinary(UnregisterLogTrackingRequestSchema, value),
374
- };
375
219
  // Include chainSelector in capability ID for routing when specified
376
220
  const capabilityId = this.chainSelector
377
221
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
378
222
  : ClientCapability.CAPABILITY_ID;
379
- const capabilityResponse = callCapability({
223
+ const capabilityResponse = runtime.callCapability({
380
224
  capabilityId,
381
225
  method: 'UnregisterLogTracking',
382
- mode: this.mode,
383
226
  payload,
227
+ inputSchema: UnregisterLogTrackingRequestSchema,
228
+ outputSchema: EmptySchema,
384
229
  });
385
230
  return {
386
231
  result: async () => {
387
- const { response } = await capabilityResponse.result();
388
- if (response.case === 'error') {
389
- throw new CapabilityError(response.value, {
390
- capabilityId,
391
- method: 'UnregisterLogTracking',
392
- mode: this.mode,
393
- });
394
- }
395
- if (response.case !== 'payload') {
396
- throw new CapabilityError('No payload in response', {
397
- capabilityId,
398
- method: 'UnregisterLogTracking',
399
- mode: this.mode,
400
- });
401
- }
402
- return fromBinary(EmptySchema, response.value.value);
232
+ return capabilityResponse.result();
403
233
  },
404
234
  };
405
235
  }
406
236
  logTrigger(config) {
407
- return new ClientLogTrigger(this.mode, config, ClientCapability.CAPABILITY_ID, 'LogTrigger');
237
+ // Include chainSelector in capability ID for routing when specified
238
+ const capabilityId = this.chainSelector
239
+ ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
240
+ : ClientCapability.CAPABILITY_ID;
241
+ return new ClientLogTrigger(config, capabilityId, 'LogTrigger');
408
242
  }
409
- writeReport(input) {
243
+ writeReport(runtime, input) {
410
244
  // biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
411
- const value = input.$typeName
245
+ const payload = input.$typeName
412
246
  ? input
413
247
  : fromJson(WriteReportRequestSchema, input);
414
- const payload = {
415
- typeUrl: getTypeUrl(WriteReportRequestSchema),
416
- value: toBinary(WriteReportRequestSchema, value),
417
- };
418
248
  // Include chainSelector in capability ID for routing when specified
419
249
  const capabilityId = this.chainSelector
420
250
  ? `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.chainSelector}@${ClientCapability.CAPABILITY_VERSION}`
421
251
  : ClientCapability.CAPABILITY_ID;
422
- const capabilityResponse = callCapability({
252
+ const capabilityResponse = runtime.callCapability({
423
253
  capabilityId,
424
254
  method: 'WriteReport',
425
- mode: this.mode,
426
255
  payload,
256
+ inputSchema: WriteReportRequestSchema,
257
+ outputSchema: WriteReportReplySchema,
427
258
  });
428
259
  return {
429
260
  result: async () => {
430
- const { response } = await capabilityResponse.result();
431
- if (response.case === 'error') {
432
- throw new CapabilityError(response.value, {
433
- capabilityId,
434
- method: 'WriteReport',
435
- mode: this.mode,
436
- });
437
- }
438
- if (response.case !== 'payload') {
439
- throw new CapabilityError('No payload in response', {
440
- capabilityId,
441
- method: 'WriteReport',
442
- mode: this.mode,
443
- });
444
- }
445
- return fromBinary(WriteReportReplySchema, response.value.value);
261
+ return capabilityResponse.result();
446
262
  },
447
263
  };
448
264
  }
@@ -451,12 +267,10 @@ export class ClientCapability {
451
267
  * Trigger implementation for LogTrigger
452
268
  */
453
269
  class ClientLogTrigger {
454
- mode;
455
270
  _capabilityId;
456
271
  _method;
457
272
  config;
458
- constructor(mode, config, _capabilityId, _method) {
459
- this.mode = mode;
273
+ constructor(config, _capabilityId, _method) {
460
274
  this._capabilityId = _capabilityId;
461
275
  this._method = _method;
462
276
  // biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
@@ -474,10 +288,7 @@ class ClientLogTrigger {
474
288
  return LogSchema;
475
289
  }
476
290
  configAsAny() {
477
- return create(AnySchema, {
478
- typeUrl: getTypeUrl(FilterLogTriggerRequestSchema),
479
- value: toBinary(FilterLogTriggerRequestSchema, this.config),
480
- });
291
+ return anyPack(FilterLogTriggerRequestSchema, this.config);
481
292
  }
482
293
  /**
483
294
  * Transform the raw trigger output - override this method if needed
@@ -1,25 +1,21 @@
1
1
  import { type Any } from '@bufbuild/protobuf/wkt';
2
2
  import { type Config, type ConfigJson, type Input, type InputJson, type Output, type TriggerEvent } from '../../../../../generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb';
3
- import { Mode } from '../../../../../generated/sdk/v1alpha/sdk_pb';
3
+ import { type Runtime } from '../../../../../sdk/runtime';
4
4
  import { type Trigger } from '../../../../../sdk/utils/triggers/trigger-interface';
5
5
  /**
6
6
  * Basic Capability
7
7
  *
8
8
  * Capability ID: basic-test-action-trigger@1.0.0
9
- * Default Mode: Mode.DON
10
9
  * Capability Name: basic-test-action-trigger
11
10
  * Capability Version: 1.0.0
12
11
  */
13
12
  export declare class BasicCapability {
14
- private readonly mode;
15
13
  /** The capability ID for this service */
16
14
  static readonly CAPABILITY_ID = "basic-test-action-trigger@1.0.0";
17
- /** The default execution mode for this capability */
18
- static readonly DEFAULT_MODE = Mode.DON;
19
15
  static readonly CAPABILITY_NAME = "basic-test-action-trigger";
20
16
  static readonly CAPABILITY_VERSION = "1.0.0";
21
- constructor(mode?: Mode);
22
- action(input: Input | InputJson): {
17
+ constructor();
18
+ action(runtime: Runtime<any>, input: Input | InputJson): {
23
19
  result: () => Promise<Output>;
24
20
  };
25
21
  trigger(config: ConfigJson): BasicTrigger;
@@ -28,11 +24,10 @@ export declare class BasicCapability {
28
24
  * Trigger implementation for Trigger
29
25
  */
30
26
  declare class BasicTrigger implements Trigger<TriggerEvent, TriggerEvent> {
31
- readonly mode: Mode;
32
27
  private readonly _capabilityId;
33
28
  private readonly _method;
34
29
  readonly config: Config;
35
- constructor(mode: Mode, config: Config | ConfigJson, _capabilityId: string, _method: string);
30
+ constructor(config: Config | ConfigJson, _capabilityId: string, _method: string);
36
31
  capabilityId(): string;
37
32
  method(): string;
38
33
  outputSchema(): import("@bufbuild/protobuf/codegenv2").GenMessage<TriggerEvent, {