@chainlink/cre-sdk 1.6.0-alpha.1 → 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 (108) hide show
  1. package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.d.ts +1023 -0
  2. package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.js +290 -0
  3. package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.d.ts +2904 -0
  4. package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.js +506 -0
  5. package/dist/generated/chain-selectors/mainnet/evm/ab-mainnet.d.ts +3 -0
  6. package/dist/generated/chain-selectors/mainnet/evm/ab-mainnet.js +12 -0
  7. package/dist/generated/chain-selectors/mainnet/evm/adi-mainnet.d.ts +3 -0
  8. package/dist/generated/chain-selectors/mainnet/evm/adi-mainnet.js +12 -0
  9. package/dist/generated/chain-selectors/mainnet/evm/edge-mainnet.d.ts +3 -0
  10. package/dist/generated/chain-selectors/mainnet/evm/edge-mainnet.js +12 -0
  11. package/dist/generated/chain-selectors/mainnet/evm/everclear-mainnet.d.ts +3 -0
  12. package/dist/generated/chain-selectors/mainnet/evm/everclear-mainnet.js +12 -0
  13. package/dist/generated/chain-selectors/mainnet/evm/gate-chain-mainnet.d.ts +3 -0
  14. package/dist/generated/chain-selectors/mainnet/evm/gate-chain-mainnet.js +12 -0
  15. package/dist/generated/chain-selectors/mainnet/evm/gate-layer-mainnet.d.ts +3 -0
  16. package/dist/generated/chain-selectors/mainnet/evm/gate-layer-mainnet.js +12 -0
  17. package/dist/generated/chain-selectors/mainnet/evm/jovay-mainnet.d.ts +3 -0
  18. package/dist/generated/chain-selectors/mainnet/evm/jovay-mainnet.js +12 -0
  19. package/dist/generated/chain-selectors/mainnet/evm/megaeth-mainnet.d.ts +3 -0
  20. package/dist/generated/chain-selectors/mainnet/evm/megaeth-mainnet.js +12 -0
  21. package/dist/generated/chain-selectors/mainnet/evm/pharos-mainnet.d.ts +3 -0
  22. package/dist/generated/chain-selectors/mainnet/evm/pharos-mainnet.js +12 -0
  23. package/dist/generated/chain-selectors/mainnet/evm/stable-mainnet.d.ts +3 -0
  24. package/dist/generated/chain-selectors/mainnet/evm/stable-mainnet.js +12 -0
  25. package/dist/generated/chain-selectors/mainnet/evm/tempo-mainnet.d.ts +3 -0
  26. package/dist/generated/chain-selectors/mainnet/evm/tempo-mainnet.js +12 -0
  27. package/dist/generated/chain-selectors/testnet/evm/0g-testnet-galileo-1.d.ts +3 -0
  28. package/dist/generated/chain-selectors/testnet/evm/0g-testnet-galileo-1.js +12 -0
  29. package/dist/generated/chain-selectors/testnet/evm/ab-testnet.d.ts +3 -0
  30. package/dist/generated/chain-selectors/testnet/evm/ab-testnet.js +12 -0
  31. package/dist/generated/chain-selectors/testnet/evm/adi-testnet.d.ts +3 -0
  32. package/dist/generated/chain-selectors/testnet/evm/adi-testnet.js +12 -0
  33. package/dist/generated/chain-selectors/testnet/evm/arc-testnet.d.ts +3 -0
  34. package/dist/generated/chain-selectors/testnet/evm/arc-testnet.js +12 -0
  35. package/dist/generated/chain-selectors/testnet/evm/celo-sepolia.d.ts +3 -0
  36. package/dist/generated/chain-selectors/testnet/evm/celo-sepolia.js +12 -0
  37. package/dist/generated/chain-selectors/testnet/evm/dogeos-testnet-chikyu.d.ts +3 -0
  38. package/dist/generated/chain-selectors/testnet/evm/dogeos-testnet-chikyu.js +12 -0
  39. package/dist/generated/chain-selectors/testnet/evm/edge-testnet.d.ts +3 -0
  40. package/dist/generated/chain-selectors/testnet/evm/edge-testnet.js +12 -0
  41. package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi-morph.d.ts +3 -0
  42. package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi-morph.js +12 -0
  43. package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi-taiko-1.d.ts +3 -0
  44. package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi-taiko-1.js +12 -0
  45. package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi-taiko.d.ts +3 -0
  46. package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi-taiko.js +12 -0
  47. package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi.d.ts +3 -0
  48. package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-hoodi.js +12 -0
  49. package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-sepolia-ronin-1.d.ts +3 -0
  50. package/dist/generated/chain-selectors/testnet/evm/ethereum-testnet-sepolia-ronin-1.js +12 -0
  51. package/dist/generated/chain-selectors/testnet/evm/everclear-testnet-sepolia.d.ts +3 -0
  52. package/dist/generated/chain-selectors/testnet/evm/everclear-testnet-sepolia.js +12 -0
  53. package/dist/generated/chain-selectors/testnet/evm/gate-chain-testnet-meteora.d.ts +3 -0
  54. package/dist/generated/chain-selectors/testnet/evm/gate-chain-testnet-meteora.js +12 -0
  55. package/dist/generated/chain-selectors/testnet/evm/gate-layer-testnet.d.ts +3 -0
  56. package/dist/generated/chain-selectors/testnet/evm/gate-layer-testnet.js +12 -0
  57. package/dist/generated/chain-selectors/testnet/evm/megaeth-testnet-2.d.ts +3 -0
  58. package/dist/generated/chain-selectors/testnet/evm/megaeth-testnet-2.js +12 -0
  59. package/dist/generated/chain-selectors/testnet/evm/pharos-atlantic-testnet.d.ts +3 -0
  60. package/dist/generated/chain-selectors/testnet/evm/pharos-atlantic-testnet.js +12 -0
  61. package/dist/generated/chain-selectors/testnet/evm/robinhood-testnet.d.ts +3 -0
  62. package/dist/generated/chain-selectors/testnet/evm/robinhood-testnet.js +12 -0
  63. package/dist/generated/chain-selectors/testnet/evm/sonic-testnet.d.ts +3 -0
  64. package/dist/generated/chain-selectors/testnet/evm/sonic-testnet.js +12 -0
  65. package/dist/generated/chain-selectors/testnet/evm/stable-testnet.d.ts +3 -0
  66. package/dist/generated/chain-selectors/testnet/evm/stable-testnet.js +12 -0
  67. package/dist/generated/chain-selectors/testnet/evm/tempo-testnet-moderato.d.ts +3 -0
  68. package/dist/generated/chain-selectors/testnet/evm/tempo-testnet-moderato.js +12 -0
  69. package/dist/generated/chain-selectors/testnet/evm/tempo-testnet.d.ts +3 -0
  70. package/dist/generated/chain-selectors/testnet/evm/tempo-testnet.js +12 -0
  71. package/dist/generated/chain-selectors/testnet/evm/xlayer-testnet.d.ts +3 -0
  72. package/dist/generated/chain-selectors/testnet/evm/xlayer-testnet.js +12 -0
  73. package/dist/generated/networks.d.ts +2 -2
  74. package/dist/generated/networks.js +238 -0
  75. package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.d.ts +52 -0
  76. package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.js +186 -0
  77. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.d.ts +92 -0
  78. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +343 -0
  79. package/dist/sdk/cre/index.d.ts +6 -0
  80. package/dist/sdk/cre/index.js +8 -0
  81. package/dist/sdk/don-info.d.ts +10 -0
  82. package/dist/sdk/don-info.js +9 -0
  83. package/dist/sdk/errors.d.ts +24 -1
  84. package/dist/sdk/errors.js +46 -1
  85. package/dist/sdk/index.d.ts +2 -0
  86. package/dist/sdk/index.js +2 -0
  87. package/dist/sdk/report-internals.d.ts +6 -0
  88. package/dist/sdk/report-internals.js +3 -0
  89. package/dist/sdk/report.d.ts +38 -0
  90. package/dist/sdk/report.js +474 -2
  91. package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.d.ts +25 -0
  92. package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.js +111 -0
  93. package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.d.ts +33 -0
  94. package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.js +178 -0
  95. package/dist/sdk/test/generated/index.d.ts +2 -0
  96. package/dist/sdk/test/generated/index.js +2 -0
  97. package/dist/sdk/testutils/test-runtime.js +4 -0
  98. package/package.json +3 -3
  99. package/scripts/run.ts +1 -0
  100. package/scripts/src/check-determinism.test.ts +64 -0
  101. package/scripts/src/check-determinism.ts +32 -0
  102. package/scripts/src/compile-to-js.ts +7 -0
  103. package/scripts/src/generate-chain-selectors.ts +9 -27
  104. package/scripts/src/generate-sdks.ts +12 -0
  105. package/scripts/src/validate-shared.ts +400 -0
  106. package/scripts/src/validate-workflow-determinism.test.ts +409 -0
  107. package/scripts/src/validate-workflow-determinism.ts +545 -0
  108. package/scripts/src/validate-workflow-runtime-compat.ts +25 -377
@@ -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';
@@ -166,6 +166,10 @@ function createTestRuntimeHelpers(registry, secrets, testWriter, state, _maxResp
166
166
  return true;
167
167
  },
168
168
  await(request, maxResponseSizeBytes) {
169
+ if (request.$typeName !==
170
+ 'sdk.v1alpha.AwaitCapabilitiesRequest') {
171
+ throw new Error('await: expected a typed AwaitCapabilitiesRequest (created via create(AwaitCapabilitiesRequestSchema, ...)); got a plain object. The real WASM bridge serializes this to binary and will fail with a plain object.');
172
+ }
169
173
  const responses = {};
170
174
  for (const id of request.ids) {
171
175
  const resp = pendingCalls.get(id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainlink/cre-sdk",
3
- "version": "1.6.0-alpha.1",
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.5.0-alpha.1",
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"
package/scripts/run.ts CHANGED
@@ -5,6 +5,7 @@ import { WorkflowRuntimeCompatibilityError } from './src/validate-workflow-runti
5
5
 
6
6
  const availableScripts = [
7
7
  'build-types',
8
+ 'check-determinism', // Check for non-deterministic patterns in workflow source
8
9
  'compile-to-js',
9
10
  'compile-to-wasm',
10
11
  'compile-workflow', // TS -> JS -> WASM compilation in single script
@@ -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
+ }
@@ -4,6 +4,7 @@ import path from 'node:path'
4
4
  import { $ } from 'bun'
5
5
  import { parseCompileCliArgs, skipTypeChecksFlag } from './compile-cli-args'
6
6
  import { assertWorkflowTypecheck } from './typecheck-workflow'
7
+ import { checkWorkflowDeterminism, printDeterminismWarnings } from './validate-workflow-determinism'
7
8
  import { assertWorkflowRuntimeCompatibility } from './validate-workflow-runtime-compat'
8
9
  import { wrapWorkflowCode } from './workflow-wrapper'
9
10
 
@@ -60,6 +61,12 @@ export const main = async (
60
61
  assertWorkflowTypecheck(resolvedInput)
61
62
  }
62
63
  assertWorkflowRuntimeCompatibility(resolvedInput)
64
+ if (!parsedSkipTypeChecks) {
65
+ const warnings = checkWorkflowDeterminism(resolvedInput)
66
+ if (warnings.length > 0) {
67
+ printDeterminismWarnings(warnings)
68
+ }
69
+ }
63
70
  console.info(`📁 Using input file: ${resolvedInput}`)
64
71
 
65
72
  // If no explicit output path → same dir, swap extension to .js
@@ -78,34 +78,16 @@ const CHAIN_CONFIGS: ChainSelectorConfig[] = [
78
78
  },
79
79
  ]
80
80
 
81
- const readYamlFile = (filename: string): string => {
82
- // Look for chain-selectors in node_modules by trying multiple possible locations
83
- // This handles different execution contexts (local dev, CI, etc.)
84
- const possiblePaths = [
85
- // Try workspace root (3 levels up from scripts/)
86
- join(process.cwd(), '..', '..', '..', 'node_modules', 'chain-selectors', filename),
87
- // Try 2 levels up (in case cwd is already in scripts/src/)
88
- join(process.cwd(), '..', '..', 'node_modules', 'chain-selectors', filename),
89
- // Try current directory's node_modules
90
- join(process.cwd(), 'node_modules', 'chain-selectors', filename),
91
- // Try parent directory's node_modules
92
- join(process.cwd(), '..', 'node_modules', 'chain-selectors', filename),
93
- ]
94
-
95
- for (const path of possiblePaths) {
96
- try {
97
- return readFileSync(path, 'utf-8')
98
- } catch {
99
- // Try next path
100
- continue
101
- }
102
- }
81
+ const resolveChainSelectorsDir = (): string => {
82
+ // Use require.resolve to find the package through bun/Node module resolution,
83
+ // which correctly handles workspace hoisting, .bun cache, etc.
84
+ const packageDir = require.resolve('chain-selectors/selectors.yml')
85
+ return join(packageDir, '..')
86
+ }
103
87
 
104
- throw new Error(
105
- `Failed to find ${filename} in any of the expected locations. Tried:\n${possiblePaths.join(
106
- '\n',
107
- )}`,
108
- )
88
+ const readYamlFile = (filename: string): string => {
89
+ const filePath = join(resolveChainSelectorsDir(), filename)
90
+ return readFileSync(filePath, 'utf-8')
109
91
  }
110
92
 
111
93
  const parseChainSelectors = (): NetworkInfo[] => {
@@ -1,5 +1,7 @@
1
1
  import { rmSync } from 'node:fs'
2
+ import { file_capabilities_blockchain_aptos_v1alpha_client } from '@cre/generated/capabilities/blockchain/aptos/v1alpha/client_pb'
2
3
  import { file_capabilities_blockchain_evm_v1alpha_client } from '@cre/generated/capabilities/blockchain/evm/v1alpha/client_pb'
4
+ import { file_capabilities_blockchain_solana_v1alpha_client } from '@cre/generated/capabilities/blockchain/solana/v1alpha/client_pb'
3
5
  import { file_capabilities_internal_actionandtrigger_v1_action_and_trigger } from '@cre/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb'
4
6
  import { file_capabilities_internal_basicaction_v1_basic_action } from '@cre/generated/capabilities/internal/basicaction/v1/basic_action_pb'
5
7
  import { file_capabilities_internal_basictrigger_v1_basic_trigger } from '@cre/generated/capabilities/internal/basictrigger/v1/basic_trigger_pb'
@@ -63,6 +65,16 @@ export const main = () => {
63
65
  ...generateMocks(file_capabilities_blockchain_evm_v1alpha_client, TEST_GENERATED_DIR),
64
66
  )
65
67
 
68
+ generateSdk(file_capabilities_blockchain_aptos_v1alpha_client, './src/generated-sdk')
69
+ allMockExports.push(
70
+ ...generateMocks(file_capabilities_blockchain_aptos_v1alpha_client, TEST_GENERATED_DIR),
71
+ )
72
+
73
+ generateSdk(file_capabilities_blockchain_solana_v1alpha_client, './src/generated-sdk')
74
+ allMockExports.push(
75
+ ...generateMocks(file_capabilities_blockchain_solana_v1alpha_client, TEST_GENERATED_DIR),
76
+ )
77
+
66
78
  generateSdk(file_capabilities_networking_http_v1alpha_client, './src/generated-sdk')
67
79
  allMockExports.push(
68
80
  ...generateMocks(file_capabilities_networking_http_v1alpha_client, TEST_GENERATED_DIR),