-
Notifications
You must be signed in to change notification settings - Fork 86
/
link.go
50 lines (42 loc) 路 1.29 KB
/
link.go
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package rpc
import (
"encoding/json"
"github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cybercongress/go-cyber/x/link"
"github.com/tendermint/tendermint/rpc/lib/types"
)
func IsLinkExist(ctx *rpctypes.Context, from string, to string, address string) (bool, error) {
if len(address) == 0 {
return cyberdApp.IsLinkExist(link.Cid(from), link.Cid(to), nil), nil
}
accAddress, err := types.AccAddressFromBech32(address)
if err != nil {
return false, err
}
return cyberdApp.IsLinkExist(link.Cid(from), link.Cid(to), accAddress), nil
}
type LinkRequest struct {
Fee auth.StdFee `json:"fee"`
Msgs []link.Msg `json:"msgs"`
Signatures []Signature `json:"signatures"`
Memo string `json:"memo"`
}
func (r LinkRequest) GetFee() auth.StdFee { return r.Fee }
func (r LinkRequest) GetSignatures() []Signature { return r.Signatures }
func (r LinkRequest) GetMemo() string { return r.Memo }
func (r LinkRequest) GetMsgs() []types.Msg {
msgs := make([]types.Msg, 0, len(r.Msgs))
for _, msg := range r.Msgs {
msgs = append(msgs, msg)
}
return msgs
}
func UnmarshalLinkRequestFn(reqBytes []byte) (TxRequest, error) {
var req LinkRequest
err := json.Unmarshal(reqBytes, &req)
if err != nil {
return nil, err
}
return req, nil
}