Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
burrow
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hang Yu
burrow
Commits
3c6417f9
Unverified
Commit
3c6417f9
authored
8 years ago
by
Benjamin Bollen
Browse files
Options
Downloads
Patches
Plain Diff
client: implement Call Transaction
parent
fac07523
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
client/cmd/transaction.go
+3
-3
3 additions, 3 deletions
client/cmd/transaction.go
client/core/core.go
+24
-24
24 additions, 24 deletions
client/core/core.go
client/transaction/transaction.go
+23
-1
23 additions, 1 deletion
client/transaction/transaction.go
with
50 additions
and
28 deletions
client/cmd/transaction.go
+
3
−
3
View file @
3c6417f9
...
...
@@ -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"
)
...
...
This diff is collapsed.
Click to expand it.
client/core/core.go
+
24
−
24
View file @
3c6417f9
...
...
@@ -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 := t
ype
s.NewCallTxWithNonce(pub, toAddrBytes, dataBytes, amt, gas, fee, int(nonce))
//
return tx, nil
//
}
tx
:=
t
x
s
.
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)
...
...
This diff is collapsed.
Click to expand it.
client/transaction/transaction.go
+
23
−
1
View file @
3c6417f9
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment