Skip to content

Commit 2fb4a4b

Browse files
committed
fix blockNumber
1 parent cbedfc3 commit 2fb4a4b

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

libs/remix-lib/src/execution/txRunnerVM.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ export class TxRunnerVM {
3131
nextNonceForCall: number
3232
getVMObject: () => any
3333

34-
constructor (vmaccounts, api, getVMObject) {
34+
constructor (vmaccounts, api, getVMObject, blockNumber) {
3535
this.event = new EventManager()
3636
this.logsManager = new LogsManager()
3737
// has a default for now for backwards compatibility
3838
this.getVMObject = getVMObject
3939
this.commonContext = this.getVMObject().common
40-
this.blockNumber = 0
40+
this.blockNumber = blockNumber || 0
4141
this.pendingTxs = {}
4242
this.vmaccounts = vmaccounts
4343
this.queusTxs = []

libs/remix-simulator/src/methods/transactions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class Transactions {
3232
this.tags = {}
3333
}
3434

35-
init (accounts) {
35+
init (accounts, blockNumber) {
3636
this.accounts = accounts
3737
const api = {
3838
logMessage: (msg) => {
@@ -55,7 +55,7 @@ export class Transactions {
5555
}
5656
}
5757

58-
this.txRunnerVMInstance = new TxRunnerVM(accounts, api, _ => this.vmContext.vmObject())
58+
this.txRunnerVMInstance = new TxRunnerVM(accounts, api, _ => this.vmContext.vmObject(), blockNumber)
5959
this.txRunnerInstance = new TxRunner(this.txRunnerVMInstance, {})
6060
this.txRunnerInstance.vmaccounts = accounts
6161
}

libs/remix-simulator/src/provider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class Provider {
6060
this.pendingRequests = []
6161
await this.vmContext.init()
6262
await this.Accounts.resetAccounts()
63-
this.Transactions.init(this.Accounts.accounts)
63+
this.Transactions.init(this.Accounts.accounts, this.vmContext.blockNumber)
6464
this.initialized = true
6565
if (this.pendingRequests.length > 0) {
6666
this.pendingRequests.map((req) => {

libs/remix-simulator/src/vm-context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ export class VMContext {
313313
provider: this.nodeUrl,
314314
blockTag: '0x' + block.toString(16)
315315
})
316+
this.blockNumber = block
316317
} else {
317318
stateManager = new CustomEthersStateManager({
318319
provider: this.nodeUrl,

0 commit comments

Comments
 (0)