Skip to content
Snippets Groups Projects
Unverified Commit 3c6417f9 authored by Benjamin Bollen's avatar Benjamin Bollen
Browse files

client: implement Call Transaction

parent fac07523
No related branches found
No related tags found
No related merge requests found
......@@ -66,7 +66,7 @@ func buildTransactionCommand() {
}
nameCmd.Flags().StringVarP(&clientDo.AmtFlag, "amt", "a", "", "specify an amount")
nameCmd.Flags().StringVarP(&clientDo.NameFlag, "name", "n", "", "specify a name")
nameCmd.Flags().StringVarP(&clientDo.DataFlag, "data", "d", "", "specify some data")
nameCmd.Flags().StringVarP(&clientDo.DataFlag, "data", "", "", "specify some data")
nameCmd.Flags().StringVarP(&clientDo.DataFileFlag, "data-file", "", "", "specify a file with some data")
nameCmd.Flags().StringVarP(&clientDo.FeeFlag, "fee", "f", "", "specify the fee to send")
......@@ -76,13 +76,13 @@ func buildTransactionCommand() {
Short: "eris-client tx call --amt <amt> --fee <fee> --gas <gas> --to <contract addr> --data <data>",
Long: "eris-client tx call --amt <amt> --fee <fee> --gas <gas> --to <contract addr> --data <data>",
Run: func(cmd *cobra.Command, args []string) {
// transaction.Call(clientDo)
transaction.Call(clientDo)
},
PreRun: assertParameters,
}
callCmd.Flags().StringVarP(&clientDo.AmtFlag, "amt", "a", "", "specify an amount")
callCmd.Flags().StringVarP(&clientDo.ToFlag, "to", "t", "", "specify an address to send to")
callCmd.Flags().StringVarP(&clientDo.DataFlag, "data", "d", "", "specify some data")
callCmd.Flags().StringVarP(&clientDo.DataFlag, "data", "", "", "specify some data")
callCmd.Flags().StringVarP(&clientDo.FeeFlag, "fee", "f", "", "specify the fee to send")
callCmd.Flags().StringVarP(&clientDo.GasFlag, "gas", "g", "", "specify the gas limit for a CallTx")
......
......@@ -69,35 +69,35 @@ func Send(nodeAddr, signAddr, pubkey, addr, toAddr, amtS, nonceS string) (*txs.S
return tx, nil
}
// func Call(nodeAddr, signAddr, pubkey, addr, toAddr, amtS, nonceS, gasS, feeS, data string) (*txs.CallTx, error) {
// pub, amt, nonce, err := checkCommon(nodeAddr, signAddr, pubkey, addr, amtS, nonceS)
// if err != nil {
// return nil, err
// }
func Call(nodeAddr, signAddr, pubkey, addr, toAddr, amtS, nonceS, gasS, feeS, data string) (*txs.CallTx, error) {
pub, amt, nonce, err := checkCommon(nodeAddr, signAddr, pubkey, addr, amtS, nonceS)
if err != nil {
return nil, err
}
// toAddrBytes, err := hex.DecodeString(toAddr)
// if err != nil {
// return nil, fmt.Errorf("toAddr is bad hex: %v", err)
// }
toAddrBytes, err := hex.DecodeString(toAddr)
if err != nil {
return nil, fmt.Errorf("toAddr is bad hex: %v", err)
}
// fee, err := strconv.ParseInt(feeS, 10, 64)
// if err != nil {
// return nil, fmt.Errorf("fee is misformatted: %v", err)
// }
fee, err := strconv.ParseInt(feeS, 10, 64)
if err != nil {
return nil, fmt.Errorf("fee is misformatted: %v", err)
}
// gas, err := strconv.ParseInt(gasS, 10, 64)
// if err != nil {
// return nil, fmt.Errorf("gas is misformatted: %v", err)
// }
gas, err := strconv.ParseInt(gasS, 10, 64)
if err != nil {
return nil, fmt.Errorf("gas is misformatted: %v", err)
}
// dataBytes, err := hex.DecodeString(data)
// if err != nil {
// return nil, fmt.Errorf("data is bad hex: %v", err)
// }
dataBytes, err := hex.DecodeString(data)
if err != nil {
return nil, fmt.Errorf("data is bad hex: %v", err)
}
// tx := types.NewCallTxWithNonce(pub, toAddrBytes, dataBytes, amt, gas, fee, int(nonce))
// return tx, nil
// }
tx := txs.NewCallTxWithNonce(pub, toAddrBytes, dataBytes, amt, gas, fee, int(nonce))
return tx, nil
}
// func Name(nodeAddr, signAddr, pubkey, addr, amtS, nonceS, feeS, name, data string) (*txs.NameTx, error) {
// pub, amt, nonce, err := checkCommon(nodeAddr, signAddr, pubkey, addr, amtS, nonceS)
......
......@@ -28,16 +28,38 @@ import (
)
func Send(do *definitions.ClientDo) {
// form the send transaction
sendTransaction, err := core.Send(do.NodeAddrFlag, do.SignAddrFlag,
do.PubkeyFlag, do.AddrFlag, do.ToFlag, do.AmtFlag, do.NonceFlag)
if err != nil {
log.Fatalf("Failed on Send Transaction: %s", err)
log.Fatalf("Failed on forming Send Transaction: %s", err)
return
}
// TODO: [ben] we carry over the sign bool, but always set it to true,
// as we move away from and deprecate the api that allows sending unsigned
// transactions and relying on (our) receiving node to sign it.
unpackSignAndBroadcast(
core.SignAndBroadcast(do.ChainidFlag, do.NodeAddrFlag,
do.SignAddrFlag, sendTransaction, true, do.BroadcastFlag, do.WaitFlag))
}
func Call(do *definitions.ClientDo) {
// form the call transaction
callTransaction, err := core.Call(do.NodeAddrFlag, do.SignAddrFlag,
do.PubkeyFlag, do.AddrFlag, do.ToFlag, do.AmtFlag, do.NonceFlag,
do.GasFlag, do.FeeFlag, do.DataFlag)
if err != nil {
log.Fatalf("Failed on forming Call Transaction: %s", err)
return
}
// TODO: [ben] we carry over the sign bool, but always set it to true,
// as we move away from and deprecate the api that allows sending unsigned
// transactions and relying on (our) receiving node to sign it.
unpackSignAndBroadcast(
core.SignAndBroadcast(do.ChainidFlag, do.NodeAddrFlag,
do.SignAddrFlag, callTransaction, true, do.BroadcastFlag, do.WaitFlag))
}
//----------------------------------------------------------------------
// Helper functions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment