@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
@@ -1,30 +1,37 @@
1
+ import { PermissionlessChain } from "../chains/types.js";
1
2
  import { PriceFeed } from "../../core/pricefeed.js";
2
3
  import "../../core/index.js";
3
4
  import { Address } from "viem";
4
5
  //#region src/permissionless/api/oracles/types.d.ts
5
6
  /**
6
- * One asset of a chain, with the feeds allowed for it. The backend indexes
7
- * the chain, so every feed listed here is one the PriceFeedStore carries and
8
- * allows for the asset.
7
+ * What identifies an asset, which is all a feed's own listing of one says.
8
+ *
9
+ * Used on its own where the asset hangs off something else — a feed's assets,
10
+ * say, where listing the feeds allowed for each would only name the feed back.
9
11
  **/
10
- export interface PermissionlessAsset {
12
+ export interface PermissionlessPriceFeedAsset {
11
13
  address: Address;
12
14
  symbol: string;
13
15
  name: string;
14
16
  decimals: number;
17
+ }
18
+ /**
19
+ * One asset of a chain, with the feeds allowed for it. The backend indexes
20
+ * the chain, so every feed listed here is one the PriceFeedStore carries and
21
+ * allows for the asset.
22
+ **/
23
+ export interface PermissionlessAsset extends PermissionlessPriceFeedAsset {
15
24
  owner: Address;
16
25
  priceFeeds: PriceFeed[];
17
26
  }
18
27
  /**
19
28
  * The PriceFeedStore of one chain as the backend has indexed it: the assets
20
29
  * it prices, the feeds it carries, and which feed is allowed on which asset.
30
+ *
31
+ * A store is a chain's, so it is described by the same fields the chain list
32
+ * answers with, plus what it holds.
21
33
  **/
22
- export interface PermissionlessPriceFeedStore {
23
- chainId: number;
24
- name: string;
25
- isPublic: boolean;
26
- isActivated: boolean;
27
- explorerUrl: string;
34
+ export interface PermissionlessPriceFeedStore extends PermissionlessChain {
28
35
  assets: PermissionlessAsset[];
29
36
  priceFeeds: PriceFeed[];
30
37
  }
@@ -38,25 +45,17 @@ export interface PermissionlessPrices {
38
45
  time: number;
39
46
  }
40
47
  /**
41
- * An asset the PriceFeedStore currently allows one feed to price.
48
+ * What names a market, whichever side it is being listed from.
42
49
  *
43
- * Narrower than {@link PermissionlessAsset} on purpose: this hangs off the
44
- * feed, so listing the feeds allowed for it would just name the feed back.
45
- **/
46
- export interface PermissionlessPriceFeedAsset {
47
- address: Address;
48
- symbol: string;
49
- name: string;
50
- decimals: number;
51
- }
52
- /**
53
- * One token a market prices with the feed.
50
+ * A feed's markets and an asset's markets are different reads, but what they
51
+ * say about the market is the same: who curates it, what it is denominated in
52
+ * and how much of its quota is taken. Only the thing the row is about differs,
53
+ * which is what each of the two below adds.
54
54
  *
55
- * A row per `(market, token, role)` rather than per market: the same feed can
56
- * be the main feed of one token and the reserve feed of another in the very
57
- * same market, and both are reported.
55
+ * "This token" throughout means whatever the extending row is about — the
56
+ * token the feed prices, or the asset the market holds as collateral.
58
57
  **/
59
- export interface PermissionlessPriceFeedMarket {
58
+ export interface PermissionlessMarket {
60
59
  market: Address;
61
60
  marketConfigurator: Address;
62
61
  /** The configurator's own name, as the backend's sync recorded it. */
@@ -66,17 +65,12 @@ export interface PermissionlessPriceFeedMarket {
66
65
  * of the backend calls a market by as well.
67
66
  */
68
67
  marketName: string | null;
69
- token: Address;
70
- /** `null` for a token the backend has no metadata row for. */
71
- tokenSymbol: string | null;
72
68
  /**
73
69
  * Symbol of the market's underlying, which is both what the market is
74
- * pictured by and what its quota limit is denominated in.
70
+ * pictured by and what its quota figures are denominated in.
75
71
  */
76
72
  underlyingSymbol: string | null;
77
- /** The feed is the market's reserve feed for this token, not its main one. */
78
- reserve: boolean;
79
- /** The token is the market's underlying. */
73
+ /** This token is the market's own underlying, so it is not quota-managed. */
80
74
  isUnderlying: boolean;
81
75
  /**
82
76
  * What the pool will take of this token, in units of the market's
@@ -101,6 +95,20 @@ export interface PermissionlessPriceFeedMarket {
101
95
  * holds no entry for at all.
102
96
  */
103
97
  quotaUsed: number | null;
98
+ }
99
+ /**
100
+ * One token a market prices with the feed.
101
+ *
102
+ * A row per `(market, token, role)` rather than per market: the same feed can
103
+ * be the main feed of one token and the reserve feed of another in the very
104
+ * same market, and both are reported.
105
+ **/
106
+ export interface PermissionlessPriceFeedMarket extends PermissionlessMarket {
107
+ token: Address;
108
+ /** `null` for a token the backend has no metadata row for. */
109
+ tokenSymbol: string | null;
110
+ /** The feed is the market's reserve feed for this token, not its main one. */
111
+ reserve: boolean;
104
112
  /**
105
113
  * Staleness period this market's own price oracle holds for the slot, in
106
114
  * seconds.
@@ -165,19 +173,9 @@ export interface PermissionlessAssetMarketFeed {
165
173
  * columns of the same market's row, and the quota is the market's whatever
166
174
  * feed holds which slot.
167
175
  **/
168
- export interface PermissionlessAssetMarket {
169
- market: Address;
170
- marketConfigurator: Address;
171
- /** The configurator's own name, as the backend's sync recorded it. */
172
- curatorName: string | null;
173
- /** The market's own name, which is the name of its pool token. */
174
- marketName: string | null;
176
+ export interface PermissionlessAssetMarket extends PermissionlessMarket {
175
177
  /** The market's underlying, which its quota figures are denominated in. */
176
178
  underlyingToken: Address;
177
- /** `null` for an underlying the backend has no metadata row for. */
178
- underlyingSymbol: string | null;
179
- /** The asset is this market's own underlying, so it is not quota-managed. */
180
- isUnderlying: boolean;
181
179
  /**
182
180
  * The market has been shut down.
183
181
  *
@@ -190,16 +188,6 @@ export interface PermissionlessAssetMarket {
190
188
  mainFeed: PermissionlessAssetMarketFeed | null;
191
189
  /** The feed the market falls back to, or `null` if it has none. */
192
190
  reserveFeed: PermissionlessAssetMarketFeed | null;
193
- /**
194
- * What the pool will take of the asset, in units of {@link underlyingToken}.
195
- *
196
- * `null` for an asset the quota keeper was never told a limit for, which the
197
- * market's own underlying always is. A zero is a limit set to zero, and the
198
- * two are different answers.
199
- */
200
- quotaLimit: number | null;
201
- /** How much of {@link quotaLimit} is actually taken, in the same units. */
202
- quotaUsed: number | null;
203
191
  }
204
192
  /**
205
193
  * One asset of the store: what prices it, and what it is used as collateral
@@ -318,6 +306,11 @@ export interface AssetArgs {
318
306
  chainId: number;
319
307
  address: Address;
320
308
  }
309
+ /** Args of {@link PermissionlessOracles.assets}. */
310
+ export interface AssetsArgs {
311
+ /** Omit for every chain the backend serves. */
312
+ chainId?: number;
313
+ }
321
314
  /** Args of {@link PermissionlessOracles.getPrices}. */
322
315
  export interface GetPricesArgs {
323
316
  chainId: number;
@@ -11,8 +11,6 @@ import { z } from "zod/v4";
11
11
  **/
12
12
  /** An address, in whatever case the backend serves it. */
13
13
  export declare const addressSchema: z.ZodCustom<`0x${string}`, `0x${string}`>;
14
- /** A `0x`-prefixed hex string, as viem's `Hex`. */
15
- export declare const hexSchema: z.ZodCustom<`0x${string}`, `0x${string}`>;
16
14
  /**
17
15
  * A record keyed by address. Spelled out here because zod types a record key
18
16
  * by the schema's output, which the branded `Address` is not inferred as.
@@ -13,7 +13,7 @@ import "./core/index.js";
13
13
  import { FunctionParams, ValueParams, encodeFunctionParams } from "./utils/abi-encoder.js";
14
14
  import { DeployArgs, DeployContractArgs, DeployPriceFeedArgs, PreparedDeployment, PreparedPriceFeedDeployment } from "./api/deploy/types.js";
15
15
  import { DEFAULT_DEPLOY_SALT, PermissionlessDeploy, priceFeedSalt } from "./api/deploy/PermissionlessDeploy.js";
16
- import { AssetArgs, GetPricesArgs, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetPrices, PermissionlessAssetSummary, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedMarketCaps, PermissionlessPriceFeedStore, PermissionlessPrices, PriceFeedArgs } from "./api/oracles/types.js";
16
+ import { AssetArgs, AssetsArgs, GetPricesArgs, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetPrices, PermissionlessAssetSummary, PermissionlessMarket, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedMarketCaps, PermissionlessPriceFeedStore, PermissionlessPrices, PriceFeedArgs } from "./api/oracles/types.js";
17
17
  import { GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, PermissionlessOracles } from "./api/oracles/PermissionlessOracles.js";
18
18
  import { AddressProviderContract } from "./bindings/address-provider.js";
19
19
  import { BytecodeRepositoryContract } from "./bindings/bytecode-repository.js";
@@ -54,4 +54,4 @@ import { getPrices } from "./utils/price-update/get-prices.js";
54
54
  import { GetUpdatablePriceFeedsArgs, getUpdatablePriceFeeds } from "./utils/price-update/get-updatable-feeds.js";
55
55
  import { normalizeSignature } from "./utils/signature.js";
56
56
  import "./utils/index.js";
57
- export { AccessMode, AddAssetParams, AddFeedsArgs, AddressProviderContract, Addresses, AllowTokenParams, ArchiveTransport, ArchiveTransportConfig, AssetArgs, AttachChainsArgs, AuditEvent, Auditor, BYTECODE_REPOSITORY, Batch, Bytecode, BytecodeRepositoryContract, CCMConstructorParams, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, ChainScope, ChainSummaryArgs, ChainsNamespace, ChangeNamesArgs, ChangeStalenessPeriodsArgs, ConstructorParams, CreditManagerFees, CrossChainCall, CrossChainMultisigContract, DEFAULT_DEPLOY_SALT, DeployArgs, DeployContractArgs, DeployParams, DeployPriceFeedArgs, Deployment, DeploymentExtended, ForbidAdapterParams, ForbidFeedsArgs, ForbidTokenParams, FunctionParams, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, GearboxPermissionlessOptions, GetPricesArgs, GetUpdatablePriceFeedsArgs, GovernorContract, INSTANCE_MANAGER, InputValueParams, InstanceManagerContract, InstanceOwnerTransactions, InstanceTxs, InstanceTxsArgs, MAINNET_CCM_CONSTRUCTOR_PARAMS, MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLOYMENT_CCM_SALT, MAINNET_DEPLOYMENT_IM_SALT, MARKET_CONFIGURATOR_FACTORY, Market, MarketConfiguratorContract, MarketConfiguratorFactoryContract, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, PauseCreditManagerParams, PeripheryDomain, PermissionlessAnalytics, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetPrices, PermissionlessAssetSummary, PermissionlessChain, PermissionlessChainSummary, PermissionlessChainUnreachableError, PermissionlessDeploy, PermissionlessNotAttachedError, PermissionlessOracles, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedMarketCaps, PermissionlessPriceFeedStore, PermissionlessPrices, PreparedDeployment, PreparedPriceFeedDeployment, PriceChartArgs, PriceFeed, PriceFeedArgs, PriceFeedChartPoint, PriceFeedConstructorParam, PriceFeedNotInStoreError, PriceFeedPair, PriceFeedParamType, PriceFeedParams, PriceFeedPriceChart, PriceFeedSaltMissingError, PriceFeedSetupParams, PriceFeedStalenessUnknownError, PriceFeedStoreContract, Proposal, QueuedAndExecutedTransaction, RecoveryMessage, RoutingManagerContract, SafeBatch, SafeMeta, SafeTx, SetExpirationDateParams, SetFeesParams, SetPriceFeedParams, SetReservePriceFeedParams, SetTokenQuotaIncreaseFeeParams, Signature, TOKEN_COMPRESSOR, TimeLockContract, TimelockTransaction, TimelockTxParams, TimelockTxs, TokenCompressorContract, TreasurySplitterContract, UnpauseCreditManagerParams, ValueParams, WithdrawalCompressorContract, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, chunkedLogsTransport, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCallData, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, deriveEffectiveStalenessPeriod, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, priceFeedSalt, priceFeedSetupParams, shortenHash, significantTrunc };
57
+ export { AccessMode, AddAssetParams, AddFeedsArgs, AddressProviderContract, Addresses, AllowTokenParams, ArchiveTransport, ArchiveTransportConfig, AssetArgs, AssetsArgs, AttachChainsArgs, AuditEvent, Auditor, BYTECODE_REPOSITORY, Batch, Bytecode, BytecodeRepositoryContract, CCMConstructorParams, CROSS_CHAIN_GOVERNANCE, CROSS_CHAIN_MULTISIG, ChainScope, ChainSummaryArgs, ChainsNamespace, ChangeNamesArgs, ChangeStalenessPeriodsArgs, ConstructorParams, CreditManagerFees, CrossChainCall, CrossChainMultisigContract, DEFAULT_DEPLOY_SALT, DeployArgs, DeployContractArgs, DeployParams, DeployPriceFeedArgs, Deployment, DeploymentExtended, ForbidAdapterParams, ForbidFeedsArgs, ForbidTokenParams, FunctionParams, GET_PRICES_CHUNK_SIZE, GET_PRICES_GAS_LIMIT_BY_CHAIN_ID, GearboxPermissionless, GearboxPermissionlessOptions, GetPricesArgs, GetUpdatablePriceFeedsArgs, GovernorContract, INSTANCE_MANAGER, InputValueParams, InstanceManagerContract, InstanceOwnerTransactions, InstanceTxs, InstanceTxsArgs, MAINNET_CCM_CONSTRUCTOR_PARAMS, MAINNET_DEPLOYMENT_BLOCK, MAINNET_DEPLOYMENT_CCM_SALT, MAINNET_DEPLOYMENT_IM_SALT, MARKET_CONFIGURATOR_FACTORY, Market, MarketConfiguratorContract, MarketConfiguratorFactoryContract, PRICE_FEED_STORE, PUBLIC_CREATE2_FACTORY, PauseCreditManagerParams, PeripheryDomain, PermissionlessAnalytics, PermissionlessAsset, PermissionlessAssetDetails, PermissionlessAssetMarket, PermissionlessAssetMarketFeed, PermissionlessAssetPrices, PermissionlessAssetSummary, PermissionlessChain, PermissionlessChainSummary, PermissionlessChainUnreachableError, PermissionlessDeploy, PermissionlessMarket, PermissionlessNotAttachedError, PermissionlessOracles, PermissionlessPriceFeedAsset, PermissionlessPriceFeedDetails, PermissionlessPriceFeedMarket, PermissionlessPriceFeedMarketCaps, PermissionlessPriceFeedStore, PermissionlessPrices, PreparedDeployment, PreparedPriceFeedDeployment, PriceChartArgs, PriceFeed, PriceFeedArgs, PriceFeedChartPoint, PriceFeedConstructorParam, PriceFeedNotInStoreError, PriceFeedPair, PriceFeedParamType, PriceFeedParams, PriceFeedPriceChart, PriceFeedSaltMissingError, PriceFeedSetupParams, PriceFeedStalenessUnknownError, PriceFeedStoreContract, Proposal, QueuedAndExecutedTransaction, RecoveryMessage, RoutingManagerContract, SafeBatch, SafeMeta, SafeTx, SetExpirationDateParams, SetFeesParams, SetPriceFeedParams, SetReservePriceFeedParams, SetTokenQuotaIncreaseFeeParams, Signature, TOKEN_COMPRESSOR, TimeLockContract, TimelockTransaction, TimelockTxParams, TimelockTxs, TokenCompressorContract, TreasurySplitterContract, UnpauseCreditManagerParams, ValueParams, WithdrawalCompressorContract, calculateChecksum, checkCreate2Deployment, checkCreate2DeploymentAddress, chunkedLogsTransport, convertPercent, convertQueueBatchToExecuteTx, convertRawTxToSafeMultisigTx, createCallData, createCreate2DeployRawTx, deepJsonParse, deployUsingPublicCreate2, deriveEffectiveStalenessPeriod, encodeFunctionParams, formatBytecodeSize, formatBytecodeVersion, getBlockNumberByTimestamp, getCreate2AddressPublicFactory, getCreate2DeploymentAddress, getPriceUpdateTx, getPrices, getSafeBatch, getSafeBatches, getUpdatablePriceFeeds, handleSalt, normalizeSignature, priceFeedSalt, priceFeedSetupParams, shortenHash, significantTrunc };
@@ -0,0 +1,108 @@
1
+ import { ILogger } from "../onchain/types/logger.js";
2
+ import { CreateTestnetRequest, Testnet, TestnetFiles, TestnetStatus } from "./types.js";
3
+ //#region src/testnets/TestnetsAPI.d.ts
4
+ /**
5
+ * Options of a {@link TestnetsAPI}.
6
+ **/
7
+ export interface TestnetsAPIOptions {
8
+ /**
9
+ * Base URL of anvil-manager.
10
+ *
11
+ * @defaultValue `"https://anvil.gearbox.foundation"`
12
+ **/
13
+ baseUrl?: string;
14
+ /**
15
+ * API key sent as a bearer token with every request. Without it the private
16
+ * routes (create, kill) answer 401, which surfaces as a
17
+ * {@link TestnetStatusError}.
18
+ **/
19
+ apiKey?: string;
20
+ /**
21
+ * Timeout of one request, in milliseconds.
22
+ *
23
+ * @defaultValue `30_000`
24
+ **/
25
+ timeout?: number;
26
+ logger?: ILogger;
27
+ }
28
+ /**
29
+ * Options of {@link TestnetsAPI.waitUntilReady}.
30
+ **/
31
+ export interface WaitUntilReadyOptions {
32
+ /**
33
+ * How long to wait for the testnet to become ready, in milliseconds.
34
+ *
35
+ * @defaultValue `600_000` (10 minutes)
36
+ **/
37
+ timeout?: number;
38
+ /**
39
+ * Pause between two status polls, in milliseconds.
40
+ *
41
+ * @defaultValue `5_000`
42
+ **/
43
+ interval?: number;
44
+ }
45
+ /**
46
+ * Client for anvil-manager, which runs the anvil forks Gearbox calls
47
+ * testnets. It manages non-persistent testnets only, addressed by their
48
+ * execution id.
49
+ *
50
+ * ```ts
51
+ * const testnets = new TestnetsAPI({ apiKey: process.env.ANVIL_MANAGER_API_KEY });
52
+ * const { executionId } = await testnets.create({ network: "Mainnet", timeout: "2h" });
53
+ * const status = await testnets.waitUntilReady(executionId);
54
+ * // ... use status.rpcUrl ...
55
+ * await testnets.kill(executionId);
56
+ * ```
57
+ *
58
+ * Every method throws a {@link TestnetsError} subclass when it fails, except
59
+ * when a response body is not JSON: then it rejects with the error of
60
+ * `response.json()`.
61
+ **/
62
+ export declare class TestnetsAPI {
63
+ #private;
64
+ protected readonly logger?: ILogger;
65
+ constructor(options?: TestnetsAPIOptions);
66
+ /**
67
+ * Base URL every request of this client is sent to.
68
+ **/
69
+ get baseUrl(): string;
70
+ /**
71
+ * Every testnet anvil-manager knows of, persistent ones included.
72
+ **/
73
+ list(): Promise<Testnet[]>;
74
+ /**
75
+ * Status of one testnet.
76
+ *
77
+ * @param id - Execution id of the testnet.
78
+ * @throws {@link TestnetNotFoundError} when there is no such testnet.
79
+ **/
80
+ get(id: string): Promise<TestnetStatus>;
81
+ /**
82
+ * Starts a testnet. It answers as soon as the testnet is created, long
83
+ * before it is {@link TestnetStatus.ready}.
84
+ *
85
+ * @param files - Saved in the testnet's shared dir, where scripts and tasks
86
+ * can read them.
87
+ **/
88
+ create(request: CreateTestnetRequest, files?: TestnetFiles): Promise<TestnetStatus>;
89
+ /**
90
+ * Stops a testnet. Stopping one that is already stopped succeeds.
91
+ *
92
+ * @param id - Execution id of the testnet.
93
+ * @throws {@link TestnetNotFoundError} when there is no such testnet.
94
+ * @throws {@link TestnetStatusError} with status 400 when the testnet is
95
+ * persistent.
96
+ **/
97
+ kill(id: string): Promise<void>;
98
+ /**
99
+ * Polls a testnet's status until it is {@link TestnetStatus.ready}.
100
+ *
101
+ * @param id - Execution id of the testnet.
102
+ * @returns The first status that is ready.
103
+ * @throws {@link TestnetWaitTimeoutError} when the testnet is not ready in
104
+ * time. Any error of a poll is thrown as is, without retrying.
105
+ **/
106
+ waitUntilReady(id: string, options?: WaitUntilReadyOptions): Promise<TestnetStatus>;
107
+ }
108
+ //#endregion
@@ -0,0 +1,12 @@
1
+ import { TestnetStatusError } from "./TestnetStatusError.js";
2
+ //#region src/testnets/errors/TestnetNotFoundError.d.ts
3
+ /**
4
+ * Thrown when anvil-manager answered 404: there is no testnet with that
5
+ * execution id.
6
+ **/
7
+ export declare class TestnetNotFoundError extends TestnetStatusError {
8
+ name: string;
9
+ readonly status: 404;
10
+ constructor(url: string, details?: string);
11
+ }
12
+ //#endregion
@@ -0,0 +1,11 @@
1
+ import { TestnetsError } from "./TestnetsError.js";
2
+ //#region src/testnets/errors/TestnetRequestFailedError.d.ts
3
+ /**
4
+ * Thrown when a request to anvil-manager never completed: the network was
5
+ * down, or it took longer than the client's timeout.
6
+ **/
7
+ export declare class TestnetRequestFailedError extends TestnetsError {
8
+ name: string;
9
+ constructor(url: string, cause: unknown);
10
+ }
11
+ //#endregion
@@ -0,0 +1,15 @@
1
+ import { TestnetsError } from "./TestnetsError.js";
2
+ //#region src/testnets/errors/TestnetStatusError.d.ts
3
+ /**
4
+ * Thrown when anvil-manager answered with a status outside the 2xx range. What
5
+ * it said about it, when it said anything, is the `details` of the error.
6
+ **/
7
+ export declare class TestnetStatusError extends TestnetsError {
8
+ name: string;
9
+ /**
10
+ * Status anvil-manager answered with.
11
+ **/
12
+ readonly status: number;
13
+ constructor(url: string, status: number, details?: string);
14
+ }
15
+ //#endregion
@@ -0,0 +1,16 @@
1
+ import { TestnetsError } from "./TestnetsError.js";
2
+ import { z } from "zod/v4";
3
+ //#region src/testnets/errors/TestnetValidationError.d.ts
4
+ /**
5
+ * Thrown when anvil-manager answered, but with a payload the testnet schemas
6
+ * do not describe, i.e. the two are of different versions.
7
+ **/
8
+ export declare class TestnetValidationError extends TestnetsError {
9
+ name: string;
10
+ /**
11
+ * The zod failure itself, e.g. for `z.treeifyError(error.zodError)`.
12
+ **/
13
+ readonly zodError: z.core.$ZodError;
14
+ constructor(url: string, zodError: z.core.$ZodError);
15
+ }
16
+ //#endregion
@@ -0,0 +1,21 @@
1
+ import { TestnetsError } from "./TestnetsError.js";
2
+ //#region src/testnets/errors/TestnetWaitTimeoutError.d.ts
3
+ /**
4
+ * Thrown when a testnet did not become ready before the wait for it ran out.
5
+ **/
6
+ export declare class TestnetWaitTimeoutError extends TestnetsError {
7
+ name: string;
8
+ /**
9
+ * Execution id of the testnet that was waited for.
10
+ **/
11
+ readonly id: string;
12
+ /**
13
+ * How long the wait lasted, in milliseconds.
14
+ **/
15
+ readonly timeout: number;
16
+ /**
17
+ * @param url - Status URL that was polled.
18
+ **/
19
+ constructor(url: string, id: string, timeout: number);
20
+ }
21
+ //#endregion
@@ -0,0 +1,47 @@
1
+ import { BaseError } from "viem";
2
+ //#region src/testnets/errors/TestnetsError.d.ts
3
+ /**
4
+ * What every failure of a testnet API call names, see {@link TestnetsError}.
5
+ **/
6
+ export interface TestnetsErrorParams {
7
+ /**
8
+ * URL that was requested.
9
+ **/
10
+ url: string;
11
+ /**
12
+ * Status anvil-manager answered with, absent when the request never
13
+ * completed.
14
+ **/
15
+ status?: number;
16
+ /**
17
+ * Value that was caught. An `Error` becomes the `cause`, anything else is
18
+ * stringified into the details.
19
+ **/
20
+ cause?: unknown;
21
+ /**
22
+ * What anvil-manager itself said. Used only when there is no {@link cause},
23
+ * whose message viem reports instead.
24
+ **/
25
+ details?: string;
26
+ /**
27
+ * Extra lines reported after the URL and status.
28
+ **/
29
+ metaMessages?: string[];
30
+ }
31
+ /**
32
+ * Thrown by every testnet API call that fails. Its subclasses say how it
33
+ * failed; catch this one to catch all of them.
34
+ **/
35
+ export declare abstract class TestnetsError extends BaseError {
36
+ /**
37
+ * URL that was requested.
38
+ **/
39
+ readonly url: string;
40
+ /**
41
+ * Status anvil-manager answered with, absent when the request never
42
+ * completed.
43
+ **/
44
+ readonly status?: number;
45
+ protected constructor(summary: string, params: TestnetsErrorParams);
46
+ }
47
+ //#endregion
@@ -0,0 +1,7 @@
1
+ import { TestnetsError, TestnetsErrorParams } from "./TestnetsError.js";
2
+ import { TestnetStatusError } from "./TestnetStatusError.js";
3
+ import { TestnetNotFoundError } from "./TestnetNotFoundError.js";
4
+ import { TestnetRequestFailedError } from "./TestnetRequestFailedError.js";
5
+ import { TestnetValidationError } from "./TestnetValidationError.js";
6
+ import { TestnetWaitTimeoutError } from "./TestnetWaitTimeoutError.js";
7
+ export { TestnetNotFoundError, TestnetRequestFailedError, TestnetStatusError, TestnetValidationError, TestnetWaitTimeoutError, TestnetsError, TestnetsErrorParams };
@@ -0,0 +1,11 @@
1
+ import { CreateTestnetRequest, Testnet, TestnetBackendOptions, TestnetBackendState, TestnetBackendStatus, TestnetBlock, TestnetFiles, TestnetOptions, TestnetScript, TestnetScriptBlock, TestnetScriptOptions, TestnetScriptRequest, TestnetStageStatus, TestnetStatus, TestnetTask, TestnetTaskDefinition, TestnetTaskDefinitionRequest, TestnetTaskProgress } from "./types.js";
2
+ import { TestnetsAPI, TestnetsAPIOptions, WaitUntilReadyOptions } from "./TestnetsAPI.js";
3
+ import { TestnetsError, TestnetsErrorParams } from "./errors/TestnetsError.js";
4
+ import { TestnetStatusError } from "./errors/TestnetStatusError.js";
5
+ import { TestnetNotFoundError } from "./errors/TestnetNotFoundError.js";
6
+ import { TestnetRequestFailedError } from "./errors/TestnetRequestFailedError.js";
7
+ import { TestnetValidationError } from "./errors/TestnetValidationError.js";
8
+ import { TestnetWaitTimeoutError } from "./errors/TestnetWaitTimeoutError.js";
9
+ import "./errors/index.js";
10
+ import { testnetBackendOptionsSchema, testnetBackendStateSchema, testnetBackendStatusSchema, testnetBlockSchema, testnetOptionsSchema, testnetSchema, testnetScriptBlockSchema, testnetScriptOptionsSchema, testnetScriptSchema, testnetStageStatusSchema, testnetStatusSchema, testnetTaskDefinitionSchema, testnetTaskProgressSchema, testnetTaskSchema } from "./schemas.js";
11
+ export { CreateTestnetRequest, Testnet, TestnetBackendOptions, TestnetBackendState, TestnetBackendStatus, TestnetBlock, TestnetFiles, TestnetNotFoundError, TestnetOptions, TestnetRequestFailedError, TestnetScript, TestnetScriptBlock, TestnetScriptOptions, TestnetScriptRequest, TestnetStageStatus, TestnetStatus, TestnetStatusError, TestnetTask, TestnetTaskDefinition, TestnetTaskDefinitionRequest, TestnetTaskProgress, TestnetValidationError, TestnetWaitTimeoutError, TestnetsAPI, TestnetsAPIOptions, TestnetsError, TestnetsErrorParams, WaitUntilReadyOptions, testnetBackendOptionsSchema, testnetBackendStateSchema, testnetBackendStatusSchema, testnetBlockSchema, testnetOptionsSchema, testnetSchema, testnetScriptBlockSchema, testnetScriptOptionsSchema, testnetScriptSchema, testnetStageStatusSchema, testnetStatusSchema, testnetTaskDefinitionSchema, testnetTaskProgressSchema, testnetTaskSchema };