github.com/MikyChow/arbitrum-go-ethereum@v0.0.0-20230306102812-078da49636de/eth/tracers/native/tracer_arbitrum.go (about) 1 // Copyright 2022 The go-ethereum Authors 2 // This file is part of the go-ethereum library. 3 // 4 // The go-ethereum library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-ethereum library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. 16 17 package native 18 19 import ( 20 "math/big" 21 22 "github.com/MikyChow/arbitrum-go-ethereum/common" 23 "github.com/MikyChow/arbitrum-go-ethereum/core/vm" 24 ) 25 26 type arbitrumTransfer struct { 27 Purpose string `json:"purpose"` 28 From *string `json:"from"` 29 To *string `json:"to"` 30 Value string `json:"value"` 31 } 32 33 func (t *callTracer) CaptureArbitrumTransfer( 34 env *vm.EVM, from, to *common.Address, value *big.Int, before bool, purpose string, 35 ) { 36 transfer := arbitrumTransfer{ 37 Purpose: purpose, 38 Value: bigToHex(value), 39 } 40 if from != nil { 41 from := from.String() 42 transfer.From = &from 43 } 44 if to != nil { 45 to := to.String() 46 transfer.To = &to 47 } 48 if before { 49 t.beforeEVMTransfers = append(t.beforeEVMTransfers, transfer) 50 } else { 51 t.afterEVMTransfers = append(t.afterEVMTransfers, transfer) 52 } 53 } 54 55 func (*fourByteTracer) CaptureArbitrumTransfer(env *vm.EVM, from, to *common.Address, value *big.Int, before bool, purpose string) { 56 } 57 func (*noopTracer) CaptureArbitrumTransfer(env *vm.EVM, from, to *common.Address, value *big.Int, before bool, purpose string) { 58 } 59 func (*prestateTracer) CaptureArbitrumTransfer(env *vm.EVM, from, to *common.Address, value *big.Int, before bool, purpose string) { 60 } 61 func (*revertReasonTracer) CaptureArbitrumTransfer(env *vm.EVM, from, to *common.Address, value *big.Int, before bool, purpose string) { 62 } 63 64 func (*callTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {} 65 func (*fourByteTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {} 66 func (*noopTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {} 67 func (*prestateTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {} 68 func (*revertReasonTracer) CaptureArbitrumStorageGet(key common.Hash, depth int, before bool) {} 69 70 func (*callTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {} 71 func (*fourByteTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {} 72 func (*noopTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {} 73 func (*prestateTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) {} 74 func (*revertReasonTracer) CaptureArbitrumStorageSet(key, value common.Hash, depth int, before bool) { 75 }