@chainlink/cre-sdk 1.16.0 → 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 (26) hide show
  1. package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.d.ts +2885 -15
  2. package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.js +459 -7
  3. package/dist/generated/capabilities/networking/http/v1alpha/client_pb.js +1 -1
  4. package/dist/generated/chain-selectors/testnet/evm/glamsterdam-devnet-6.d.ts +3 -0
  5. package/dist/generated/chain-selectors/testnet/evm/glamsterdam-devnet-6.js +12 -0
  6. package/dist/generated/chain-selectors/testnet/evm/t-rex-testnet.d.ts +3 -0
  7. package/dist/generated/chain-selectors/testnet/evm/t-rex-testnet.js +12 -0
  8. package/dist/generated/networks.d.ts +1 -1
  9. package/dist/generated/networks.js +14 -0
  10. package/dist/generated/sdk/v1alpha/sdk_pb.d.ts +505 -0
  11. package/dist/generated/sdk/v1alpha/sdk_pb.js +121 -15
  12. package/dist/generated/tools/generator/v1alpha/cre_metadata_pb.d.ts +30 -1
  13. package/dist/generated/tools/generator/v1alpha/cre_metadata_pb.js +20 -2
  14. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.d.ts +54 -2
  15. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +287 -1
  16. package/dist/sdk/cre/index.d.ts +2 -2
  17. package/dist/sdk/cre/index.js +1 -1
  18. package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.d.ts +19 -1
  19. package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.js +141 -1
  20. package/dist/sdk/utils/capabilities/blockchain/solana/solana-helpers.d.ts +65 -1
  21. package/dist/sdk/utils/capabilities/blockchain/solana/solana-helpers.js +76 -0
  22. package/dist/sdk/utils/index.d.ts +1 -0
  23. package/dist/sdk/utils/index.js +1 -0
  24. package/dist/sdk/utils/triggers/trigger-interface.d.ts +7 -0
  25. package/dist/sdk/utils/triggers/trigger-interface.js +13 -1
  26. package/package.json +2 -2
@@ -1,5 +1,6 @@
1
1
  import { create, fromJson } from '@bufbuild/protobuf';
2
- import { AccountMetaSchema, ComputeConfigSchema, WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
2
+ import { AnySchema, anyPack } from '@bufbuild/protobuf/wkt';
3
+ import { AccountMetaSchema, ComputeConfigSchema, FilterLogTriggerRequestSchema, GetAccountInfoWithOptsReplySchema, GetAccountInfoWithOptsRequestSchema, GetBalanceReplySchema, GetBalanceRequestSchema, GetBlockReplySchema, GetBlockRequestSchema, GetFeeForMessageReplySchema, GetFeeForMessageRequestSchema, GetMultipleAccountsWithOptsReplySchema, GetMultipleAccountsWithOptsRequestSchema, GetProgramAccountsReplySchema, GetProgramAccountsRequestSchema, GetSignatureStatusesReplySchema, GetSignatureStatusesRequestSchema, GetSlotHeightReplySchema, GetSlotHeightRequestSchema, GetTransactionReplySchema, GetTransactionRequestSchema, LogSchema, WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
3
4
  import { ReportResponseSchema, } from '../../../../../generated/sdk/v1alpha/sdk_pb';
4
5
  import { Report } from '../../../../../sdk/report';
5
6
  import { hexToBytes } from '../../../../../sdk/utils/hex-utils';
@@ -52,6 +53,254 @@ export class ClientCapability {
52
53
  constructor(ChainSelector) {
53
54
  this.ChainSelector = ChainSelector;
54
55
  }
56
+ getAccountInfoWithOpts(runtime, input) {
57
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
58
+ let payload;
59
+ if (input.$typeName) {
60
+ // It's the original protobuf type
61
+ payload = input;
62
+ }
63
+ else {
64
+ // It's regular JSON, convert using fromJson
65
+ payload = fromJson(GetAccountInfoWithOptsRequestSchema, input);
66
+ }
67
+ // Include all labels in capability ID for routing when specified
68
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
69
+ const capabilityResponse = runtime.callCapability({
70
+ capabilityId,
71
+ method: 'GetAccountInfoWithOpts',
72
+ payload,
73
+ inputSchema: GetAccountInfoWithOptsRequestSchema,
74
+ outputSchema: GetAccountInfoWithOptsReplySchema,
75
+ });
76
+ return {
77
+ result: () => {
78
+ const result = capabilityResponse.result();
79
+ return result;
80
+ },
81
+ };
82
+ }
83
+ getBalance(runtime, input) {
84
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
85
+ let payload;
86
+ if (input.$typeName) {
87
+ // It's the original protobuf type
88
+ payload = input;
89
+ }
90
+ else {
91
+ // It's regular JSON, convert using fromJson
92
+ payload = fromJson(GetBalanceRequestSchema, input);
93
+ }
94
+ // Include all labels in capability ID for routing when specified
95
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
96
+ const capabilityResponse = runtime.callCapability({
97
+ capabilityId,
98
+ method: 'GetBalance',
99
+ payload,
100
+ inputSchema: GetBalanceRequestSchema,
101
+ outputSchema: GetBalanceReplySchema,
102
+ });
103
+ return {
104
+ result: () => {
105
+ const result = capabilityResponse.result();
106
+ return result;
107
+ },
108
+ };
109
+ }
110
+ getBlock(runtime, input) {
111
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
112
+ let payload;
113
+ if (input.$typeName) {
114
+ // It's the original protobuf type
115
+ payload = input;
116
+ }
117
+ else {
118
+ // It's regular JSON, convert using fromJson
119
+ payload = fromJson(GetBlockRequestSchema, input);
120
+ }
121
+ // Include all labels in capability ID for routing when specified
122
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
123
+ const capabilityResponse = runtime.callCapability({
124
+ capabilityId,
125
+ method: 'GetBlock',
126
+ payload,
127
+ inputSchema: GetBlockRequestSchema,
128
+ outputSchema: GetBlockReplySchema,
129
+ });
130
+ return {
131
+ result: () => {
132
+ const result = capabilityResponse.result();
133
+ return result;
134
+ },
135
+ };
136
+ }
137
+ getFeeForMessage(runtime, input) {
138
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
139
+ let payload;
140
+ if (input.$typeName) {
141
+ // It's the original protobuf type
142
+ payload = input;
143
+ }
144
+ else {
145
+ // It's regular JSON, convert using fromJson
146
+ payload = fromJson(GetFeeForMessageRequestSchema, input);
147
+ }
148
+ // Include all labels in capability ID for routing when specified
149
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
150
+ const capabilityResponse = runtime.callCapability({
151
+ capabilityId,
152
+ method: 'GetFeeForMessage',
153
+ payload,
154
+ inputSchema: GetFeeForMessageRequestSchema,
155
+ outputSchema: GetFeeForMessageReplySchema,
156
+ });
157
+ return {
158
+ result: () => {
159
+ const result = capabilityResponse.result();
160
+ return result;
161
+ },
162
+ };
163
+ }
164
+ getMultipleAccountsWithOpts(runtime, input) {
165
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
166
+ let payload;
167
+ if (input.$typeName) {
168
+ // It's the original protobuf type
169
+ payload = input;
170
+ }
171
+ else {
172
+ // It's regular JSON, convert using fromJson
173
+ payload = fromJson(GetMultipleAccountsWithOptsRequestSchema, input);
174
+ }
175
+ // Include all labels in capability ID for routing when specified
176
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
177
+ const capabilityResponse = runtime.callCapability({
178
+ capabilityId,
179
+ method: 'GetMultipleAccountsWithOpts',
180
+ payload,
181
+ inputSchema: GetMultipleAccountsWithOptsRequestSchema,
182
+ outputSchema: GetMultipleAccountsWithOptsReplySchema,
183
+ });
184
+ return {
185
+ result: () => {
186
+ const result = capabilityResponse.result();
187
+ return result;
188
+ },
189
+ };
190
+ }
191
+ getProgramAccounts(runtime, input) {
192
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
193
+ let payload;
194
+ if (input.$typeName) {
195
+ // It's the original protobuf type
196
+ payload = input;
197
+ }
198
+ else {
199
+ // It's regular JSON, convert using fromJson
200
+ payload = fromJson(GetProgramAccountsRequestSchema, input);
201
+ }
202
+ // Include all labels in capability ID for routing when specified
203
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
204
+ const capabilityResponse = runtime.callCapability({
205
+ capabilityId,
206
+ method: 'GetProgramAccounts',
207
+ payload,
208
+ inputSchema: GetProgramAccountsRequestSchema,
209
+ outputSchema: GetProgramAccountsReplySchema,
210
+ });
211
+ return {
212
+ result: () => {
213
+ const result = capabilityResponse.result();
214
+ return result;
215
+ },
216
+ };
217
+ }
218
+ getSignatureStatuses(runtime, input) {
219
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
220
+ let payload;
221
+ if (input.$typeName) {
222
+ // It's the original protobuf type
223
+ payload = input;
224
+ }
225
+ else {
226
+ // It's regular JSON, convert using fromJson
227
+ payload = fromJson(GetSignatureStatusesRequestSchema, input);
228
+ }
229
+ // Include all labels in capability ID for routing when specified
230
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
231
+ const capabilityResponse = runtime.callCapability({
232
+ capabilityId,
233
+ method: 'GetSignatureStatuses',
234
+ payload,
235
+ inputSchema: GetSignatureStatusesRequestSchema,
236
+ outputSchema: GetSignatureStatusesReplySchema,
237
+ });
238
+ return {
239
+ result: () => {
240
+ const result = capabilityResponse.result();
241
+ return result;
242
+ },
243
+ };
244
+ }
245
+ getSlotHeight(runtime, input) {
246
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
247
+ let payload;
248
+ if (input.$typeName) {
249
+ // It's the original protobuf type
250
+ payload = input;
251
+ }
252
+ else {
253
+ // It's regular JSON, convert using fromJson
254
+ payload = fromJson(GetSlotHeightRequestSchema, input);
255
+ }
256
+ // Include all labels in capability ID for routing when specified
257
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
258
+ const capabilityResponse = runtime.callCapability({
259
+ capabilityId,
260
+ method: 'GetSlotHeight',
261
+ payload,
262
+ inputSchema: GetSlotHeightRequestSchema,
263
+ outputSchema: GetSlotHeightReplySchema,
264
+ });
265
+ return {
266
+ result: () => {
267
+ const result = capabilityResponse.result();
268
+ return result;
269
+ },
270
+ };
271
+ }
272
+ getTransaction(runtime, input) {
273
+ // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
274
+ let payload;
275
+ if (input.$typeName) {
276
+ // It's the original protobuf type
277
+ payload = input;
278
+ }
279
+ else {
280
+ // It's regular JSON, convert using fromJson
281
+ payload = fromJson(GetTransactionRequestSchema, input);
282
+ }
283
+ // Include all labels in capability ID for routing when specified
284
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
285
+ const capabilityResponse = runtime.callCapability({
286
+ capabilityId,
287
+ method: 'GetTransaction',
288
+ payload,
289
+ inputSchema: GetTransactionRequestSchema,
290
+ outputSchema: GetTransactionReplySchema,
291
+ });
292
+ return {
293
+ result: () => {
294
+ const result = capabilityResponse.result();
295
+ return result;
296
+ },
297
+ };
298
+ }
299
+ logTrigger(config) {
300
+ // Include all labels in capability ID for routing when specified
301
+ const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
302
+ return new ClientLogTrigger(config, capabilityId, 'LogTrigger', this.ChainSelector);
303
+ }
55
304
  writeReport(runtime, input) {
56
305
  // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
57
306
  let payload;
@@ -81,3 +330,40 @@ export class ClientCapability {
81
330
  };
82
331
  }
83
332
  }
333
+ /**
334
+ * Trigger implementation for LogTrigger
335
+ */
336
+ class ClientLogTrigger {
337
+ _capabilityId;
338
+ _method;
339
+ ChainSelector;
340
+ config;
341
+ constructor(config, _capabilityId, _method, ChainSelector) {
342
+ this._capabilityId = _capabilityId;
343
+ this._method = _method;
344
+ this.ChainSelector = ChainSelector;
345
+ // biome-ignore lint/suspicious/noExplicitAny: Needed for runtime type checking of protocol buffer messages
346
+ this.config = config.$typeName
347
+ ? config
348
+ : fromJson(FilterLogTriggerRequestSchema, config);
349
+ }
350
+ capabilityId() {
351
+ return this._capabilityId;
352
+ }
353
+ method() {
354
+ return this._method;
355
+ }
356
+ outputSchema() {
357
+ return LogSchema;
358
+ }
359
+ configAsAny() {
360
+ return anyPack(FilterLogTriggerRequestSchema, this.config);
361
+ }
362
+ /**
363
+ * Transform the raw trigger output - override this method if needed
364
+ * Default implementation returns the raw output unchanged
365
+ */
366
+ adapt(rawOutput) {
367
+ return rawOutput;
368
+ }
369
+ }
@@ -11,7 +11,7 @@ import { CronCapability } from '../../generated-sdk/capabilities/scheduler/cron/
11
11
  * Public exports for the CRE SDK.
12
12
  */
13
13
  export { type Log as EVMLog, TxStatus, } from '../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
14
- 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';
15
15
  export type { Payload as HTTPPayload } from '../../generated/capabilities/networking/http/v1alpha/trigger_pb';
16
16
  export type { Payload as CronPayload } from '../../generated/capabilities/scheduler/cron/v1/trigger_pb';
17
17
  export { ClientCapability as EVMClient, type WriteCreReportRequest, type WriteCreReportRequestJson, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
@@ -31,5 +31,5 @@ export declare const cre: {
31
31
  EVMClient: typeof EVMClient;
32
32
  SolanaClient: typeof SolanaClient;
33
33
  };
34
- handler: <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("../workflow").HandlerEntry<TConfig, TRawTriggerOutput, TTriggerOutput, TResult>;
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>;
35
35
  };
@@ -13,7 +13,7 @@ import { handler } from '../workflow';
13
13
  * Public exports for the CRE SDK.
14
14
  */
15
15
  export { TxStatus, } from '../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
16
- export { ReceiverContractExecutionStatus as SolanaReceiverContractExecutionStatus, TxStatus as SolanaTxStatus, } from '../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
16
+ export { ComparisonOperator as SolanaComparisonOperator, ReceiverContractExecutionStatus as SolanaReceiverContractExecutionStatus, TxStatus as SolanaTxStatus, } from '../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
17
17
  // EVM Capability
18
18
  export { ClientCapability as EVMClient, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
19
19
  // Solana Capability
@@ -1,10 +1,28 @@
1
- import { type WriteReportReply, type WriteReportReplyJson, type WriteReportRequest } from '../../../../../../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
1
+ import { type GetAccountInfoWithOptsReply, type GetAccountInfoWithOptsReplyJson, type GetAccountInfoWithOptsRequest, type GetBalanceReply, type GetBalanceReplyJson, type GetBalanceRequest, type GetBlockReply, type GetBlockReplyJson, type GetBlockRequest, type GetFeeForMessageReply, type GetFeeForMessageReplyJson, type GetFeeForMessageRequest, type GetMultipleAccountsWithOptsReply, type GetMultipleAccountsWithOptsReplyJson, type GetMultipleAccountsWithOptsRequest, type GetProgramAccountsReply, type GetProgramAccountsReplyJson, type GetProgramAccountsRequest, type GetSignatureStatusesReply, type GetSignatureStatusesReplyJson, type GetSignatureStatusesRequest, type GetSlotHeightReply, type GetSlotHeightReplyJson, type GetSlotHeightRequest, type GetTransactionReply, type GetTransactionReplyJson, type GetTransactionRequest, type WriteReportReply, type WriteReportReplyJson, type WriteReportRequest } from '../../../../../../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
2
2
  /**
3
3
  * Mock for ClientCapability. Use testInstance() to obtain an instance; do not construct directly.
4
4
  * Set per-method properties (e.g. performAction) to define return values. If a method is invoked without a handler set, an error is thrown.
5
5
  */
6
6
  export declare class SolanaMock {
7
7
  static readonly CAPABILITY_ID = "solana@1.0.0";
8
+ /** Set to define the return value for GetAccountInfoWithOpts. May return a plain object (GetAccountInfoWithOptsReplyJson) or the message type. */
9
+ getAccountInfoWithOpts?: (input: GetAccountInfoWithOptsRequest) => GetAccountInfoWithOptsReply | GetAccountInfoWithOptsReplyJson;
10
+ /** Set to define the return value for GetBalance. May return a plain object (GetBalanceReplyJson) or the message type. */
11
+ getBalance?: (input: GetBalanceRequest) => GetBalanceReply | GetBalanceReplyJson;
12
+ /** Set to define the return value for GetBlock. May return a plain object (GetBlockReplyJson) or the message type. */
13
+ getBlock?: (input: GetBlockRequest) => GetBlockReply | GetBlockReplyJson;
14
+ /** Set to define the return value for GetFeeForMessage. May return a plain object (GetFeeForMessageReplyJson) or the message type. */
15
+ getFeeForMessage?: (input: GetFeeForMessageRequest) => GetFeeForMessageReply | GetFeeForMessageReplyJson;
16
+ /** Set to define the return value for GetMultipleAccountsWithOpts. May return a plain object (GetMultipleAccountsWithOptsReplyJson) or the message type. */
17
+ getMultipleAccountsWithOpts?: (input: GetMultipleAccountsWithOptsRequest) => GetMultipleAccountsWithOptsReply | GetMultipleAccountsWithOptsReplyJson;
18
+ /** Set to define the return value for GetProgramAccounts. May return a plain object (GetProgramAccountsReplyJson) or the message type. */
19
+ getProgramAccounts?: (input: GetProgramAccountsRequest) => GetProgramAccountsReply | GetProgramAccountsReplyJson;
20
+ /** Set to define the return value for GetSignatureStatuses. May return a plain object (GetSignatureStatusesReplyJson) or the message type. */
21
+ getSignatureStatuses?: (input: GetSignatureStatusesRequest) => GetSignatureStatusesReply | GetSignatureStatusesReplyJson;
22
+ /** Set to define the return value for GetSlotHeight. May return a plain object (GetSlotHeightReplyJson) or the message type. */
23
+ getSlotHeight?: (input: GetSlotHeightRequest) => GetSlotHeightReply | GetSlotHeightReplyJson;
24
+ /** Set to define the return value for GetTransaction. May return a plain object (GetTransactionReplyJson) or the message type. */
25
+ getTransaction?: (input: GetTransactionRequest) => GetTransactionReply | GetTransactionReplyJson;
8
26
  /** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
9
27
  writeReport?: (input: WriteReportRequest) => WriteReportReply | WriteReportReplyJson;
10
28
  private constructor();
@@ -1,6 +1,6 @@
1
1
  import { fromJson } from '@bufbuild/protobuf';
2
2
  import { anyPack, anyUnpack } from '@bufbuild/protobuf/wkt';
3
- import { WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
3
+ import { GetAccountInfoWithOptsReplySchema, GetAccountInfoWithOptsRequestSchema, GetBalanceReplySchema, GetBalanceRequestSchema, GetBlockReplySchema, GetBlockRequestSchema, GetFeeForMessageReplySchema, GetFeeForMessageRequestSchema, GetMultipleAccountsWithOptsReplySchema, GetMultipleAccountsWithOptsRequestSchema, GetProgramAccountsReplySchema, GetProgramAccountsRequestSchema, GetSignatureStatusesReplySchema, GetSignatureStatusesRequestSchema, GetSlotHeightReplySchema, GetSlotHeightRequestSchema, GetTransactionReplySchema, GetTransactionRequestSchema, WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
4
4
  import { __getTestMockInstance, __setTestMockInstance, registerTestCapability, } from '../../../../../../testutils/test-runtime';
5
5
  /**
6
6
  * Mock for ClientCapability. Use testInstance() to obtain an instance; do not construct directly.
@@ -8,6 +8,24 @@ import { __getTestMockInstance, __setTestMockInstance, registerTestCapability, }
8
8
  */
9
9
  export class SolanaMock {
10
10
  static CAPABILITY_ID = 'solana@1.0.0';
11
+ /** Set to define the return value for GetAccountInfoWithOpts. May return a plain object (GetAccountInfoWithOptsReplyJson) or the message type. */
12
+ getAccountInfoWithOpts;
13
+ /** Set to define the return value for GetBalance. May return a plain object (GetBalanceReplyJson) or the message type. */
14
+ getBalance;
15
+ /** Set to define the return value for GetBlock. May return a plain object (GetBlockReplyJson) or the message type. */
16
+ getBlock;
17
+ /** Set to define the return value for GetFeeForMessage. May return a plain object (GetFeeForMessageReplyJson) or the message type. */
18
+ getFeeForMessage;
19
+ /** Set to define the return value for GetMultipleAccountsWithOpts. May return a plain object (GetMultipleAccountsWithOptsReplyJson) or the message type. */
20
+ getMultipleAccountsWithOpts;
21
+ /** Set to define the return value for GetProgramAccounts. May return a plain object (GetProgramAccountsReplyJson) or the message type. */
22
+ getProgramAccounts;
23
+ /** Set to define the return value for GetSignatureStatuses. May return a plain object (GetSignatureStatusesReplyJson) or the message type. */
24
+ getSignatureStatuses;
25
+ /** Set to define the return value for GetSlotHeight. May return a plain object (GetSlotHeightReplyJson) or the message type. */
26
+ getSlotHeight;
27
+ /** Set to define the return value for GetTransaction. May return a plain object (GetTransactionReplyJson) or the message type. */
28
+ getTransaction;
11
29
  /** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
12
30
  writeReport;
13
31
  constructor(chainSelector) {
@@ -16,6 +34,128 @@ export class SolanaMock {
16
34
  try {
17
35
  registerTestCapability(qualifiedId, (req) => {
18
36
  switch (req.method) {
37
+ case 'GetAccountInfoWithOpts': {
38
+ const input = anyUnpack(req.payload, GetAccountInfoWithOptsRequestSchema);
39
+ const handler = self.getAccountInfoWithOpts;
40
+ if (typeof handler !== 'function')
41
+ throw new Error("GetAccountInfoWithOpts: no implementation provided; set the mock's getAccountInfoWithOpts property to define the return value.");
42
+ const raw = handler(input);
43
+ const output = raw && typeof raw.$typeName === 'string'
44
+ ? raw
45
+ : fromJson(GetAccountInfoWithOptsReplySchema, raw);
46
+ return {
47
+ response: {
48
+ case: 'payload',
49
+ value: anyPack(GetAccountInfoWithOptsReplySchema, output),
50
+ },
51
+ };
52
+ }
53
+ case 'GetBalance': {
54
+ const input = anyUnpack(req.payload, GetBalanceRequestSchema);
55
+ const handler = self.getBalance;
56
+ if (typeof handler !== 'function')
57
+ throw new Error("GetBalance: no implementation provided; set the mock's getBalance property to define the return value.");
58
+ const raw = handler(input);
59
+ const output = raw && typeof raw.$typeName === 'string'
60
+ ? raw
61
+ : fromJson(GetBalanceReplySchema, raw);
62
+ return { response: { case: 'payload', value: anyPack(GetBalanceReplySchema, output) } };
63
+ }
64
+ case 'GetBlock': {
65
+ const input = anyUnpack(req.payload, GetBlockRequestSchema);
66
+ const handler = self.getBlock;
67
+ if (typeof handler !== 'function')
68
+ throw new Error("GetBlock: no implementation provided; set the mock's getBlock property to define the return value.");
69
+ const raw = handler(input);
70
+ const output = raw && typeof raw.$typeName === 'string'
71
+ ? raw
72
+ : fromJson(GetBlockReplySchema, raw);
73
+ return { response: { case: 'payload', value: anyPack(GetBlockReplySchema, output) } };
74
+ }
75
+ case 'GetFeeForMessage': {
76
+ const input = anyUnpack(req.payload, GetFeeForMessageRequestSchema);
77
+ const handler = self.getFeeForMessage;
78
+ if (typeof handler !== 'function')
79
+ throw new Error("GetFeeForMessage: no implementation provided; set the mock's getFeeForMessage property to define the return value.");
80
+ const raw = handler(input);
81
+ const output = raw && typeof raw.$typeName === 'string'
82
+ ? raw
83
+ : fromJson(GetFeeForMessageReplySchema, raw);
84
+ return {
85
+ response: { case: 'payload', value: anyPack(GetFeeForMessageReplySchema, output) },
86
+ };
87
+ }
88
+ case 'GetMultipleAccountsWithOpts': {
89
+ const input = anyUnpack(req.payload, GetMultipleAccountsWithOptsRequestSchema);
90
+ const handler = self.getMultipleAccountsWithOpts;
91
+ if (typeof handler !== 'function')
92
+ throw new Error("GetMultipleAccountsWithOpts: no implementation provided; set the mock's getMultipleAccountsWithOpts property to define the return value.");
93
+ const raw = handler(input);
94
+ const output = raw && typeof raw.$typeName === 'string'
95
+ ? raw
96
+ : fromJson(GetMultipleAccountsWithOptsReplySchema, raw);
97
+ return {
98
+ response: {
99
+ case: 'payload',
100
+ value: anyPack(GetMultipleAccountsWithOptsReplySchema, output),
101
+ },
102
+ };
103
+ }
104
+ case 'GetProgramAccounts': {
105
+ const input = anyUnpack(req.payload, GetProgramAccountsRequestSchema);
106
+ const handler = self.getProgramAccounts;
107
+ if (typeof handler !== 'function')
108
+ throw new Error("GetProgramAccounts: no implementation provided; set the mock's getProgramAccounts property to define the return value.");
109
+ const raw = handler(input);
110
+ const output = raw && typeof raw.$typeName === 'string'
111
+ ? raw
112
+ : fromJson(GetProgramAccountsReplySchema, raw);
113
+ return {
114
+ response: { case: 'payload', value: anyPack(GetProgramAccountsReplySchema, output) },
115
+ };
116
+ }
117
+ case 'GetSignatureStatuses': {
118
+ const input = anyUnpack(req.payload, GetSignatureStatusesRequestSchema);
119
+ const handler = self.getSignatureStatuses;
120
+ if (typeof handler !== 'function')
121
+ throw new Error("GetSignatureStatuses: no implementation provided; set the mock's getSignatureStatuses property to define the return value.");
122
+ const raw = handler(input);
123
+ const output = raw && typeof raw.$typeName === 'string'
124
+ ? raw
125
+ : fromJson(GetSignatureStatusesReplySchema, raw);
126
+ return {
127
+ response: {
128
+ case: 'payload',
129
+ value: anyPack(GetSignatureStatusesReplySchema, output),
130
+ },
131
+ };
132
+ }
133
+ case 'GetSlotHeight': {
134
+ const input = anyUnpack(req.payload, GetSlotHeightRequestSchema);
135
+ const handler = self.getSlotHeight;
136
+ if (typeof handler !== 'function')
137
+ throw new Error("GetSlotHeight: no implementation provided; set the mock's getSlotHeight property to define the return value.");
138
+ const raw = handler(input);
139
+ const output = raw && typeof raw.$typeName === 'string'
140
+ ? raw
141
+ : fromJson(GetSlotHeightReplySchema, raw);
142
+ return {
143
+ response: { case: 'payload', value: anyPack(GetSlotHeightReplySchema, output) },
144
+ };
145
+ }
146
+ case 'GetTransaction': {
147
+ const input = anyUnpack(req.payload, GetTransactionRequestSchema);
148
+ const handler = self.getTransaction;
149
+ if (typeof handler !== 'function')
150
+ throw new Error("GetTransaction: no implementation provided; set the mock's getTransaction property to define the return value.");
151
+ const raw = handler(input);
152
+ const output = raw && typeof raw.$typeName === 'string'
153
+ ? raw
154
+ : fromJson(GetTransactionReplySchema, raw);
155
+ return {
156
+ response: { case: 'payload', value: anyPack(GetTransactionReplySchema, output) },
157
+ };
158
+ }
19
159
  case 'WriteReport': {
20
160
  const input = anyUnpack(req.payload, WriteReportRequestSchema);
21
161
  const handler = self.writeReport;
@@ -1,4 +1,4 @@
1
- import type { AccountMetaJson, ComputeConfigJson } from '../../../../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
1
+ import type { AccountMetaJson, ComputeConfigJson, CPIFilterConfigJson, Log } from '../../../../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
2
2
  import type { ReportRequestJson } from '../../../../../generated/sdk/v1alpha/sdk_pb';
3
3
  import { type ReportEncoder } from '../report-helpers';
4
4
  /**
@@ -99,3 +99,67 @@ export declare const SOLANA_DEFAULT_REPORT_ENCODER: {
99
99
  * @returns The prepared report request.
100
100
  */
101
101
  export declare const prepareSolanaReportRequest: (payload: Uint8Array, reportEncoder?: ReportEncoder) => ReportRequestJson;
102
+ /**
103
+ * A filter value accepted by {@link prepareSubkeyValue}.
104
+ * Solana public keys must be passed as their 32 raw bytes
105
+ * (see {@link solanaAddressToBytes}), not as base58 strings.
106
+ */
107
+ export type SolanaSubkeyValue = Uint8Array | string | bigint | number;
108
+ /**
109
+ * Encodes a filter value for use in a `SubkeyConfig` `ValueComparator`,
110
+ * matching the byte representation the Solana log-trigger capability indexes.
111
+ *
112
+ * Encodings (mirrors Go `bindings.PrepareSubkeyValue`):
113
+ * - `Uint8Array` — used as-is (public keys, fixed byte arrays, `bytes` fields)
114
+ * - `string` — UTF-8 bytes
115
+ * - `bigint` / integer `number` — 8-byte big-endian two's complement
116
+ *
117
+ * For `f32`/`f64` event fields use {@link prepareSubkeyFloatValue}; passing a
118
+ * non-integer `number` here throws.
119
+ *
120
+ * @param value - The filter value to encode.
121
+ * @returns The encoded comparator value bytes.
122
+ */
123
+ export declare const prepareSubkeyValue: (value: SolanaSubkeyValue) => Uint8Array;
124
+ /**
125
+ * Encodes an `f32`/`f64` filter value into the 8-byte big-endian
126
+ * representation the Solana log-trigger capability indexes.
127
+ *
128
+ * Byte-compatible with Go `bindings.EncodeIndexedValue` for floats: positive
129
+ * values map to `float64bits + 2^63`, others to `2^63 - float64bits`
130
+ * (modulo 2^64). Ordering is preserved among values of the same sign.
131
+ *
132
+ * @param value - The float filter value to encode.
133
+ * @returns The encoded comparator value bytes.
134
+ */
135
+ export declare const prepareSubkeyFloatValue: (value: number) => Uint8Array;
136
+ /**
137
+ * A Solana log paired with its decoded event data. Generated log-trigger
138
+ * bindings adapt raw `Log` payloads into this shape.
139
+ *
140
+ * Mirrors Go `bindings.DecodedLog[T]`.
141
+ */
142
+ export type SolanaDecodedLog<T> = {
143
+ log: Log;
144
+ data: T;
145
+ };
146
+ /** Options for generated Solana log-trigger bindings. */
147
+ export interface SolanaLogTriggerOptions {
148
+ /**
149
+ * Listen for events emitted via Anchor's `emit_cpi!` (self-CPI) instead of
150
+ * program logs. Sets the trigger's CPI filter to the program's
151
+ * `anchor:event` method (see {@link anchorCPILogTriggerConfig}).
152
+ */
153
+ cpi?: boolean;
154
+ }
155
+ /**
156
+ * Builds the `CPIFilterConfig` for log triggers on events emitted via
157
+ * Anchor's `emit_cpi!`: destination is the program itself, method is
158
+ * `anchor:event`.
159
+ *
160
+ * Mirrors Go `bindings.AnchorCPILogTriggerConfig`.
161
+ *
162
+ * @param programId - The program's public key, as 32 raw bytes or a base58 string.
163
+ * @returns The CPI filter config in protobuf JSON shape.
164
+ */
165
+ export declare const anchorCPILogTriggerConfig: (programId: Uint8Array | string) => CPIFilterConfigJson;