diff options
Diffstat (limited to 'rpc/args.go')
-rw-r--r-- | rpc/args.go | 88 |
1 files changed, 45 insertions, 43 deletions
diff --git a/rpc/args.go b/rpc/args.go index 8b01cc191..79519e7d2 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -1,8 +1,7 @@ package rpc -import ( - "encoding/json" -) +import "encoding/json" +import "github.com/ethereum/go-ethereum/core" type GetBlockArgs struct { BlockNumber int32 @@ -30,33 +29,15 @@ func (obj *GetBlockArgs) requirements() error { } type NewTxArgs struct { - Sec string `json:"sec"` - Recipient string `json:"recipient"` - Value string `json:"value"` - Gas string `json:"gas"` - GasPrice string `json:"gasprice"` - Init string `json:"init"` - Body string `json:"body"` -} - -// type TxResponse struct { -// Hash string -// } - -func (obj *NewTxArgs) UnmarshalJSON(b []byte) (err error) { - if err = json.Unmarshal(b, obj); err == nil { - return - } - return NewErrorResponse(ErrorDecodeArgs) + From string `json:"from"` + To string `json:"to"` + Value string `json:"value"` + Gas string `json:"gas"` + GasPrice string `json:"gasPrice"` + Data string `json:"data"` } func (a *NewTxArgs) requirements() error { - if a.Recipient == "" { - return NewErrorResponse("Transact requires a 'recipient' address as argument") - } - if a.Value == "" { - return NewErrorResponse("Transact requires a 'value' as argument") - } if a.Gas == "" { return NewErrorResponse("Transact requires a 'gas' value as argument") } @@ -66,22 +47,6 @@ func (a *NewTxArgs) requirements() error { return nil } -func (a *NewTxArgs) requirementsContract() error { - if a.Value == "" { - return NewErrorResponse("Create requires a 'value' as argument") - } - if a.Gas == "" { - return NewErrorResponse("Create requires a 'gas' value as argument") - } - if a.GasPrice == "" { - return NewErrorResponse("Create requires a 'gasprice' value as argument") - } - if a.Body == "" { - return NewErrorResponse("Create requires a 'body' value as argument") - } - return nil -} - type PushTxArgs struct { Tx string `json:"tx"` } @@ -216,3 +181,40 @@ func (a *GetCodeAtArgs) requirements() error { } return nil } + +type Sha3Args struct { + Data string +} + +func (obj *Sha3Args) UnmarshalJSON(b []byte) (err error) { + if err = json.Unmarshal(b, &obj.Data); err != nil { + return NewErrorResponse(ErrorDecodeArgs) + } + return +} + +type FilterOptions struct { + Earliest int64 + Latest int64 + Address string + Topics []string + Skip int + Max int +} + +func toFilterOptions(options *FilterOptions) core.FilterOptions { + var opts core.FilterOptions + opts.Earliest = options.Earliest + opts.Latest = options.Latest + opts.Address = fromHex(options.Address) + opts.Topics = make([][]byte, len(options.Topics)) + for i, topic := range options.Topics { + opts.Topics[i] = fromHex(topic) + } + + return opts +} + +type FilterChangedArgs struct { + n int +} |