diff --git a/src/solidity/types/RefType.js b/src/solidity/types/RefType.js index 5d2fb217ab..22439e8867 100644 --- a/src/solidity/types/RefType.js +++ b/src/solidity/types/RefType.js @@ -1,5 +1,4 @@ 'use strict' -var util = require('./util') class RefType { constructor (storageSlots, storageBytes, typeName, location) { @@ -39,15 +38,34 @@ class RefType { offset = parseInt(offset, 16) return decodeInternal(this, offset, memory, storage) } + + /** + * current type defined in storage + * + * @return {Bool} - return true if the type is defined in the storage + */ + storageStore () { + return this.location.indexOf('storage') === 0 + } + + /** + * current type defined in memory + * + * @return {Bool} - return true if the type is defined in the memory + */ + memoryStore () { + return this.location.indexOf('memory') === 0 + } + } function decodeInternal (self, offset, memory, storage) { if (!storage) { storage = {} // TODO this is a fallback, should manage properly locals store in storage } - if (util.storageStore(self)) { + if (self.storageStore()) { return self.decodeFromStorage({ offset: 0, slot: offset }, storage) - } else if (util.memoryStore(self)) { + } else if (self.memoryStore()) { return self.decodeFromMemory(offset, memory) } else { return { error: '' } diff --git a/src/solidity/types/util.js b/src/solidity/types/util.js index 328dff7b34..64324c293c 100644 --- a/src/solidity/types/util.js +++ b/src/solidity/types/util.js @@ -11,8 +11,6 @@ module.exports = { sha3: sha3, toBN: toBN, add: add, - storageStore: storageStore, - memoryStore: memoryStore, extractLocation: extractLocation } @@ -103,11 +101,3 @@ function extractLocation (type) { return null } } - -function storageStore (type) { - return type.location.indexOf('storage') === 0 -} - -function memoryStore (type) { - return type.location.indexOf('memory') === 0 -}