@gearbox-protocol/sdk 18.2.0-next.4 → 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 (49) hide show
  1. package/dist/cjs/permissionless/api/oracles/PermissionlessOracles.js +3 -3
  2. package/dist/cjs/permissionless/api/oracles/schemas.js +44 -35
  3. package/dist/cjs/permissionless/api/schemas.js +0 -3
  4. package/dist/cjs/testnets/TestnetsAPI.js +179 -0
  5. package/dist/cjs/testnets/errors/TestnetNotFoundError.js +15 -0
  6. package/dist/cjs/testnets/errors/TestnetRequestFailedError.js +24 -0
  7. package/dist/cjs/testnets/errors/TestnetStatusError.js +19 -0
  8. package/dist/cjs/testnets/errors/TestnetValidationError.js +24 -0
  9. package/dist/cjs/testnets/errors/TestnetWaitTimeoutError.js +30 -0
  10. package/dist/cjs/testnets/errors/TestnetsError.js +34 -0
  11. package/dist/cjs/testnets/errors/index.js +13 -0
  12. package/dist/cjs/testnets/index.js +32 -0
  13. package/dist/cjs/testnets/package.json +1 -0
  14. package/dist/cjs/testnets/schemas.js +242 -0
  15. package/dist/cjs/testnets/types.js +1 -0
  16. package/dist/esm/permissionless/api/oracles/PermissionlessOracles.js +3 -3
  17. package/dist/esm/permissionless/api/oracles/schemas.js +44 -35
  18. package/dist/esm/permissionless/api/schemas.js +2 -4
  19. package/dist/esm/testnets/TestnetsAPI.js +178 -0
  20. package/dist/esm/testnets/errors/TestnetNotFoundError.js +14 -0
  21. package/dist/esm/testnets/errors/TestnetRequestFailedError.js +23 -0
  22. package/dist/esm/testnets/errors/TestnetStatusError.js +18 -0
  23. package/dist/esm/testnets/errors/TestnetValidationError.js +23 -0
  24. package/dist/esm/testnets/errors/TestnetWaitTimeoutError.js +29 -0
  25. package/dist/esm/testnets/errors/TestnetsError.js +33 -0
  26. package/dist/esm/testnets/errors/index.js +7 -0
  27. package/dist/esm/testnets/index.js +11 -0
  28. package/dist/esm/testnets/package.json +1 -0
  29. package/dist/esm/testnets/schemas.js +228 -0
  30. package/dist/esm/testnets/types.js +1 -0
  31. package/dist/types/permissionless/api/index.d.ts +2 -2
  32. package/dist/types/permissionless/api/oracles/PermissionlessOracles.d.ts +2 -4
  33. package/dist/types/permissionless/api/oracles/index.d.ts +2 -2
  34. package/dist/types/permissionless/api/oracles/schemas.d.ts +39 -24
  35. package/dist/types/permissionless/api/oracles/types.d.ts +47 -54
  36. package/dist/types/permissionless/api/schemas.d.ts +0 -2
  37. package/dist/types/permissionless/index.d.ts +2 -2
  38. package/dist/types/testnets/TestnetsAPI.d.ts +108 -0
  39. package/dist/types/testnets/errors/TestnetNotFoundError.d.ts +12 -0
  40. package/dist/types/testnets/errors/TestnetRequestFailedError.d.ts +11 -0
  41. package/dist/types/testnets/errors/TestnetStatusError.d.ts +15 -0
  42. package/dist/types/testnets/errors/TestnetValidationError.d.ts +16 -0
  43. package/dist/types/testnets/errors/TestnetWaitTimeoutError.d.ts +21 -0
  44. package/dist/types/testnets/errors/TestnetsError.d.ts +47 -0
  45. package/dist/types/testnets/errors/index.d.ts +7 -0
  46. package/dist/types/testnets/index.d.ts +11 -0
  47. package/dist/types/testnets/schemas.d.ts +554 -0
  48. package/dist/types/testnets/types.d.ts +717 -0
  49. package/package.json +6 -1
@@ -125,10 +125,10 @@ var PermissionlessOracles = class extends require_offchain_AbstractOffchainNames
125
125
  * const everywhere = await permissionless.oracles.assets();
126
126
  * ```
127
127
  **/
128
- async assets(args = {}) {
129
- const query = args.chainId === void 0 ? "" : `?chainId=${encodeURIComponent(args.chainId)}`;
128
+ async assets({ chainId } = {}) {
130
129
  return this.getData({
131
- path: `/pfs/assets${query}`,
130
+ path: "/pfs/assets",
131
+ query: { chainId: chainId?.toString() },
132
132
  schema: require_permissionless_api_oracles_schemas.assetSummariesSchema
133
133
  });
134
134
  }
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_permissionless_api_chains_schemas = require("../chains/schemas.js");
2
3
  const require_permissionless_api_schemas = require("../schemas.js");
3
4
  let zod_v4 = require("zod/v4");
4
5
  //#region src/permissionless/api/oracles/schemas.ts
@@ -19,22 +20,29 @@ const priceFeedSchema = zod_v4.z.looseObject({
19
20
  stalenessPeriod: zod_v4.z.number(),
20
21
  name: zod_v4.z.string()
21
22
  });
22
- /** {@link PermissionlessAsset} */
23
- const assetSchema = zod_v4.z.looseObject({
23
+ /**
24
+ * {@link PermissionlessPriceFeedAsset}
25
+ *
26
+ * What identifies an asset, which is all a feed's own listing of one says.
27
+ **/
28
+ const priceFeedAssetSchema = zod_v4.z.looseObject({
24
29
  address: require_permissionless_api_schemas.addressSchema,
25
30
  symbol: zod_v4.z.string(),
26
31
  name: zod_v4.z.string(),
27
- decimals: zod_v4.z.number(),
32
+ decimals: zod_v4.z.number()
33
+ });
34
+ /** {@link PermissionlessAsset} — identified as above, plus what prices it. */
35
+ const assetSchema = priceFeedAssetSchema.extend({
28
36
  owner: require_permissionless_api_schemas.addressSchema,
29
37
  priceFeeds: zod_v4.z.array(priceFeedSchema)
30
38
  });
31
- /** {@link PermissionlessPriceFeedStore} */
32
- const priceFeedStoreSchema = zod_v4.z.looseObject({
33
- chainId: zod_v4.z.number(),
34
- name: zod_v4.z.string(),
35
- isPublic: zod_v4.z.boolean(),
36
- isActivated: zod_v4.z.boolean(),
37
- explorerUrl: zod_v4.z.string(),
39
+ /**
40
+ * {@link PermissionlessPriceFeedStore}
41
+ *
42
+ * A store is a chain's, and is described by the same five fields the chain
43
+ * list answers with, so those are extended rather than restated.
44
+ **/
45
+ const priceFeedStoreSchema = require_permissionless_api_chains_schemas.chainSchema.extend({
38
46
  assets: zod_v4.z.array(assetSchema),
39
47
  priceFeeds: zod_v4.z.array(priceFeedSchema)
40
48
  });
@@ -44,26 +52,29 @@ const pricesSchema = zod_v4.z.looseObject({
44
52
  marketCaps: require_permissionless_api_schemas.addressRecord(require_permissionless_api_schemas.addressRecord(zod_v4.z.string().nullable())),
45
53
  time: zod_v4.z.number()
46
54
  });
47
- /** {@link PermissionlessPriceFeedAsset} */
48
- const priceFeedAssetSchema = zod_v4.z.looseObject({
49
- address: require_permissionless_api_schemas.addressSchema,
50
- symbol: zod_v4.z.string(),
51
- name: zod_v4.z.string(),
52
- decimals: zod_v4.z.number()
53
- });
54
- /** {@link PermissionlessPriceFeedMarket} */
55
- const priceFeedMarketSchema = zod_v4.z.looseObject({
55
+ /**
56
+ * What names a market, whichever side it is being listed from.
57
+ *
58
+ * A feed's markets and an asset's markets are different reads, but they
59
+ * answer with the same market: who curates it, what it is denominated in and
60
+ * how much of the quota is taken. Only what the read is about differs, which
61
+ * is what each of the two below adds.
62
+ **/
63
+ const marketSchema = zod_v4.z.looseObject({
56
64
  market: require_permissionless_api_schemas.addressSchema,
57
65
  marketConfigurator: require_permissionless_api_schemas.addressSchema,
58
66
  curatorName: zod_v4.z.string().nullable(),
59
67
  marketName: zod_v4.z.string().nullable(),
60
- token: require_permissionless_api_schemas.addressSchema,
61
- tokenSymbol: zod_v4.z.string().nullable(),
62
68
  underlyingSymbol: zod_v4.z.string().nullable(),
63
- reserve: zod_v4.z.boolean(),
64
69
  isUnderlying: zod_v4.z.boolean(),
65
70
  quotaLimit: zod_v4.z.number().nullable(),
66
- quotaUsed: zod_v4.z.number().nullable(),
71
+ quotaUsed: zod_v4.z.number().nullable()
72
+ });
73
+ /** {@link PermissionlessPriceFeedMarket} — the market as the feed's slot in it. */
74
+ const priceFeedMarketSchema = marketSchema.extend({
75
+ token: require_permissionless_api_schemas.addressSchema,
76
+ tokenSymbol: zod_v4.z.string().nullable(),
77
+ reserve: zod_v4.z.boolean(),
67
78
  marketStalenessPeriod: zod_v4.z.number().nullable()
68
79
  });
69
80
  /** {@link PermissionlessPriceFeedDetails} */
@@ -84,20 +95,12 @@ const assetMarketFeedSchema = zod_v4.z.looseObject({
84
95
  name: zod_v4.z.string().nullable(),
85
96
  inStore: zod_v4.z.boolean()
86
97
  });
87
- /** {@link PermissionlessAssetMarket} */
88
- const assetMarketSchema = zod_v4.z.looseObject({
89
- market: require_permissionless_api_schemas.addressSchema,
90
- marketConfigurator: require_permissionless_api_schemas.addressSchema,
91
- curatorName: zod_v4.z.string().nullable(),
92
- marketName: zod_v4.z.string().nullable(),
98
+ /** {@link PermissionlessAssetMarket} — the market as what prices the asset in it. */
99
+ const assetMarketSchema = marketSchema.extend({
93
100
  underlyingToken: require_permissionless_api_schemas.addressSchema,
94
- underlyingSymbol: zod_v4.z.string().nullable(),
95
- isUnderlying: zod_v4.z.boolean(),
96
101
  isShutdown: zod_v4.z.boolean(),
97
102
  mainFeed: assetMarketFeedSchema.nullable(),
98
- reserveFeed: assetMarketFeedSchema.nullable(),
99
- quotaLimit: zod_v4.z.number().nullable(),
100
- quotaUsed: zod_v4.z.number().nullable()
103
+ reserveFeed: assetMarketFeedSchema.nullable()
101
104
  });
102
105
  /** {@link PermissionlessAssetDetails} */
103
106
  const assetDetailsSchema = zod_v4.z.looseObject({
@@ -108,7 +111,13 @@ const assetDetailsSchema = zod_v4.z.looseObject({
108
111
  quotaLimitUsd: zod_v4.z.number().nullable(),
109
112
  quotaUsedUsd: zod_v4.z.number().nullable()
110
113
  });
111
- /** {@link PermissionlessAssetPrices} */
114
+ /**
115
+ * {@link PermissionlessAssetPrices}
116
+ *
117
+ * The same shape as {@link priceFeedMarketCapsSchema} plus the prices, but not
118
+ * an extension of it: the caps there are keyed by asset and these are keyed by
119
+ * feed, so what the two have in common is a coincidence of form.
120
+ **/
112
121
  const assetPricesSchema = zod_v4.z.looseObject({
113
122
  prices: require_permissionless_api_schemas.addressRecord(zod_v4.z.string().nullable()),
114
123
  marketCaps: require_permissionless_api_schemas.addressRecord(zod_v4.z.string().nullable()),
@@ -12,8 +12,6 @@ let zod_v4 = require("zod/v4");
12
12
  **/
13
13
  /** An address, in whatever case the backend serves it. */
14
14
  const addressSchema = zod_v4.z.custom((value) => typeof value === "string" && (0, viem.isAddress)(value, { strict: false }), { message: "invalid address" });
15
- /** A `0x`-prefixed hex string, as viem's `Hex`. */
16
- const hexSchema = zod_v4.z.custom((value) => typeof value === "string" && (0, viem.isHex)(value), { message: "invalid hex string" });
17
15
  /**
18
16
  * A record keyed by address. Spelled out here because zod types a record key
19
17
  * by the schema's output, which the branded `Address` is not inferred as.
@@ -25,4 +23,3 @@ function addressRecord(value) {
25
23
  //#endregion
26
24
  exports.addressRecord = addressRecord;
27
25
  exports.addressSchema = addressSchema;
28
- exports.hexSchema = hexSchema;
@@ -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"}