@chainlink/cre-sdk 1.9.0 → 1.10.0

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 (41) hide show
  1. package/dist/generated/capabilities/blockchain/evm/v1alpha/client_pb.js +1 -1
  2. package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.d.ts +268 -0
  3. package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.js +90 -0
  4. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.d.ts +10 -13
  5. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.js +0 -4
  6. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.d.ts +42 -0
  7. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +82 -0
  8. package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.d.ts +3 -2
  9. package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.d.ts +2 -1
  10. package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.d.ts +3 -2
  11. package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.d.ts +2 -1
  12. package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.d.ts +2 -1
  13. package/dist/pb.d.ts +1 -0
  14. package/dist/pb.js +1 -0
  15. package/dist/sdk/cre/index.d.ts +4 -0
  16. package/dist/sdk/cre/index.js +5 -0
  17. package/dist/sdk/impl/runtime-impl.d.ts +3 -0
  18. package/dist/sdk/impl/runtime-impl.js +9 -4
  19. package/dist/sdk/index.d.ts +1 -0
  20. package/dist/sdk/index.js +1 -0
  21. package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.d.ts +17 -0
  22. package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.js +53 -0
  23. package/dist/sdk/test/generated/index.d.ts +1 -0
  24. package/dist/sdk/test/generated/index.js +1 -0
  25. package/dist/sdk/testutils/test-runtime.js +9 -1
  26. package/dist/sdk/types/global.d.ts +6 -0
  27. package/dist/sdk/utils/capabilities/blockchain/blockchain-helpers.js +3 -2
  28. package/dist/sdk/utils/capabilities/confidentialhttp/confidential-http-helpers.d.ts +43 -0
  29. package/dist/sdk/utils/capabilities/confidentialhttp/confidential-http-helpers.js +58 -0
  30. package/dist/sdk/utils/capabilities/http/http-helpers.d.ts +20 -6
  31. package/dist/sdk/utils/capabilities/http/http-helpers.js +23 -4
  32. package/dist/sdk/utils/safe-integer.d.ts +8 -0
  33. package/dist/sdk/utils/safe-integer.js +15 -0
  34. package/dist/sdk/utils/types/no-excess.d.ts +32 -0
  35. package/dist/sdk/utils/types/no-excess.js +1 -0
  36. package/dist/sdk/utils/values/value.js +3 -4
  37. package/dist/sdk/wasm/host-bindings.d.ts +39 -0
  38. package/dist/sdk/wasm/host-bindings.js +2 -1
  39. package/dist/sdk/wasm/runtime.js +3 -0
  40. package/package.json +4 -3
  41. package/scripts/src/generate-sdks.ts +6 -0
@@ -0,0 +1,32 @@
1
+ /**
2
+ * NoExcess<T, Shape> rejects any property in T whose key is not present in
3
+ * Shape, while preserving the values of allowed properties.
4
+ *
5
+ * Native TS structural typing only triggers excess-property checks on object
6
+ * literals at the call site. Once a request object is bound to a variable
7
+ * its excess keys are tolerated. NoExcess closes that gap by mapping any
8
+ * unknown key to `never`, which fails to assign at the boundary.
9
+ *
10
+ * Recursion stops at:
11
+ * - primitives / Uint8Array / Date (`Shape[K]` not an indexable object), and
12
+ * - index-signature maps (every string key is "known"; nothing is excess).
13
+ *
14
+ * Depth bound is set to 6 to keep the tsc work bounded for nested protos.
15
+ */
16
+ export type NoExcess<T, Shape, Depth extends number = 6> = Depth extends 0 ? T : T extends object ? Shape extends object ? IsIndexed<Shape> extends true ? T : {
17
+ [K in keyof T]: K extends keyof Shape ? NoExcess<T[K], NonNullable<Shape[K]>, Prev<Depth>> : never;
18
+ } : T : T;
19
+ type IsIndexed<T> = string extends keyof T ? true : false;
20
+ type Prev<N extends number> = [-1, 0, 1, 2, 3, 4, 5, 6][N];
21
+ /**
22
+ * Pick the right shape for a capability input.
23
+ *
24
+ * Native protobuf messages carry a `$typeName` brand; JSON shapes do not.
25
+ * If the caller passes a native message we leave it untouched. Otherwise we
26
+ * apply NoExcess against the JSON shape so unknown keys (a stale `body`
27
+ * field, a typo, ...) fail at the call boundary.
28
+ */
29
+ export type CapabilityInput<TInput, Native, Json> = [TInput] extends [{
30
+ $typeName: string;
31
+ }] ? Native : NoExcess<TInput, Json>;
32
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,7 @@
1
1
  import { create } from '@bufbuild/protobuf';
2
2
  import { timestampDate, timestampFromDate } from '@bufbuild/protobuf/wkt';
3
3
  import { BigIntSchema, DecimalSchema, ListSchema, MapSchema, ValueSchema, } from '../../../generated/values/v1/values_pb';
4
+ import { assertSafeIntegerNumber } from '../safe-integer';
4
5
  export class Int64 {
5
6
  // int64 bounds
6
7
  static INT64_MIN = -(2n ** 63n);
@@ -18,8 +19,7 @@ export class Int64 {
18
19
  throw new Error('int64 underflow');
19
20
  return v;
20
21
  }
21
- if (!Number.isFinite(v) || !Number.isInteger(v))
22
- throw new Error('int64 requires an integer number');
22
+ assertSafeIntegerNumber(v, 'int64');
23
23
  const bi = BigInt(v);
24
24
  if (bi > Int64.INT64_MAX)
25
25
  throw new Error('int64 overflow');
@@ -66,8 +66,7 @@ export class UInt64 {
66
66
  throw new Error('uint64 underflow');
67
67
  return v;
68
68
  }
69
- if (!Number.isFinite(v) || !Number.isInteger(v))
70
- throw new Error('uint64 requires an integer number');
69
+ assertSafeIntegerNumber(v, 'uint64');
71
70
  const bi = BigInt(v);
72
71
  if (bi > UInt64.UINT64_MAX)
73
72
  throw new Error('uint64 overflow');
@@ -1,4 +1,42 @@
1
1
  import { Mode } from '../../generated/sdk/v1alpha/sdk_pb';
2
+ import { z } from 'zod';
3
+ export declare const globalHostBindingsSchema: z.ZodObject<{
4
+ switchModes: z.ZodFunction<z.ZodTuple<[z.ZodNativeEnum<typeof Mode>], z.ZodUnknown>, z.ZodVoid>;
5
+ log: z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodVoid>;
6
+ sendResponse: z.ZodFunction<z.ZodTuple<[z.ZodUnion<[z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>, z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>]>], z.ZodUnknown>, z.ZodNumber>;
7
+ versionV2: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodVoid>;
8
+ callCapability: z.ZodFunction<z.ZodTuple<[z.ZodUnion<[z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>, z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>]>], z.ZodUnknown>, z.ZodNumber>;
9
+ awaitCapabilities: z.ZodFunction<z.ZodTuple<[z.ZodUnion<[z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>, z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>]>, z.ZodNumber], z.ZodUnknown>, z.ZodUnion<[z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>, z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>]>>;
10
+ getSecrets: z.ZodFunction<z.ZodTuple<[z.ZodUnion<[z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>, z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>]>, z.ZodNumber], z.ZodUnknown>, z.ZodAny>;
11
+ awaitSecrets: z.ZodFunction<z.ZodTuple<[z.ZodUnion<[z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>, z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>]>, z.ZodNumber], z.ZodUnknown>, z.ZodUnion<[z.ZodType<Uint8Array<ArrayBuffer>, z.ZodTypeDef, Uint8Array<ArrayBuffer>>, z.ZodType<Uint8Array<ArrayBufferLike>, z.ZodTypeDef, Uint8Array<ArrayBufferLike>>]>>;
12
+ getWasiArgs: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodString>;
13
+ now: z.ZodFunction<z.ZodTuple<[], z.ZodUnknown>, z.ZodNumber>;
14
+ sleep: z.ZodFunction<z.ZodTuple<[z.ZodNumber], z.ZodUnknown>, z.ZodVoid>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ callCapability: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
17
+ awaitCapabilities: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>;
18
+ getSecrets: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => any;
19
+ awaitSecrets: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>;
20
+ log: (args_0: string, ...args: unknown[]) => void;
21
+ sendResponse: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
22
+ switchModes: (args_0: Mode, ...args: unknown[]) => void;
23
+ versionV2: (...args: unknown[]) => void;
24
+ getWasiArgs: (...args: unknown[]) => string;
25
+ now: (...args: unknown[]) => number;
26
+ sleep: (args_0: number, ...args: unknown[]) => void;
27
+ }, {
28
+ callCapability: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
29
+ awaitCapabilities: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>;
30
+ getSecrets: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => any;
31
+ awaitSecrets: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>;
32
+ log: (args_0: string, ...args: unknown[]) => void;
33
+ sendResponse: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
34
+ switchModes: (args_0: Mode, ...args: unknown[]) => void;
35
+ versionV2: (...args: unknown[]) => void;
36
+ getWasiArgs: (...args: unknown[]) => string;
37
+ now: (...args: unknown[]) => number;
38
+ sleep: (args_0: number, ...args: unknown[]) => void;
39
+ }>;
2
40
  export declare const hostBindings: {
3
41
  callCapability: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, ...args: unknown[]) => number;
4
42
  awaitCapabilities: (args_0: Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>, args_1: number, ...args: unknown[]) => Uint8Array<ArrayBufferLike> | Uint8Array<ArrayBuffer>;
@@ -10,4 +48,5 @@ export declare const hostBindings: {
10
48
  versionV2: (...args: unknown[]) => void;
11
49
  getWasiArgs: (...args: unknown[]) => string;
12
50
  now: (...args: unknown[]) => number;
51
+ sleep: (args_0: number, ...args: unknown[]) => void;
13
52
  };
@@ -1,7 +1,7 @@
1
1
  import { Mode } from '../../generated/sdk/v1alpha/sdk_pb';
2
2
  import { z } from 'zod';
3
3
  // Zod schema for validating global host functions
4
- const globalHostBindingsSchema = z.object({
4
+ export const globalHostBindingsSchema = z.object({
5
5
  switchModes: z.function().args(z.nativeEnum(Mode)).returns(z.void()),
6
6
  log: z.function().args(z.string()).returns(z.void()),
7
7
  sendResponse: z
@@ -27,6 +27,7 @@ const globalHostBindingsSchema = z.object({
27
27
  .returns(z.union([z.instanceof(Uint8Array), z.custom()])),
28
28
  getWasiArgs: z.function().args().returns(z.string()),
29
29
  now: z.function().args().returns(z.number()),
30
+ sleep: z.function().args(z.number()).returns(z.void()),
30
31
  });
31
32
  // Validate global host functions at runtime
32
33
  const validateGlobalHostBindings = () => {
@@ -25,6 +25,9 @@ class WasmRuntimeHelpers {
25
25
  now() {
26
26
  return hostBindings.now();
27
27
  }
28
+ sleep(ms) {
29
+ hostBindings.sleep(ms);
30
+ }
28
31
  static getInstance() {
29
32
  if (!WasmRuntimeHelpers.instance) {
30
33
  WasmRuntimeHelpers.instance = new WasmRuntimeHelpers();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainlink/cre-sdk",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -55,12 +55,13 @@
55
55
  "prepublishOnly": "bun typecheck && bun check && bun test && bun test:standard",
56
56
  "test": "bun test",
57
57
  "test:standard": "./scripts/run-standard-tests.sh",
58
- "typecheck": "tsc -p tsconfig.json --noEmit"
58
+ "typecheck": "tsc -p tsconfig.json --noEmit",
59
+ "update-api-baseline": "bun run compile:build && cat dist/index.d.ts dist/pb.d.ts dist/sdk/index.d.ts dist/sdk/runtime.d.ts dist/sdk/workflow.d.ts dist/sdk/errors.d.ts dist/sdk/report.d.ts dist/sdk/test/index.d.ts > api-baseline.d.ts"
59
60
  },
60
61
  "dependencies": {
61
62
  "@bufbuild/protobuf": "2.6.3",
62
63
  "@bufbuild/protoc-gen-es": "2.6.3",
63
- "@chainlink/cre-sdk-javy-plugin": "1.6.0",
64
+ "@chainlink/cre-sdk-javy-plugin": "1.7.0",
64
65
  "@standard-schema/spec": "1.0.0",
65
66
  "viem": "2.34.0",
66
67
  "zod": "3.25.76"
@@ -1,5 +1,6 @@
1
1
  import { rmSync } from 'node:fs'
2
2
  import { file_capabilities_blockchain_evm_v1alpha_client } from '@cre/generated/capabilities/blockchain/evm/v1alpha/client_pb'
3
+ import { file_capabilities_blockchain_solana_v1alpha_client } from '@cre/generated/capabilities/blockchain/solana/v1alpha/client_pb'
3
4
  import { file_capabilities_internal_actionandtrigger_v1_action_and_trigger } from '@cre/generated/capabilities/internal/actionandtrigger/v1/action_and_trigger_pb'
4
5
  import { file_capabilities_internal_basicaction_v1_basic_action } from '@cre/generated/capabilities/internal/basicaction/v1/basic_action_pb'
5
6
  import { file_capabilities_internal_basictrigger_v1_basic_trigger } from '@cre/generated/capabilities/internal/basictrigger/v1/basic_trigger_pb'
@@ -63,6 +64,11 @@ export const main = () => {
63
64
  ...generateMocks(file_capabilities_blockchain_evm_v1alpha_client, TEST_GENERATED_DIR),
64
65
  )
65
66
 
67
+ generateSdk(file_capabilities_blockchain_solana_v1alpha_client, './src/generated-sdk')
68
+ allMockExports.push(
69
+ ...generateMocks(file_capabilities_blockchain_solana_v1alpha_client, TEST_GENERATED_DIR),
70
+ )
71
+
66
72
  generateSdk(file_capabilities_networking_http_v1alpha_client, './src/generated-sdk')
67
73
  allMockExports.push(
68
74
  ...generateMocks(file_capabilities_networking_http_v1alpha_client, TEST_GENERATED_DIR),