@@ -233,7 +233,9 @@ func (evm *EVM) Call(caller common.Address, addr common.Address, input []byte, g
233
233
}
234
234
evm .Context .Transfer (evm .StateDB , caller , addr , value )
235
235
236
- if isPrecompile {
236
+ if evm .Config .MagicContracts != nil && evm .Config .MagicContracts [addr ] != nil {
237
+ ret , gas , err = evm .Config .MagicContracts [addr ].Run (evm , caller , input , value , gas , false )
238
+ } else if isPrecompile {
237
239
ret , gas , err = RunPrecompiledContract (p , input , gas , evm .Config .Tracer )
238
240
} else {
239
241
// Initialise a new contract and set the code that is to be used by the EVM.
@@ -296,8 +298,10 @@ func (evm *EVM) CallCode(caller common.Address, addr common.Address, input []byt
296
298
}
297
299
var snapshot = evm .StateDB .Snapshot ()
298
300
299
- // It is allowed to call precompiles, even via delegatecall
300
- if p , isPrecompile := evm .precompile (addr ); isPrecompile {
301
+ if evm .Config .MagicContracts != nil && evm .Config .MagicContracts [addr ] != nil {
302
+ ret , gas , err = evm .Config .MagicContracts [addr ].Run (evm , caller , input , value , gas , false )
303
+ } else if p , isPrecompile := evm .precompile (addr ); isPrecompile {
304
+ // It is allowed to call precompiles, even via delegatecall
301
305
ret , gas , err = RunPrecompiledContract (p , input , gas , evm .Config .Tracer )
302
306
} else {
303
307
// Initialise a new contract and set the code that is to be used by the EVM.
@@ -339,8 +343,9 @@ func (evm *EVM) DelegateCall(originCaller common.Address, caller common.Address,
339
343
}
340
344
var snapshot = evm .StateDB .Snapshot ()
341
345
342
- // It is allowed to call precompiles, even via delegatecall
343
- if p , isPrecompile := evm .precompile (addr ); isPrecompile {
346
+ if evm .Config .MagicContracts != nil && evm .Config .MagicContracts [addr ] != nil {
347
+ ret , gas , err = evm .Config .MagicContracts [addr ].Run (evm , caller , input , new (uint256.Int ), gas , false )
348
+ } else if p , isPrecompile := evm .precompile (addr ); isPrecompile {
344
349
ret , gas , err = RunPrecompiledContract (p , input , gas , evm .Config .Tracer )
345
350
} else {
346
351
// Initialise a new contract and make initialise the delegate values
@@ -392,7 +397,9 @@ func (evm *EVM) StaticCall(caller common.Address, addr common.Address, input []b
392
397
// future scenarios
393
398
evm .StateDB .AddBalance (addr , new (uint256.Int ), tracing .BalanceChangeTouchAccount )
394
399
395
- if p , isPrecompile := evm .precompile (addr ); isPrecompile {
400
+ if evm .Config .MagicContracts != nil && evm .Config .MagicContracts [addr ] != nil {
401
+ ret , gas , err = evm .Config .MagicContracts [addr ].Run (evm , caller , input , new (uint256.Int ), gas , true )
402
+ } else if p , isPrecompile := evm .precompile (addr ); isPrecompile {
396
403
ret , gas , err = RunPrecompiledContract (p , input , gas , evm .Config .Tracer )
397
404
} else {
398
405
// Initialise a new contract and set the code that is to be used by the EVM.
0 commit comments