-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
53 lines (44 loc) · 1.75 KB
/
types.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
package v04
import (
"time"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
// ModuleName nolint
ModuleName = "msgauth"
)
type (
// Authorization represents the interface of various Authorization instances
Authorization interface{}
// GenericAuthorization grants the permission to execute any transaction of the provided
// msg type without restrictions
GenericAuthorization struct {
// GrantMsgType is the type of Msg this capability grant allows
GrantMsgType string `json:"grant_msg_type"`
}
//SendAuthorization grants the permission to execute send transaction
SendAuthorization struct {
// SpendLimit specifies the maximum amount of tokens that can be spent
// by this authorization and will be updated as tokens are spent. If it is
// empty, there is no spend limit and any amount of coins can be spent.
SpendLimit sdk.Coins `json:"spend_limit"`
}
// AuthorizationEntry hold each authorization information
AuthorizationEntry struct {
Granter sdk.AccAddress `json:"granter" yaml:"granter"`
Grantee sdk.AccAddress `json:"grantee" yaml:"grantee"`
Authorization Authorization `json:"authorization" yaml:"authorization"`
Expiration time.Time `json:"expiration" yaml:"expiration"`
}
// GenesisState is the struct representation of the export genesis
GenesisState struct {
AuthorizationEntries []AuthorizationEntry `json:"authorization_entries" yaml:"authorization_entries"`
}
)
// RegisterLegacyAminoCodec nolint
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterInterface((*Authorization)(nil), nil)
cdc.RegisterConcrete(GenericAuthorization{}, "msgauth/GenericAuthorization", nil)
cdc.RegisterConcrete(SendAuthorization{}, "msgauth/SendAuthorization", nil)
}