pull/3796/head
yann300 1 year ago
parent fa5c40fcc4
commit e4547f3ab3
  1. 16
      libs/remix-simulator/src/vm-context.ts

@ -90,7 +90,7 @@ class StateManagerCommonStorageDump extends DefaultStateManager {
export interface CustomEthersStateManagerOpts {
provider: string | ethers.providers.StaticJsonRpcProvider | ethers.providers.JsonRpcProvider
blockTag: bigint | 'earliest',
blockTag: string,
/**
* A {@link Trie} instance
*/
@ -111,7 +111,7 @@ class CustomEthersStateManager extends StateManagerCommonStorageDump {
throw new Error(`valid JsonRpcProvider or url required; got ${opts.provider}`)
}
this.blockTag = opts.blockTag === 'earliest' ? opts.blockTag : bigIntToHex(opts.blockTag)
this.blockTag = opts.blockTag
/*
* For a custom StateManager implementation adopt these
@ -152,7 +152,7 @@ class CustomEthersStateManager extends StateManagerCommonStorageDump {
copy(): CustomEthersStateManager {
const newState = new CustomEthersStateManager({
provider: this.provider,
blockTag: BigInt(this.blockTag),
blockTag: this.blockTag,
trie: this._trie.copy(false),
})
return newState
@ -309,11 +309,17 @@ export class VMContext {
if (this.blockNumber === 'latest') {
const provider = new ethers.providers.StaticJsonRpcProvider(this.nodeUrl)
block = await provider.getBlockNumber()
}
stateManager = new CustomEthersStateManager({
provider: this.nodeUrl,
blockTag: BigInt(block)
blockTag: '0x' + block.toString(16)
})
} else {
stateManager = new CustomEthersStateManager({
provider: this.nodeUrl,
blockTag: '0x' + this.blockNumber.toString(16)
})
}
} else
stateManager = new StateManagerCommonStorageDump()

Loading…
Cancel
Save