Skip to content

Commit 2b5adb9

Browse files
authored
Merge pull request ConsenSys-archive#2490 from trufflesuite/hotFixShim
Internal Improvement: Enable backwards compatible provider during testing
2 parents 1d58f90 + c72ffa0 commit 2b5adb9

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

packages/core/lib/test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ const Test = {
4141
const web3 = new Web3Shim({
4242
provider: config.provider,
4343
networkType: config.networks[config.network].type
44+
? config.networks[config.network].type
45+
: "web3js"
4446
});
4547

4648
// Override console.warn() because web3 outputs gross errors to it.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Web3Shim } from "./web3-shim";
2+
3+
// We simply return plain ol' Web3.js
4+
export const Web3JsDefinition = {
5+
async initNetworkType(web3: Web3Shim) {}
6+
};

packages/interface-adapter/lib/web3-shim.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@ import { Provider } from "web3/providers";
44
import { EthereumDefinition } from "./ethereum-overloads";
55
import { QuorumDefinition } from "./quorum-overloads";
66
import { FabricEvmDefinition } from "./fabric-evm-overloads";
7-
8-
const initInterface = async(web3Shim: Web3Shim) => {
9-
10-
const networkTypes: NetworkTypesConfig = new Map(Object.entries({
11-
"ethereum": EthereumDefinition,
12-
"quorum": QuorumDefinition,
7+
import { Web3JsDefinition } from "./web3-js-definition";
8+
9+
const initInterface = async (web3Shim: Web3Shim) => {
10+
const networkTypes: NetworkTypesConfig = new Map(
11+
Object.entries({
12+
web3js: Web3JsDefinition,
13+
ethereum: EthereumDefinition,
14+
quorum: QuorumDefinition,
1315
"fabric-evm": FabricEvmDefinition
14-
}));
16+
})
17+
);
1518

16-
networkTypes.get(web3Shim.networkType).initNetworkType(web3Shim);
17-
}
19+
networkTypes.get(web3Shim.networkType).initNetworkType(web3Shim);
20+
};
1821

1922
// March 13, 2019 - Mike Seese:
2023
// This is a temporary shim to support the basic, Ethereum-based
@@ -27,12 +30,12 @@ export type NetworkType = string;
2730
export interface Web3ShimOptions {
2831
provider?: Provider;
2932
networkType?: NetworkType;
30-
};
33+
}
3134

3235
export type InitNetworkType = (web3Shim: Web3Shim) => Promise<void>;
3336

3437
export interface NetworkTypeDefinition {
35-
initNetworkType: InitNetworkType
38+
initNetworkType: InitNetworkType;
3639
}
3740

3841
export type NetworkTypesConfig = Map<NetworkType, NetworkTypeDefinition>;
@@ -75,4 +78,4 @@ export class Web3Shim extends Web3 {
7578
this.networkType = networkType;
7679
initInterface(this);
7780
}
78-
};
81+
}

0 commit comments

Comments
 (0)