mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 13:07:17 +00:00
f76736e14a
- 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
31 lines
791 B
Go
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
|
|
}
|