OSDN Git Service

Wallet store test (#312)
[bytom/vapor.git] / vendor / github.com / tendermint / go-crypto / pubkeyinner_wrapper.go
1 // Generated by: main
2 // TypeWriter: wrapper
3 // Directive: +gen on PubKeyInner
4
5 package crypto
6
7 import (
8         "github.com/tendermint/go-wire/data"
9 )
10
11 // Auto-generated adapters for happily unmarshaling interfaces
12 // Apache License 2.0
13 // Copyright (c) 2017 Ethan Frey (ethan.frey@tendermint.com)
14
15 type PubKey struct {
16         PubKeyInner "json:\"unwrap\""
17 }
18
19 var PubKeyMapper = data.NewMapper(PubKey{})
20
21 func (h PubKey) MarshalJSON() ([]byte, error) {
22         return PubKeyMapper.ToJSON(h.PubKeyInner)
23 }
24
25 func (h *PubKey) UnmarshalJSON(data []byte) (err error) {
26         parsed, err := PubKeyMapper.FromJSON(data)
27         if err == nil && parsed != nil {
28                 h.PubKeyInner = parsed.(PubKeyInner)
29         }
30         return err
31 }
32
33 // Unwrap recovers the concrete interface safely (regardless of levels of embeds)
34 func (h PubKey) Unwrap() PubKeyInner {
35         hi := h.PubKeyInner
36         for wrap, ok := hi.(PubKey); ok; wrap, ok = hi.(PubKey) {
37                 hi = wrap.PubKeyInner
38         }
39         return hi
40 }
41
42 /*** below are bindings for each implementation ***/
43
44 func init() {
45         PubKeyMapper.RegisterImplementation(PubKeyEd25519{}, "ed25519", 0x1)
46 }
47
48 func (hi PubKeyEd25519) Wrap() PubKey {
49         return PubKey{hi}
50 }