erigon-pulse/cmd/devnettest/commands/parity.go
leonardchinonso d0322ab840
Added eth_getTransactionCount to the devnet tool (#3734)
* Added eth_getTransactionCount to the devnet tool

* Fixed lint errors
2022-03-18 11:57:23 +00:00

43 lines
1.3 KiB
Go

package commands
import (
"fmt"
"github.com/ledgerwatch/erigon/cmd/devnettest/services"
"strings"
"github.com/ledgerwatch/erigon/cmd/devnettest/requests"
"github.com/ledgerwatch/erigon/common"
"github.com/spf13/cobra"
)
var (
offsetAddr string
quantity int
)
func init() {
listStorageKeysCmd.Flags().StringVar(&addr, "addr", "", "String address to list keys")
listStorageKeysCmd.MarkFlagRequired("addr")
listStorageKeysCmd.Flags().StringVar(&offsetAddr, "offset", "", "Offset storage key from which the batch should start")
listStorageKeysCmd.Flags().IntVar(&quantity, "quantity", 10, "Integer number of addresses to display in a batch")
listStorageKeysCmd.Flags().StringVar(&blockNum, "block", "latest", "Integer block number, or the string 'latest', 'earliest' or 'pending'; now only 'latest' is available")
rootCmd.AddCommand(listStorageKeysCmd)
}
var listStorageKeysCmd = &cobra.Command{
Use: "parity-list",
Short: "Returns all storage keys of the given address",
RunE: func(cmd *cobra.Command, args []string) error {
if clearDev {
defer services.ClearDevDB()
}
toAddress := common.HexToAddress(addr)
offset := common.Hex2Bytes(strings.TrimSuffix(offsetAddr, "0x"))
if err := requests.ParityList(reqId, toAddress, quantity, offset, blockNum); err != nil {
fmt.Printf("error getting parity list: %v\n", err)
}
return nil
},
}