diff --git a/src/packages/core/index.ts b/src/packages/core/index.ts index 7f2b0bda70..41f23a2fd4 100644 --- a/src/packages/core/index.ts +++ b/src/packages/core/index.ts @@ -1,11 +1,26 @@ import { ConnectorsByName, DefaultFlavor, FlavorName } from "@ganache/flavors"; +import { KNOWN_CHAINIDS } from "@ganache/utils"; import ConnectorLoader from "./src/connector-loader"; import { ProviderOptions, ServerOptions } from "./src/options"; import Server from "./src/server"; export { Server, ServerStatus, _DefaultServerOptions } from "./src/server"; - export type { Provider, EthereumProvider, FilecoinProvider } from "@ganache/flavors"; export type { ProviderOptions, ServerOptions } from "./src/options"; +export type _ExperimentalInfo = Readonly<{ + version: string, + fork: Readonly<{ + /** + * Chains Ganache is known to be compatible with. Operations performed + * locally at historic block numbers will use the Ethereum Virtual Machine + * OPCODEs, gas prices, and EIPs that were active at the time the historic + * block originally took place. + */ + knownChainIds: number[], + }> +}> + + +const version = process.env.VERSION || "DEV"; /** * @public @@ -46,6 +61,18 @@ const Ganache = { ): ConnectorsByName[T]["provider"] => { const loader = ConnectorLoader.initialize(options); return loader.connector.provider; + }, + /** + * + * @experimental + */ + __experimental_info(): _ExperimentalInfo { + return { + version, + fork: { + knownChainIds: Array.from(KNOWN_CHAINIDS) + } + }; } }; @@ -57,6 +84,10 @@ export const server = Ganache.server; * @public */ export const provider = Ganache.provider; +/** + * @experimental + */ +export const __experimental_info = Ganache.__experimental_info; /** * @public */ diff --git a/src/packages/core/tests/interface.test.ts b/src/packages/core/tests/interface.test.ts index ad9f658680..4a185f4133 100644 --- a/src/packages/core/tests/interface.test.ts +++ b/src/packages/core/tests/interface.test.ts @@ -1,14 +1,18 @@ import Ganache from ".."; import * as assert from "assert"; +import { KNOWN_CHAINIDS } from "@ganache/utils"; describe("interface", () => { it("has an interface", () => { assert.ok(Ganache.server); assert.ok(Ganache.provider); - assert.strictEqual(Object.keys(Ganache).length, 2); + const info = Ganache.__experimental_info(); + assert.deepStrictEqual(info.fork.knownChainIds, Array.from(KNOWN_CHAINIDS)); + assert.deepStrictEqual(info.version, "DEV"); + assert.strictEqual(Object.keys(Ganache).length, 3); // in v3 these two properties were *removed* because it was confusing. - // these tests are kinda unncessary, but I just want to intent to be + // these tests are kinda unnecessary, but I just want to intent to be // explicit. assert.strictEqual("Server" in Ganache, false); assert.strictEqual("Provider" in Ganache, false); diff --git a/src/packages/ganache/index.ts b/src/packages/ganache/index.ts index 1af4d62274..124acd2880 100644 --- a/src/packages/ganache/index.ts +++ b/src/packages/ganache/index.ts @@ -12,10 +12,15 @@ export type { ProviderOptions, EthereumProvider, FilecoinProvider, + _ExperimentalInfo } from "@ganache/core"; export { server, - provider + provider, + /** + * @experimental + */ + __experimental_info } from "@ganache/core"; import Ganache from "@ganache/core"; export default Ganache;