@chainlink/cre-sdk 1.6.0-alpha.2 → 1.6.0-alpha.3

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 (38) hide show
  1. package/README.md +7 -1
  2. package/bin/cre-compile.ts +34 -17
  3. package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.d.ts +1023 -0
  4. package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.js +290 -0
  5. package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.d.ts +2904 -0
  6. package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.js +506 -0
  7. package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.d.ts +52 -0
  8. package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.js +186 -0
  9. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.d.ts +92 -0
  10. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +343 -0
  11. package/dist/sdk/cre/index.d.ts +6 -0
  12. package/dist/sdk/cre/index.js +8 -0
  13. package/dist/sdk/report.js +0 -15
  14. package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.d.ts +25 -0
  15. package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.js +111 -0
  16. package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.d.ts +33 -0
  17. package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.js +178 -0
  18. package/dist/sdk/test/generated/index.d.ts +2 -0
  19. package/dist/sdk/test/generated/index.js +2 -0
  20. package/package.json +3 -3
  21. package/scripts/run-standard-tests.sh +3 -3
  22. package/scripts/run.ts +6 -1
  23. package/scripts/src/check-determinism.test.ts +64 -0
  24. package/scripts/src/check-determinism.ts +32 -0
  25. package/scripts/src/compile-cli-args.test.ts +32 -0
  26. package/scripts/src/compile-cli-args.ts +35 -0
  27. package/scripts/src/compile-to-js.test.ts +90 -0
  28. package/scripts/src/compile-to-js.ts +53 -7
  29. package/scripts/src/compile-to-wasm.ts +18 -32
  30. package/scripts/src/compile-workflow.ts +55 -27
  31. package/scripts/src/generate-chain-selectors.ts +9 -27
  32. package/scripts/src/generate-sdks.ts +12 -0
  33. package/scripts/src/typecheck-workflow.test.ts +77 -0
  34. package/scripts/src/typecheck-workflow.ts +96 -0
  35. package/scripts/src/validate-shared.ts +400 -0
  36. package/scripts/src/validate-workflow-determinism.test.ts +409 -0
  37. package/scripts/src/validate-workflow-determinism.ts +545 -0
  38. package/scripts/src/validate-workflow-runtime-compat.ts +25 -377
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Public API for the CRE SDK.
3
3
  */
4
+ import { ClientCapability as AptosClient } from '../../generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen';
4
5
  import { ClientCapability as EVMClient } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
6
+ import { ClientCapability as SolanaClient } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
5
7
  import { ClientCapability as ConfidentialHTTPClient } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
6
8
  import { ClientCapability as HTTPClient } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
7
9
  import { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
@@ -12,8 +14,12 @@ import { handler } from '../workflow';
12
14
  * Public exports for the CRE SDK.
13
15
  */
14
16
  export { TxStatus, } from '../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
17
+ // Aptos Capability
18
+ export { ClientCapability as AptosClient, } from '../../generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen';
15
19
  // EVM Capability
16
20
  export { ClientCapability as EVMClient, } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
21
+ // Solana Capability
22
+ export { ClientCapability as SolanaClient, } from '../../generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen';
17
23
  // Confidential HTTP Capability
18
24
  export { ClientCapability as ConfidentialHTTPClient } from '../../generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen';
19
25
  // HTTP Capability
@@ -30,6 +36,8 @@ export const cre = {
30
36
  ConfidentialHTTPClient,
31
37
  HTTPClient,
32
38
  EVMClient,
39
+ AptosClient,
40
+ SolanaClient,
33
41
  },
34
42
  handler,
35
43
  };
@@ -227,21 +227,6 @@ function fetchDONInfo(runtime, env, donID) {
227
227
  signers.set(addr, nodeOperatorId);
228
228
  }
229
229
  const info = { f, signers };
230
- if (donID === 1 && isProductionEnvironmentForReport(env)) {
231
- const patch = (hexAddr, id) => {
232
- info.signers.set(getAddress(hexAddr), id);
233
- };
234
- patch('0xcdf20f8ffd41b02c680988b20e68735cc8c1ca17', 5 + 1);
235
- patch('0xff9b062fccb2f042311343048b9518068370f837', 4 + 1);
236
- patch('0xde5cd1dd4300a0b4854f8223add60d20e1dfe21b', 1 + 1);
237
- patch('0x4d6cfd44f94408a39fb1af94a53c107a730ba161', 9 + 1);
238
- patch('0xf3baa9a99b5ad64f50779f449bac83baac8bfdb6', 0 + 1);
239
- patch('0xd7f22fb5382ff477d2ff5c702cab0ef8abf18233', 7 + 1);
240
- patch('0x4d7d71c7e584cfa1f5c06275e5d283b9d3176924', 8 + 1);
241
- patch('0x1a89c98e75983ec384ad8e83eaf7d0176eeaf155', 3 + 1);
242
- patch('0x4f99b550623e77b807df7cbed9c79d55e1163b48', 2 + 1);
243
- patch('0xe55fcaf921e76c6bbcf9415bba12b1236f07b0c3', 6 + 1);
244
- }
245
230
  donInfoCache.set(key, info);
246
231
  return info;
247
232
  }
@@ -0,0 +1,25 @@
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
+ }
@@ -0,0 +1,111 @@
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
+ }
@@ -0,0 +1,33 @@
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 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
+ /**
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 SolanaMock {
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 GetSignatureStatuses. May return a plain object (GetSignatureStatusesReplyJson) or the message type. */
19
+ getSignatureStatuses?: (input: GetSignatureStatusesRequest) => GetSignatureStatusesReply | GetSignatureStatusesReplyJson;
20
+ /** Set to define the return value for GetSlotHeight. May return a plain object (GetSlotHeightReplyJson) or the message type. */
21
+ getSlotHeight?: (input: GetSlotHeightRequest) => GetSlotHeightReply | GetSlotHeightReplyJson;
22
+ /** Set to define the return value for GetTransaction. May return a plain object (GetTransactionReplyJson) or the message type. */
23
+ getTransaction?: (input: GetTransactionRequest) => GetTransactionReply | GetTransactionReplyJson;
24
+ /** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
25
+ writeReport?: (input: WriteReportRequest) => WriteReportReply | WriteReportReplyJson;
26
+ private constructor();
27
+ /**
28
+ * Returns the mock instance for this capability and the specified tags.
29
+ * Multiple calls with the same tag values return the same instance.
30
+ * Must be called within the test framework's test() method.
31
+ */
32
+ static testInstance(chainSelector: bigint): SolanaMock;
33
+ }
@@ -0,0 +1,178 @@
1
+ import { fromJson } from '@bufbuild/protobuf';
2
+ import { anyPack, anyUnpack } from '@bufbuild/protobuf/wkt';
3
+ import { GetAccountInfoWithOptsReplySchema, GetAccountInfoWithOptsRequestSchema, GetBalanceReplySchema, GetBalanceRequestSchema, GetBlockReplySchema, GetBlockRequestSchema, GetFeeForMessageReplySchema, GetFeeForMessageRequestSchema, GetMultipleAccountsWithOptsReplySchema, GetMultipleAccountsWithOptsRequestSchema, GetSignatureStatusesReplySchema, GetSignatureStatusesRequestSchema, GetSlotHeightReplySchema, GetSlotHeightRequestSchema, GetTransactionReplySchema, GetTransactionRequestSchema, WriteReportReplySchema, WriteReportRequestSchema, } from '../../../../../../../generated/capabilities/blockchain/solana/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 SolanaMock {
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 GetSignatureStatuses. May return a plain object (GetSignatureStatusesReplyJson) or the message type. */
22
+ getSignatureStatuses;
23
+ /** Set to define the return value for GetSlotHeight. May return a plain object (GetSlotHeightReplyJson) or the message type. */
24
+ getSlotHeight;
25
+ /** Set to define the return value for GetTransaction. May return a plain object (GetTransactionReplyJson) or the message type. */
26
+ getTransaction;
27
+ /** Set to define the return value for WriteReport. May return a plain object (WriteReportReplyJson) or the message type. */
28
+ writeReport;
29
+ constructor(chainSelector) {
30
+ const self = this;
31
+ const qualifiedId = `solana:ChainSelector:${chainSelector}@1.0.0`;
32
+ try {
33
+ registerTestCapability(qualifiedId, (req) => {
34
+ switch (req.method) {
35
+ case 'GetAccountInfoWithOpts': {
36
+ const input = anyUnpack(req.payload, GetAccountInfoWithOptsRequestSchema);
37
+ const handler = self.getAccountInfoWithOpts;
38
+ if (typeof handler !== 'function')
39
+ throw new Error("GetAccountInfoWithOpts: no implementation provided; set the mock's getAccountInfoWithOpts property to define the return value.");
40
+ const raw = handler(input);
41
+ const output = raw && typeof raw.$typeName === 'string'
42
+ ? raw
43
+ : fromJson(GetAccountInfoWithOptsReplySchema, raw);
44
+ return {
45
+ response: {
46
+ case: 'payload',
47
+ value: anyPack(GetAccountInfoWithOptsReplySchema, output),
48
+ },
49
+ };
50
+ }
51
+ case 'GetBalance': {
52
+ const input = anyUnpack(req.payload, GetBalanceRequestSchema);
53
+ const handler = self.getBalance;
54
+ if (typeof handler !== 'function')
55
+ throw new Error("GetBalance: no implementation provided; set the mock's getBalance property to define the return value.");
56
+ const raw = handler(input);
57
+ const output = raw && typeof raw.$typeName === 'string'
58
+ ? raw
59
+ : fromJson(GetBalanceReplySchema, raw);
60
+ return { response: { case: 'payload', value: anyPack(GetBalanceReplySchema, output) } };
61
+ }
62
+ case 'GetBlock': {
63
+ const input = anyUnpack(req.payload, GetBlockRequestSchema);
64
+ const handler = self.getBlock;
65
+ if (typeof handler !== 'function')
66
+ throw new Error("GetBlock: no implementation provided; set the mock's getBlock property to define the return value.");
67
+ const raw = handler(input);
68
+ const output = raw && typeof raw.$typeName === 'string'
69
+ ? raw
70
+ : fromJson(GetBlockReplySchema, raw);
71
+ return { response: { case: 'payload', value: anyPack(GetBlockReplySchema, output) } };
72
+ }
73
+ case 'GetFeeForMessage': {
74
+ const input = anyUnpack(req.payload, GetFeeForMessageRequestSchema);
75
+ const handler = self.getFeeForMessage;
76
+ if (typeof handler !== 'function')
77
+ throw new Error("GetFeeForMessage: no implementation provided; set the mock's getFeeForMessage property to define the return value.");
78
+ const raw = handler(input);
79
+ const output = raw && typeof raw.$typeName === 'string'
80
+ ? raw
81
+ : fromJson(GetFeeForMessageReplySchema, raw);
82
+ return {
83
+ response: { case: 'payload', value: anyPack(GetFeeForMessageReplySchema, output) },
84
+ };
85
+ }
86
+ case 'GetMultipleAccountsWithOpts': {
87
+ const input = anyUnpack(req.payload, GetMultipleAccountsWithOptsRequestSchema);
88
+ const handler = self.getMultipleAccountsWithOpts;
89
+ if (typeof handler !== 'function')
90
+ throw new Error("GetMultipleAccountsWithOpts: no implementation provided; set the mock's getMultipleAccountsWithOpts property to define the return value.");
91
+ const raw = handler(input);
92
+ const output = raw && typeof raw.$typeName === 'string'
93
+ ? raw
94
+ : fromJson(GetMultipleAccountsWithOptsReplySchema, raw);
95
+ return {
96
+ response: {
97
+ case: 'payload',
98
+ value: anyPack(GetMultipleAccountsWithOptsReplySchema, output),
99
+ },
100
+ };
101
+ }
102
+ case 'GetSignatureStatuses': {
103
+ const input = anyUnpack(req.payload, GetSignatureStatusesRequestSchema);
104
+ const handler = self.getSignatureStatuses;
105
+ if (typeof handler !== 'function')
106
+ throw new Error("GetSignatureStatuses: no implementation provided; set the mock's getSignatureStatuses property to define the return value.");
107
+ const raw = handler(input);
108
+ const output = raw && typeof raw.$typeName === 'string'
109
+ ? raw
110
+ : fromJson(GetSignatureStatusesReplySchema, raw);
111
+ return {
112
+ response: {
113
+ case: 'payload',
114
+ value: anyPack(GetSignatureStatusesReplySchema, output),
115
+ },
116
+ };
117
+ }
118
+ case 'GetSlotHeight': {
119
+ const input = anyUnpack(req.payload, GetSlotHeightRequestSchema);
120
+ const handler = self.getSlotHeight;
121
+ if (typeof handler !== 'function')
122
+ throw new Error("GetSlotHeight: no implementation provided; set the mock's getSlotHeight property to define the return value.");
123
+ const raw = handler(input);
124
+ const output = raw && typeof raw.$typeName === 'string'
125
+ ? raw
126
+ : fromJson(GetSlotHeightReplySchema, raw);
127
+ return {
128
+ response: { case: 'payload', value: anyPack(GetSlotHeightReplySchema, output) },
129
+ };
130
+ }
131
+ case 'GetTransaction': {
132
+ const input = anyUnpack(req.payload, GetTransactionRequestSchema);
133
+ const handler = self.getTransaction;
134
+ if (typeof handler !== 'function')
135
+ throw new Error("GetTransaction: no implementation provided; set the mock's getTransaction property to define the return value.");
136
+ const raw = handler(input);
137
+ const output = raw && typeof raw.$typeName === 'string'
138
+ ? raw
139
+ : fromJson(GetTransactionReplySchema, raw);
140
+ return {
141
+ response: { case: 'payload', value: anyPack(GetTransactionReplySchema, output) },
142
+ };
143
+ }
144
+ case 'WriteReport': {
145
+ const input = anyUnpack(req.payload, WriteReportRequestSchema);
146
+ const handler = self.writeReport;
147
+ if (typeof handler !== 'function')
148
+ throw new Error("WriteReport: no implementation provided; set the mock's writeReport property to define the return value.");
149
+ const raw = handler(input);
150
+ const output = raw && typeof raw.$typeName === 'string'
151
+ ? raw
152
+ : fromJson(WriteReportReplySchema, raw);
153
+ return { response: { case: 'payload', value: anyPack(WriteReportReplySchema, output) } };
154
+ }
155
+ default:
156
+ return { response: { case: 'error', value: `unknown method ${req.method}` } };
157
+ }
158
+ });
159
+ }
160
+ catch {
161
+ throw new Error("Capability mocks must be used within the CRE test framework's test() method.");
162
+ }
163
+ }
164
+ /**
165
+ * Returns the mock instance for this capability and the specified tags.
166
+ * Multiple calls with the same tag values return the same instance.
167
+ * Must be called within the test framework's test() method.
168
+ */
169
+ static testInstance(chainSelector) {
170
+ const qualifiedId = `solana:ChainSelector:${chainSelector}@1.0.0`;
171
+ let instance = __getTestMockInstance(qualifiedId);
172
+ if (!instance) {
173
+ instance = new SolanaMock(chainSelector);
174
+ __setTestMockInstance(qualifiedId, instance);
175
+ }
176
+ return instance;
177
+ }
178
+ }
@@ -1,5 +1,7 @@
1
1
  /** Auto-generated barrel of capability mocks. Do not edit. */
2
+ export { AptosMock } from './capabilities/blockchain/aptos/v1alpha/aptos_mock_gen';
2
3
  export { EvmMock } from './capabilities/blockchain/evm/v1alpha/evm_mock_gen';
4
+ export { SolanaMock } from './capabilities/blockchain/solana/v1alpha/solana_mock_gen';
3
5
  export { BasicTestActionTriggerMock } from './capabilities/internal/actionandtrigger/v1/basic_test_action_trigger_mock_gen';
4
6
  export { BasicTestActionMock } from './capabilities/internal/basicaction/v1/basic_test_action_mock_gen';
5
7
  export { ConsensusMock } from './capabilities/internal/consensus/v1alpha/consensus_mock_gen';
@@ -1,5 +1,7 @@
1
1
  /** Auto-generated barrel of capability mocks. Do not edit. */
2
+ export { AptosMock } from './capabilities/blockchain/aptos/v1alpha/aptos_mock_gen';
2
3
  export { EvmMock } from './capabilities/blockchain/evm/v1alpha/evm_mock_gen';
4
+ export { SolanaMock } from './capabilities/blockchain/solana/v1alpha/solana_mock_gen';
3
5
  export { BasicTestActionTriggerMock } from './capabilities/internal/actionandtrigger/v1/basic_test_action_trigger_mock_gen';
4
6
  export { BasicTestActionMock } from './capabilities/internal/basicaction/v1/basic_test_action_mock_gen';
5
7
  export { ConsensusMock } from './capabilities/internal/consensus/v1alpha/consensus_mock_gen';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainlink/cre-sdk",
3
- "version": "1.6.0-alpha.2",
3
+ "version": "1.6.0-alpha.3",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -49,7 +49,7 @@
49
49
  "format": "biome format --write ${BIOME_PATHS:-.}",
50
50
  "full-checks": "bun generate:sdk && bun run build && bun typecheck && bun check && bun test && bun test:standard",
51
51
  "generate:chain-selectors": "bun scripts/run.ts generate-chain-selectors && BIOME_PATHS=\"src/generated\" bun check",
52
- "generate:proto": "bunx @bufbuild/buf generate && BIOME_PATHS=\"src/generated\" bun check",
52
+ "generate:proto": "bun x @bufbuild/buf generate && BIOME_PATHS=\"src/generated\" bun check",
53
53
  "generate:sdk": "bun generate:proto && bun generate:chain-selectors && bun scripts/run generate-sdks && BIOME_PATHS=\"src/generated src/generated-sdk src/sdk/test/generated\" bun check",
54
54
  "lint": "biome lint --write",
55
55
  "prepublishOnly": "bun typecheck && bun check && bun test && bun test:standard",
@@ -60,7 +60,7 @@
60
60
  "dependencies": {
61
61
  "@bufbuild/protobuf": "2.6.3",
62
62
  "@bufbuild/protoc-gen-es": "2.6.3",
63
- "@chainlink/cre-sdk-javy-plugin": "1.6.0-alpha.2",
63
+ "@chainlink/cre-sdk-javy-plugin": "1.5.0",
64
64
  "@standard-schema/spec": "1.0.0",
65
65
  "viem": "2.34.0",
66
66
  "zod": "3.25.76"
@@ -8,9 +8,9 @@ set -e
8
8
  # Create dist test workflow folder
9
9
  mkdir -p ./dist/workflows/standard_tests
10
10
 
11
- # Plugin package must be built (initialized plugin is what we ship).
12
- if [ ! -f ../cre-sdk-javy-plugin/dist/javy-chainlink-sdk.plugin.wasm ]; then
13
- echo "Error: javy-chainlink-sdk.plugin.wasm not found (run cre-sdk-javy-plugin build first)"
11
+ # Build javy wasm
12
+ if [ ! -f ../cre-sdk-javy-plugin/dist/javy_chainlink_sdk.wasm ]; then
13
+ echo "Error: javy_chainlink_sdk.wasm not found"
14
14
  exit 1
15
15
  fi
16
16
 
package/scripts/run.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env bun
2
2
 
3
+ import { WorkflowTypecheckError } from './src/typecheck-workflow'
3
4
  import { WorkflowRuntimeCompatibilityError } from './src/validate-workflow-runtime-compat'
4
5
 
5
6
  const availableScripts = [
6
7
  'build-types',
8
+ 'check-determinism', // Check for non-deterministic patterns in workflow source
7
9
  'compile-to-js',
8
10
  'compile-to-wasm',
9
11
  'compile-workflow', // TS -> JS -> WASM compilation in single script
@@ -39,7 +41,10 @@ const main = async () => {
39
41
  process.exit(1)
40
42
  }
41
43
  } catch (error) {
42
- if (error instanceof WorkflowRuntimeCompatibilityError) {
44
+ if (
45
+ error instanceof WorkflowRuntimeCompatibilityError ||
46
+ error instanceof WorkflowTypecheckError
47
+ ) {
43
48
  console.error(`\n❌ ${error.message}`)
44
49
  } else {
45
50
  console.error(`Failed to run script ${scriptName}:`, error)
@@ -0,0 +1,64 @@
1
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test'
2
+ import { spawnSync } from 'node:child_process'
3
+ import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
4
+ import { tmpdir } from 'node:os'
5
+ import path from 'node:path'
6
+
7
+ let tempDir: string
8
+
9
+ const scriptsDir = path.resolve(import.meta.dir, '..')
10
+ const runScript = path.join(scriptsDir, 'run.ts')
11
+
12
+ beforeEach(() => {
13
+ tempDir = mkdtempSync(path.join(tmpdir(), 'cre-check-determinism-test-'))
14
+ })
15
+
16
+ afterEach(() => {
17
+ rmSync(tempDir, { recursive: true, force: true })
18
+ })
19
+
20
+ const runCheckDeterminism = (filePath: string) =>
21
+ spawnSync(process.execPath, [runScript, 'check-determinism', filePath], {
22
+ cwd: scriptsDir,
23
+ encoding: 'utf-8',
24
+ })
25
+
26
+ describe('check-determinism CLI', () => {
27
+ test('fails when the input file does not exist', () => {
28
+ const missingFile = path.join(tempDir, 'does-not-exist.ts')
29
+ const result = runCheckDeterminism(missingFile)
30
+
31
+ expect(result.status).toBe(1)
32
+ expect(result.stdout).not.toContain('No non-determinism warnings found.')
33
+ expect(result.stderr).toContain(`❌ File not found: ${missingFile}`)
34
+ })
35
+
36
+ test('prints warnings for non-deterministic patterns and exits 0', () => {
37
+ const filePath = path.join(tempDir, 'workflow.ts')
38
+ writeFileSync(filePath, `const result = await Promise.race([]);\n`, 'utf-8')
39
+ const result = runCheckDeterminism(filePath)
40
+
41
+ expect(result.status).toBe(0)
42
+ expect(result.stderr).toContain('Non-determinism warnings')
43
+ expect(result.stderr).toContain('Promise.race()')
44
+ })
45
+
46
+ test('prints success message for clean workflow and exits 0', () => {
47
+ const filePath = path.join(tempDir, 'workflow.ts')
48
+ writeFileSync(filePath, `const x = 1;\n`, 'utf-8')
49
+ const result = runCheckDeterminism(filePath)
50
+
51
+ expect(result.status).toBe(0)
52
+ expect(result.stdout).toContain('No non-determinism warnings found.')
53
+ })
54
+
55
+ test('fails when no input file is provided', () => {
56
+ const result = spawnSync(process.execPath, [runScript, 'check-determinism'], {
57
+ cwd: scriptsDir,
58
+ encoding: 'utf-8',
59
+ })
60
+
61
+ expect(result.status).toBe(1)
62
+ expect(result.stderr).toContain('Usage:')
63
+ })
64
+ })
@@ -0,0 +1,32 @@
1
+ import { existsSync } from 'node:fs'
2
+ import path from 'node:path'
3
+ import { checkWorkflowDeterminism, printDeterminismWarnings } from './validate-workflow-determinism'
4
+
5
+ const printUsage = () => {
6
+ console.error('Usage: bun scripts/run.ts check-determinism <path/to/workflow.ts>')
7
+ console.error('Example:')
8
+ console.error(' bun scripts/run.ts check-determinism src/workflows/my-workflow/index.ts')
9
+ }
10
+
11
+ export const main = () => {
12
+ const inputPath = process.argv[3]
13
+
14
+ if (!inputPath) {
15
+ printUsage()
16
+ process.exit(1)
17
+ }
18
+
19
+ const resolvedInput = path.resolve(inputPath)
20
+ if (!existsSync(resolvedInput)) {
21
+ console.error(`❌ File not found: ${resolvedInput}`)
22
+ process.exit(1)
23
+ }
24
+
25
+ const warnings = checkWorkflowDeterminism(resolvedInput)
26
+
27
+ if (warnings.length > 0) {
28
+ printDeterminismWarnings(warnings)
29
+ } else {
30
+ console.info('No non-determinism warnings found.')
31
+ }
32
+ }
@@ -0,0 +1,32 @@
1
+ import { describe, expect, test } from 'bun:test'
2
+ import { parseCompileCliArgs } from './compile-cli-args'
3
+
4
+ describe('parseCompileCliArgs', () => {
5
+ test('parses positional input and output', () => {
6
+ const parsed = parseCompileCliArgs(['src/workflow.ts', 'dist/workflow.wasm'])
7
+ expect(parsed).toEqual({
8
+ inputPath: 'src/workflow.ts',
9
+ outputPath: 'dist/workflow.wasm',
10
+ skipTypeChecks: false,
11
+ })
12
+ })
13
+
14
+ test('parses --skip-type-checks flag', () => {
15
+ const parsed = parseCompileCliArgs(['src/workflow.ts', '--skip-type-checks'])
16
+ expect(parsed).toEqual({
17
+ inputPath: 'src/workflow.ts',
18
+ outputPath: undefined,
19
+ skipTypeChecks: true,
20
+ })
21
+ })
22
+
23
+ test('throws on unknown flags', () => {
24
+ expect(() => parseCompileCliArgs(['src/workflow.ts', '--foo'])).toThrow('Unknown option: --foo')
25
+ })
26
+
27
+ test('throws on too many positional args', () => {
28
+ expect(() => parseCompileCliArgs(['src/workflow.ts', 'dist/workflow.wasm', 'extra'])).toThrow(
29
+ 'Too many positional arguments.',
30
+ )
31
+ })
32
+ })