-
Notifications
You must be signed in to change notification settings - Fork 0
/
bank.go
56 lines (45 loc) · 2 KB
/
bank.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
51
52
53
54
55
56
package bank
import (
"github.com/Moonyongjung/xpriv.go/core"
"github.com/Moonyongjung/xpriv.go/key"
"github.com/Moonyongjung/xpriv.go/types"
"github.com/Moonyongjung/xpriv.go/types/errors"
"github.com/Moonyongjung/xpriv.go/util"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
)
// (Tx) make msg - bank send
func MakeBankSendMsg(bankSendMsg types.BankSendMsg, privKey key.PrivateKey) (banktypes.MsgSend, error) {
return parseBankSendArgs(bankSendMsg, privKey)
}
// (Query) make msg - all balances
func MakeBankAllBalancesMsg(bankBalancesMsg types.BankBalancesMsg) (banktypes.QueryAllBalancesRequest, error) {
if (types.BankBalancesMsg{}) == bankBalancesMsg {
return banktypes.QueryAllBalancesRequest{}, util.LogErr(errors.ErrInsufficientParams, "Empty request or type of parameter is not correct")
}
return parseBankAllBalancesArgs(bankBalancesMsg)
}
// (Query) make msg - balance
func MakeBankBalanceMsg(bankBalancesMsg types.BankBalancesMsg) (banktypes.QueryBalanceRequest, error) {
if (types.BankBalancesMsg{}) == bankBalancesMsg {
return banktypes.QueryBalanceRequest{}, util.LogErr(errors.ErrInsufficientParams, "Empty request or type of parameter is not correct")
}
return parseBankBalanceArgs(bankBalancesMsg)
}
// (Query) make msg - denominations metadata
func MakeDenomsMetaDataMsg() (banktypes.QueryDenomsMetadataRequest, error) {
return banktypes.QueryDenomsMetadataRequest{}, nil
}
// (Query) make msg - denomination metadata
func MakeDenomMetaDataMsg(denomMetadataMsg types.DenomMetadataMsg) (banktypes.QueryDenomMetadataRequest, error) {
return banktypes.QueryDenomMetadataRequest{
Denom: denomMetadataMsg.Denom,
}, nil
}
// (Query) make msg - total supply
func MakeTotalSupplyMsg() (banktypes.QueryTotalSupplyRequest, error) {
return banktypes.QueryTotalSupplyRequest{Pagination: core.PageRequest}, nil
}
// (Query) make msg - supply of
func MakeSupplyOfMsg(totalMsg types.TotalMsg) (banktypes.QuerySupplyOfRequest, error) {
return banktypes.QuerySupplyOfRequest{Denom: totalMsg.Denom}, nil
}