aboutsummaryrefslogtreecommitdiffstats
path: root/packages/dev-utils
diff options
context:
space:
mode:
authorJacob Evans <jacob@dekz.net>2018-09-26 13:41:49 +0800
committerJacob Evans <jacob@dekz.net>2018-09-28 07:59:58 +0800
commit21f60721863c974e0565009100891db53b7fb42c (patch)
tree26a7a26023e29b669c79ea4989af81ba1c84d6ec /packages/dev-utils
parentbf3795d2acd377c6896bf3e825d43b8697a12f67 (diff)
downloaddexon-sol-tools-21f60721863c974e0565009100891db53b7fb42c.tar
dexon-sol-tools-21f60721863c974e0565009100891db53b7fb42c.tar.gz
dexon-sol-tools-21f60721863c974e0565009100891db53b7fb42c.tar.bz2
dexon-sol-tools-21f60721863c974e0565009100891db53b7fb42c.tar.lz
dexon-sol-tools-21f60721863c974e0565009100891db53b7fb42c.tar.xz
dexon-sol-tools-21f60721863c974e0565009100891db53b7fb42c.tar.zst
dexon-sol-tools-21f60721863c974e0565009100891db53b7fb42c.zip
Handle revert with reason when decoding call result
We use in-process ganache which throws on an RPC error. This means all of our tests get a nice revert error thrown when testing against ganache. This is not possible with RPC providers and a revert with reason result is returned. Our callAsync doesn't handle this and attempts to decode the revert with reason error log as a successful log, which results in an error while decoding. This only works with our fork of ethers https://github.com/ethers-io/ethers.js/pull/188 and will need to be re-worked when updating to Ethers.js 4
Diffstat (limited to 'packages/dev-utils')
-rw-r--r--packages/dev-utils/src/web3_factory.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/packages/dev-utils/src/web3_factory.ts b/packages/dev-utils/src/web3_factory.ts
index 8e713fa68..7c86d3df4 100644
--- a/packages/dev-utils/src/web3_factory.ts
+++ b/packages/dev-utils/src/web3_factory.ts
@@ -14,6 +14,7 @@ import { env, EnvVars } from './env';
export interface Web3Config {
hasAddresses?: boolean; // default: true
shouldUseInProcessGanache?: boolean; // default: false
+ shouldThrowErrorsOnGanacheRPCResponse?: boolean; // default: true
rpcUrl?: string; // default: localhost:8545
shouldUseFakeGasEstimate?: boolean; // default: true
}
@@ -41,15 +42,19 @@ export const web3Factory = {
if (!_.isUndefined(config.rpcUrl)) {
throw new Error('Cannot use both GanacheSubrovider and RPCSubprovider');
}
+ const shouldThrowErrorsOnGanacheRPCResponse =
+ _.isUndefined(config.shouldThrowErrorsOnGanacheRPCResponse) ||
+ config.shouldThrowErrorsOnGanacheRPCResponse;
provider.addProvider(
new GanacheSubprovider({
+ vmErrorsOnRPCResponse: shouldThrowErrorsOnGanacheRPCResponse,
gasLimit: constants.GAS_LIMIT,
logger,
verbose: env.parseBoolean(EnvVars.VerboseGanache),
port: 8545,
network_id: 50,
mnemonic: 'concert load couple harbor equip island argue ramp clarify fence smart topic',
- }),
+ } as any), // TODO remove any once types are merged in DefinitelyTyped
);
} else {
provider.addProvider(new RPCSubprovider(config.rpcUrl || constants.RPC_URL));