From d07e688a83ae835f3bcbc3013c227cf280dbc433 Mon Sep 17 00:00:00 2001 From: David Murdoch Date: Fri, 4 Mar 2022 17:21:23 -0500 Subject: [PATCH 1/5] add __experimental_info export to core --- src/packages/core/index.ts | 30 ++++++++++++++++++++++- src/packages/core/tests/interface.test.ts | 5 ++-- src/packages/ganache/index.ts | 7 +++++- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/packages/core/index.ts b/src/packages/core/index.ts index 7f2b0bda70..852b94f614 100644 --- a/src/packages/core/index.ts +++ b/src/packages/core/index.ts @@ -1,11 +1,23 @@ 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 fully supported by Ganache forking. + */ + supportedChainIds: number[], + }> +}> + + +const version = process.env.VERSION || "DEV"; /** * @public @@ -46,6 +58,18 @@ const Ganache = { ): ConnectorsByName[T]["provider"] => { const loader = ConnectorLoader.initialize(options); return loader.connector.provider; + }, + /** + * + * @experimental + */ + __experimental_info(): _ExperimentalInfo { + return { + version, + fork: { + supportedChainIds: Array.from(KNOWN_CHAINIDS) + } + }; } }; @@ -57,6 +81,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..3e4f9f3dd2 100644 --- a/src/packages/core/tests/interface.test.ts +++ b/src/packages/core/tests/interface.test.ts @@ -5,10 +5,11 @@ describe("interface", () => { it("has an interface", () => { assert.ok(Ganache.server); assert.ok(Ganache.provider); - assert.strictEqual(Object.keys(Ganache).length, 2); + assert.ok(Ganache.__experimental_info); + 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; From dd99e2f827a935a686c97703e2d815ea8baf780d Mon Sep 17 00:00:00 2001 From: David Murdoch Date: Fri, 4 Mar 2022 17:30:40 -0500 Subject: [PATCH 2/5] improve the tests --- src/packages/core/tests/interface.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/packages/core/tests/interface.test.ts b/src/packages/core/tests/interface.test.ts index 3e4f9f3dd2..c33dd51262 100644 --- a/src/packages/core/tests/interface.test.ts +++ b/src/packages/core/tests/interface.test.ts @@ -1,11 +1,14 @@ import Ganache from ".."; import * as assert from "assert"; +import { KNOWN_CHAINIDS } from "@ganache/utils"; describe("interface", () => { - it("has an interface", () => { + it.only("has an interface", () => { assert.ok(Ganache.server); assert.ok(Ganache.provider); - assert.ok(Ganache.__experimental_info); + const info = Ganache.__experimental_info(); + assert.deepStrictEqual(info.fork.supportedChainIds, 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. From 312b9ed4082cbfcae5061d724451ddab464034e5 Mon Sep 17 00:00:00 2001 From: David Murdoch <187813+davidmurdoch@users.noreply.github.com> Date: Fri, 4 Mar 2022 20:50:48 -0500 Subject: [PATCH 3/5] Update src/packages/core/tests/interface.test.ts --- src/packages/core/tests/interface.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/core/tests/interface.test.ts b/src/packages/core/tests/interface.test.ts index c33dd51262..3159813243 100644 --- a/src/packages/core/tests/interface.test.ts +++ b/src/packages/core/tests/interface.test.ts @@ -3,7 +3,7 @@ import * as assert from "assert"; import { KNOWN_CHAINIDS } from "@ganache/utils"; describe("interface", () => { - it.only("has an interface", () => { + it("has an interface", () => { assert.ok(Ganache.server); assert.ok(Ganache.provider); const info = Ganache.__experimental_info(); From 29ffb1591c262f9df67d774a66982bed40b4fb54 Mon Sep 17 00:00:00 2001 From: David Murdoch Date: Tue, 8 Mar 2022 17:39:30 -0500 Subject: [PATCH 4/5] rename field and reword comment for clarity --- src/packages/core/index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/packages/core/index.ts b/src/packages/core/index.ts index 852b94f614..41f23a2fd4 100644 --- a/src/packages/core/index.ts +++ b/src/packages/core/index.ts @@ -10,9 +10,12 @@ export type _ExperimentalInfo = Readonly<{ version: string, fork: Readonly<{ /** - * Chains fully supported by Ganache forking. + * 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. */ - supportedChainIds: number[], + knownChainIds: number[], }> }> @@ -67,7 +70,7 @@ const Ganache = { return { version, fork: { - supportedChainIds: Array.from(KNOWN_CHAINIDS) + knownChainIds: Array.from(KNOWN_CHAINIDS) } }; } From e837d85aa70ee5a63b958cc1f59f2b85fb26c6c2 Mon Sep 17 00:00:00 2001 From: David Murdoch Date: Wed, 9 Mar 2022 12:17:13 -0500 Subject: [PATCH 5/5] update the test --- src/packages/core/tests/interface.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/core/tests/interface.test.ts b/src/packages/core/tests/interface.test.ts index 3159813243..4a185f4133 100644 --- a/src/packages/core/tests/interface.test.ts +++ b/src/packages/core/tests/interface.test.ts @@ -7,7 +7,7 @@ describe("interface", () => { assert.ok(Ganache.server); assert.ok(Ganache.provider); const info = Ganache.__experimental_info(); - assert.deepStrictEqual(info.fork.supportedChainIds, Array.from(KNOWN_CHAINIDS)); + assert.deepStrictEqual(info.fork.knownChainIds, Array.from(KNOWN_CHAINIDS)); assert.deepStrictEqual(info.version, "DEV"); assert.strictEqual(Object.keys(Ganache).length, 3);