Implement eth_sendTransaction (#104)

* Set up framework for sending transaction with correct args and nonce mutex locking

* Set up printing ethereum address through emintkeys and getting chainid from flags

* Implemented defaults for eth_sendTransaction

* Fix bug with no data provided

* Updated comments and error, as well as RLP encoded tx bytes for return instead of amino encoded
This commit is contained in:
Austin Abell
2019-09-20 09:30:20 -04:00
committed by GitHub
parent 2ca42cc155
commit 28aaba0695
8 changed files with 213 additions and 18 deletions
+11 -3
View File
@@ -19,6 +19,8 @@ import (
const (
// FlagAddress is the flag for the user's address on the command line.
FlagAddress = "address"
// FlagAddress is the flag for the user's address on the command line.
FlagETHAddress = "ethwallet"
// FlagPublicKey represents the user's public key on the command line.
FlagPublicKey = "pubkey"
// FlagBechPrefix defines a desired Bech32 prefix encoding for a key.
@@ -38,6 +40,7 @@ func showKeysCmd() *cobra.Command {
cmd.Flags().String(FlagBechPrefix, sdk.PrefixAccount, "The Bech32 prefix encoding for a key (acc|val|cons)")
cmd.Flags().BoolP(FlagAddress, "a", false, "Output the address only (overrides --output)")
cmd.Flags().BoolP(FlagETHAddress, "w", false, "Output the Ethereum address only (overrides --output)")
cmd.Flags().BoolP(FlagPublicKey, "p", false, "Output the public key only (overrides --output)")
cmd.Flags().BoolP(FlagDevice, "d", false, "Output the address in a ledger device")
cmd.Flags().Bool(flags.FlagIndentResponse, false, "Add indent to JSON response")
@@ -58,6 +61,7 @@ func runShowCmd(cmd *cobra.Command, args []string) (err error) {
}
isShowAddr := viper.GetBool(FlagAddress)
isShowEthAddr := viper.GetBool(FlagETHAddress)
isShowPubKey := viper.GetBool(FlagPublicKey)
isShowDevice := viper.GetBool(FlagDevice)
@@ -67,11 +71,13 @@ func runShowCmd(cmd *cobra.Command, args []string) (err error) {
isOutputSet = tmp.Changed
}
if isShowAddr && isShowPubKey {
return errors.New("cannot use both --address and --pubkey at once")
isShowEitherAddr := isShowAddr || isShowEthAddr
if isShowEitherAddr && isShowPubKey {
return errors.New("cannot get address, with --address or --ethwallet, and --pubkey at once")
}
if isOutputSet && (isShowAddr || isShowPubKey) {
if isOutputSet && (isShowEitherAddr || isShowPubKey) {
return errors.New("cannot use --output with --address or --pubkey")
}
@@ -80,6 +86,8 @@ func runShowCmd(cmd *cobra.Command, args []string) (err error) {
switch {
case isShowAddr:
printKeyAddress(info, keyOutputFunction)
case isShowEthAddr:
printKeyEthAddress(info, keyOutputFunction)
case isShowPubKey:
printPubKey(info, keyOutputFunction)
default:
+9
View File
@@ -148,6 +148,15 @@ func printKeyAddress(info cosmosKeys.Info, bechKeyOut bechKeyOutFn) {
fmt.Println(ko.Address)
}
func printKeyEthAddress(info cosmosKeys.Info, bechKeyOut bechKeyOutFn) {
ko, err := bechKeyOut(info)
if err != nil {
panic(err)
}
fmt.Println(ko.ETHAddress)
}
func printPubKey(info cosmosKeys.Info, bechKeyOut bechKeyOutFn) {
ko, err := bechKeyOut(info)
if err != nil {