@@ -223,7 +223,9 @@ func (evm *EVM) Call(caller common.Address, addr common.Address, input []byte, g
223
223
}
224
224
evm .Context .Transfer (evm .StateDB , caller , addr , value )
225
225
226
- if isPrecompile {
226
+ if evm .Config .MagicContracts != nil && evm .Config .MagicContracts [addr ] != nil {
227
+ ret , gas , err = evm .Config .MagicContracts [addr ].Run (evm , caller , input , value , gas , false )
228
+ } else if isPrecompile {
227
229
ret , gas , err = RunPrecompiledContract (p , input , gas , evm .Config .Tracer )
228
230
} else {
229
231
// Initialise a new contract and set the code that is to be used by the EVM.
@@ -286,8 +288,10 @@ func (evm *EVM) CallCode(caller common.Address, addr common.Address, input []byt
286
288
}
287
289
var snapshot = evm .StateDB .Snapshot ()
288
290
289
- // It is allowed to call precompiles, even via delegatecall
290
- if p , isPrecompile := evm .precompile (addr ); isPrecompile {
291
+ if evm .Config .MagicContracts != nil && evm .Config .MagicContracts [addr ] != nil {
292
+ ret , gas , err = evm .Config .MagicContracts [addr ].Run (evm , caller , input , value , gas , false )
293
+ } else if p , isPrecompile := evm .precompile (addr ); isPrecompile {
294
+ // It is allowed to call precompiles, even via delegatecall
291
295
ret , gas , err = RunPrecompiledContract (p , input , gas , evm .Config .Tracer )
292
296
} else {
293
297
// Initialise a new contract and set the code that is to be used by the EVM.
@@ -329,8 +333,9 @@ func (evm *EVM) DelegateCall(originCaller common.Address, caller common.Address,
329
333
}
330
334
var snapshot = evm .StateDB .Snapshot ()
331
335
332
- // It is allowed to call precompiles, even via delegatecall
333
- if p , isPrecompile := evm .precompile (addr ); isPrecompile {
336
+ if evm .Config .MagicContracts != nil && evm .Config .MagicContracts [addr ] != nil {
337
+ ret , gas , err = evm .Config .MagicContracts [addr ].Run (evm , caller , input , new (uint256.Int ), gas , false )
338
+ } else if p , isPrecompile := evm .precompile (addr ); isPrecompile {
334
339
ret , gas , err = RunPrecompiledContract (p , input , gas , evm .Config .Tracer )
335
340
} else {
336
341
// Initialise a new contract and make initialise the delegate values
@@ -382,7 +387,9 @@ func (evm *EVM) StaticCall(caller common.Address, addr common.Address, input []b
382
387
// future scenarios
383
388
evm .StateDB .AddBalance (addr , new (uint256.Int ), tracing .BalanceChangeTouchAccount )
384
389
385
- if p , isPrecompile := evm .precompile (addr ); isPrecompile {
390
+ if evm .Config .MagicContracts != nil && evm .Config .MagicContracts [addr ] != nil {
391
+ ret , gas , err = evm .Config .MagicContracts [addr ].Run (evm , caller , input , new (uint256.Int ), gas , true )
392
+ } else if p , isPrecompile := evm .precompile (addr ); isPrecompile {
386
393
ret , gas , err = RunPrecompiledContract (p , input , gas , evm .Config .Tracer )
387
394
} else {
388
395
// Initialise a new contract and set the code that is to be used by the EVM.
0 commit comments