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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +62 -2
  2. package/dist/generated/chain-selectors/testnet/evm/glamsterdam-devnet-6.d.ts +3 -0
  3. package/dist/generated/chain-selectors/testnet/evm/glamsterdam-devnet-6.js +12 -0
  4. package/dist/generated/chain-selectors/testnet/evm/t-rex-testnet.d.ts +3 -0
  5. package/dist/generated/chain-selectors/testnet/evm/t-rex-testnet.js +12 -0
  6. package/dist/generated/networks.d.ts +1 -1
  7. package/dist/generated/networks.js +14 -0
  8. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.d.ts +0 -13
  9. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.js +0 -94
  10. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.d.ts +0 -15
  11. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +0 -116
  12. package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.d.ts +1 -5
  13. package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.js +0 -22
  14. package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.d.ts +0 -4
  15. package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.js +0 -12
  16. package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.d.ts +1 -11
  17. package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.js +0 -12
  18. package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.d.ts +0 -2
  19. package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.js +0 -2
  20. package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.d.ts +0 -2
  21. package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.js +0 -2
  22. package/dist/sdk/cre/index.d.ts +16 -31
  23. package/dist/sdk/cre/index.js +15 -30
  24. package/dist/sdk/impl/runtime-impl.d.ts +1 -28
  25. package/dist/sdk/impl/runtime-impl.js +1 -52
  26. package/dist/sdk/runtime.d.ts +1 -23
  27. package/dist/sdk/test/contract-mock-core.d.ts +16 -0
  28. package/dist/sdk/test/contract-mock-core.js +21 -0
  29. package/dist/sdk/test/evm-contract-mock.js +60 -58
  30. package/dist/sdk/test/generated/index.d.ts +0 -1
  31. package/dist/sdk/test/generated/index.js +0 -1
  32. package/dist/sdk/test/index.d.ts +1 -0
  33. package/dist/sdk/test/index.js +1 -0
  34. package/dist/sdk/test/solana-contract-mock.d.ts +54 -0
  35. package/dist/sdk/test/solana-contract-mock.js +63 -0
  36. package/dist/sdk/testutils/index.d.ts +1 -1
  37. package/dist/sdk/testutils/index.js +1 -1
  38. package/dist/sdk/testutils/test-runtime.d.ts +4 -17
  39. package/dist/sdk/testutils/test-runtime.js +5 -31
  40. package/dist/sdk/testutils/test-writer.d.ts +1 -7
  41. package/dist/sdk/testutils/test-writer.js +1 -13
  42. package/dist/sdk/types/global.d.ts +0 -8
  43. package/dist/sdk/utils/capabilities/blockchain/{blockchain-helpers.d.ts → evm/evm-helpers.d.ts} +7 -6
  44. package/dist/sdk/utils/capabilities/blockchain/{blockchain-helpers.js → evm/evm-helpers.js} +6 -8
  45. package/dist/sdk/utils/capabilities/blockchain/report-helpers.d.ts +19 -0
  46. package/dist/sdk/utils/capabilities/blockchain/report-helpers.js +16 -0
  47. package/dist/sdk/utils/capabilities/blockchain/solana/solana-helpers.d.ts +165 -0
  48. package/dist/sdk/utils/capabilities/blockchain/solana/solana-helpers.js +176 -0
  49. package/dist/sdk/utils/hex-utils.d.ts +6 -0
  50. package/dist/sdk/utils/hex-utils.js +8 -0
  51. package/dist/sdk/utils/index.d.ts +4 -1
  52. package/dist/sdk/utils/index.js +3 -1
  53. package/dist/sdk/utils/triggers/trigger-interface.d.ts +7 -0
  54. package/dist/sdk/utils/triggers/trigger-interface.js +13 -1
  55. package/dist/sdk/wasm/host-bindings.d.ts +0 -4
  56. package/dist/sdk/wasm/host-bindings.js +0 -4
  57. package/dist/sdk/wasm/runner.d.ts +4 -10
  58. package/dist/sdk/wasm/runner.js +13 -86
  59. package/dist/sdk/wasm/runtime.d.ts +1 -4
  60. package/dist/sdk/wasm/runtime.js +1 -9
  61. package/dist/sdk/workflow.d.ts +7 -16
  62. package/dist/sdk/workflow.js +2 -10
  63. package/package.json +7 -4
  64. package/scripts/src/generate-sdks.ts +0 -6
  65. package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.d.ts +0 -1035
  66. package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.js +0 -290
  67. package/dist/generated/workflows/v2/cre_info_pb.d.ts +0 -123
  68. package/dist/generated/workflows/v2/cre_info_pb.js +0 -17
  69. package/dist/generated/workflows/v2/workflow_key_pb.d.ts +0 -55
  70. package/dist/generated/workflows/v2/workflow_key_pb.js +0 -17
  71. package/dist/generated/workflows/v2/workflow_user_metric_pb.d.ts +0 -118
  72. package/dist/generated/workflows/v2/workflow_user_metric_pb.js +0 -41
  73. package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.d.ts +0 -63
  74. package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.js +0 -247
  75. package/dist/sdk/tee-constraints.d.ts +0 -68
  76. package/dist/sdk/tee-constraints.js +0 -59
  77. package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.d.ts +0 -25
  78. package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.js +0 -111
  79. package/dist/workflows/standard_tests/restrictions/test.ts +0 -41
  80. package/dist/workflows/standard_tests/tee_runtime/test.ts +0 -29
@@ -1,63 +0,0 @@
1
- import { type AccountAPTBalanceReply, type AccountAPTBalanceRequest, type AccountAPTBalanceRequestJson, type AccountTransactionsReply, type AccountTransactionsRequest, type AccountTransactionsRequestJson, type GasConfig, type GasConfigJson, type TransactionByHashReply, type TransactionByHashRequest, type TransactionByHashRequestJson, type ViewReply, type ViewRequest, type ViewRequestJson, type WriteReportReply, type WriteReportRequest } from '../../../../../generated/capabilities/blockchain/aptos/v1alpha/client_pb';
2
- import { type CapabilityRestrictionJson } from '../../../../../generated/sdk/v1alpha/sdk_pb';
3
- import type { Runtime } from '../../../../../sdk';
4
- import { Report } from '../../../../../sdk/report';
5
- import type { CapabilityInput } from '../../../../../sdk/utils/types/no-excess';
6
- export type WriteCreReportRequest = {
7
- receiver: Uint8Array;
8
- gasConfig?: GasConfig;
9
- report?: Report;
10
- $report: true;
11
- };
12
- export type WriteCreReportRequestJson = {
13
- receiver: string;
14
- gasConfig?: GasConfigJson;
15
- report?: Report;
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;
20
- /**
21
- * Client Capability
22
- *
23
- * Capability ID: aptos@1.0.0
24
- * Capability Name: aptos
25
- * Capability Version: 1.0.0
26
- */
27
- export declare class ClientCapability {
28
- private readonly ChainSelector;
29
- /** The capability ID for this service */
30
- static readonly CAPABILITY_ID = "aptos@1.0.0";
31
- static readonly CAPABILITY_NAME = "aptos";
32
- static readonly CAPABILITY_VERSION = "1.0.0";
33
- /** Available ChainSelector values */
34
- static readonly SUPPORTED_CHAIN_SELECTORS: {
35
- readonly 'aptos-mainnet': 4741433654826277614n;
36
- readonly 'aptos-testnet': 743186221051783445n;
37
- };
38
- constructor(ChainSelector: bigint);
39
- accountAPTBalance<TInput>(runtime: Runtime<unknown>, input: CapabilityInput<TInput, AccountAPTBalanceRequest, AccountAPTBalanceRequestJson>): {
40
- result: () => AccountAPTBalanceReply;
41
- };
42
- view<TInput>(runtime: Runtime<unknown>, input: CapabilityInput<TInput, ViewRequest, ViewRequestJson>): {
43
- result: () => ViewReply;
44
- };
45
- transactionByHash<TInput>(runtime: Runtime<unknown>, input: CapabilityInput<TInput, TransactionByHashRequest, TransactionByHashRequestJson>): {
46
- result: () => TransactionByHashReply;
47
- };
48
- accountTransactions<TInput>(runtime: Runtime<unknown>, input: CapabilityInput<TInput, AccountTransactionsRequest, AccountTransactionsRequestJson>): {
49
- result: () => AccountTransactionsReply;
50
- };
51
- writeReport<TInput>(runtime: Runtime<unknown>, input: CapabilityInput<TInput, WriteCreReportRequest, WriteCreReportRequestJson>): {
52
- result: () => WriteReportReply;
53
- };
54
- }
55
- export declare class ClientRestrictor {
56
- private readonly ChainSelector;
57
- constructor(ChainSelector: bigint);
58
- limitAccountAPTBalance(maxCalls: number): CapabilityRestrictionJson;
59
- limitView(maxCalls: number): CapabilityRestrictionJson;
60
- limitTransactionByHash(maxCalls: number): CapabilityRestrictionJson;
61
- limitAccountTransactions(maxCalls: number): CapabilityRestrictionJson;
62
- limitWriteReport(maxCalls: number): CapabilityRestrictionJson;
63
- }
@@ -1,247 +0,0 @@
1
- import { create, fromJson } from '@bufbuild/protobuf';
2
- import { AccountAPTBalanceReplySchema, AccountAPTBalanceRequestSchema, AccountTransactionsReplySchema, AccountTransactionsRequestSchema, GasConfigSchema, TransactionByHashReplySchema, TransactionByHashRequestSchema, ViewReplySchema, ViewRequestSchema, WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../generated/capabilities/blockchain/aptos/v1alpha/client_pb';
3
- import { ReportResponseSchema, } from '../../../../../generated/sdk/v1alpha/sdk_pb';
4
- import { Report } from '../../../../../sdk/report';
5
- import { hexToBytes } from '../../../../../sdk/utils/hex-utils';
6
- export function x_generatedCodeOnly_wrap_WriteCreReportRequest(input) {
7
- return {
8
- receiver: input.receiver,
9
- gasConfig: input.gasConfig,
10
- report: input.report !== undefined ? new Report(input.report) : undefined,
11
- $report: true,
12
- };
13
- }
14
- export function createWriteCreReportRequest(input) {
15
- return {
16
- receiver: hexToBytes(input.receiver),
17
- gasConfig: input.gasConfig !== undefined ? fromJson(GasConfigSchema, input.gasConfig) : undefined,
18
- report: input.report,
19
- $report: true,
20
- };
21
- }
22
- export function x_generatedCodeOnly_unwrap_WriteCreReportRequest(input) {
23
- return create(WriteReportRequestSchema, {
24
- receiver: input.receiver,
25
- gasConfig: input.gasConfig,
26
- report: input.report !== undefined ? input.report.x_generatedCodeOnly_unwrap() : undefined,
27
- });
28
- }
29
- /**
30
- * Client Capability
31
- *
32
- * Capability ID: aptos@1.0.0
33
- * Capability Name: aptos
34
- * Capability Version: 1.0.0
35
- */
36
- export class ClientCapability {
37
- ChainSelector;
38
- /** The capability ID for this service */
39
- static CAPABILITY_ID = 'aptos@1.0.0';
40
- static CAPABILITY_NAME = 'aptos';
41
- static CAPABILITY_VERSION = '1.0.0';
42
- /** Available ChainSelector values */
43
- static SUPPORTED_CHAIN_SELECTORS = {
44
- 'aptos-mainnet': 4741433654826277614n,
45
- 'aptos-testnet': 743186221051783445n,
46
- };
47
- constructor(ChainSelector) {
48
- this.ChainSelector = ChainSelector;
49
- }
50
- accountAPTBalance(runtime, input) {
51
- // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
52
- let payload;
53
- if (input.$typeName) {
54
- // It's the original protobuf type
55
- payload = input;
56
- }
57
- else {
58
- // It's regular JSON, convert using fromJson
59
- payload = fromJson(AccountAPTBalanceRequestSchema, input);
60
- }
61
- // Include all labels in capability ID for routing when specified
62
- const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
63
- const capabilityResponse = runtime.callCapability({
64
- capabilityId,
65
- method: 'AccountAPTBalance',
66
- payload,
67
- inputSchema: AccountAPTBalanceRequestSchema,
68
- outputSchema: AccountAPTBalanceReplySchema,
69
- });
70
- return {
71
- result: () => {
72
- const result = capabilityResponse.result();
73
- return result;
74
- },
75
- };
76
- }
77
- view(runtime, input) {
78
- // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
79
- let payload;
80
- if (input.$typeName) {
81
- // It's the original protobuf type
82
- payload = input;
83
- }
84
- else {
85
- // It's regular JSON, convert using fromJson
86
- payload = fromJson(ViewRequestSchema, input);
87
- }
88
- // Include all labels in capability ID for routing when specified
89
- const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
90
- const capabilityResponse = runtime.callCapability({
91
- capabilityId,
92
- method: 'View',
93
- payload,
94
- inputSchema: ViewRequestSchema,
95
- outputSchema: ViewReplySchema,
96
- });
97
- return {
98
- result: () => {
99
- const result = capabilityResponse.result();
100
- return result;
101
- },
102
- };
103
- }
104
- transactionByHash(runtime, input) {
105
- // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
106
- let payload;
107
- if (input.$typeName) {
108
- // It's the original protobuf type
109
- payload = input;
110
- }
111
- else {
112
- // It's regular JSON, convert using fromJson
113
- payload = fromJson(TransactionByHashRequestSchema, input);
114
- }
115
- // Include all labels in capability ID for routing when specified
116
- const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
117
- const capabilityResponse = runtime.callCapability({
118
- capabilityId,
119
- method: 'TransactionByHash',
120
- payload,
121
- inputSchema: TransactionByHashRequestSchema,
122
- outputSchema: TransactionByHashReplySchema,
123
- });
124
- return {
125
- result: () => {
126
- const result = capabilityResponse.result();
127
- return result;
128
- },
129
- };
130
- }
131
- accountTransactions(runtime, input) {
132
- // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
133
- let payload;
134
- if (input.$typeName) {
135
- // It's the original protobuf type
136
- payload = input;
137
- }
138
- else {
139
- // It's regular JSON, convert using fromJson
140
- payload = fromJson(AccountTransactionsRequestSchema, input);
141
- }
142
- // Include all labels in capability ID for routing when specified
143
- const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
144
- const capabilityResponse = runtime.callCapability({
145
- capabilityId,
146
- method: 'AccountTransactions',
147
- payload,
148
- inputSchema: AccountTransactionsRequestSchema,
149
- outputSchema: AccountTransactionsReplySchema,
150
- });
151
- return {
152
- result: () => {
153
- const result = capabilityResponse.result();
154
- return result;
155
- },
156
- };
157
- }
158
- writeReport(runtime, input) {
159
- // Handle input conversion - unwrap if it's a wrapped type, convert from JSON if needed
160
- let payload;
161
- // Check if it's a wrapped type by looking for the $report property
162
- if (input.$report) {
163
- // It's a wrapped type, unwrap it
164
- payload = x_generatedCodeOnly_unwrap_WriteCreReportRequest(input);
165
- }
166
- else {
167
- // It's wrapped JSON, convert using create function
168
- payload = x_generatedCodeOnly_unwrap_WriteCreReportRequest(createWriteCreReportRequest(input));
169
- }
170
- // Include all labels in capability ID for routing when specified
171
- const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
172
- const capabilityResponse = runtime.callCapability({
173
- capabilityId,
174
- method: 'WriteReport',
175
- payload,
176
- inputSchema: WriteReportRequestSchema,
177
- outputSchema: WriteReportReplySchema,
178
- });
179
- return {
180
- result: () => {
181
- const result = capabilityResponse.result();
182
- return result;
183
- },
184
- };
185
- }
186
- }
187
- export class ClientRestrictor {
188
- ChainSelector;
189
- constructor(ChainSelector) {
190
- this.ChainSelector = ChainSelector;
191
- }
192
- limitAccountAPTBalance(maxCalls) {
193
- // Include all labels in capability ID for routing when specified
194
- const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
195
- return {
196
- method: {
197
- id: capabilityId,
198
- method: 'AccountAPTBalance',
199
- maxCalls,
200
- },
201
- };
202
- }
203
- limitView(maxCalls) {
204
- // Include all labels in capability ID for routing when specified
205
- const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
206
- return {
207
- method: {
208
- id: capabilityId,
209
- method: 'View',
210
- maxCalls,
211
- },
212
- };
213
- }
214
- limitTransactionByHash(maxCalls) {
215
- // Include all labels in capability ID for routing when specified
216
- const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
217
- return {
218
- method: {
219
- id: capabilityId,
220
- method: 'TransactionByHash',
221
- maxCalls,
222
- },
223
- };
224
- }
225
- limitAccountTransactions(maxCalls) {
226
- // Include all labels in capability ID for routing when specified
227
- const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
228
- return {
229
- method: {
230
- id: capabilityId,
231
- method: 'AccountTransactions',
232
- maxCalls,
233
- },
234
- };
235
- }
236
- limitWriteReport(maxCalls) {
237
- // Include all labels in capability ID for routing when specified
238
- const capabilityId = `${ClientCapability.CAPABILITY_NAME}:ChainSelector:${this.ChainSelector}@${ClientCapability.CAPABILITY_VERSION}`;
239
- return {
240
- method: {
241
- id: capabilityId,
242
- method: 'WriteReport',
243
- maxCalls,
244
- },
245
- };
246
- }
247
- }
@@ -1,68 +0,0 @@
1
- import type { Requirements } from '../generated/sdk/v1alpha/sdk_pb';
2
- import { z } from 'zod';
3
- export declare const REGIONS: readonly ["us-west-2"];
4
- export declare const NITRO_REGIONS: readonly ["us-west-2"];
5
- declare const regionSchema: z.ZodEnum<["us-west-2"]>;
6
- declare const nitroRegionSchema: z.ZodEnum<["us-west-2"]>;
7
- declare const nitroBindingSchema: z.ZodObject<{
8
- tee: z.ZodLiteral<"nitro">;
9
- regions: z.ZodOptional<z.ZodArray<z.ZodEnum<["us-west-2"]>, "atleastone">>;
10
- }, "strict", z.ZodTypeAny, {
11
- tee: "nitro";
12
- regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
13
- }, {
14
- tee: "nitro";
15
- regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
16
- }>;
17
- declare const teeBindingSchema: z.ZodDiscriminatedUnion<"tee", [z.ZodObject<{
18
- tee: z.ZodLiteral<"nitro">;
19
- regions: z.ZodOptional<z.ZodArray<z.ZodEnum<["us-west-2"]>, "atleastone">>;
20
- }, "strict", z.ZodTypeAny, {
21
- tee: "nitro";
22
- regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
23
- }, {
24
- tee: "nitro";
25
- regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
26
- }>]>;
27
- declare const oneOfTeesSchema: z.ZodArray<z.ZodDiscriminatedUnion<"tee", [z.ZodObject<{
28
- tee: z.ZodLiteral<"nitro">;
29
- regions: z.ZodOptional<z.ZodArray<z.ZodEnum<["us-west-2"]>, "atleastone">>;
30
- }, "strict", z.ZodTypeAny, {
31
- tee: "nitro";
32
- regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
33
- }, {
34
- tee: "nitro";
35
- regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
36
- }>]>, "atleastone">;
37
- declare const anyTeeConstraintSchema: z.ZodObject<{
38
- regions: z.ZodOptional<z.ZodArray<z.ZodEnum<["us-west-2"]>, "atleastone">>;
39
- }, "strict", z.ZodTypeAny, {
40
- regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
41
- }, {
42
- regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
43
- }>;
44
- export declare const teeConstraintSchema: z.ZodUnion<[z.ZodArray<z.ZodDiscriminatedUnion<"tee", [z.ZodObject<{
45
- tee: z.ZodLiteral<"nitro">;
46
- regions: z.ZodOptional<z.ZodArray<z.ZodEnum<["us-west-2"]>, "atleastone">>;
47
- }, "strict", z.ZodTypeAny, {
48
- tee: "nitro";
49
- regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
50
- }, {
51
- tee: "nitro";
52
- regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
53
- }>]>, "atleastone">, z.ZodObject<{
54
- regions: z.ZodOptional<z.ZodArray<z.ZodEnum<["us-west-2"]>, "atleastone">>;
55
- }, "strict", z.ZodTypeAny, {
56
- regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
57
- }, {
58
- regions?: ["us-west-2", ..."us-west-2"[]] | undefined;
59
- }>]>;
60
- export type Region = z.infer<typeof regionSchema>;
61
- export type NitroRegion = z.infer<typeof nitroRegionSchema>;
62
- export type NitroBinding = z.infer<typeof nitroBindingSchema>;
63
- export type TeeBinding = z.infer<typeof teeBindingSchema>;
64
- export type OneOfTees = z.infer<typeof oneOfTeesSchema>;
65
- export type AnyTeeConstraint = z.infer<typeof anyTeeConstraintSchema>;
66
- export type TeeConstraint = z.infer<typeof teeConstraintSchema>;
67
- export declare function buildTeeRequirements(input: TeeConstraint): Requirements;
68
- export {};
@@ -1,59 +0,0 @@
1
- import { create } from '@bufbuild/protobuf';
2
- import { RegionsSchema, RequirementsSchema, TeeSchema, TeeType, TeeTypesAndRegionsSchema, } from '../generated/sdk/v1alpha/sdk_pb';
3
- import { z } from 'zod';
4
- // --- Region schemas (source of truth) ---
5
- export const REGIONS = ['us-west-2'];
6
- export const NITRO_REGIONS = ['us-west-2'];
7
- const regionSchema = z.enum(REGIONS, {
8
- message: `unknown region; expected one of: ${REGIONS.join(', ')}`,
9
- });
10
- const nitroRegionSchema = z.enum(NITRO_REGIONS, {
11
- message: `aws nitro does not support this region; expected one of: ${NITRO_REGIONS.join(', ')}`,
12
- });
13
- // --- TeeConstraint schemas (types inferred from these) ---
14
- const nitroBindingSchema = z
15
- .object({
16
- tee: z.literal('nitro'),
17
- regions: z.array(nitroRegionSchema).nonempty().optional(),
18
- })
19
- .strict();
20
- const teeBindingSchema = z.discriminatedUnion('tee', [nitroBindingSchema]);
21
- const oneOfTeesSchema = z.array(teeBindingSchema).nonempty();
22
- const anyTeeConstraintSchema = z
23
- .object({
24
- regions: z.array(regionSchema).nonempty().optional(),
25
- })
26
- .strict();
27
- export const teeConstraintSchema = z.union([oneOfTeesSchema, anyTeeConstraintSchema]);
28
- // --- Conversion to protobuf Requirements ---
29
- export function buildTeeRequirements(input) {
30
- const parsed = teeConstraintSchema.parse(input);
31
- if (Array.isArray(parsed)) {
32
- const teeTypes = parsed.map((binding) => ({
33
- type: teeTypeFromBinding(binding),
34
- regions: binding.regions ?? [],
35
- }));
36
- return create(RequirementsSchema, {
37
- tee: create(TeeSchema, {
38
- item: {
39
- case: 'teeTypesAndRegions',
40
- value: create(TeeTypesAndRegionsSchema, { teeTypeAndRegions: teeTypes }),
41
- },
42
- }),
43
- });
44
- }
45
- return create(RequirementsSchema, {
46
- tee: create(TeeSchema, {
47
- item: {
48
- case: 'anyRegions',
49
- value: create(RegionsSchema, { regions: parsed.regions ?? [] }),
50
- },
51
- }),
52
- });
53
- }
54
- function teeTypeFromBinding(binding) {
55
- switch (binding.tee) {
56
- case 'nitro':
57
- return TeeType.AWS_NITRO;
58
- }
59
- }
@@ -1,25 +0,0 @@
1
- import { type AccountAPTBalanceReply, type AccountAPTBalanceReplyJson, type AccountAPTBalanceRequest, type AccountTransactionsReply, type AccountTransactionsReplyJson, type AccountTransactionsRequest, type TransactionByHashReply, type TransactionByHashReplyJson, type TransactionByHashRequest, type ViewReply, type ViewReplyJson, type ViewRequest, type WriteReportReply, type WriteReportReplyJson, type WriteReportRequest } from '../../../../../../../generated/capabilities/blockchain/aptos/v1alpha/client_pb';
2
- /**
3
- * Mock for ClientCapability. Use testInstance() to obtain an instance; do not construct directly.
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
- */
6
- export declare class AptosMock {
7
- static readonly CAPABILITY_ID = "aptos@1.0.0";
8
- /** Set to define the return value for AccountAPTBalance. May return a plain object (AccountAPTBalanceReplyJson) or the message type. */
9
- accountAPTBalance?: (input: AccountAPTBalanceRequest) => AccountAPTBalanceReply | AccountAPTBalanceReplyJson;
10
- /** Set to define the return value for View. May return a plain object (ViewReplyJson) or the message type. */
11
- view?: (input: ViewRequest) => ViewReply | ViewReplyJson;
12
- /** Set to define the return value for TransactionByHash. May return a plain object (TransactionByHashReplyJson) or the message type. */
13
- transactionByHash?: (input: TransactionByHashRequest) => TransactionByHashReply | TransactionByHashReplyJson;
14
- /** Set to define the return value for AccountTransactions. May return a plain object (AccountTransactionsReplyJson) or the message type. */
15
- accountTransactions?: (input: AccountTransactionsRequest) => AccountTransactionsReply | AccountTransactionsReplyJson;
16
- /** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
17
- writeReport?: (input: WriteReportRequest) => WriteReportReply | WriteReportReplyJson;
18
- private constructor();
19
- /**
20
- * Returns the mock instance for this capability and the specified tags.
21
- * Multiple calls with the same tag values return the same instance.
22
- * Must be called within the test framework's test() method.
23
- */
24
- static testInstance(chainSelector: bigint): AptosMock;
25
- }
@@ -1,111 +0,0 @@
1
- import { fromJson } from '@bufbuild/protobuf';
2
- import { anyPack, anyUnpack } from '@bufbuild/protobuf/wkt';
3
- import { AccountAPTBalanceReplySchema, AccountAPTBalanceRequestSchema, AccountTransactionsReplySchema, AccountTransactionsRequestSchema, TransactionByHashReplySchema, TransactionByHashRequestSchema, ViewReplySchema, ViewRequestSchema, WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../../../generated/capabilities/blockchain/aptos/v1alpha/client_pb';
4
- import { __getTestMockInstance, __setTestMockInstance, registerTestCapability, } from '../../../../../../testutils/test-runtime';
5
- /**
6
- * Mock for ClientCapability. Use testInstance() to obtain an instance; do not construct directly.
7
- * Set per-method properties (e.g. performAction) to define return values. If a method is invoked without a handler set, an error is thrown.
8
- */
9
- export class AptosMock {
10
- static CAPABILITY_ID = 'aptos@1.0.0';
11
- /** Set to define the return value for AccountAPTBalance. May return a plain object (AccountAPTBalanceReplyJson) or the message type. */
12
- accountAPTBalance;
13
- /** Set to define the return value for View. May return a plain object (ViewReplyJson) or the message type. */
14
- view;
15
- /** Set to define the return value for TransactionByHash. May return a plain object (TransactionByHashReplyJson) or the message type. */
16
- transactionByHash;
17
- /** Set to define the return value for AccountTransactions. May return a plain object (AccountTransactionsReplyJson) or the message type. */
18
- accountTransactions;
19
- /** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
20
- writeReport;
21
- constructor(chainSelector) {
22
- const self = this;
23
- const qualifiedId = `aptos:ChainSelector:${chainSelector}@1.0.0`;
24
- try {
25
- registerTestCapability(qualifiedId, (req) => {
26
- switch (req.method) {
27
- case 'AccountAPTBalance': {
28
- const input = anyUnpack(req.payload, AccountAPTBalanceRequestSchema);
29
- const handler = self.accountAPTBalance;
30
- if (typeof handler !== 'function')
31
- throw new Error("AccountAPTBalance: no implementation provided; set the mock's accountAPTBalance property to define the return value.");
32
- const raw = handler(input);
33
- const output = raw && typeof raw.$typeName === 'string'
34
- ? raw
35
- : fromJson(AccountAPTBalanceReplySchema, raw);
36
- return {
37
- response: { case: 'payload', value: anyPack(AccountAPTBalanceReplySchema, output) },
38
- };
39
- }
40
- case 'View': {
41
- const input = anyUnpack(req.payload, ViewRequestSchema);
42
- const handler = self.view;
43
- if (typeof handler !== 'function')
44
- throw new Error("View: no implementation provided; set the mock's view property to define the return value.");
45
- const raw = handler(input);
46
- const output = raw && typeof raw.$typeName === 'string'
47
- ? raw
48
- : fromJson(ViewReplySchema, raw);
49
- return { response: { case: 'payload', value: anyPack(ViewReplySchema, output) } };
50
- }
51
- case 'TransactionByHash': {
52
- const input = anyUnpack(req.payload, TransactionByHashRequestSchema);
53
- const handler = self.transactionByHash;
54
- if (typeof handler !== 'function')
55
- throw new Error("TransactionByHash: no implementation provided; set the mock's transactionByHash property to define the return value.");
56
- const raw = handler(input);
57
- const output = raw && typeof raw.$typeName === 'string'
58
- ? raw
59
- : fromJson(TransactionByHashReplySchema, raw);
60
- return {
61
- response: { case: 'payload', value: anyPack(TransactionByHashReplySchema, output) },
62
- };
63
- }
64
- case 'AccountTransactions': {
65
- const input = anyUnpack(req.payload, AccountTransactionsRequestSchema);
66
- const handler = self.accountTransactions;
67
- if (typeof handler !== 'function')
68
- throw new Error("AccountTransactions: no implementation provided; set the mock's accountTransactions property to define the return value.");
69
- const raw = handler(input);
70
- const output = raw && typeof raw.$typeName === 'string'
71
- ? raw
72
- : fromJson(AccountTransactionsReplySchema, raw);
73
- return {
74
- response: { case: 'payload', value: anyPack(AccountTransactionsReplySchema, output) },
75
- };
76
- }
77
- case 'WriteReport': {
78
- const input = anyUnpack(req.payload, WriteReportRequestSchema);
79
- const handler = self.writeReport;
80
- if (typeof handler !== 'function')
81
- throw new Error("WriteReport: no implementation provided; set the mock's writeReport property to define the return value.");
82
- const raw = handler(input);
83
- const output = raw && typeof raw.$typeName === 'string'
84
- ? raw
85
- : fromJson(WriteReportReplySchema, raw);
86
- return { response: { case: 'payload', value: anyPack(WriteReportReplySchema, output) } };
87
- }
88
- default:
89
- return { response: { case: 'error', value: `unknown method ${req.method}` } };
90
- }
91
- });
92
- }
93
- catch {
94
- throw new Error("Capability mocks must be used within the CRE test framework's test() method.");
95
- }
96
- }
97
- /**
98
- * Returns the mock instance for this capability and the specified tags.
99
- * Multiple calls with the same tag values return the same instance.
100
- * Must be called within the test framework's test() method.
101
- */
102
- static testInstance(chainSelector) {
103
- const qualifiedId = `aptos:ChainSelector:${chainSelector}@1.0.0`;
104
- let instance = __getTestMockInstance(qualifiedId);
105
- if (!instance) {
106
- instance = new AptosMock(chainSelector);
107
- __setTestMockInstance(qualifiedId, instance);
108
- }
109
- return instance;
110
- }
111
- }
@@ -1,41 +0,0 @@
1
- import type { Outputs } from '@cre/generated/capabilities/internal/basictrigger/v1/basic_trigger_pb'
2
- import type { RestrictionsJson } from '@cre/generated/sdk/v1alpha/sdk_pb'
3
- import { BasicActionCapability } from '@cre/generated-sdk/capabilities/internal/basicaction/v1/basicaction_sdk_gen'
4
- import { BasicCapability as BasicTriggerCapability } from '@cre/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen'
5
- import type { Workflow } from '@cre/sdk'
6
- import { cre, type Runtime } from '@cre/sdk/cre'
7
- import { Runner } from '@cre/sdk/wasm'
8
- import type { ByteArray } from 'viem'
9
-
10
- const trigger = (runtime: Runtime<Uint8Array>, __: Outputs): string => {
11
- const basicCapability = new BasicActionCapability()
12
- const result = basicCapability.performAction(runtime, { inputThing: true }).result()
13
- return result.adaptedThing
14
- }
15
-
16
- const preHook = (_: ByteArray, __: Outputs): RestrictionsJson => {
17
- return {
18
- capabilities: {
19
- maxTotalCalls: 0,
20
- },
21
- }
22
- }
23
-
24
- const initWorkflow = (_: ByteArray): Workflow<Uint8Array> => {
25
- const basicTrigger = new BasicTriggerCapability()
26
-
27
- return [
28
- cre.handler(basicTrigger.trigger({ name: 'first-trigger', number: 100 }), trigger, {
29
- preHook: preHook,
30
- }),
31
- ]
32
- }
33
-
34
- export async function main() {
35
- const runner = await Runner.newRunner<Uint8Array>({
36
- configParser: (c) => c,
37
- })
38
- await runner.run(initWorkflow)
39
- }
40
-
41
- await main()
@@ -1,29 +0,0 @@
1
- import type { Outputs } from '@cre/generated/capabilities/internal/basictrigger/v1/basic_trigger_pb'
2
- import { BasicCapability as BasicTriggerCapability } from '@cre/generated-sdk/capabilities/internal/basictrigger/v1/basic_sdk_gen'
3
- import { cre, type Runtime, type TeeRuntime } from '@cre/sdk/cre'
4
- import { Runner } from '@cre/sdk/wasm'
5
- import { handlerInTee } from '@cre/sdk/workflow'
6
-
7
- const teeTrigger = (_: TeeRuntime<Uint8Array>, __: Outputs) => 0
8
- const regularTrigger = (_: Runtime<Uint8Array>, __: Outputs) => 0
9
-
10
- const initWorkflow = () => {
11
- const basicTrigger = new BasicTriggerCapability()
12
- return [
13
- handlerInTee(basicTrigger.trigger({ name: 'first-trigger', number: 100 }), teeTrigger, [
14
- { tee: 'nitro', regions: ['us-west-2'] },
15
- ]),
16
- cre.handler(basicTrigger.trigger({ name: 'second-trigger', number: 200 }), regularTrigger),
17
- ]
18
- }
19
-
20
- export async function main() {
21
- console.log(`TS workflow: standard test: config [${new Date().toISOString()}]`)
22
-
23
- const runner = await Runner.newRunner<Uint8Array>({
24
- configParser: (c: Uint8Array) => c,
25
- })
26
- await runner.run(initWorkflow)
27
- }
28
-
29
- await main()