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

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 (82) hide show
  1. package/README.md +2 -62
  2. package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.d.ts +1035 -0
  3. package/dist/generated/capabilities/blockchain/aptos/v1alpha/client_pb.js +290 -0
  4. package/dist/generated/capabilities/blockchain/evm/v1alpha/client_pb.js +1 -1
  5. package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.d.ts +2885 -15
  6. package/dist/generated/capabilities/blockchain/solana/v1alpha/client_pb.js +459 -7
  7. package/dist/generated/capabilities/networking/http/v1alpha/client_pb.js +1 -1
  8. package/dist/generated/sdk/v1alpha/sdk_pb.d.ts +505 -0
  9. package/dist/generated/sdk/v1alpha/sdk_pb.js +121 -15
  10. package/dist/generated/tools/generator/v1alpha/cre_metadata_pb.d.ts +30 -1
  11. package/dist/generated/tools/generator/v1alpha/cre_metadata_pb.js +20 -2
  12. package/dist/generated/workflows/v2/cre_info_pb.d.ts +123 -0
  13. package/dist/generated/workflows/v2/cre_info_pb.js +17 -0
  14. package/dist/generated/workflows/v2/workflow_key_pb.d.ts +55 -0
  15. package/dist/generated/workflows/v2/workflow_key_pb.js +17 -0
  16. package/dist/generated/workflows/v2/workflow_user_metric_pb.d.ts +118 -0
  17. package/dist/generated/workflows/v2/workflow_user_metric_pb.js +41 -0
  18. package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.d.ts +63 -0
  19. package/dist/generated-sdk/capabilities/blockchain/aptos/v1alpha/client_sdk_gen.js +247 -0
  20. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.d.ts +14 -0
  21. package/dist/generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen.js +95 -0
  22. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.d.ts +69 -2
  23. package/dist/generated-sdk/capabilities/blockchain/solana/v1alpha/client_sdk_gen.js +403 -1
  24. package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.d.ts +5 -1
  25. package/dist/generated-sdk/capabilities/internal/consensus/v1alpha/consensus_sdk_gen.js +22 -0
  26. package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.d.ts +4 -0
  27. package/dist/generated-sdk/capabilities/networking/confidentialhttp/v1alpha/client_sdk_gen.js +12 -0
  28. package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.d.ts +11 -1
  29. package/dist/generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen.js +12 -0
  30. package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.d.ts +2 -0
  31. package/dist/generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen.js +2 -0
  32. package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.d.ts +2 -0
  33. package/dist/generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen.js +2 -0
  34. package/dist/sdk/cre/index.d.ts +30 -15
  35. package/dist/sdk/cre/index.js +29 -14
  36. package/dist/sdk/impl/runtime-impl.d.ts +28 -1
  37. package/dist/sdk/impl/runtime-impl.js +52 -1
  38. package/dist/sdk/runtime.d.ts +23 -1
  39. package/dist/sdk/tee-constraints.d.ts +68 -0
  40. package/dist/sdk/tee-constraints.js +59 -0
  41. package/dist/sdk/test/evm-contract-mock.js +58 -60
  42. package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.d.ts +25 -0
  43. package/dist/sdk/test/generated/capabilities/blockchain/aptos/v1alpha/aptos_mock_gen.js +111 -0
  44. package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.d.ts +19 -1
  45. package/dist/sdk/test/generated/capabilities/blockchain/solana/v1alpha/solana_mock_gen.js +141 -1
  46. package/dist/sdk/test/generated/index.d.ts +1 -0
  47. package/dist/sdk/test/generated/index.js +1 -0
  48. package/dist/sdk/test/index.d.ts +0 -1
  49. package/dist/sdk/test/index.js +0 -1
  50. package/dist/sdk/testutils/index.d.ts +1 -1
  51. package/dist/sdk/testutils/index.js +1 -1
  52. package/dist/sdk/testutils/test-runtime.d.ts +17 -4
  53. package/dist/sdk/testutils/test-runtime.js +31 -5
  54. package/dist/sdk/testutils/test-writer.d.ts +7 -1
  55. package/dist/sdk/testutils/test-writer.js +13 -1
  56. package/dist/sdk/types/global.d.ts +8 -0
  57. package/dist/sdk/utils/capabilities/blockchain/{evm/evm-helpers.d.ts → blockchain-helpers.d.ts} +6 -7
  58. package/dist/sdk/utils/capabilities/blockchain/{evm/evm-helpers.js → blockchain-helpers.js} +8 -6
  59. package/dist/sdk/utils/hex-utils.d.ts +0 -6
  60. package/dist/sdk/utils/hex-utils.js +0 -8
  61. package/dist/sdk/utils/index.d.ts +1 -3
  62. package/dist/sdk/utils/index.js +1 -2
  63. package/dist/sdk/wasm/host-bindings.d.ts +4 -0
  64. package/dist/sdk/wasm/host-bindings.js +4 -0
  65. package/dist/sdk/wasm/runner.d.ts +10 -4
  66. package/dist/sdk/wasm/runner.js +86 -13
  67. package/dist/sdk/wasm/runtime.d.ts +4 -1
  68. package/dist/sdk/wasm/runtime.js +9 -1
  69. package/dist/sdk/workflow.d.ts +16 -7
  70. package/dist/sdk/workflow.js +10 -2
  71. package/dist/workflows/standard_tests/restrictions/test.ts +41 -0
  72. package/dist/workflows/standard_tests/tee_runtime/test.ts +29 -0
  73. package/package.json +3 -6
  74. package/scripts/src/generate-sdks.ts +6 -0
  75. package/dist/sdk/test/contract-mock-core.d.ts +0 -16
  76. package/dist/sdk/test/contract-mock-core.js +0 -21
  77. package/dist/sdk/test/solana-contract-mock.d.ts +0 -54
  78. package/dist/sdk/test/solana-contract-mock.js +0 -63
  79. package/dist/sdk/utils/capabilities/blockchain/report-helpers.d.ts +0 -19
  80. package/dist/sdk/utils/capabilities/blockchain/report-helpers.js +0 -16
  81. package/dist/sdk/utils/capabilities/blockchain/solana/solana-helpers.d.ts +0 -101
  82. package/dist/sdk/utils/capabilities/blockchain/solana/solana-helpers.js +0 -100
@@ -1,16 +0,0 @@
1
- import { bytesToBase64 } from '../../hex-utils';
2
- /**
3
- * Chain-agnostic core for building a `ReportRequest` from raw payload bytes.
4
- *
5
- * Per-chain wrappers (`prepareReportRequest` for EVM hex payloads,
6
- * `prepareSolanaReportRequest` for Solana Borsh payloads) delegate here so
7
- * there is a single payload-assembly path.
8
- *
9
- * @param payload - The raw payload bytes to be signed.
10
- * @param reportEncoder - The report encoder settings to use.
11
- * @returns The prepared report request.
12
- */
13
- export const prepareReportRequestFromBytes = (payload, reportEncoder) => ({
14
- encodedPayload: bytesToBase64(payload),
15
- ...reportEncoder,
16
- });
@@ -1,101 +0,0 @@
1
- import type { AccountMetaJson, ComputeConfigJson } from '../../../../../generated/capabilities/blockchain/solana/v1alpha/client_pb';
2
- import type { ReportRequestJson } from '../../../../../generated/sdk/v1alpha/sdk_pb';
3
- import { type ReportEncoder } from '../report-helpers';
4
- /**
5
- * An account passed to the Solana capability's `remainingAccounts` list.
6
- * Build instances with {@link solanaAccountMeta}; generated bindings convert
7
- * to the capability's protobuf JSON shape internally.
8
- */
9
- export interface SolanaAccountMeta {
10
- publicKey: Uint8Array;
11
- isWritable: boolean;
12
- }
13
- /**
14
- * Compute settings for a Solana write-report request. Mirrors the
15
- * capability's `ComputeConfig` protobuf JSON shape.
16
- */
17
- export type SolanaComputeConfig = ComputeConfigJson;
18
- /**
19
- * The minimal account shape needed by {@link calculateAccountsHash} —
20
- * only the public key participates in the hash. Structurally compatible
21
- * with both {@link SolanaAccountMeta} and the capability's protobuf
22
- * `AccountMeta`.
23
- */
24
- export type SolanaAccountInput = Pick<SolanaAccountMeta, 'publicKey'> & Partial<Pick<SolanaAccountMeta, 'isWritable'>>;
25
- /**
26
- * Converts a base58-encoded Solana address to its 32 raw bytes.
27
- *
28
- * @param base58Address - The base58-encoded address (validated).
29
- * @returns The 32-byte public key.
30
- */
31
- export declare const solanaAddressToBytes: (base58Address: string) => Uint8Array;
32
- /**
33
- * Builds an account entry for the Solana capability's `remainingAccounts` list.
34
- *
35
- * @param publicKey - The account's public key, as 32 raw bytes or a base58 string.
36
- * @param isWritable - Whether the account is writable. Defaults to false.
37
- * @returns The account meta.
38
- */
39
- export declare const solanaAccountMeta: (publicKey: Uint8Array | string, isWritable?: boolean) => SolanaAccountMeta;
40
- /**
41
- * Converts {@link SolanaAccountMeta} entries to the capability's protobuf
42
- * JSON `AccountMeta` shape (base64 public keys), as expected by
43
- * `SolanaClient.writeReport`. Used by generated bindings.
44
- */
45
- export declare const solanaAccountMetasToJson: (accounts: ReadonlyArray<SolanaAccountMeta>) => AccountMetaJson[];
46
- /**
47
- * Computes the SHA-256 hash of the concatenated public keys of the given
48
- * accounts, matching the keystone-forwarder's on-chain account hash
49
- * verification. Nullish entries are skipped; account order matters.
50
- *
51
- * Mirrors Go `bindings.CalculateAccountsHash`.
52
- *
53
- * @param accounts - The accounts whose public keys are hashed.
54
- * @returns The 32-byte account hash.
55
- */
56
- export declare const calculateAccountsHash: (accounts: ReadonlyArray<SolanaAccountInput | null | undefined>) => Uint8Array;
57
- export interface ForwarderReport {
58
- /** The 32-byte hash from `calculateAccountsHash`. */
59
- accountHash: Uint8Array;
60
- /** The Borsh-encoded report payload the receiver's `on_report` deserializes. */
61
- payload: Uint8Array;
62
- }
63
- /**
64
- * Borsh-encodes a `ForwarderReport` for the keystone-forwarder:
65
- * `[32-byte accountHash][u32-LE payload length][payload bytes]`.
66
- *
67
- * Mirrors Go `bindings.ForwarderReport.Marshal`.
68
- *
69
- * @param report - The account hash and payload to encode.
70
- * @returns The encoded forwarder report.
71
- */
72
- export declare const encodeForwarderReport: (report: ForwarderReport) => Uint8Array;
73
- /**
74
- * Returns the Anchor/Borsh encoding of a Vec whose elements are opaque byte
75
- * payloads: `[u32-LE element count][concatenated element payloads]`.
76
- * Each element must already be fully serialized for one Vec item on the wire.
77
- *
78
- * Mirrors Go's generated `EncodeBorshVecU32`.
79
- *
80
- * @param elementPayloads - The pre-encoded Vec elements.
81
- * @returns The encoded Vec.
82
- */
83
- export declare const encodeBorshVecU32: (elementPayloads: ReadonlyArray<Uint8Array>) => Uint8Array;
84
- /**
85
- * Default values expected by the Solana capability for report encoding.
86
- * Mirrors the constants emitted by the Go Solana bindings generator.
87
- */
88
- export declare const SOLANA_DEFAULT_REPORT_ENCODER: {
89
- encoderName: string;
90
- signingAlgo: string;
91
- hashingAlgo: string;
92
- };
93
- /**
94
- * Prepares a report request for the Solana capability to pass to `.report()`.
95
- * Takes raw bytes (typically an encoded `ForwarderReport`), not hex.
96
- *
97
- * @param payload - The encoded payload bytes to be signed.
98
- * @param reportEncoder - The report encoder to use. Defaults to SOLANA_DEFAULT_REPORT_ENCODER.
99
- * @returns The prepared report request.
100
- */
101
- export declare const prepareSolanaReportRequest: (payload: Uint8Array, reportEncoder?: ReportEncoder) => ReportRequestJson;
@@ -1,100 +0,0 @@
1
- import { bytesToBase64 } from '../../../hex-utils';
2
- import { sha256 } from '@noble/hashes/sha2.js';
3
- import { concatBytes } from '@noble/hashes/utils.js';
4
- import { address, getAddressEncoder } from '@solana/addresses';
5
- import { prepareReportRequestFromBytes } from '../report-helpers';
6
- const ACCOUNT_HASH_LENGTH = 32;
7
- const U32_LENGTH = 4;
8
- // Stateless address encoder; hoisted so the encoder stack isn't rebuilt per call.
9
- const ADDRESS_ENCODER = getAddressEncoder();
10
- /** Encodes a number as a little-endian Borsh u32. */
11
- const u32LE = (value) => {
12
- const bytes = new Uint8Array(U32_LENGTH);
13
- new DataView(bytes.buffer).setUint32(0, value, true);
14
- return bytes;
15
- };
16
- /**
17
- * Converts a base58-encoded Solana address to its 32 raw bytes.
18
- *
19
- * @param base58Address - The base58-encoded address (validated).
20
- * @returns The 32-byte public key.
21
- */
22
- export const solanaAddressToBytes = (base58Address) => new Uint8Array(ADDRESS_ENCODER.encode(address(base58Address)));
23
- /**
24
- * Builds an account entry for the Solana capability's `remainingAccounts` list.
25
- *
26
- * @param publicKey - The account's public key, as 32 raw bytes or a base58 string.
27
- * @param isWritable - Whether the account is writable. Defaults to false.
28
- * @returns The account meta.
29
- */
30
- export const solanaAccountMeta = (publicKey, isWritable = false) => ({
31
- publicKey: typeof publicKey === 'string' ? solanaAddressToBytes(publicKey) : publicKey,
32
- isWritable,
33
- });
34
- /**
35
- * Converts {@link SolanaAccountMeta} entries to the capability's protobuf
36
- * JSON `AccountMeta` shape (base64 public keys), as expected by
37
- * `SolanaClient.writeReport`. Used by generated bindings.
38
- */
39
- export const solanaAccountMetasToJson = (accounts) => accounts.map((account) => ({
40
- publicKey: bytesToBase64(account.publicKey),
41
- isWritable: account.isWritable,
42
- }));
43
- /**
44
- * Computes the SHA-256 hash of the concatenated public keys of the given
45
- * accounts, matching the keystone-forwarder's on-chain account hash
46
- * verification. Nullish entries are skipped; account order matters.
47
- *
48
- * Mirrors Go `bindings.CalculateAccountsHash`.
49
- *
50
- * @param accounts - The accounts whose public keys are hashed.
51
- * @returns The 32-byte account hash.
52
- */
53
- export const calculateAccountsHash = (accounts) => {
54
- const publicKeys = accounts.filter((acc) => acc != null).map(({ publicKey }) => publicKey);
55
- return sha256(concatBytes(...publicKeys));
56
- };
57
- /**
58
- * Borsh-encodes a `ForwarderReport` for the keystone-forwarder:
59
- * `[32-byte accountHash][u32-LE payload length][payload bytes]`.
60
- *
61
- * Mirrors Go `bindings.ForwarderReport.Marshal`.
62
- *
63
- * @param report - The account hash and payload to encode.
64
- * @returns The encoded forwarder report.
65
- */
66
- export const encodeForwarderReport = (report) => {
67
- if (report.accountHash.length !== ACCOUNT_HASH_LENGTH) {
68
- throw new Error(`encodeForwarderReport: accountHash must be exactly ${ACCOUNT_HASH_LENGTH} bytes, got ${report.accountHash.length}`);
69
- }
70
- return concatBytes(report.accountHash, u32LE(report.payload.length), report.payload);
71
- };
72
- /**
73
- * Returns the Anchor/Borsh encoding of a Vec whose elements are opaque byte
74
- * payloads: `[u32-LE element count][concatenated element payloads]`.
75
- * Each element must already be fully serialized for one Vec item on the wire.
76
- *
77
- * Mirrors Go's generated `EncodeBorshVecU32`.
78
- *
79
- * @param elementPayloads - The pre-encoded Vec elements.
80
- * @returns The encoded Vec.
81
- */
82
- export const encodeBorshVecU32 = (elementPayloads) => concatBytes(u32LE(elementPayloads.length), ...elementPayloads);
83
- /**
84
- * Default values expected by the Solana capability for report encoding.
85
- * Mirrors the constants emitted by the Go Solana bindings generator.
86
- */
87
- export const SOLANA_DEFAULT_REPORT_ENCODER = {
88
- encoderName: 'solana',
89
- signingAlgo: 'ecdsa',
90
- hashingAlgo: 'keccak256',
91
- };
92
- /**
93
- * Prepares a report request for the Solana capability to pass to `.report()`.
94
- * Takes raw bytes (typically an encoded `ForwarderReport`), not hex.
95
- *
96
- * @param payload - The encoded payload bytes to be signed.
97
- * @param reportEncoder - The report encoder to use. Defaults to SOLANA_DEFAULT_REPORT_ENCODER.
98
- * @returns The prepared report request.
99
- */
100
- export const prepareSolanaReportRequest = (payload, reportEncoder = SOLANA_DEFAULT_REPORT_ENCODER) => prepareReportRequestFromBytes(payload, reportEncoder);