package v046 import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" ) var ( ModuleName = "feegrant" // FeeAllowanceKeyPrefix is the set of the kvstore for fee allowance data // - 0x00: allowance FeeAllowanceKeyPrefix = []byte{0x00} // FeeAllowanceQueueKeyPrefix is the set of the kvstore for fee allowance keys data // - 0x01: FeeAllowanceQueueKeyPrefix = []byte{0x01} ) // FeeAllowancePrefixQueue is the canonical key to store grant key. // // Key format: // - <0x01> func FeeAllowancePrefixQueue(exp *time.Time, key []byte) []byte { // no need of appending len(exp_bytes) here, `FormatTimeBytes` gives const length everytime. allowanceByExpTimeKey := append(FeeAllowanceQueueKeyPrefix, sdk.FormatTimeBytes(*exp)...) return append(allowanceByExpTimeKey, key...) } // FeeAllowanceKey is the canonical key to store a grant from granter to grantee // We store by grantee first to allow searching by everyone who granted to you // // Key format: // - <0x00> func FeeAllowanceKey(granter sdk.AccAddress, grantee sdk.AccAddress) []byte { return append(FeeAllowancePrefixByGrantee(grantee), address.MustLengthPrefix(granter.Bytes())...) } // FeeAllowancePrefixByGrantee returns a prefix to scan for all grants to this given address. // // Key format: // - <0x00> func FeeAllowancePrefixByGrantee(grantee sdk.AccAddress) []byte { return append(FeeAllowanceKeyPrefix, address.MustLengthPrefix(grantee.Bytes())...) }