aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Hysen <greg.hysen@gmail.com>2019-01-10 16:36:42 +0800
committerGreg Hysen <greg.hysen@gmail.com>2019-01-15 02:49:44 +0800
commit80aa2884a3aeb8b6f64080d665671e22a5c453cd (patch)
treec5233e90dd47ec30f08a7b3973686fedca29c4c6
parent3a28eb1c6a5e213f4874c34e8a3c85eadfe98fc9 (diff)
downloaddexon-sol-tools-80aa2884a3aeb8b6f64080d665671e22a5c453cd.tar
dexon-sol-tools-80aa2884a3aeb8b6f64080d665671e22a5c453cd.tar.gz
dexon-sol-tools-80aa2884a3aeb8b6f64080d665671e22a5c453cd.tar.bz2
dexon-sol-tools-80aa2884a3aeb8b6f64080d665671e22a5c453cd.tar.lz
dexon-sol-tools-80aa2884a3aeb8b6f64080d665671e22a5c453cd.tar.xz
dexon-sol-tools-80aa2884a3aeb8b6f64080d665671e22a5c453cd.tar.zst
dexon-sol-tools-80aa2884a3aeb8b6f64080d665671e22a5c453cd.zip
Linter
-rw-r--r--contracts/protocol/test/utils/exchange_wrapper.ts2
-rw-r--r--packages/base-contract/src/index.ts8
2 files changed, 7 insertions, 3 deletions
diff --git a/contracts/protocol/test/utils/exchange_wrapper.ts b/contracts/protocol/test/utils/exchange_wrapper.ts
index 871db3529..437882b41 100644
--- a/contracts/protocol/test/utils/exchange_wrapper.ts
+++ b/contracts/protocol/test/utils/exchange_wrapper.ts
@@ -10,7 +10,7 @@ import { artifacts as tokensArtifacts } from '@0x/contracts-tokens';
import { SignedOrder } from '@0x/types';
import { AbiEncoder, BigNumber } from '@0x/utils';
import { Web3Wrapper } from '@0x/web3-wrapper';
-import { AbiDefinition, MethodAbi, Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
+import { MethodAbi, Provider, TransactionReceiptWithDecodedLogs } from 'ethereum-types';
import * as _ from 'lodash';
import { ExchangeContract } from '../../generated-wrappers/exchange';
diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts
index 2471ded92..f14b9a96a 100644
--- a/packages/base-contract/src/index.ts
+++ b/packages/base-contract/src/index.ts
@@ -86,9 +86,13 @@ export class BaseContract {
}
protected static _throwIfRevertWithReasonCallResult(rawCallResult: string): void {
if (rawCallResult.slice(REVERT_ERROR_SELECTOR_OFFSET, REVERT_ERROR_SELECTOR_END) === REVERT_ERROR_SELECTOR) {
- const revertReason = AbiEncoder.create('(string)').decodeAsArray(
+ const revertReasonArray = AbiEncoder.create('(string)').decodeAsArray(
ethers.utils.hexDataSlice(rawCallResult, REVERT_ERROR_SELECTOR_BYTES_LENGTH),
- )[0];
+ );
+ if (revertReasonArray.length !== 1) {
+ throw new Error(`Cannot safely decode revert reason: Expected an array with one element, got ${revertReasonArray}`);
+ }
+ const revertReason = revertReasonArray[0];
throw new Error(revertReason);
}
}