-
Notifications
You must be signed in to change notification settings - Fork 86
/
account.go
45 lines (37 loc) 路 1.07 KB
/
account.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
package rpc
import (
"errors"
"github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
bw "github.com/cybercongress/go-cyber/x/bandwidth"
"github.com/tendermint/tendermint/rpc/lib/types"
)
type ResultAccount struct {
Account auth.BaseAccount `json:"account"`
}
func Account(ctx *rpctypes.Context, address string) (*ResultAccount, error) {
accAddress, err := types.AccAddressFromBech32(address)
if err != nil {
return nil, err
}
account := cyberdApp.Account(accAddress)
if account == nil {
return nil, errors.New("account not found")
}
return &ResultAccount{
auth.BaseAccount{
Address: account.GetAddress(),
Coins: account.GetCoins(),
PubKey: account.GetPubKey(),
AccountNumber: account.GetAccountNumber(),
Sequence: account.GetSequence()},
}, nil
}
func AccountBandwidth(ctx *rpctypes.Context, address string) (*bw.Ac褋Bandwidth, error) {
accAddress, err := types.AccAddressFromBech32(address)
if err != nil {
return nil, err
}
accBdwth := cyberdApp.AccountBandwidth(accAddress)
return &accBdwth, nil
}