@gearbox-protocol/sdk 18.2.0-next.5 → 18.2.0-next.6

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 (36) hide show
  1. package/dist/cjs/testnets/TestnetsAPI.js +179 -0
  2. package/dist/cjs/testnets/errors/TestnetNotFoundError.js +15 -0
  3. package/dist/cjs/testnets/errors/TestnetRequestFailedError.js +24 -0
  4. package/dist/cjs/testnets/errors/TestnetStatusError.js +19 -0
  5. package/dist/cjs/testnets/errors/TestnetValidationError.js +24 -0
  6. package/dist/cjs/testnets/errors/TestnetWaitTimeoutError.js +30 -0
  7. package/dist/cjs/testnets/errors/TestnetsError.js +34 -0
  8. package/dist/cjs/testnets/errors/index.js +13 -0
  9. package/dist/cjs/testnets/index.js +32 -0
  10. package/dist/cjs/testnets/package.json +1 -0
  11. package/dist/cjs/testnets/schemas.js +242 -0
  12. package/dist/cjs/testnets/types.js +1 -0
  13. package/dist/esm/testnets/TestnetsAPI.js +178 -0
  14. package/dist/esm/testnets/errors/TestnetNotFoundError.js +14 -0
  15. package/dist/esm/testnets/errors/TestnetRequestFailedError.js +23 -0
  16. package/dist/esm/testnets/errors/TestnetStatusError.js +18 -0
  17. package/dist/esm/testnets/errors/TestnetValidationError.js +23 -0
  18. package/dist/esm/testnets/errors/TestnetWaitTimeoutError.js +29 -0
  19. package/dist/esm/testnets/errors/TestnetsError.js +33 -0
  20. package/dist/esm/testnets/errors/index.js +7 -0
  21. package/dist/esm/testnets/index.js +11 -0
  22. package/dist/esm/testnets/package.json +1 -0
  23. package/dist/esm/testnets/schemas.js +228 -0
  24. package/dist/esm/testnets/types.js +1 -0
  25. package/dist/types/testnets/TestnetsAPI.d.ts +108 -0
  26. package/dist/types/testnets/errors/TestnetNotFoundError.d.ts +12 -0
  27. package/dist/types/testnets/errors/TestnetRequestFailedError.d.ts +11 -0
  28. package/dist/types/testnets/errors/TestnetStatusError.d.ts +15 -0
  29. package/dist/types/testnets/errors/TestnetValidationError.d.ts +16 -0
  30. package/dist/types/testnets/errors/TestnetWaitTimeoutError.d.ts +21 -0
  31. package/dist/types/testnets/errors/TestnetsError.d.ts +47 -0
  32. package/dist/types/testnets/errors/index.d.ts +7 -0
  33. package/dist/types/testnets/index.d.ts +11 -0
  34. package/dist/types/testnets/schemas.d.ts +554 -0
  35. package/dist/types/testnets/types.d.ts +717 -0
  36. package/package.json +6 -1
@@ -0,0 +1,179 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_testnets_errors_TestnetStatusError = require("./errors/TestnetStatusError.js");
3
+ const require_testnets_errors_TestnetNotFoundError = require("./errors/TestnetNotFoundError.js");
4
+ const require_testnets_errors_TestnetRequestFailedError = require("./errors/TestnetRequestFailedError.js");
5
+ const require_testnets_errors_TestnetValidationError = require("./errors/TestnetValidationError.js");
6
+ const require_testnets_errors_TestnetWaitTimeoutError = require("./errors/TestnetWaitTimeoutError.js");
7
+ require("./errors/index.js");
8
+ const require_testnets_schemas = require("./schemas.js");
9
+ let zod_v4 = require("zod/v4");
10
+ //#region src/testnets/TestnetsAPI.ts
11
+ const DEFAULT_BASE_URL = "https://anvil.gearbox.foundation";
12
+ const DEFAULT_TIMEOUT = 3e4;
13
+ const DEFAULT_WAIT_TIMEOUT = 6e5;
14
+ const DEFAULT_WAIT_INTERVAL = 5e3;
15
+ const errorBodySchema = zod_v4.z.object({ error: zod_v4.z.string() });
16
+ /**
17
+ * Client for anvil-manager, which runs the anvil forks Gearbox calls
18
+ * testnets. It manages non-persistent testnets only, addressed by their
19
+ * execution id.
20
+ *
21
+ * ```ts
22
+ * const testnets = new TestnetsAPI({ apiKey: process.env.ANVIL_MANAGER_API_KEY });
23
+ * const { executionId } = await testnets.create({ network: "Mainnet", timeout: "2h" });
24
+ * const status = await testnets.waitUntilReady(executionId);
25
+ * // ... use status.rpcUrl ...
26
+ * await testnets.kill(executionId);
27
+ * ```
28
+ *
29
+ * Every method throws a {@link TestnetsError} subclass when it fails, except
30
+ * when a response body is not JSON: then it rejects with the error of
31
+ * `response.json()`.
32
+ **/
33
+ var TestnetsAPI = class {
34
+ logger;
35
+ #baseUrl;
36
+ #apiKey;
37
+ #timeout;
38
+ constructor(options = {}) {
39
+ this.#baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
40
+ this.#apiKey = options.apiKey;
41
+ this.#timeout = options.timeout ?? DEFAULT_TIMEOUT;
42
+ this.logger = options.logger?.child?.({ name: "TestnetsAPI" }) ?? options.logger;
43
+ }
44
+ /**
45
+ * Base URL every request of this client is sent to.
46
+ **/
47
+ get baseUrl() {
48
+ return this.#baseUrl;
49
+ }
50
+ /**
51
+ * Every testnet anvil-manager knows of, persistent ones included.
52
+ **/
53
+ async list() {
54
+ const url = this.#url("/api/v1/forks");
55
+ const response = await this.#fetch(url, { method: "GET" });
56
+ return this.#decode(url, response, zod_v4.z.array(require_testnets_schemas.testnetSchema));
57
+ }
58
+ /**
59
+ * Status of one testnet.
60
+ *
61
+ * @param id - Execution id of the testnet.
62
+ * @throws {@link TestnetNotFoundError} when there is no such testnet.
63
+ **/
64
+ async get(id) {
65
+ const url = this.#forkUrl(id);
66
+ const response = await this.#fetch(url, { method: "GET" });
67
+ return this.#decode(url, response, require_testnets_schemas.testnetStatusSchema);
68
+ }
69
+ /**
70
+ * Starts a testnet. It answers as soon as the testnet is created, long
71
+ * before it is {@link TestnetStatus.ready}.
72
+ *
73
+ * @param files - Saved in the testnet's shared dir, where scripts and tasks
74
+ * can read them.
75
+ **/
76
+ async create(request, files) {
77
+ const url = this.#url("/api/v1/forks");
78
+ const response = await this.#fetch(url, {
79
+ method: "POST",
80
+ ...createBody(request, files)
81
+ });
82
+ return this.#decode(url, response, require_testnets_schemas.testnetStatusSchema);
83
+ }
84
+ /**
85
+ * Stops a testnet. Stopping one that is already stopped succeeds.
86
+ *
87
+ * @param id - Execution id of the testnet.
88
+ * @throws {@link TestnetNotFoundError} when there is no such testnet.
89
+ * @throws {@link TestnetStatusError} with status 400 when the testnet is
90
+ * persistent.
91
+ **/
92
+ async kill(id) {
93
+ await this.#fetch(this.#forkUrl(id), { method: "DELETE" });
94
+ }
95
+ /**
96
+ * Polls a testnet's status until it is {@link TestnetStatus.ready}.
97
+ *
98
+ * @param id - Execution id of the testnet.
99
+ * @returns The first status that is ready.
100
+ * @throws {@link TestnetWaitTimeoutError} when the testnet is not ready in
101
+ * time. Any error of a poll is thrown as is, without retrying.
102
+ **/
103
+ async waitUntilReady(id, options = {}) {
104
+ const { timeout = DEFAULT_WAIT_TIMEOUT, interval = DEFAULT_WAIT_INTERVAL } = options;
105
+ const deadline = Date.now() + timeout;
106
+ while (true) {
107
+ const status = await this.get(id);
108
+ if (status.ready) return status;
109
+ const remaining = deadline - Date.now();
110
+ if (remaining <= 0) throw new require_testnets_errors_TestnetWaitTimeoutError.TestnetWaitTimeoutError(this.#forkUrl(id), id, timeout);
111
+ this.logger?.debug(`testnet ${id} is not ready yet`);
112
+ await new Promise((resolve) => setTimeout(resolve, Math.min(interval, remaining)));
113
+ }
114
+ }
115
+ #url(path) {
116
+ return `${this.#baseUrl}${path}`;
117
+ }
118
+ #forkUrl(id) {
119
+ return this.#url(`/api/v1/forks/${encodeURIComponent(id)}`);
120
+ }
121
+ /**
122
+ * Sends one request and returns its response once it is known to be 2xx.
123
+ **/
124
+ async #fetch(url, init) {
125
+ const headers = new Headers(init.headers);
126
+ headers.set("accept", "application/json");
127
+ if (this.#apiKey) headers.set("authorization", `Bearer ${this.#apiKey}`);
128
+ let response;
129
+ try {
130
+ response = await fetch(url, {
131
+ ...init,
132
+ headers,
133
+ signal: AbortSignal.timeout(this.#timeout)
134
+ });
135
+ } catch (error) {
136
+ throw new require_testnets_errors_TestnetRequestFailedError.TestnetRequestFailedError(url, error);
137
+ }
138
+ if (!response.ok) {
139
+ const responseBody = await response.text();
140
+ const details = errorBodySchema.safeParse(responseBody).data?.error;
141
+ throw response.status === 404 ? new require_testnets_errors_TestnetNotFoundError.TestnetNotFoundError(url, details) : new require_testnets_errors_TestnetStatusError.TestnetStatusError(url, response.status, details);
142
+ }
143
+ return response;
144
+ }
145
+ /**
146
+ * Body of a 2xx response, decoded.
147
+ **/
148
+ async #decode(url, response, schema) {
149
+ const payload = await response.json();
150
+ const parsed = schema.safeParse(payload);
151
+ if (!parsed.success) {
152
+ const error = new require_testnets_errors_TestnetValidationError.TestnetValidationError(url, parsed.error);
153
+ this.logger?.error(error, "anvil-manager response does not match the testnet schemas");
154
+ throw error;
155
+ }
156
+ return parsed.data;
157
+ }
158
+ };
159
+ /**
160
+ * Body and content type of a create request: JSON alone, or a multipart form
161
+ * with the JSON in its `json` field when there are files to upload.
162
+ **/
163
+ function createBody(request, files) {
164
+ const json = JSON.stringify(request);
165
+ if (!files || Object.keys(files).length === 0) return {
166
+ body: json,
167
+ headers: { "content-type": "application/json" }
168
+ };
169
+ const form = new FormData();
170
+ form.append("json", json);
171
+ for (const [name, contents] of Object.entries(files)) form.append("file", toBlob(contents), name);
172
+ return { body: form };
173
+ }
174
+ function toBlob(contents) {
175
+ if (contents instanceof Blob) return contents;
176
+ return new Blob([typeof contents === "string" ? contents : new Uint8Array(contents)]);
177
+ }
178
+ //#endregion
179
+ exports.TestnetsAPI = TestnetsAPI;
@@ -0,0 +1,15 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_testnets_errors_TestnetStatusError = require("./TestnetStatusError.js");
3
+ //#region src/testnets/errors/TestnetNotFoundError.ts
4
+ /**
5
+ * Thrown when anvil-manager answered 404: there is no testnet with that
6
+ * execution id.
7
+ **/
8
+ var TestnetNotFoundError = class extends require_testnets_errors_TestnetStatusError.TestnetStatusError {
9
+ name = "TestnetNotFoundError";
10
+ constructor(url, details) {
11
+ super(url, 404, details);
12
+ }
13
+ };
14
+ //#endregion
15
+ exports.TestnetNotFoundError = TestnetNotFoundError;
@@ -0,0 +1,24 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_testnets_errors_TestnetsError = require("./TestnetsError.js");
3
+ //#region src/testnets/errors/TestnetRequestFailedError.ts
4
+ /**
5
+ * Thrown when a request to anvil-manager never completed: the network was
6
+ * down, or it took longer than the client's timeout.
7
+ **/
8
+ var TestnetRequestFailedError = class extends require_testnets_errors_TestnetsError.TestnetsError {
9
+ name = "TestnetRequestFailedError";
10
+ constructor(url, cause) {
11
+ super(timedOut(cause) ? "The request to anvil-manager timed out." : "The request to anvil-manager failed.", {
12
+ url,
13
+ cause
14
+ });
15
+ }
16
+ };
17
+ /**
18
+ * Whether a caught value is the rejection `AbortSignal.timeout` produces.
19
+ **/
20
+ function timedOut(error) {
21
+ return error instanceof Error && error.name === "TimeoutError";
22
+ }
23
+ //#endregion
24
+ exports.TestnetRequestFailedError = TestnetRequestFailedError;
@@ -0,0 +1,19 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_testnets_errors_TestnetsError = require("./TestnetsError.js");
3
+ //#region src/testnets/errors/TestnetStatusError.ts
4
+ /**
5
+ * Thrown when anvil-manager answered with a status outside the 2xx range. What
6
+ * it said about it, when it said anything, is the `details` of the error.
7
+ **/
8
+ var TestnetStatusError = class extends require_testnets_errors_TestnetsError.TestnetsError {
9
+ name = "TestnetStatusError";
10
+ constructor(url, status, details) {
11
+ super(`anvil-manager answered ${status}.`, {
12
+ url,
13
+ status,
14
+ details
15
+ });
16
+ }
17
+ };
18
+ //#endregion
19
+ exports.TestnetStatusError = TestnetStatusError;
@@ -0,0 +1,24 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_testnets_errors_TestnetsError = require("./TestnetsError.js");
3
+ let zod_v4 = require("zod/v4");
4
+ //#region src/testnets/errors/TestnetValidationError.ts
5
+ /**
6
+ * Thrown when anvil-manager answered, but with a payload the testnet schemas
7
+ * do not describe, i.e. the two are of different versions.
8
+ **/
9
+ var TestnetValidationError = class extends require_testnets_errors_TestnetsError.TestnetsError {
10
+ name = "TestnetValidationError";
11
+ /**
12
+ * The zod failure itself, e.g. for `z.treeifyError(error.zodError)`.
13
+ **/
14
+ zodError;
15
+ constructor(url, zodError) {
16
+ super("The anvil-manager response does not match the testnet schemas.", {
17
+ url,
18
+ metaMessages: zod_v4.z.prettifyError(zodError).split("\n")
19
+ });
20
+ this.zodError = zodError;
21
+ }
22
+ };
23
+ //#endregion
24
+ exports.TestnetValidationError = TestnetValidationError;
@@ -0,0 +1,30 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_testnets_errors_TestnetsError = require("./TestnetsError.js");
3
+ //#region src/testnets/errors/TestnetWaitTimeoutError.ts
4
+ /**
5
+ * Thrown when a testnet did not become ready before the wait for it ran out.
6
+ **/
7
+ var TestnetWaitTimeoutError = class extends require_testnets_errors_TestnetsError.TestnetsError {
8
+ name = "TestnetWaitTimeoutError";
9
+ /**
10
+ * Execution id of the testnet that was waited for.
11
+ **/
12
+ id;
13
+ /**
14
+ * How long the wait lasted, in milliseconds.
15
+ **/
16
+ timeout;
17
+ /**
18
+ * @param url - Status URL that was polled.
19
+ **/
20
+ constructor(url, id, timeout) {
21
+ super(`Testnet ${id} did not become ready within ${timeout} ms.`, {
22
+ url,
23
+ metaMessages: [`Execution id: ${id}`, `Timeout: ${timeout} ms`]
24
+ });
25
+ this.id = id;
26
+ this.timeout = timeout;
27
+ }
28
+ };
29
+ //#endregion
30
+ exports.TestnetWaitTimeoutError = TestnetWaitTimeoutError;
@@ -0,0 +1,34 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let viem = require("viem");
3
+ //#region src/testnets/errors/TestnetsError.ts
4
+ /**
5
+ * Thrown by every testnet API call that fails. Its subclasses say how it
6
+ * failed; catch this one to catch all of them.
7
+ **/
8
+ var TestnetsError = class extends viem.BaseError {
9
+ /**
10
+ * URL that was requested.
11
+ **/
12
+ url;
13
+ /**
14
+ * Status anvil-manager answered with, absent when the request never
15
+ * completed.
16
+ **/
17
+ status;
18
+ constructor(summary, params) {
19
+ const { cause, details } = params;
20
+ super(summary, {
21
+ cause: cause instanceof Error ? cause : void 0,
22
+ details: cause === void 0 || cause instanceof Error ? details : String(cause),
23
+ metaMessages: [
24
+ `URL: ${params.url}`,
25
+ ...params.status === void 0 ? [] : [`Status: ${params.status}`],
26
+ ...params.metaMessages ?? []
27
+ ]
28
+ });
29
+ this.url = params.url;
30
+ this.status = params.status;
31
+ }
32
+ };
33
+ //#endregion
34
+ exports.TestnetsError = TestnetsError;
@@ -0,0 +1,13 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_testnets_errors_TestnetsError = require("./TestnetsError.js");
3
+ const require_testnets_errors_TestnetStatusError = require("./TestnetStatusError.js");
4
+ const require_testnets_errors_TestnetNotFoundError = require("./TestnetNotFoundError.js");
5
+ const require_testnets_errors_TestnetRequestFailedError = require("./TestnetRequestFailedError.js");
6
+ const require_testnets_errors_TestnetValidationError = require("./TestnetValidationError.js");
7
+ const require_testnets_errors_TestnetWaitTimeoutError = require("./TestnetWaitTimeoutError.js");
8
+ exports.TestnetNotFoundError = require_testnets_errors_TestnetNotFoundError.TestnetNotFoundError;
9
+ exports.TestnetRequestFailedError = require_testnets_errors_TestnetRequestFailedError.TestnetRequestFailedError;
10
+ exports.TestnetStatusError = require_testnets_errors_TestnetStatusError.TestnetStatusError;
11
+ exports.TestnetValidationError = require_testnets_errors_TestnetValidationError.TestnetValidationError;
12
+ exports.TestnetWaitTimeoutError = require_testnets_errors_TestnetWaitTimeoutError.TestnetWaitTimeoutError;
13
+ exports.TestnetsError = require_testnets_errors_TestnetsError.TestnetsError;
@@ -0,0 +1,32 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_testnets_errors_TestnetsError = require("./errors/TestnetsError.js");
3
+ const require_testnets_errors_TestnetStatusError = require("./errors/TestnetStatusError.js");
4
+ const require_testnets_errors_TestnetNotFoundError = require("./errors/TestnetNotFoundError.js");
5
+ const require_testnets_errors_TestnetRequestFailedError = require("./errors/TestnetRequestFailedError.js");
6
+ const require_testnets_errors_TestnetValidationError = require("./errors/TestnetValidationError.js");
7
+ const require_testnets_errors_TestnetWaitTimeoutError = require("./errors/TestnetWaitTimeoutError.js");
8
+ require("./errors/index.js");
9
+ const require_testnets_schemas = require("./schemas.js");
10
+ const require_testnets_TestnetsAPI = require("./TestnetsAPI.js");
11
+ require("./types.js");
12
+ exports.TestnetNotFoundError = require_testnets_errors_TestnetNotFoundError.TestnetNotFoundError;
13
+ exports.TestnetRequestFailedError = require_testnets_errors_TestnetRequestFailedError.TestnetRequestFailedError;
14
+ exports.TestnetStatusError = require_testnets_errors_TestnetStatusError.TestnetStatusError;
15
+ exports.TestnetValidationError = require_testnets_errors_TestnetValidationError.TestnetValidationError;
16
+ exports.TestnetWaitTimeoutError = require_testnets_errors_TestnetWaitTimeoutError.TestnetWaitTimeoutError;
17
+ exports.TestnetsAPI = require_testnets_TestnetsAPI.TestnetsAPI;
18
+ exports.TestnetsError = require_testnets_errors_TestnetsError.TestnetsError;
19
+ exports.testnetBackendOptionsSchema = require_testnets_schemas.testnetBackendOptionsSchema;
20
+ exports.testnetBackendStateSchema = require_testnets_schemas.testnetBackendStateSchema;
21
+ exports.testnetBackendStatusSchema = require_testnets_schemas.testnetBackendStatusSchema;
22
+ exports.testnetBlockSchema = require_testnets_schemas.testnetBlockSchema;
23
+ exports.testnetOptionsSchema = require_testnets_schemas.testnetOptionsSchema;
24
+ exports.testnetSchema = require_testnets_schemas.testnetSchema;
25
+ exports.testnetScriptBlockSchema = require_testnets_schemas.testnetScriptBlockSchema;
26
+ exports.testnetScriptOptionsSchema = require_testnets_schemas.testnetScriptOptionsSchema;
27
+ exports.testnetScriptSchema = require_testnets_schemas.testnetScriptSchema;
28
+ exports.testnetStageStatusSchema = require_testnets_schemas.testnetStageStatusSchema;
29
+ exports.testnetStatusSchema = require_testnets_schemas.testnetStatusSchema;
30
+ exports.testnetTaskDefinitionSchema = require_testnets_schemas.testnetTaskDefinitionSchema;
31
+ exports.testnetTaskProgressSchema = require_testnets_schemas.testnetTaskProgressSchema;
32
+ exports.testnetTaskSchema = require_testnets_schemas.testnetTaskSchema;
@@ -0,0 +1 @@
1
+ {"type": "commonjs"}
@@ -0,0 +1,242 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_onchain_chain_chains = require("../onchain/chain/chains.js");
3
+ const require_onchain_utils_zod = require("../onchain/utils/zod.js");
4
+ let zod_v4 = require("zod/v4");
5
+ //#region src/testnets/schemas.ts
6
+ /**
7
+ * Go marshals a nil slice as `null`; this reads it as an empty array.
8
+ **/
9
+ function nullableArray(item) {
10
+ return zod_v4.z.array(item).nullable().transform((value) => value ?? []);
11
+ }
12
+ /**
13
+ * Go marshals a nil map as `null`; this reads it as an empty record.
14
+ **/
15
+ function nullableRecord(value) {
16
+ return zod_v4.z.record(zod_v4.z.string(), value).nullable().transform((record) => record ?? {});
17
+ }
18
+ const timestamp = zod_v4.z.iso.datetime({ offset: true });
19
+ /**
20
+ * {@link TestnetStageStatus}
21
+ **/
22
+ const testnetStageStatusSchema = zod_v4.z.enum([
23
+ "queued",
24
+ "started",
25
+ "error",
26
+ "failed",
27
+ "success",
28
+ "terminated"
29
+ ]);
30
+ /**
31
+ * {@link TestnetBackendState}
32
+ **/
33
+ const testnetBackendStateSchema = zod_v4.z.enum([
34
+ "provisioning",
35
+ "starting",
36
+ "active",
37
+ "error"
38
+ ]);
39
+ /**
40
+ * {@link Testnet}
41
+ **/
42
+ const testnetSchema = zod_v4.z.object({
43
+ alias: zod_v4.z.string(),
44
+ executionId: zod_v4.z.string(),
45
+ isActive: zod_v4.z.boolean(),
46
+ description: zod_v4.z.string(),
47
+ persistent: zod_v4.z.boolean(),
48
+ paused: zod_v4.z.boolean(),
49
+ network: require_onchain_chain_chains.NetworkType,
50
+ createdAt: timestamp
51
+ });
52
+ /**
53
+ * {@link TestnetBackendOptions}
54
+ **/
55
+ const testnetBackendOptionsSchema = zod_v4.z.object({
56
+ version: zod_v4.z.string().optional(),
57
+ env: zod_v4.z.record(zod_v4.z.string(), zod_v4.z.string()).optional(),
58
+ parentBranchId: zod_v4.z.string().optional()
59
+ });
60
+ /**
61
+ * {@link TestnetBackendStatus}
62
+ **/
63
+ const testnetBackendStatusSchema = zod_v4.z.object({
64
+ state: testnetBackendStateSchema,
65
+ error: zod_v4.z.string().optional(),
66
+ version: zod_v4.z.string().optional()
67
+ });
68
+ /**
69
+ * {@link TestnetBlock}
70
+ **/
71
+ const testnetBlockSchema = zod_v4.z.object({
72
+ number: zod_v4.z.number(),
73
+ time: timestamp
74
+ });
75
+ /**
76
+ * {@link TestnetScriptBlock}
77
+ **/
78
+ const testnetScriptBlockSchema = testnetBlockSchema.extend({
79
+ timeDrift: zod_v4.z.number(),
80
+ originDrift: zod_v4.z.string(),
81
+ automine: zod_v4.z.boolean(),
82
+ mineInterval: zod_v4.z.number()
83
+ });
84
+ /**
85
+ * {@link TestnetScriptOptions}
86
+ **/
87
+ const testnetScriptOptionsSchema = zod_v4.z.object({
88
+ id: zod_v4.z.string(),
89
+ description: zod_v4.z.string(),
90
+ npx: zod_v4.z.string().optional(),
91
+ docker: zod_v4.z.string().optional(),
92
+ args: nullableArray(zod_v4.z.string()),
93
+ env: nullableRecord(zod_v4.z.string()),
94
+ flags: nullableArray(zod_v4.z.string()),
95
+ timeout: zod_v4.z.string(),
96
+ packageManager: zod_v4.z.string().optional(),
97
+ input: zod_v4.z.unknown().optional()
98
+ });
99
+ /**
100
+ * {@link TestnetScript}
101
+ **/
102
+ const testnetScriptSchema = zod_v4.z.object({
103
+ script: testnetScriptOptionsSchema,
104
+ duration: zod_v4.z.string(),
105
+ blockBefore: testnetScriptBlockSchema.optional(),
106
+ blockAfter: testnetScriptBlockSchema.optional(),
107
+ status: testnetStageStatusSchema,
108
+ error: zod_v4.z.string().optional(),
109
+ exitCode: zod_v4.z.number(),
110
+ source: zod_v4.z.string().optional(),
111
+ revision: zod_v4.z.string().optional()
112
+ });
113
+ /**
114
+ * {@link TestnetTaskDefinition}
115
+ **/
116
+ const testnetTaskDefinitionSchema = zod_v4.z.object({
117
+ id: zod_v4.z.string().optional(),
118
+ family: zod_v4.z.string().optional(),
119
+ name: zod_v4.z.string().optional(),
120
+ description: zod_v4.z.string().optional(),
121
+ image: zod_v4.z.string(),
122
+ version: zod_v4.z.string().optional(),
123
+ entrypoint: zod_v4.z.array(zod_v4.z.string()).optional(),
124
+ command: zod_v4.z.array(zod_v4.z.string()).optional(),
125
+ env: zod_v4.z.record(zod_v4.z.string(), zod_v4.z.string()).optional(),
126
+ secrets: zod_v4.z.record(zod_v4.z.string(), zod_v4.z.string()).optional(),
127
+ input: zod_v4.z.unknown().optional(),
128
+ timeout: zod_v4.z.number().optional(),
129
+ concurrent: zod_v4.z.boolean(),
130
+ multicontainer: zod_v4.z.boolean(),
131
+ schemaVersion: zod_v4.z.number().optional()
132
+ });
133
+ /**
134
+ * {@link TestnetTaskProgress}
135
+ **/
136
+ const testnetTaskProgressSchema = zod_v4.z.object({
137
+ completed: zod_v4.z.number(),
138
+ total: zod_v4.z.number(),
139
+ details: zod_v4.z.unknown().optional()
140
+ });
141
+ /**
142
+ * {@link TestnetTask}
143
+ **/
144
+ const testnetTaskSchema = zod_v4.z.object({
145
+ id: zod_v4.z.string(),
146
+ definitionId: zod_v4.z.string(),
147
+ family: zod_v4.z.string(),
148
+ executionId: zod_v4.z.string(),
149
+ name: zod_v4.z.string().optional(),
150
+ description: zod_v4.z.string().optional(),
151
+ image: zod_v4.z.string(),
152
+ source: zod_v4.z.string().optional(),
153
+ revision: zod_v4.z.string().optional(),
154
+ entrypoint: zod_v4.z.array(zod_v4.z.string()).optional(),
155
+ command: zod_v4.z.array(zod_v4.z.string()).optional(),
156
+ env: zod_v4.z.record(zod_v4.z.string(), zod_v4.z.string()).optional(),
157
+ secrets: zod_v4.z.record(zod_v4.z.string(), zod_v4.z.string()).optional(),
158
+ input: zod_v4.z.unknown().optional(),
159
+ multicontainer: zod_v4.z.boolean(),
160
+ concurrent: zod_v4.z.boolean(),
161
+ outputDir: zod_v4.z.string().optional(),
162
+ status: testnetStageStatusSchema,
163
+ error: zod_v4.z.string().optional(),
164
+ createdAt: timestamp,
165
+ updatedAt: timestamp,
166
+ progress: testnetTaskProgressSchema
167
+ });
168
+ /**
169
+ * {@link TestnetOptions}
170
+ **/
171
+ const testnetOptionsSchema = zod_v4.z.object({
172
+ description: zod_v4.z.string().optional(),
173
+ chainId: zod_v4.z.number().optional(),
174
+ network: require_onchain_chain_chains.NetworkType,
175
+ cid: zod_v4.z.string().optional(),
176
+ anvilFlags: zod_v4.z.array(zod_v4.z.string()).optional(),
177
+ anvilImage: zod_v4.z.string().optional(),
178
+ rpcProvider: zod_v4.z.string().optional(),
179
+ addressProvider: require_onchain_utils_zod.ZodAddress().optional(),
180
+ marketConfigurators: zod_v4.z.array(require_onchain_utils_zod.ZodAddress()).optional(),
181
+ rwaFactories: zod_v4.z.array(require_onchain_utils_zod.ZodAddress()).optional(),
182
+ blockNumber: zod_v4.z.string(),
183
+ owner: zod_v4.z.string(),
184
+ timeout: zod_v4.z.string(),
185
+ synctronLogLevel: zod_v4.z.string().optional(),
186
+ scripts: nullableArray(testnetScriptOptionsSchema),
187
+ disableSync: zod_v4.z.boolean(),
188
+ disableIntervalMining: zod_v4.z.boolean(),
189
+ disableRPCProtection: zod_v4.z.boolean(),
190
+ debug: zod_v4.z.boolean().optional(),
191
+ webhooks: nullableArray(zod_v4.z.string()),
192
+ backend: testnetBackendOptionsSchema.optional(),
193
+ tasks: zod_v4.z.array(testnetTaskDefinitionSchema).optional()
194
+ });
195
+ /**
196
+ * {@link TestnetStatus}
197
+ **/
198
+ const testnetStatusSchema = zod_v4.z.object({
199
+ alias: zod_v4.z.string().optional(),
200
+ network: require_onchain_chain_chains.NetworkType,
201
+ nextRestart: timestamp.optional(),
202
+ isActive: zod_v4.z.boolean(),
203
+ ready: zod_v4.z.boolean(),
204
+ paused: zod_v4.z.boolean(),
205
+ rpcUrl: zod_v4.z.string().optional(),
206
+ url: zod_v4.z.string(),
207
+ logsUrl: zod_v4.z.string(),
208
+ persistent: zod_v4.z.boolean(),
209
+ latestBlock: testnetScriptBlockSchema.optional(),
210
+ tasks: zod_v4.z.array(testnetTaskSchema).optional(),
211
+ backend: testnetBackendStatusSchema.optional(),
212
+ executionId: zod_v4.z.string(),
213
+ options: testnetOptionsSchema,
214
+ forkBlock: testnetBlockSchema,
215
+ syncBlock: zod_v4.z.number(),
216
+ syncError: zod_v4.z.string().optional(),
217
+ originChainId: zod_v4.z.number(),
218
+ anvilChainId: zod_v4.z.number(),
219
+ createdAt: timestamp,
220
+ addressProvider: require_onchain_utils_zod.ZodAddress(),
221
+ marketConfigurators: zod_v4.z.array(require_onchain_utils_zod.ZodAddress()).optional(),
222
+ rwaFactories: zod_v4.z.array(require_onchain_utils_zod.ZodAddress()).optional(),
223
+ onchainExecutionId: require_onchain_utils_zod.ZodAddress(),
224
+ scripts: zod_v4.z.array(testnetScriptSchema).optional(),
225
+ cid: zod_v4.z.string().optional(),
226
+ files: zod_v4.z.array(zod_v4.z.string()).optional()
227
+ });
228
+ //#endregion
229
+ exports.testnetBackendOptionsSchema = testnetBackendOptionsSchema;
230
+ exports.testnetBackendStateSchema = testnetBackendStateSchema;
231
+ exports.testnetBackendStatusSchema = testnetBackendStatusSchema;
232
+ exports.testnetBlockSchema = testnetBlockSchema;
233
+ exports.testnetOptionsSchema = testnetOptionsSchema;
234
+ exports.testnetSchema = testnetSchema;
235
+ exports.testnetScriptBlockSchema = testnetScriptBlockSchema;
236
+ exports.testnetScriptOptionsSchema = testnetScriptOptionsSchema;
237
+ exports.testnetScriptSchema = testnetScriptSchema;
238
+ exports.testnetStageStatusSchema = testnetStageStatusSchema;
239
+ exports.testnetStatusSchema = testnetStatusSchema;
240
+ exports.testnetTaskDefinitionSchema = testnetTaskDefinitionSchema;
241
+ exports.testnetTaskProgressSchema = testnetTaskProgressSchema;
242
+ exports.testnetTaskSchema = testnetTaskSchema;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });