From 2dc8d11a5616054d0b8cf80f8f5520e8dd601cf5 Mon Sep 17 00:00:00 2001 From: aniket-engg Date: Tue, 15 Dec 2020 14:03:27 +0530 Subject: [PATCH] imports and some type updated --- libs/remix-debug/src/code/codeManager.ts | 10 +++---- libs/remix-debug/src/debugger/VmDebugger.ts | 8 +++--- libs/remix-debug/src/debugger/debugger.ts | 11 ++++---- .../src/debugger/solidityLocals.ts | 12 ++++---- .../remix-debug/src/debugger/solidityState.ts | 12 ++++---- libs/remix-debug/src/debugger/stepManager.ts | 2 +- .../src/solidity-decoder/types/Address.ts | 6 ++-- .../src/solidity-decoder/types/ArrayType.ts | 23 ++++++++------- .../src/solidity-decoder/types/Bool.ts | 6 ++-- .../types/DynamicByteArray.ts | 20 ++++++------- .../src/solidity-decoder/types/Enum.ts | 5 +++- .../solidity-decoder/types/FixedByteArray.ts | 2 +- .../src/solidity-decoder/types/Int.ts | 8 +++--- .../src/solidity-decoder/types/Mapping.ts | 28 +++++++++++-------- .../src/solidity-decoder/types/RefType.ts | 2 +- .../src/solidity-decoder/types/StringType.ts | 11 +++++--- .../src/solidity-decoder/types/Struct.ts | 9 ++++-- .../src/solidity-decoder/types/Uint.ts | 8 +++--- .../src/solidity-decoder/types/ValueType.ts | 6 ++-- .../src/solidity-decoder/types/util.ts | 4 +-- 20 files changed, 104 insertions(+), 89 deletions(-) diff --git a/libs/remix-debug/src/code/codeManager.ts b/libs/remix-debug/src/code/codeManager.ts index da23851bb4..a081b0db75 100644 --- a/libs/remix-debug/src/code/codeManager.ts +++ b/libs/remix-debug/src/code/codeManager.ts @@ -1,8 +1,8 @@ 'use strict' -const EventManager = require('../eventManager') -const traceHelper = require('../trace/traceHelper') -const SourceMappingDecoder = require('../source/sourceMappingDecoder') +import { EventManager } from '../eventManager' +import { isContractCreation } from '../trace/traceHelper' +import { findNodeAtInstructionIndex } from '../source/sourceMappingDecoder' import { CodeResolver } from './codeResolver' /* @@ -70,7 +70,7 @@ export class CodeManager { * @param {Function} cb - callback function, return the bytecode */ async getCode (address) { - if (!traceHelper.isContractCreation(address)) { + if (!isContractCreation(address)) { const code = await this.codeResolver.resolveCode(address) return code } @@ -131,7 +131,7 @@ export class CodeManager { */ getFunctionFromPC (address, pc, sourceMap, ast) { const instIndex = this.codeResolver.getInstructionIndex(address, pc) - return SourceMappingDecoder.findNodeAtInstructionIndex('FunctionDefinition', instIndex, sourceMap, ast) + return findNodeAtInstructionIndex('FunctionDefinition', instIndex, sourceMap, ast) } private retrieveCodeAndTrigger (codeMananger, address, stepIndex, tx) { diff --git a/libs/remix-debug/src/debugger/VmDebugger.ts b/libs/remix-debug/src/debugger/VmDebugger.ts index 3f4aaa4edc..f552498a8f 100644 --- a/libs/remix-debug/src/debugger/VmDebugger.ts +++ b/libs/remix-debug/src/debugger/VmDebugger.ts @@ -1,10 +1,10 @@ -const EventManager = require('../eventManager') -const StorageResolver = require('../storage/storageResolver') -const StorageViewer = require('../storage/storageViewer') +import { EventManager } from '../eventManager' +import { StorageResolver } from '../storage/storageResolver' +import { StorageViewer } from '../storage/storageViewer' import { helpers } from '@remix-project/remix-lib' import { DebuggerSolidityState } from './solidityState' import { DebuggerSolidityLocals } from './solidityLocals' -const ui = helpers.ui +const { ui } = helpers export class VmDebuggerLogic { diff --git a/libs/remix-debug/src/debugger/debugger.ts b/libs/remix-debug/src/debugger/debugger.ts index ebdd12c2ac..21ee41100f 100644 --- a/libs/remix-debug/src/debugger/debugger.ts +++ b/libs/remix-debug/src/debugger/debugger.ts @@ -1,7 +1,7 @@ 'use strict' -const Ethdebugger = require('../Ethdebugger') -const EventManager = require('../eventManager') -const traceHelper = require('../trace/traceHelper') +import { Ethdebugger } from '../Ethdebugger' +import { EventManager } from '../eventManager' +import { contractCreationToken } from '../trace/traceHelper' import { BreakpointManager } from '../code/breakpointManager' import { DebuggerStepManager } from './stepManager' import { VmDebuggerLogic } from './VmDebugger' @@ -18,7 +18,6 @@ export class Debugger { constructor (options) { this.event = new EventManager() - this.offsetToLineColumnConverter = options.offsetToLineColumnConverter /* Returns a compilation result for a given address or the last one available if none are found @@ -96,7 +95,7 @@ export class Debugger { this.debugger.web3 = web3 } - debug (blockNumber, txNumber, tx, loadingCb) { + debug (blockNumber, txNumber, tx, loadingCb): Promise { const web3 = this.debugger.web3 return new Promise((resolve, reject) => { @@ -106,7 +105,7 @@ export class Debugger { if (tx) { if (!tx.to) { - tx.to = traceHelper.contractCreationToken('0') + tx.to = contractCreationToken('0') } this.debugTx(tx, loadingCb) return resolve() diff --git a/libs/remix-debug/src/debugger/solidityLocals.ts b/libs/remix-debug/src/debugger/solidityLocals.ts index 74506a6b80..938df24cad 100644 --- a/libs/remix-debug/src/debugger/solidityLocals.ts +++ b/libs/remix-debug/src/debugger/solidityLocals.ts @@ -1,6 +1,6 @@ -const EventManager = require('../eventManager') -const localDecoder = require('../solidity-decoder/localDecoder') -const StorageViewer = require('../storage/storageViewer') +import { EventManager } from '../eventManager' +import { solidityLocals } from '../solidity-decoder/localDecoder' +import { StorageViewer } from '../storage/storageViewer' export class DebuggerSolidityLocals { @@ -73,16 +73,16 @@ export class DebuggerSolidityLocals { var memory = result[1].value try { var storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: result[2].value }, this.storageResolver, this.traceManager) - localDecoder.solidityLocals(this.stepManager.currentStepIndex, this.internalTreeCall, stack, memory, storageViewer, sourceLocation, cursor).then((locals) => { + solidityLocals(this.stepManager.currentStepIndex, this.internalTreeCall, stack, memory, storageViewer, sourceLocation, cursor).then((locals) => { if (!cursor) { - if (!locals.error) { + if (!locals['error']) { this.event.trigger('solidityLocals', [locals]) } if (!Object.keys(locals).length) { this.event.trigger('solidityLocalsMessage', ['no locals']) } } else { - if (!locals.error) { + if (!locals['error']) { this.event.trigger('solidityLocalsLoadMoreCompleted', [locals]) } } diff --git a/libs/remix-debug/src/debugger/solidityState.ts b/libs/remix-debug/src/debugger/solidityState.ts index 99eddc9473..5f7babb4d5 100644 --- a/libs/remix-debug/src/debugger/solidityState.ts +++ b/libs/remix-debug/src/debugger/solidityState.ts @@ -1,6 +1,6 @@ -const EventManager = require('../eventManager') -const stateDecoder = require('../solidity-decoder/stateDecoder') -const StorageViewer = require('../storage/storageViewer') +import { EventManager } from '../eventManager' +import { decodeState } from '../solidity-decoder/stateDecoder' +import { StorageViewer } from '../storage/storageViewer' export class DebuggerSolidityState { @@ -76,10 +76,10 @@ export class DebuggerSolidityState { extractStateVariables (stateVars, address) { const storageViewer = new StorageViewer({ stepIndex: this.stepManager.currentStepIndex, tx: this.tx, address: address }, this.storageResolver, this.traceManager) - stateDecoder.decodeState(stateVars, storageViewer).then((result) => { + decodeState(stateVars, storageViewer).then((result) => { this.event.trigger('solidityStateMessage', ['']) - if (result.error) { - return this.event.trigger('solidityStateMessage', [result.error]) + if (result['error']) { + return this.event.trigger('solidityStateMessage', [result['error']]) } this.event.trigger('solidityState', [result]) }) diff --git a/libs/remix-debug/src/debugger/stepManager.ts b/libs/remix-debug/src/debugger/stepManager.ts index 19bca66cae..a855235181 100644 --- a/libs/remix-debug/src/debugger/stepManager.ts +++ b/libs/remix-debug/src/debugger/stepManager.ts @@ -1,5 +1,5 @@ import { util } from '@remix-project/remix-lib' -const EventManager = require('../eventManager') +import { EventManager } from '../eventManager' export class DebuggerStepManager { diff --git a/libs/remix-debug/src/solidity-decoder/types/Address.ts b/libs/remix-debug/src/solidity-decoder/types/Address.ts index b5a43021a4..ffe03c1c9f 100644 --- a/libs/remix-debug/src/solidity-decoder/types/Address.ts +++ b/libs/remix-debug/src/solidity-decoder/types/Address.ts @@ -1,6 +1,6 @@ 'use strict' -const util = require('./util') -const ValueType = require('./ValueType') +import { extractHexByteSlice } from './util' +import { ValueType } from './ValueType' export class Address extends ValueType { constructor () { @@ -11,6 +11,6 @@ export class Address extends ValueType { if (!value) { return '0x0000000000000000000000000000000000000000' } - return '0x' + util.extractHexByteSlice(value, this.storageBytes, 0).toUpperCase() + return '0x' + extractHexByteSlice(value, this.storageBytes, 0).toUpperCase() } } diff --git a/libs/remix-debug/src/solidity-decoder/types/ArrayType.ts b/libs/remix-debug/src/solidity-decoder/types/ArrayType.ts index a4672465fa..9870b57b81 100644 --- a/libs/remix-debug/src/solidity-decoder/types/ArrayType.ts +++ b/libs/remix-debug/src/solidity-decoder/types/ArrayType.ts @@ -1,12 +1,15 @@ 'use strict' -const util = require('./util') -const remixLib = require('@remix-project/remix-lib') -const sha3256 = remixLib.util.sha3_256 -const BN = require('ethereumjs-util').BN -const RefType = require('./RefType') +import { add, toBN, extractHexValue } from './util' +import { util } from '@remix-project/remix-lib' +import { BN } from 'ethereumjs-util' +import { RefType } from './RefType' +const sha3256 = util.sha3_256 export class ArrayType extends RefType { + underlyingType + arraySize + constructor (underlyingType, arraySize, location) { let storageSlots = null if (arraySize === 'dynamic') { @@ -30,7 +33,7 @@ export class ArrayType extends RefType { let size = null let slotValue try { - slotValue = await util.extractHexValue(location, storageResolver, this.storageBytes) + slotValue = await extractHexValue(location, storageResolver, this.storageBytes) } catch (e) { console.log(e) return { @@ -43,12 +46,12 @@ export class ArrayType extends RefType { slot: location.slot } if (this.arraySize === 'dynamic') { - size = util.toBN('0x' + slotValue) + size = toBN('0x' + slotValue) currentLocation.slot = sha3256(location.slot) } else { size = new BN(this.arraySize) } - var k = util.toBN(0) + var k = toBN(0) for (; k.lt(size) && k.ltn(300); k.iaddn(1)) { try { ret.push(await this.underlyingType.decodeFromStorage(currentLocation, storageResolver)) @@ -62,10 +65,10 @@ export class ArrayType extends RefType { currentLocation.offset += this.underlyingType.storageBytes if (currentLocation.offset + this.underlyingType.storageBytes > 32) { currentLocation.offset = 0 - currentLocation.slot = '0x' + util.add(currentLocation.slot, 1).toString(16) + currentLocation.slot = '0x' + add(currentLocation.slot, 1).toString(16) } } else { - currentLocation.slot = '0x' + util.add(currentLocation.slot, this.underlyingType.storageSlots).toString(16) + currentLocation.slot = '0x' + add(currentLocation.slot, this.underlyingType.storageSlots).toString(16) currentLocation.offset = 0 } } diff --git a/libs/remix-debug/src/solidity-decoder/types/Bool.ts b/libs/remix-debug/src/solidity-decoder/types/Bool.ts index fec866138c..8c067c011b 100644 --- a/libs/remix-debug/src/solidity-decoder/types/Bool.ts +++ b/libs/remix-debug/src/solidity-decoder/types/Bool.ts @@ -1,6 +1,6 @@ 'use strict' -const ValueType = require('./ValueType') -const util = require('./util') +import { ValueType } from './ValueType' +import { extractHexByteSlice } from './util' export class Bool extends ValueType { constructor () { @@ -11,7 +11,7 @@ export class Bool extends ValueType { if (!value) { return false } - value = util.extractHexByteSlice(value, this.storageBytes, 0) + value = extractHexByteSlice(value, this.storageBytes, 0) return value !== '00' } } diff --git a/libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts b/libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts index 9c86fc4cbb..2ed55bd630 100644 --- a/libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts +++ b/libs/remix-debug/src/solidity-decoder/types/DynamicByteArray.ts @@ -1,9 +1,9 @@ 'use strict' -const util = require('./util') -const remixLib = require('@remix-project/remix-lib') -const sha3256 = remixLib.util.sha3_256 -const BN = require('ethereumjs-util').BN -const RefType = require('./RefType') +import { extractHexValue, readFromStorage } from './util' +import { util } from '@remix-project/remix-lib' +import { BN } from 'ethereumjs-util' +import { RefType } from './RefType' +const sha3256 = util.sha3_256 export class DynamicByteArray extends RefType { constructor (location) { @@ -13,29 +13,29 @@ export class DynamicByteArray extends RefType { async decodeFromStorage (location, storageResolver) { let value = '0x0' try { - value = await util.extractHexValue(location, storageResolver, this.storageBytes) + value = await extractHexValue(location, storageResolver, this.storageBytes) } catch (e) { console.log(e) return {value: '', type: this.typeName} } const bn = new BN(value, 16) if (bn.testn(0)) { - const length = bn.div(new BN(2)) + const length: BN = bn.div(new BN(2)) let dataPos = new BN(sha3256(location.slot).replace('0x', ''), 16) let ret = '' let currentSlot = '0x' try { - currentSlot = await util.readFromStorage(dataPos, storageResolver) + currentSlot = await readFromStorage(dataPos, storageResolver) } catch (e) { console.log(e) return {value: '', type: this.typeName} } - while (length.gt(ret.length) && ret.length < 32000) { + while (length.gt(new BN(ret.length)) && ret.length < 32000) { currentSlot = currentSlot.replace('0x', '') ret += currentSlot dataPos = dataPos.add(new BN(1)) try { - currentSlot = await util.readFromStorage(dataPos, storageResolver) + currentSlot = await readFromStorage(dataPos, storageResolver) } catch (e) { console.log(e) return {value: '', type: this.typeName} diff --git a/libs/remix-debug/src/solidity-decoder/types/Enum.ts b/libs/remix-debug/src/solidity-decoder/types/Enum.ts index 10cc27e728..956b09ecca 100644 --- a/libs/remix-debug/src/solidity-decoder/types/Enum.ts +++ b/libs/remix-debug/src/solidity-decoder/types/Enum.ts @@ -1,7 +1,10 @@ 'use strict' -const ValueType = require('./ValueType') +import { ValueType } from './ValueType' export class Enum extends ValueType { + + enumDef + constructor (enumDef) { let storageBytes = 0 let length = enumDef.members.length diff --git a/libs/remix-debug/src/solidity-decoder/types/FixedByteArray.ts b/libs/remix-debug/src/solidity-decoder/types/FixedByteArray.ts index e1cc4db867..a6704dc962 100644 --- a/libs/remix-debug/src/solidity-decoder/types/FixedByteArray.ts +++ b/libs/remix-debug/src/solidity-decoder/types/FixedByteArray.ts @@ -1,5 +1,5 @@ 'use strict' -const ValueType = require('./ValueType') +import { ValueType } from './ValueType' export class FixedByteArray extends ValueType { constructor (storageBytes) { diff --git a/libs/remix-debug/src/solidity-decoder/types/Int.ts b/libs/remix-debug/src/solidity-decoder/types/Int.ts index ad4eee2fe8..ed35f79292 100644 --- a/libs/remix-debug/src/solidity-decoder/types/Int.ts +++ b/libs/remix-debug/src/solidity-decoder/types/Int.ts @@ -1,6 +1,6 @@ 'use strict' -const util = require('./util') -const ValueType = require('./ValueType') +import { extractHexByteSlice, decodeIntFromHex } from './util' +import { ValueType } from './ValueType' export class Int extends ValueType { constructor (storageBytes) { @@ -8,7 +8,7 @@ export class Int extends ValueType { } decodeValue (value) { - value = util.extractHexByteSlice(value, this.storageBytes, 0) - return util.decodeIntFromHex(value, this.storageBytes, true) + value = extractHexByteSlice(value, this.storageBytes, 0) + return decodeIntFromHex(value, this.storageBytes, true) } } diff --git a/libs/remix-debug/src/solidity-decoder/types/Mapping.ts b/libs/remix-debug/src/solidity-decoder/types/Mapping.ts index 0334e9b2a5..cf7fc8958e 100644 --- a/libs/remix-debug/src/solidity-decoder/types/Mapping.ts +++ b/libs/remix-debug/src/solidity-decoder/types/Mapping.ts @@ -1,9 +1,15 @@ 'use strict' -const RefType = require('./RefType') -const util = require('./util') -const ethutil = require('ethereumjs-util') +import { RefType } from './RefType' +import { normalizeHex } from './util' +import { toBuffer, setLengthLeft, keccak, BN, bufferToHex} from 'ethereumjs-util' +import { intToBuffer } from 'ethjs-util' export class Mapping extends RefType { + + keyType + valueType + initialDecodedState + constructor (underlyingTypes, location, fullType) { super(1, 32, fullType, 'storage') this.keyType = underlyingTypes.keyType @@ -38,7 +44,7 @@ export class Mapping extends RefType { } async decodeMappingsLocation (preimages, location, storageResolver) { - const mapSlot = util.normalizeHex(ethutil.bufferToHex(location.slot)) + const mapSlot = normalizeHex(bufferToHex(location.slot)) if (!preimages[mapSlot]) { return {} } @@ -60,14 +66,14 @@ function getMappingLocation (key, position) { // > the value corresponding to a mapping key k is located at keccak256(k . p) where . is concatenation. // key should be a hex string, and position an int - const mappingK = ethutil.toBuffer('0x' + key) - let mappingP = ethutil.intToBuffer(position) - mappingP = ethutil.setLengthLeft(mappingP, 32) + const mappingK = toBuffer('0x' + key) + let mappingP = intToBuffer(position) + mappingP = setLengthLeft(mappingP, 32) const mappingKeyBuf = concatTypedArrays(mappingK, mappingP) - const mappingKeyPreimage = '0x' + mappingKeyBuf.toString('hex') - let mappingStorageLocation = ethutil.keccak(mappingKeyPreimage) - mappingStorageLocation = new ethutil.BN(mappingStorageLocation, 16) - return mappingStorageLocation + const mappingKeyPreimage: string = '0x' + mappingKeyBuf.toString('hex') + let mappingStorageLocation: Buffer = keccak(mappingKeyPreimage) + const mappingStorageLocationinBn: BN = new BN(mappingStorageLocation, 16) + return mappingStorageLocationinBn } function concatTypedArrays (a, b) { // a, b TypedArray of same type diff --git a/libs/remix-debug/src/solidity-decoder/types/RefType.ts b/libs/remix-debug/src/solidity-decoder/types/RefType.ts index bf4a6b91a2..181ef5c675 100644 --- a/libs/remix-debug/src/solidity-decoder/types/RefType.ts +++ b/libs/remix-debug/src/solidity-decoder/types/RefType.ts @@ -1,5 +1,5 @@ 'use strict' -const util = require('./util') +import { toBN } from './util' export class RefType { diff --git a/libs/remix-debug/src/solidity-decoder/types/StringType.ts b/libs/remix-debug/src/solidity-decoder/types/StringType.ts index 9963fd0b3c..49a37e31cc 100644 --- a/libs/remix-debug/src/solidity-decoder/types/StringType.ts +++ b/libs/remix-debug/src/solidity-decoder/types/StringType.ts @@ -1,14 +1,17 @@ 'use strict' -const DynamicBytes = require('./DynamicByteArray') +import { DynamicByteArray } from './DynamicByteArray' + +export class StringType extends DynamicByteArray { + + typeName -export class StringType extends DynamicBytes { constructor (location) { super(location) this.typeName = 'string' } async decodeFromStorage (location, storageResolver) { - let decoded = '0x' + let decoded: any = '0x' try { decoded = await super.decodeFromStorage(location, storageResolver) } catch (e) { @@ -20,7 +23,7 @@ export class StringType extends DynamicBytes { async decodeFromStack (stackDepth, stack, memory) { try { - return await super.decodeFromStack(stackDepth, stack, memory) + return await super.decodeFromStack(stackDepth, stack, memory, null, null) } catch (e) { console.log(e) return '' diff --git a/libs/remix-debug/src/solidity-decoder/types/Struct.ts b/libs/remix-debug/src/solidity-decoder/types/Struct.ts index c54f778744..22883d6b22 100644 --- a/libs/remix-debug/src/solidity-decoder/types/Struct.ts +++ b/libs/remix-debug/src/solidity-decoder/types/Struct.ts @@ -1,8 +1,11 @@ 'use strict' -const util = require('./util') -const RefType = require('./RefType') +import { add } from './util' +import { RefType } from './RefType' export class Struct extends RefType { + + members + constructor (memberDetails, location, fullType) { super(memberDetails.storageSlots, 32, 'struct ' + fullType, location) this.members = memberDetails.members @@ -13,7 +16,7 @@ export class Struct extends RefType { for (var item of this.members) { const globalLocation = { offset: location.offset + item.storagelocation.offset, - slot: util.add(location.slot, item.storagelocation.slot) + slot: add(location.slot, item.storagelocation.slot) } try { ret[item.name] = await item.type.decodeFromStorage(globalLocation, storageResolver) diff --git a/libs/remix-debug/src/solidity-decoder/types/Uint.ts b/libs/remix-debug/src/solidity-decoder/types/Uint.ts index beabd9aa4f..8e27fc4621 100644 --- a/libs/remix-debug/src/solidity-decoder/types/Uint.ts +++ b/libs/remix-debug/src/solidity-decoder/types/Uint.ts @@ -1,6 +1,6 @@ 'use strict' -const util = require('./util') -const ValueType = require('./ValueType') +import { extractHexByteSlice, decodeIntFromHex } from './util' +import { ValueType } from './ValueType' export class Uint extends ValueType { constructor (storageBytes) { @@ -8,7 +8,7 @@ export class Uint extends ValueType { } decodeValue (value) { - value = util.extractHexByteSlice(value, this.storageBytes, 0) - return util.decodeIntFromHex(value, this.storageBytes, false) + value = extractHexByteSlice(value, this.storageBytes, 0) + return decodeIntFromHex(value, this.storageBytes, false) } } diff --git a/libs/remix-debug/src/solidity-decoder/types/ValueType.ts b/libs/remix-debug/src/solidity-decoder/types/ValueType.ts index eb3d4f526d..9340453d8b 100644 --- a/libs/remix-debug/src/solidity-decoder/types/ValueType.ts +++ b/libs/remix-debug/src/solidity-decoder/types/ValueType.ts @@ -1,5 +1,5 @@ 'use strict' -var util = require('./util') +import { extractHexValue } from './util' export class ValueType { @@ -24,7 +24,7 @@ export class ValueType { */ async decodeFromStorage (location, storageResolver) { try { - var value = await util.extractHexValue(location, storageResolver, this.storageBytes) + var value = await extractHexValue(location, storageResolver, this.storageBytes) return {value: this.decodeValue(value), type: this.typeName} } catch (e) { console.log(e) @@ -62,5 +62,3 @@ export class ValueType { return {value: this.decodeValue(value), type: this.typeName} } } - -module.exports = ValueType diff --git a/libs/remix-debug/src/solidity-decoder/types/util.ts b/libs/remix-debug/src/solidity-decoder/types/util.ts index a66b5e99ec..a13cc8fc86 100644 --- a/libs/remix-debug/src/solidity-decoder/types/util.ts +++ b/libs/remix-debug/src/solidity-decoder/types/util.ts @@ -9,7 +9,7 @@ export function decodeIntFromHex (value, byteLength, signed) { return bigNumber.toString(10) } -export function readFromStorage(slot, storageResolver) { +export function readFromStorage(slot, storageResolver): Promise { const hexSlot = '0x' + normalizeHex(bufferToHex(slot)) return new Promise((resolve, reject) => { storageResolver.storageSlot(hexSlot, (error, slot) => { @@ -94,7 +94,7 @@ export function extractLocationFromAstVariable (node) { return 'default' // local variables => storage, function parameters & return values => memory, state => storage } -export function normalizeHex (hex) { +export function normalizeHex (hex): string { hex = hex.replace('0x', '') if (hex.length < 64) { return (new Array(64 - hex.length + 1).join('0')) + hex