erigon-pulse/cmd/devnet/requests/event.go
Leonard Chinonso f76736e14a
Implemented mining of contract transactions on the devnet tool (#6102)
- Added a new method and type for contract transactions.
- Added functions to emit fallback events from contract transactions.
- Added GetLogs request generator
- Added tests for GetLogs request generator
2022-11-22 20:28:53 +07:00

31 lines
791 B
Go

package requests
import (
"fmt"
"github.com/ledgerwatch/erigon/cmd/devnet/devnetutils"
"github.com/ledgerwatch/erigon/cmd/devnet/models"
"github.com/ledgerwatch/erigon/cmd/rpctest/rpctest"
"github.com/ledgerwatch/erigon/common"
)
func GetLogs(reqId int, fromBlock uint64, toBlock uint64, address common.Address, printLogs bool) error {
reqGen := initialiseRequestGenerator(reqId)
var b rpctest.EthGetLogs
if res := reqGen.Erigon(models.ETHGetLogs, reqGen.GetLogs(fromBlock, toBlock, address), &b); res.Err != nil {
return fmt.Errorf("failed to fetch logs: %v", res.Err)
}
s, err := devnetutils.ParseResponse(b)
if err != nil {
return fmt.Errorf("error parsing response: %v", err)
}
if printLogs {
fmt.Printf("Logs ======================> %v\n", s)
}
return nil
}