Skip to content

Commit

Permalink
Merge pull request #32 from oilnam/manlio-fix-call-params
Browse files Browse the repository at this point in the history
Make From param optional in Transaction object
  • Loading branch information
onrik authored Jul 27, 2022
2 parents c04c090 + d977398 commit 1256c94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 1 addition & 4 deletions ethrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -526,10 +526,7 @@ func (s *EthRPCTestSuite) TestSendTransaction() {
httpmock.Reset()
s.registerResponse(fmt.Sprintf(`"%s"`, result), func(body []byte) {
s.methodEqual(body, "eth_sendTransaction")
s.paramsEqual(body, `[{
"from": ""
}]`)

s.paramsEqual(body,`[{}]`)
})

txid, err = s.rpc.EthSendTransaction(t)
Expand Down
7 changes: 4 additions & 3 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ type T struct {

// MarshalJSON implements the json.Unmarshaler interface.
func (t T) MarshalJSON() ([]byte, error) {
params := map[string]interface{}{
"from": t.From,
}
params := map[string]interface{}{}
if t.To != "" {
params["to"] = t.To
}
if t.From != "" {
params["from"] = t.From
}
if t.Gas > 0 {
params["gas"] = IntToHex(t.Gas)
}
Expand Down

0 comments on commit 1256c94

Please sign in to comment.