|
|
@ -91,10 +91,8 @@ class StorageResolver { |
|
|
|
if (cached && cached.storage[slotKey]) { // we have the current slot in the cache and maybe the next 1000...
|
|
|
|
if (cached && cached.storage[slotKey]) { // we have the current slot in the cache and maybe the next 1000...
|
|
|
|
return resolve(cached.storage) |
|
|
|
return resolve(cached.storage) |
|
|
|
} |
|
|
|
} |
|
|
|
this.storageRangeWeb3Call(tx, address, slotKey, self.maxSize, (error, storage, nextKey) => { |
|
|
|
this.storageRangeWeb3Call(tx, address, slotKey, self.maxSize).then((result) => { |
|
|
|
if (error) { |
|
|
|
const [storage, nextKey] = result |
|
|
|
return reject(error) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!storage[slotKey] && slotKey !== self.zeroSlot) { // we don't cache the zero slot (could lead to inconsistency)
|
|
|
|
if (!storage[slotKey] && slotKey !== self.zeroSlot) { // we don't cache the zero slot (could lead to inconsistency)
|
|
|
|
storage[slotKey] = { |
|
|
|
storage[slotKey] = { |
|
|
|
key: slotKey, |
|
|
|
key: slotKey, |
|
|
@ -106,7 +104,7 @@ class StorageResolver { |
|
|
|
self.storageByAddress[address].complete = true |
|
|
|
self.storageByAddress[address].complete = true |
|
|
|
} |
|
|
|
} |
|
|
|
return resolve(storage) |
|
|
|
return resolve(storage) |
|
|
|
}) |
|
|
|
}).catch(reject) |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -136,9 +134,10 @@ class StorageResolver { |
|
|
|
self.storageByAddress[address].storage = Object.assign(self.storageByAddress[address].storage || {}, storage) |
|
|
|
self.storageByAddress[address].storage = Object.assign(self.storageByAddress[address].storage || {}, storage) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
storageRangeWeb3Call (tx, address, start, maxSize, callback) { |
|
|
|
storageRangeWeb3Call (tx, address, start, maxSize) { |
|
|
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
if (traceHelper.isContractCreation(address)) { |
|
|
|
if (traceHelper.isContractCreation(address)) { |
|
|
|
callback(null, {}, null) |
|
|
|
resolve([{}, null]) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.web3.debug.storageRangeAt( |
|
|
|
this.web3.debug.storageRangeAt( |
|
|
|
tx.blockHash, tx.transactionIndex === undefined ? tx.hash : tx.transactionIndex, |
|
|
|
tx.blockHash, tx.transactionIndex === undefined ? tx.hash : tx.transactionIndex, |
|
|
@ -147,14 +146,15 @@ class StorageResolver { |
|
|
|
maxSize, |
|
|
|
maxSize, |
|
|
|
(error, result) => { |
|
|
|
(error, result) => { |
|
|
|
if (error) { |
|
|
|
if (error) { |
|
|
|
callback(error) |
|
|
|
reject(error) |
|
|
|
} else if (result.storage) { |
|
|
|
} else if (result.storage) { |
|
|
|
callback(null, result.storage, result.nextKey) |
|
|
|
resolve([result.storage, result.nextKey]) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
callback('the storage has not been provided') |
|
|
|
reject('the storage has not been provided') |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|