Skip to content

Commit 1256c94

Browse files
authored
Merge pull request #32 from oilnam/manlio-fix-call-params
Make From param optional in Transaction object
2 parents c04c090 + d977398 commit 1256c94

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

ethrpc_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,7 @@ func (s *EthRPCTestSuite) TestSendTransaction() {
526526
httpmock.Reset()
527527
s.registerResponse(fmt.Sprintf(`"%s"`, result), func(body []byte) {
528528
s.methodEqual(body, "eth_sendTransaction")
529-
s.paramsEqual(body, `[{
530-
"from": ""
531-
}]`)
532-
529+
s.paramsEqual(body,`[{}]`)
533530
})
534531

535532
txid, err = s.rpc.EthSendTransaction(t)

types.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ type T struct {
4141

4242
// MarshalJSON implements the json.Unmarshaler interface.
4343
func (t T) MarshalJSON() ([]byte, error) {
44-
params := map[string]interface{}{
45-
"from": t.From,
46-
}
44+
params := map[string]interface{}{}
4745
if t.To != "" {
4846
params["to"] = t.To
4947
}
48+
if t.From != "" {
49+
params["from"] = t.From
50+
}
5051
if t.Gas > 0 {
5152
params["gas"] = IntToHex(t.Gas)
5253
}

0 commit comments

Comments
 (0)