diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-23 02:10:03 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-23 06:27:17 +0800 |
commit | 0c53d276f8f4725feeae48fc3534ab63db8fcafb (patch) | |
tree | 18522ba85a2bdff4612c4d244de3fa63ba6074d5 | |
parent | 83c37c6a7a320326975c8afd9d49a42c9afcefd4 (diff) | |
download | dexon-sol-tools-0c53d276f8f4725feeae48fc3534ab63db8fcafb.tar dexon-sol-tools-0c53d276f8f4725feeae48fc3534ab63db8fcafb.tar.gz dexon-sol-tools-0c53d276f8f4725feeae48fc3534ab63db8fcafb.tar.bz2 dexon-sol-tools-0c53d276f8f4725feeae48fc3534ab63db8fcafb.tar.lz dexon-sol-tools-0c53d276f8f4725feeae48fc3534ab63db8fcafb.tar.xz dexon-sol-tools-0c53d276f8f4725feeae48fc3534ab63db8fcafb.tar.zst dexon-sol-tools-0c53d276f8f4725feeae48fc3534ab63db8fcafb.zip |
Use BlockParamLiteral.Latest
-rw-r--r-- | packages/sol-cov/src/coverage_subprovider.ts | 8 | ||||
-rw-r--r-- | packages/sol-cov/src/types.ts | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/packages/sol-cov/src/coverage_subprovider.ts b/packages/sol-cov/src/coverage_subprovider.ts index 1e050080f..3fd45bbd1 100644 --- a/packages/sol-cov/src/coverage_subprovider.ts +++ b/packages/sol-cov/src/coverage_subprovider.ts @@ -8,7 +8,7 @@ import { AbstractArtifactAdapter } from './artifact_adapters/abstract_artifact_a import { constants } from './constants'; import { CoverageManager } from './coverage_manager'; import { getTracesByContractAddress } from './trace'; -import { TraceInfoExistingContract, TraceInfoNewContract } from './types'; +import { BlockParamLiteral, TraceInfoExistingContract, TraceInfoNewContract } from './types'; interface MaybeFakeTxData extends TxData { isFakeTransaction?: boolean; @@ -89,7 +89,7 @@ export class CoverageSubprovider extends Subprovider { } else { const payload = { method: 'eth_getBlockByNumber', - params: ['latest', true], + params: [BlockParamLiteral.Latest, true], }; const jsonRPCResponsePayload = await this.emitPayloadAsync(payload); const transactions = jsonRPCResponsePayload.result.transactions; @@ -136,7 +136,7 @@ export class CoverageSubprovider extends Subprovider { } else { const tracesByContractAddress = getTracesByContractAddress(trace.structLogs, address); for (const subcallAddress of _.keys(tracesByContractAddress)) { - payload = { method: 'eth_getCode', params: [subcallAddress, 'latest'] }; + payload = { method: 'eth_getCode', params: [subcallAddress, BlockParamLiteral.Latest] }; const runtimeBytecode = (await this.emitPayloadAsync(payload)).result; const traceForThatSubcall = tracesByContractAddress[subcallAddress]; const coveredPcs = _.map(traceForThatSubcall, log => log.pc); @@ -178,7 +178,7 @@ export class CoverageSubprovider extends Subprovider { private async _getContractCodeAsync(address: string): Promise<string> { const payload = { method: 'eth_getCode', - params: [address, 'latest'], + params: [address, BlockParamLiteral.Latest], }; const jsonRPCResponsePayload = await this.emitPayloadAsync(payload); const contractCode: string = jsonRPCResponsePayload.result; diff --git a/packages/sol-cov/src/types.ts b/packages/sol-cov/src/types.ts index 01359d858..4c3de55a1 100644 --- a/packages/sol-cov/src/types.ts +++ b/packages/sol-cov/src/types.ts @@ -98,3 +98,7 @@ export interface TraceInfoExistingContract extends TraceInfoBase { } export type TraceInfo = TraceInfoNewContract | TraceInfoExistingContract; + +export enum BlockParamLiteral { + Latest = 'latest', +} |