aboutsummaryrefslogtreecommitdiffstats
path: root/packages/sol-cov/src/utils.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-06-19 18:35:32 +0800
committerFabio Berger <me@fabioberger.com>2018-06-19 18:35:32 +0800
commit08ea71cb243067d8f4a4b08b2ed83ee11225d494 (patch)
tree0b9e213e05a050ede2be9d11ed2e040dc0947a81 /packages/sol-cov/src/utils.ts
parent0d0c1af7f741834f076a604b776d4542c4dbb6ec (diff)
parent0bfcf79e79b762a9fb98e90b8e6310c781cfae97 (diff)
downloaddexon-sol-tools-08ea71cb243067d8f4a4b08b2ed83ee11225d494.tar
dexon-sol-tools-08ea71cb243067d8f4a4b08b2ed83ee11225d494.tar.gz
dexon-sol-tools-08ea71cb243067d8f4a4b08b2ed83ee11225d494.tar.bz2
dexon-sol-tools-08ea71cb243067d8f4a4b08b2ed83ee11225d494.tar.lz
dexon-sol-tools-08ea71cb243067d8f4a4b08b2ed83ee11225d494.tar.xz
dexon-sol-tools-08ea71cb243067d8f4a4b08b2ed83ee11225d494.tar.zst
dexon-sol-tools-08ea71cb243067d8f4a4b08b2ed83ee11225d494.zip
Merge branch 'v2-prototype' into feature/combinatorial-testing
* v2-prototype: (40 commits) Increase number of columns in relayer grid for small screens Make isValidSignature public Make batchFill methods return FIllResults struct Remove remove_tags script Small fixes Use semver package instead of getNextPatchVersion Use semver library instead of semverUtils small fixes Show all errors of a given kind at once rather then throwing after the first instance is encountered fix package.json Add more prepublish checks remove remove_tags script Create a shared Image component Adjust version in changelog Update RelayerGridTile render logic to incorportate colors and logos Add max width to top bar Set max-width for LargeLayout Finish last onboarding step Finish set allowance step Add onboarding assets ...
Diffstat (limited to 'packages/sol-cov/src/utils.ts')
-rw-r--r--packages/sol-cov/src/utils.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/sol-cov/src/utils.ts b/packages/sol-cov/src/utils.ts
index 0b32df02e..4f16a1cda 100644
--- a/packages/sol-cov/src/utils.ts
+++ b/packages/sol-cov/src/utils.ts
@@ -1,3 +1,6 @@
+import { addressUtils, BigNumber } from '@0xproject/utils';
+import { OpCode, StructLog } from 'ethereum-types';
+import { addHexPrefix } from 'ethereumjs-util';
import * as _ from 'lodash';
import { ContractData, LineColumn, SingleFileSourceRange } from './types';
@@ -42,4 +45,25 @@ export const utils = {
});
return contractData;
},
+ isCallLike(op: OpCode): boolean {
+ return _.includes([OpCode.CallCode, OpCode.StaticCall, OpCode.Call, OpCode.DelegateCall], op);
+ },
+ isEndOpcode(op: OpCode): boolean {
+ return _.includes([OpCode.Return, OpCode.Stop, OpCode.Revert, OpCode.Invalid, OpCode.SelfDestruct], op);
+ },
+ getAddressFromStackEntry(stackEntry: string): string {
+ const hexBase = 16;
+ return addressUtils.padZeros(new BigNumber(addHexPrefix(stackEntry)).toString(hexBase));
+ },
+ normalizeStructLogs(structLogs: StructLog[]): StructLog[] {
+ if (structLogs[0].depth === 1) {
+ // Geth uses 1-indexed depth counter whilst ganache starts from 0
+ const newStructLogs = _.map(structLogs, structLog => ({
+ ...structLog,
+ depth: structLog.depth - 1,
+ }));
+ return newStructLogs;
+ }
+ return structLogs;
+ },
};