blob: 38af7191e382f750a2a6f88bc93ae449f6e2cfc6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
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
}
|