@chainlink/cre-sdk 0.0.5-alpha → 0.0.7-alpha
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.
- package/dist/index.d.ts +0 -4
- package/dist/index.js +1 -5
- package/dist/pb.d.ts +6 -0
- package/dist/pb.js +6 -0
- package/dist/sdk/cre/index.d.ts +9 -2
- package/dist/sdk/cre/index.js +12 -1
- package/dist/sdk/index.d.ts +3 -0
- package/dist/sdk/index.js +4 -0
- package/dist/sdk/types/global.d.ts +83 -0
- package/dist/sdk/types/restricted-apis.d.ts +27 -0
- package/dist/sdk/utils/capabilities/http/http-helpers.d.ts +37 -1
- package/dist/sdk/utils/capabilities/http/http-helpers.js +45 -5
- package/dist/sdk/utils/decode-json.d.ts +8 -0
- package/dist/sdk/utils/decode-json.js +12 -0
- package/dist/sdk/utils/index.d.ts +1 -0
- package/dist/sdk/utils/index.js +1 -0
- package/package.json +13 -5
- package/scripts/run.ts +2 -2
- package/scripts/src/build-types.ts +33 -0
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
/// <reference types="./sdk/types/global" />
|
|
2
|
+
/// <reference types="./sdk/types/restricted-apis" />
|
|
2
3
|
export * from './sdk';
|
|
3
|
-
export * from './sdk/runtime';
|
|
4
|
-
export * from './sdk/utils';
|
|
5
|
-
// Export HTTP response helpers
|
|
6
|
-
export * from './sdk/utils/capabilities/http/http-helpers';
|
|
7
|
-
export * from './sdk/wasm';
|
package/dist/pb.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as EVM_PB from './generated/capabilities/blockchain/evm/v1alpha/client_pb';
|
|
2
|
+
export * as HTTP_CLIENT_PB from './generated/capabilities/networking/http/v1alpha/client_pb';
|
|
3
|
+
export * as HTTP_TRIGGER_PB from './generated/capabilities/networking/http/v1alpha/trigger_pb';
|
|
4
|
+
export * as CRON_TRIGGER_PB from './generated/capabilities/scheduler/cron/v1/trigger_pb';
|
|
5
|
+
export * as SDK_PB from './generated/sdk/v1alpha/sdk_pb';
|
|
6
|
+
export * as VALUES_PB from './generated/values/v1/values_pb';
|
package/dist/pb.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * as EVM_PB from './generated/capabilities/blockchain/evm/v1alpha/client_pb';
|
|
2
|
+
export * as HTTP_CLIENT_PB from './generated/capabilities/networking/http/v1alpha/client_pb';
|
|
3
|
+
export * as HTTP_TRIGGER_PB from './generated/capabilities/networking/http/v1alpha/trigger_pb';
|
|
4
|
+
export * as CRON_TRIGGER_PB from './generated/capabilities/scheduler/cron/v1/trigger_pb';
|
|
5
|
+
export * as SDK_PB from './generated/sdk/v1alpha/sdk_pb';
|
|
6
|
+
export * as VALUES_PB from './generated/values/v1/values_pb';
|
package/dist/sdk/cre/index.d.ts
CHANGED
|
@@ -2,14 +2,21 @@
|
|
|
2
2
|
* Public API for the CRE SDK.
|
|
3
3
|
*/
|
|
4
4
|
import { ClientCapability as EVMClient } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
|
|
5
|
-
import { ClientCapability as HTTPClient
|
|
5
|
+
import { ClientCapability as HTTPClient } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
|
|
6
6
|
import { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
|
|
7
7
|
import { CronCapability } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
|
|
8
|
+
/**
|
|
9
|
+
* Public exports for the CRE SDK.
|
|
10
|
+
*/
|
|
8
11
|
export { type Log as EVMLog, TxStatus, } from '../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
|
|
9
12
|
export type { Payload as HTTPPayload } from '../../generated/capabilities/networking/http/v1alpha/trigger_pb';
|
|
10
13
|
export type { Payload as CronPayload } from '../../generated/capabilities/scheduler/cron/v1/trigger_pb';
|
|
14
|
+
export { ClientCapability as EVMClient } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
|
|
15
|
+
export { ClientCapability as HTTPClient, type SendRequester as HTTPSendRequester, } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
|
|
16
|
+
export { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
|
|
17
|
+
export { CronCapability } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
|
|
11
18
|
export type { NodeRuntime, Runtime } from '../runtime';
|
|
12
|
-
export
|
|
19
|
+
export { handler } from '../workflow';
|
|
13
20
|
export declare const cre: {
|
|
14
21
|
capabilities: {
|
|
15
22
|
CronCapability: typeof CronCapability;
|
package/dist/sdk/cre/index.js
CHANGED
|
@@ -2,12 +2,23 @@
|
|
|
2
2
|
* Public API for the CRE SDK.
|
|
3
3
|
*/
|
|
4
4
|
import { ClientCapability as EVMClient } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
|
|
5
|
-
import { ClientCapability as HTTPClient
|
|
5
|
+
import { ClientCapability as HTTPClient } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
|
|
6
6
|
import { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
|
|
7
7
|
import { CronCapability } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
|
|
8
8
|
import { prepareRuntime } from '../utils/prepare-runtime';
|
|
9
9
|
import { handler } from '../workflow';
|
|
10
|
+
/**
|
|
11
|
+
* Public exports for the CRE SDK.
|
|
12
|
+
*/
|
|
10
13
|
export { TxStatus, } from '../../generated/capabilities/blockchain/evm/v1alpha/client_pb';
|
|
14
|
+
// EVM Capability
|
|
15
|
+
export { ClientCapability as EVMClient } from '../../generated-sdk/capabilities/blockchain/evm/v1alpha/client_sdk_gen';
|
|
16
|
+
// HTTP Capability
|
|
17
|
+
export { ClientCapability as HTTPClient, } from '../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
|
|
18
|
+
export { HTTPCapability } from '../../generated-sdk/capabilities/networking/http/v1alpha/http_sdk_gen';
|
|
19
|
+
// CRON Capability
|
|
20
|
+
export { CronCapability } from '../../generated-sdk/capabilities/scheduler/cron/v1/cron_sdk_gen';
|
|
21
|
+
export { handler } from '../workflow';
|
|
11
22
|
prepareRuntime();
|
|
12
23
|
export const cre = {
|
|
13
24
|
capabilities: {
|
package/dist/sdk/index.d.ts
CHANGED
package/dist/sdk/index.js
CHANGED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Global type declarations for the CRE SDK runtime
|
|
2
|
+
// Those are the methods that the Host exposes to the Guest.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Host functions exposed by the CRE runtime to WASM guests
|
|
6
|
+
*/
|
|
7
|
+
declare global {
|
|
8
|
+
/**
|
|
9
|
+
* Initiates an asynchronous capability call
|
|
10
|
+
* @param request - protobuf request as bytes
|
|
11
|
+
* @returns Callback ID for the async operation
|
|
12
|
+
*/
|
|
13
|
+
function callCapability(request: Uint8Array): number
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Awaits completion of async capability calls
|
|
17
|
+
* @param awaitRequest - protobuf await request as bytes
|
|
18
|
+
* @param maxResponseLen - Maximum response size in bytes
|
|
19
|
+
* @returns response as bytes
|
|
20
|
+
*/
|
|
21
|
+
function awaitCapabilities(awaitRequest: Uint8Array, maxResponseLen: number): Uint8Array
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Gets secrets asynchronously
|
|
25
|
+
* @param request - protobuf secret request as bytes
|
|
26
|
+
* @param maxResponseLen - Maximum response size in bytes
|
|
27
|
+
* @returns Callback ID for the async operation
|
|
28
|
+
*/
|
|
29
|
+
function getSecrets(request: Uint8Array, maxResponseLen: number): number
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Awaits completion of async secret requests
|
|
33
|
+
* @param awaitRequest - protobuf await secret request as bytes
|
|
34
|
+
* @param maxResponseLen - Maximum response size in bytes
|
|
35
|
+
* @returns response as bytes
|
|
36
|
+
*/
|
|
37
|
+
function awaitSecrets(awaitRequest: Uint8Array, maxResponseLen: number): Uint8Array
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Logs a message to the host runtime
|
|
41
|
+
* @param message - The message to log
|
|
42
|
+
*/
|
|
43
|
+
function log(message: string): void
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Sends a response back to the host
|
|
47
|
+
* @param response - bytes response
|
|
48
|
+
* @returns Status code (0 for success)
|
|
49
|
+
*/
|
|
50
|
+
function sendResponse(response: Uint8Array): number
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Switches execution mode between NODE and DON
|
|
54
|
+
* @param mode - The mode to switch to (0 = UNSPECIFIED, 1 = DON, 2 = NODE)
|
|
55
|
+
*/
|
|
56
|
+
function switchModes(mode: 0 | 1 | 2): void
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Indicates this is a V2 SDK workflow
|
|
60
|
+
*/
|
|
61
|
+
function versionV2(): void
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Gets a random seed from the host
|
|
65
|
+
* @param mode - 1 for non-deterministic, 2 for deterministic
|
|
66
|
+
* @returns Random seed value
|
|
67
|
+
*/
|
|
68
|
+
function randomSeed(mode: 1 | 2): number
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Gets WASI command line arguments
|
|
72
|
+
* @returns Serialized arguments
|
|
73
|
+
*/
|
|
74
|
+
function getWasiArgs(): string
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Gets the current time from the host runtime
|
|
78
|
+
* @returns Unix timestamp in milliseconds
|
|
79
|
+
*/
|
|
80
|
+
function now(): number
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export {}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
/** @deprecated fetch is not available in CRE WASM workflows. Use cre.capabilities.HTTPClient instead. */
|
|
3
|
+
const fetch: never
|
|
4
|
+
|
|
5
|
+
/** @deprecated window is not available in CRE WASM workflows. */
|
|
6
|
+
const window: never
|
|
7
|
+
|
|
8
|
+
/** @deprecated document is not available in CRE WASM workflows. */
|
|
9
|
+
const document: never
|
|
10
|
+
|
|
11
|
+
/** @deprecated XMLHttpRequest is not available in CRE WASM workflows. Use cre.capabilities.HTTPClient instead. */
|
|
12
|
+
const XMLHttpRequest: never
|
|
13
|
+
|
|
14
|
+
/** @deprecated localStorage is not available in CRE WASM workflows. */
|
|
15
|
+
const localStorage: never
|
|
16
|
+
|
|
17
|
+
/** @deprecated sessionStorage is not available in CRE WASM workflows. */
|
|
18
|
+
const sessionStorage: never
|
|
19
|
+
|
|
20
|
+
/** @deprecated setTimeout is not available in CRE WASM workflows. Use cre.capabilities.CronCapability for scheduling. */
|
|
21
|
+
const setTimeout: never
|
|
22
|
+
|
|
23
|
+
/** @deprecated setInterval is not available in CRE WASM workflows. Use cre.capabilities.CronCapability for scheduling. */
|
|
24
|
+
const setInterval: never
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export {}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type { Response } from '../../../../generated/capabilities/networking/http/v1alpha/client_pb';
|
|
1
|
+
import type { Request, RequestJson, Response } from '../../../../generated/capabilities/networking/http/v1alpha/client_pb';
|
|
2
|
+
import type { ReportResponse } from '../../../../generated/sdk/v1alpha/sdk_pb';
|
|
3
|
+
import type { NodeRuntime } from '../../..';
|
|
4
|
+
import type { Report } from '../../../report';
|
|
2
5
|
/**
|
|
3
6
|
* HTTP Response Helper Functions
|
|
4
7
|
*
|
|
@@ -110,3 +113,36 @@ export declare function ok(responseFn: () => {
|
|
|
110
113
|
}): {
|
|
111
114
|
result: () => boolean;
|
|
112
115
|
};
|
|
116
|
+
declare module '../../../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen' {
|
|
117
|
+
interface ClientCapability {
|
|
118
|
+
/**
|
|
119
|
+
* SendReport functions the same as SendRequest, but takes a Report and a function
|
|
120
|
+
* to convert the inner ReportResponse to a Request.
|
|
121
|
+
* Note that caching is limited as reports may contain different sets of signatures
|
|
122
|
+
* on different nodes, leading to a cache miss.
|
|
123
|
+
*
|
|
124
|
+
* @param runtime - The runtime instance
|
|
125
|
+
* @param report - The Report to process
|
|
126
|
+
* @param fn - Function to convert ReportResponse to Request
|
|
127
|
+
* @returns Response result function
|
|
128
|
+
*/
|
|
129
|
+
sendReport(runtime: NodeRuntime<unknown>, report: Report, fn: (reportResponse: ReportResponse) => Request | RequestJson): {
|
|
130
|
+
result: () => Response;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
interface SendRequester {
|
|
134
|
+
/**
|
|
135
|
+
* SendReport functions the same as SendRequest, but takes a Report and a function
|
|
136
|
+
* to convert the inner ReportResponse to a Request.
|
|
137
|
+
* Note that caching is limited as reports may contain different sets of signatures
|
|
138
|
+
* on different nodes, leading to a cache miss.
|
|
139
|
+
*
|
|
140
|
+
* @param report - The Report to process
|
|
141
|
+
* @param fn - Function to convert ReportResponse to Request
|
|
142
|
+
* @returns Response result function
|
|
143
|
+
*/
|
|
144
|
+
sendReport(report: Report, fn: (reportResponse: ReportResponse) => Request | RequestJson): {
|
|
145
|
+
result: () => Response;
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decodeJson } from '../../decode-json';
|
|
1
2
|
export function text(responseOrFn) {
|
|
2
3
|
if (typeof responseOrFn === 'function') {
|
|
3
4
|
return {
|
|
@@ -15,11 +16,7 @@ export function json(responseOrFn) {
|
|
|
15
16
|
result: () => json(responseOrFn().result),
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
const decoder = new TextDecoder('utf-8');
|
|
20
|
-
const textBody = decoder.decode(responseOrFn.body);
|
|
21
|
-
return JSON.parse(textBody);
|
|
22
|
-
}
|
|
19
|
+
return decodeJson(responseOrFn.body);
|
|
23
20
|
}
|
|
24
21
|
export function getHeader(responseOrFn, name) {
|
|
25
22
|
if (typeof responseOrFn === 'function') {
|
|
@@ -42,3 +39,46 @@ export function ok(responseOrFn) {
|
|
|
42
39
|
return responseOrFn.statusCode >= 200 && responseOrFn.statusCode < 300;
|
|
43
40
|
}
|
|
44
41
|
}
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// SendReport Helper Methods for ClientCapability and SendRequester
|
|
44
|
+
// ============================================================================
|
|
45
|
+
/**
|
|
46
|
+
* SendReport functions the same as SendRequest, but takes a Report and a function
|
|
47
|
+
* to convert the inner ReportResponse to a Request.
|
|
48
|
+
* Note that caching is limited as reports may contain different sets of signatures
|
|
49
|
+
* on different nodes, leading to a cache miss.
|
|
50
|
+
*
|
|
51
|
+
* @param runtime - The runtime instance
|
|
52
|
+
* @param report - The Report to process
|
|
53
|
+
* @param fn - Function to convert ReportResponse to Request
|
|
54
|
+
* @returns Response result function
|
|
55
|
+
*/
|
|
56
|
+
function sendReport(runtime, report, fn) {
|
|
57
|
+
const rawReport = report.x_generatedCodeOnly_unwrap();
|
|
58
|
+
const request = fn(rawReport);
|
|
59
|
+
return this.sendRequest(runtime, request);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* SendReport functions the same as SendRequest, but takes a Report and a function
|
|
63
|
+
* to convert the inner ReportResponse to a Request.
|
|
64
|
+
* Note that caching is limited as reports may contain different sets of signatures
|
|
65
|
+
* on different nodes, leading to a cache miss.
|
|
66
|
+
*
|
|
67
|
+
* @param report - The Report to process
|
|
68
|
+
* @param fn - Function to convert ReportResponse to Request
|
|
69
|
+
* @returns Response result function
|
|
70
|
+
*/
|
|
71
|
+
function sendRequesterSendReport(report, fn) {
|
|
72
|
+
const rawReport = report.x_generatedCodeOnly_unwrap();
|
|
73
|
+
const request = fn(rawReport);
|
|
74
|
+
return this.sendRequest(request);
|
|
75
|
+
}
|
|
76
|
+
// ============================================================================
|
|
77
|
+
// Prototype Extensions
|
|
78
|
+
// ============================================================================
|
|
79
|
+
// Import the actual classes for prototype extension
|
|
80
|
+
import { ClientCapability as ClientCapabilityClass, SendRequester as SendRequesterClass, } from '../../../../generated-sdk/capabilities/networking/http/v1alpha/client_sdk_gen';
|
|
81
|
+
// Extend ClientCapability prototype
|
|
82
|
+
ClientCapabilityClass.prototype.sendReport = sendReport;
|
|
83
|
+
// Extend SendRequester prototype
|
|
84
|
+
SendRequesterClass.prototype.sendReport = sendRequesterSendReport;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decodes a Uint8Array into a JSON object.
|
|
3
|
+
* Function would throw if the input is not a valid JSON string encoded as bytes.
|
|
4
|
+
*
|
|
5
|
+
* @param input - The Uint8Array to decode.
|
|
6
|
+
* @returns The decoded JSON object.
|
|
7
|
+
*/
|
|
8
|
+
export declare const decodeJson: (input: Uint8Array) => any;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decodes a Uint8Array into a JSON object.
|
|
3
|
+
* Function would throw if the input is not a valid JSON string encoded as bytes.
|
|
4
|
+
*
|
|
5
|
+
* @param input - The Uint8Array to decode.
|
|
6
|
+
* @returns The decoded JSON object.
|
|
7
|
+
*/
|
|
8
|
+
export const decodeJson = (input) => {
|
|
9
|
+
const decoder = new TextDecoder('utf-8');
|
|
10
|
+
const textBody = decoder.decode(input);
|
|
11
|
+
return JSON.parse(textBody);
|
|
12
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './capabilities/blockchain/blockchain-helpers';
|
|
2
2
|
export * from './capabilities/http/http-helpers';
|
|
3
3
|
export * from './chain-selectors';
|
|
4
|
+
export * from './decode-json';
|
|
4
5
|
export * from './hex-utils';
|
|
5
6
|
export * from './values/consensus_aggregators';
|
|
6
7
|
export * from './values/serializer_types';
|
package/dist/sdk/utils/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './capabilities/blockchain/blockchain-helpers';
|
|
2
2
|
export * from './capabilities/http/http-helpers';
|
|
3
3
|
export * from './chain-selectors';
|
|
4
|
+
export * from './decode-json';
|
|
4
5
|
export * from './hex-utils';
|
|
5
6
|
export * from './values/consensus_aggregators';
|
|
6
7
|
export * from './values/serializer_types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainlink/cre-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7-alpha",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,6 +8,13 @@
|
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./restricted-apis": {
|
|
13
|
+
"types": "./dist/sdk/types/restricted-apis.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./pb": {
|
|
16
|
+
"types": "./dist/pb.d.ts",
|
|
17
|
+
"import": "./dist/pb.js"
|
|
11
18
|
}
|
|
12
19
|
},
|
|
13
20
|
"bin": {
|
|
@@ -22,7 +29,8 @@
|
|
|
22
29
|
"LICENSE.md"
|
|
23
30
|
],
|
|
24
31
|
"scripts": {
|
|
25
|
-
"build": "bun run clean && bun run compile:build && bun run fix-imports",
|
|
32
|
+
"build": "bun run clean && bun run compile:build && bun run build:types && bun run fix-imports",
|
|
33
|
+
"build:types": "bun run scripts/run.ts build-types",
|
|
26
34
|
"check": "biome check --write ${BIOME_PATHS:-.}",
|
|
27
35
|
"clean": "rm -rf dist",
|
|
28
36
|
"compile:all-standard-tests": "bun scripts/run.ts compile-all-standard-tests",
|
|
@@ -33,12 +41,12 @@
|
|
|
33
41
|
"compile:workflow": "bun scripts/run.ts compile-workflow",
|
|
34
42
|
"fix-imports": "bun scripts/run.ts fix-imports",
|
|
35
43
|
"format": "biome format --write ${BIOME_PATHS:-.}",
|
|
36
|
-
"full-checks": "bun generate:sdk && bun build && bun typecheck && bun
|
|
44
|
+
"full-checks": "bun generate:sdk && bun build && bun typecheck && bun check && bun test && bun test:standard",
|
|
37
45
|
"generate:chain-selectors": "bun scripts/run.ts generate-chain-selectors && BIOME_PATHS=\"src/generated\" bun check",
|
|
38
46
|
"generate:proto": "bunx @bufbuild/buf generate && BIOME_PATHS=\"src/generated\" bun check",
|
|
39
47
|
"generate:sdk": "bun generate:proto && bun generate:chain-selectors && bun scripts/run generate-sdks && BIOME_PATHS=\"src/generated src/generated-sdk\" bun check",
|
|
40
48
|
"lint": "biome lint --write",
|
|
41
|
-
"prepublishOnly": "bun typecheck && bun
|
|
49
|
+
"prepublishOnly": "bun typecheck && bun check && bun test && bun test:standard",
|
|
42
50
|
"test": "bun test",
|
|
43
51
|
"test:standard": "./scripts/run-standard-tests.sh",
|
|
44
52
|
"typecheck": "tsc"
|
|
@@ -46,7 +54,7 @@
|
|
|
46
54
|
"dependencies": {
|
|
47
55
|
"@bufbuild/protobuf": "2.6.3",
|
|
48
56
|
"@bufbuild/protoc-gen-es": "2.6.3",
|
|
49
|
-
"@chainlink/cre-sdk-javy-plugin": "0.0.
|
|
57
|
+
"@chainlink/cre-sdk-javy-plugin": "0.0.5-alpha",
|
|
50
58
|
"@standard-schema/spec": "1.0.0",
|
|
51
59
|
"viem": "2.34.0",
|
|
52
60
|
"zod": "3.25.76"
|
package/scripts/run.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
3
|
const availableScripts = [
|
|
4
|
+
'build-types',
|
|
4
5
|
'compile-to-js',
|
|
5
6
|
'compile-to-wasm',
|
|
6
7
|
'compile-workflow', // TS -> JS -> WASM compilation in single script
|
|
7
8
|
'compile-all-standard-tests', // Do the above but for all standard tests
|
|
8
|
-
|
|
9
|
+
'fix-imports', // Fix @cre/* imports to relative paths
|
|
9
10
|
'generate-chain-selectors',
|
|
10
11
|
'generate-sdks',
|
|
11
|
-
'fix-imports', // Fix @cre/* imports to relative paths
|
|
12
12
|
]
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { glob } from 'fast-glob'
|
|
2
|
+
import { copyFile, mkdir } from 'fs/promises'
|
|
3
|
+
import { join } from 'path'
|
|
4
|
+
|
|
5
|
+
const buildTypes = async () => {
|
|
6
|
+
console.log('🔧 Copying type definition files to dist...')
|
|
7
|
+
|
|
8
|
+
// Define paths relative to the scripts directory
|
|
9
|
+
const packageRoot = join(import.meta.dir, '../..')
|
|
10
|
+
const sourceDir = join(packageRoot, 'src/sdk/types')
|
|
11
|
+
const destDir = join(packageRoot, 'dist/sdk/types')
|
|
12
|
+
|
|
13
|
+
// Ensure the destination directory exists
|
|
14
|
+
await mkdir(destDir, { recursive: true })
|
|
15
|
+
|
|
16
|
+
// Find all .d.ts files in the source directory
|
|
17
|
+
const typeFiles = await glob('*.d.ts', {
|
|
18
|
+
cwd: sourceDir,
|
|
19
|
+
absolute: false,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
// Copy each file
|
|
23
|
+
for (const file of typeFiles) {
|
|
24
|
+
const sourceFile = join(sourceDir, file)
|
|
25
|
+
const destFile = join(destDir, file)
|
|
26
|
+
await copyFile(sourceFile, destFile)
|
|
27
|
+
console.log(` ✓ Copied ${file}`)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
console.log(`✅ Copied ${typeFiles.length} type definition file(s) to dist/sdk/types`)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const main = buildTypes
|