2015-06-08 13:43:58 +03:00
|
|
|
package api
|
|
|
|
|
2015-06-16 16:16:06 +03:00
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/rpc/shared"
|
|
|
|
)
|
|
|
|
|
2015-06-08 13:43:58 +03:00
|
|
|
type Sha3Args struct {
|
|
|
|
Data string
|
|
|
|
}
|
2015-06-16 16:16:06 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|