github.com/Finschia/finschia-sdk@v0.49.1/x/bank/legacy/v040/keys.go (about) 1 // Package v040 is copy-pasted from: 2 // https://github.com/cosmos/cosmos-sdk/blob/v0.41.0/x/bank/types/key.go 3 package v040 4 5 import ( 6 sdk "github.com/Finschia/finschia-sdk/types" 7 "github.com/Finschia/finschia-sdk/types/kv" 8 v040auth "github.com/Finschia/finschia-sdk/x/auth/legacy/v040" 9 ) 10 11 const ( 12 // ModuleName defines the module name 13 ModuleName = "bank" 14 15 // StoreKey defines the primary module store key 16 StoreKey = ModuleName 17 18 // RouterKey defines the module's message routing key 19 RouterKey = ModuleName 20 21 // QuerierRoute defines the module's query routing key 22 QuerierRoute = ModuleName 23 ) 24 25 // KVStore keys 26 var ( 27 BalancesPrefix = []byte("balances") 28 SupplyKey = []byte{0x00} 29 DenomMetadataPrefix = []byte{0x1} 30 ) 31 32 // DenomMetadataKey returns the denomination metadata key. 33 func DenomMetadataKey(denom string) []byte { 34 d := []byte(denom) 35 return append(DenomMetadataPrefix, d...) 36 } 37 38 // AddressFromBalancesStore returns an account address from a balances prefix 39 // store. The key must not contain the perfix BalancesPrefix as the prefix store 40 // iterator discards the actual prefix. 41 func AddressFromBalancesStore(key []byte) sdk.AccAddress { 42 kv.AssertKeyAtLeastLength(key, 1+v040auth.AddrLen) 43 addr := key[:v040auth.AddrLen] 44 kv.AssertKeyLength(addr, v040auth.AddrLen) 45 return sdk.AccAddress(addr) 46 }