mirror of https://github.com/ethereum/go-ethereum
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
533 B
29 lines
533 B
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/ethereum/go-ethereum/rpc/shared"
|
|
)
|
|
|
|
type Sha3Args struct {
|
|
Data string
|
|
}
|
|
|
|
func (args *Sha3Args) UnmarshalJSON(b []byte) (err error) {
|
|
var obj []interface{}
|
|
if err := json.Unmarshal(b, &obj); err != nil {
|
|
return shared.NewDecodeParamError(err.Error())
|
|
}
|
|
|
|
if len(obj) < 1 {
|
|
return shared.NewInsufficientParamsError(len(obj), 1)
|
|
}
|
|
|
|
argstr, ok := obj[0].(string)
|
|
if !ok {
|
|
return shared.NewInvalidTypeError("data", "is not a string")
|
|
}
|
|
args.Data = argstr
|
|
return nil
|
|
}
|
|
|