-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
70 lines (60 loc) · 1.99 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package v042
import (
codectypes "github.com/blockgenx/blockgen-sdk/codec/types"
sdk "github.com/blockgenx/blockgen-sdk/types"
"github.com/blockgenx/blockgen-sdk/types/kv"
v042auth "github.com/blockgenx/blockgen-sdk/x/auth/migrations/v042"
"github.com/blockgenx/blockgen-sdk/x/bank/types"
"github.com/golang/protobuf/proto"
)
const (
// ModuleName defines the module name
ModuleName = "bank"
// StoreKey defines the primary module store key
StoreKey = ModuleName
// RouterKey defines the module's message routing key
RouterKey = ModuleName
// QuerierRoute defines the module's query routing key
QuerierRoute = ModuleName
)
// KVStore keys
var (
BalancesPrefix = []byte("balances")
SupplyKey = []byte{0x00}
DenomMetadataPrefix = []byte{0x1}
)
// DenomMetadataKey returns the denomination metadata key.
func DenomMetadataKey(denom string) []byte {
d := []byte(denom)
return append(DenomMetadataPrefix, d...)
}
// AddressFromBalancesStore returns an account address from a balances prefix
// store. The key must not contain the perfix BalancesPrefix as the prefix store
// iterator discards the actual prefix.
func AddressFromBalancesStore(key []byte) sdk.AccAddress {
kv.AssertKeyAtLeastLength(key, 1+v042auth.AddrLen)
addr := key[:v042auth.AddrLen]
kv.AssertKeyLength(addr, v042auth.AddrLen)
return sdk.AccAddress(addr)
}
// SupplyI defines an inflationary supply interface for modules that handle
// token supply.
// It is copy-pasted from:
// https://github.com/blockgenx/blockgen-sdk/blob/v0.42.3/x/bank/exported/exported.go
// where we stripped off the unnecessary methods.
//
// It is used in the migration script, because we save this interface as an Any
// in the supply state.
//
// Deprecated.
type SupplyI interface {
proto.Message
}
// RegisterInterfaces registers interfaces required for the v0.40 migrations.
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
registry.RegisterInterface(
"cosmos.bank.v1beta1.SupplyI",
(*SupplyI)(nil),
&types.Supply{},
)
}