pull/5370/head
yann300 4 years ago
parent 77c7295756
commit 36c9ee3db2
  1. 46
      libs/remix-lib/src/execution/execution-context.ts

@ -31,32 +31,32 @@ class StateManagerCommonStorageDump extends StateManager {
this.keyHashes = {} this.keyHashes = {}
} }
S
putContractStorage (address, key, value) {
this.keyHashes[keccak(key).toString('hex')] = bufferToHex(key)
return super.putContractStorage(address, key, value)
}
dumpStorage (address) { putContractStorage (address, key, value) {
return new Promise<StorageDump>((resolve, reject) => { this.keyHashes[keccak(key).toString('hex')] = bufferToHex(key)
this._getStorageTrie(address).then((trie) => { return super.putContractStorage(address, key, value)
const storage = {} }
const stream = trie.createReadStream()
stream.on('data', (val) => { dumpStorage (address) {
const value = rlp.decode(val.value) return new Promise<StorageDump>((resolve, reject) => {
storage['0x' + val.key.toString('hex')] = { this._getStorageTrie(address).then((trie) => {
key: this.keyHashes[val.key.toString('hex')], const storage = {}
value: '0x' + value.toString('hex') const stream = trie.createReadStream()
} stream.on('data', (val) => {
}) const value = rlp.decode(val.value)
stream.on('end', function () { storage['0x' + val.key.toString('hex')] = {
resolve(storage) key: this.keyHashes[val.key.toString('hex')],
value: '0x' + value.toString('hex')
}
})
stream.on('end', function () {
resolve(storage)
})
}).catch((error) => {
reject(error)
}) })
}).catch((error) => {
reject(error)
}) })
}) }
}
async getStateRoot (force: boolean = false): Promise<Buffer> { async getStateRoot (force: boolean = false): Promise<Buffer> {
if (!force && this._checkpointCount !== 0) { if (!force && this._checkpointCount !== 0) {

Loading…
Cancel
Save