keeper

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2025 License: LGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const StoreKey = types.ModuleName

StoreKey is the store key string for nft

Variables

View Source
var (
	ErrCollectionNotExists                      = sdkerrors.Register(types.ModuleName, 4, "collection does not exist")
	ErrForbiddenTime                            = sdkerrors.Register(types.ModuleName, 5, "this permission is forbidden at this time")
	ErrUserBalanceNotExists                     = sdkerrors.Register(types.ModuleName, 8, "user balance is empty or does not exist")
	ErrSupplyEqualsZero                         = sdkerrors.Register(types.ModuleName, 13, "can't create a badge with zero supply")
	ErrSenderIsNotManager                       = sdkerrors.Register(types.ModuleName, 14, "sender of tx is not the manager of the badge. must be manager to access this privilege")
	ErrAccountCanNotEqualCreator                = sdkerrors.Register(types.ModuleName, 35, "account can not equal creator")
	ErrRootHashInvalid                          = sdkerrors.Register(types.ModuleName, 49, "root hash invalid")
	ErrDecodingHexString                        = sdkerrors.Register(types.ModuleName, 53, "couldn't decode hex string")
	ErrWrongBalancesType                        = sdkerrors.Register(types.ModuleName, 64, "wrong balances type ")
	ErrCollectionIsArchived                     = sdkerrors.Register(types.ModuleName, 67, "collection is currently archived (read-only)")
	ErrNotImplemented                           = sdkerrors.Register(types.ModuleName, 69, "not implemented")
	ErrInadequateApprovals                      = sdkerrors.Register(types.ModuleName, 71, "inadequate approvals")
	ErrInvalidAddressListId                     = sdkerrors.Register(types.ModuleName, 72, "invalid address list id")
	ErrAddressListNotFound                      = sdkerrors.Register(types.ModuleName, 73, "address list not found")
	ErrCircularDependency                       = sdkerrors.Register(types.ModuleName, 75, "circular dependency")
	ErrDisallowedTransfer                       = sdkerrors.Register(types.ModuleName, 76, "disallowed transfer")
	ErrNoValidSolutionForChallenge              = sdkerrors.Register(types.ModuleName, 77, "challenge failed")
	ErrExceedsThreshold                         = sdkerrors.Register(types.ModuleName, 78, "exceeds threshold")
	ErrCircularInheritance                      = sdkerrors.Register(types.ModuleName, 79, "circular inheritance")
	ErrAddressListAlreadyExists                 = sdkerrors.Register(types.ModuleName, 80, "address list already exists")
	ErrGlobalArchive                            = sdkerrors.Register(types.ModuleName, 81, "global halt is active")
	ErrNoMatchingChallengeForChallengeTrackerId = sdkerrors.Register(types.ModuleName, 82, "no matching challenge for challenge tracker id")
)
View Source
var (
	CollectionKey         = []byte{0x01}
	UserBalanceKey        = []byte{0x02}
	NextCollectionIdKey   = []byte{0x03}
	UsedClaimChallengeKey = []byte{0x04}
	AddressListKey        = []byte{0x06}
	ApprovalTrackerKey    = []byte{0x07}

	AccountGenerationPrefix = []byte{0x08}
	AddressGenerationPrefix = []byte{0x09}

	NextAddressListIdKey = []byte{0x0A}

	Delimiter   = []byte{0xDD}
	Placeholder = []byte{0xFF}

	IDLength = 8

	BalanceKeyDelimiter = "-"
)

Functions

func AppendSelfInitiatedIncomingApproval

func AppendSelfInitiatedIncomingApproval(currApprovals []*types.UserIncomingApproval, userAddress string) []*types.UserIncomingApproval

func AppendSelfInitiatedOutgoingApproval

func AppendSelfInitiatedOutgoingApproval(currApprovals []*types.UserOutgoingApproval, userAddress string) []*types.UserOutgoingApproval

By default, we approve all transfers if from === initiatedBy

func CheckMerklePath

func CheckMerklePath(leaf string, expectedRoot string, aunts []*types.MerklePathItem) error

func CheckNotForbidden

func CheckNotForbidden(ctx sdk.Context, permission *types.UniversalPermissionDetails, permissionStr string) error

func CheckNotForbiddenForAllOverlaps

func CheckNotForbiddenForAllOverlaps(ctx sdk.Context, castedPermissions []*types.UniversalPermission, detailsToCheck []*types.UniversalPermissionDetails, permissionStr string) error

func ConstructAddressListKey

func ConstructAddressListKey(addressListId string) string

func ConstructApprovalTrackerKey

func ConstructApprovalTrackerKey(collectionID sdkmath.Uint, addressForApproval, approvalID, amountTrackerID, level, trackerType, address string) string

func ConstructBalanceKey

func ConstructBalanceKey(address string, id sdkmath.Uint) string

Creates the balance key from an address and collectionId. Note this is not prefixed yet. It is just performing a delimited string concatenation.

func ConstructUsedClaimChallengeKey

func ConstructUsedClaimChallengeKey(collectionId sdkmath.Uint, addressForChallenge string, approvalLevel string, approvalId string, challengeId string, codeLeafIndex sdkmath.Uint) string

func ConstructUsedClaimDataKey

func ConstructUsedClaimDataKey(collectionId sdkmath.Uint, claimId sdkmath.Uint) string

Creates the used claim data key from an id and data. Note this is not prefixed yet. It is just performing a delimited string concatenation.

func GetDefaultBalanceStoreForCollection

func GetDefaultBalanceStoreForCollection(collection *types.BadgeCollection) *types.UserBalanceStore

func GetFirstMatchOnlyWithApprovalCriteria

func GetFirstMatchOnlyWithApprovalCriteria(ctx sdk.Context, permissions []*types.UniversalPermission) []*types.UniversalPermissionDetails

func GetLeafIndex

func GetLeafIndex(aunts []*types.MerklePathItem) sdkmath.Uint

func GetPotentialUpdatesForTimelineValues

func GetPotentialUpdatesForTimelineValues(ctx sdk.Context,
	times [][]*types.UintRange, values []interface{}) []*types.UniversalPermissionDetails

To make it easier, we first

func GetUpdateCombinationsToCheck

func GetUpdateCombinationsToCheck(
	ctx sdk.Context,
	firstMatchesForOld []*types.UniversalPermissionDetails,
	firstMatchesForNew []*types.UniversalPermissionDetails,
	emptyValue interface{},
	compareAndGetUpdateCombosToCheck func(ctx sdk.Context, oldValue interface{}, newValue interface{}) ([]*types.UniversalPermissionDetails, error),
) ([]*types.UniversalPermissionDetails, error)

Precondition: Assumes that all passed-in matches have .ArbitraryValue set

This is a generic function that is used to get the "updated" field combinations Ex: If we go from [badgeIDs 1 to 10 -> www.example.com] to [badgeIDs 1 to 2 -> www.example2.com, badgeIDs 3 to 10 -> www.example.com]

This will return a UniversalPermissionDetails with badgeIDs 1 to 2 because they changed and are the ones we need to check

Note that updates are field-specific, so the comparison logic is handled via a custom passed-in function - compareAndGetUpdateCombosToCheck

func GetUpdateStringArrayCombinations

func GetUpdateStringArrayCombinations(ctx sdk.Context, oldValue interface{}, newValue interface{}) ([]*types.UniversalPermissionDetails, error)

func GetUpdatedBoolCombinations

func GetUpdatedBoolCombinations(ctx sdk.Context, oldValue interface{}, newValue interface{}) ([]*types.UniversalPermissionDetails, error)

func GetUpdatedCollectionMetadataCombinations

func GetUpdatedCollectionMetadataCombinations(ctx sdk.Context, oldValue interface{}, newValue interface{}) ([]*types.UniversalPermissionDetails, error)

func GetUpdatedOffChainBalancesMetadataCombinations

func GetUpdatedOffChainBalancesMetadataCombinations(ctx sdk.Context, oldValue interface{}, newValue interface{}) ([]*types.UniversalPermissionDetails, error)

func GetUpdatedStringCombinations

func GetUpdatedStringCombinations(ctx sdk.Context, oldValue interface{}, newValue interface{}) ([]*types.UniversalPermissionDetails, error)

func IsNonIndexedBalances

func IsNonIndexedBalances(collection *types.BadgeCollection) bool

func IsNonPublicBalances

func IsNonPublicBalances(collection *types.BadgeCollection) bool

func IsOffChainBalances

func IsOffChainBalances(collection *types.BadgeCollection) bool

func IsStandardBalances

func IsStandardBalances(collection *types.BadgeCollection) bool

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the MsgServer interface for the provided Keeper.

func SortViaPrioritizedApprovals

func SortViaPrioritizedApprovals(_approvals []*types.CollectionApproval, transfer *types.Transfer, approvalLevel string, approverAddress string) []*types.CollectionApproval

Types

type ApprovalCriteriaWithIsApproved

type ApprovalCriteriaWithIsApproved struct {
	ApprovalCriteria *types.ApprovalCriteria
}

Make a struct with a bool flag isApproved and an approval details arr

type BalanceKeyDetails

type BalanceKeyDetails struct {
	// contains filtered or unexported fields
}

func GetDetailsFromBalanceKey

func GetDetailsFromBalanceKey(id string) BalanceKeyDetails

Helper function to unparse a balance key and get the information from it.

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeService store.KVStoreService,
	logger log.Logger,
	authority string,
	bankKeeper types.BankKeeper,
) Keeper

func (Keeper) CastActionPermissionToUniversalPermission

func (k Keeper) CastActionPermissionToUniversalPermission(actionPermission []*types.ActionPermission) ([]*types.UniversalPermission, error)

func (Keeper) CastBadgeIdsActionPermissionToUniversalPermission

func (k Keeper) CastBadgeIdsActionPermissionToUniversalPermission(BadgeIdsActionPermission []*types.BadgeIdsActionPermission) ([]*types.UniversalPermission, error)

func (Keeper) CastBadgeMetadataToUniversalPermission

func (k Keeper) CastBadgeMetadataToUniversalPermission(badgeMetadata []*types.BadgeMetadata) []*types.UniversalPermission

func (Keeper) CastCollectionApprovalPermissionToUniversalPermission

func (k Keeper) CastCollectionApprovalPermissionToUniversalPermission(ctx sdk.Context, collectionUpdatePermission []*types.CollectionApprovalPermission) ([]*types.UniversalPermission, error)

func (Keeper) CastCollectionApprovalToUniversalPermission

func (k Keeper) CastCollectionApprovalToUniversalPermission(ctx sdk.Context, approvals []*types.CollectionApproval) ([]*types.UniversalPermission, error)

func (Keeper) CastTimedUpdatePermissionToUniversalPermission

func (k Keeper) CastTimedUpdatePermissionToUniversalPermission(timedUpdatePermission []*types.TimedUpdatePermission) ([]*types.UniversalPermission, error)

func (Keeper) CastTimedUpdateWithBadgeIdsPermissionToUniversalPermission

func (k Keeper) CastTimedUpdateWithBadgeIdsPermissionToUniversalPermission(timedUpdateWithBadgeIdsPermission []*types.TimedUpdateWithBadgeIdsPermission) ([]*types.UniversalPermission, error)

func (Keeper) CastUserIncomingApprovalPermissionToUniversalPermission

func (k Keeper) CastUserIncomingApprovalPermissionToUniversalPermission(ctx sdk.Context, permissions []*types.UserIncomingApprovalPermission) ([]*types.UniversalPermission, error)

func (Keeper) CastUserOutgoingApprovalPermissionToUniversalPermission

func (k Keeper) CastUserOutgoingApprovalPermissionToUniversalPermission(ctx sdk.Context, permissions []*types.UserOutgoingApprovalPermission) ([]*types.UniversalPermission, error)

func (Keeper) CheckAddresses

func (k Keeper) CheckAddresses(ctx sdk.Context, addressListId string, addressToCheck string) (bool, error)

func (Keeper) CheckIfActionPermissionPermits

func (k Keeper) CheckIfActionPermissionPermits(ctx sdk.Context, permissions []*types.ActionPermission, permissionStr string) error

func (Keeper) CheckIfAddressesMatchCollectionListIds

func (k Keeper) CheckIfAddressesMatchCollectionListIds(ctx sdk.Context, collectionApproval *types.CollectionApproval, from string, to string, initiatedBy string) bool

Checks if the addresses in the (to, from, initiatedBy) are approved

func (Keeper) CheckIfBadgeIdsActionPermissionPermits

func (k Keeper) CheckIfBadgeIdsActionPermissionPermits(ctx sdk.Context, detailsToCheck []*types.UniversalPermissionDetails, permissions []*types.BadgeIdsActionPermission, permissionStr string) error

func (Keeper) CheckIfCollectionApprovalPermissionPermits

func (k Keeper) CheckIfCollectionApprovalPermissionPermits(ctx sdk.Context, detailsToCheck []*types.UniversalPermissionDetails, permissions []*types.CollectionApprovalPermission, permissionStr string) error

func (Keeper) CheckIfTimedUpdatePermissionPermits

func (k Keeper) CheckIfTimedUpdatePermissionPermits(ctx sdk.Context, detailsToCheck []*types.UniversalPermissionDetails, permissions []*types.TimedUpdatePermission, permissionStr string) error

func (Keeper) CheckIfTimedUpdateWithBadgeIdsPermissionPermits

func (k Keeper) CheckIfTimedUpdateWithBadgeIdsPermissionPermits(ctx sdk.Context, detailsToCheck []*types.UniversalPermissionDetails, permissions []*types.TimedUpdateWithBadgeIdsPermission, permissionStr string) error

func (Keeper) CheckIfUserIncomingApprovalPermissionPermits

func (k Keeper) CheckIfUserIncomingApprovalPermissionPermits(ctx sdk.Context, detailsToCheck []*types.UniversalPermissionDetails, permissions []*types.UserIncomingApprovalPermission, permissionStr string) error

func (Keeper) CheckIfUserOutgoingApprovalPermissionPermits

func (k Keeper) CheckIfUserOutgoingApprovalPermissionPermits(ctx sdk.Context, detailsToCheck []*types.UniversalPermissionDetails, permissions []*types.UserOutgoingApprovalPermission, permissionStr string) error

func (Keeper) CreateAddressList

func (k Keeper) CreateAddressList(ctx sdk.Context, addressList *types.AddressList) error

func (Keeper) CreateBadges

func (k Keeper) CreateBadges(ctx sdk.Context, collection *types.BadgeCollection, newBadgeIdsToAdd []*types.UintRange) (*types.BadgeCollection, error)

Create badges and update the unminted / total supplys for the collection

func (Keeper) DeductAndGetUserApprovals

func (k Keeper) DeductAndGetUserApprovals(
	ctx sdk.Context,
	collection *types.BadgeCollection,
	originalTransferBalances []*types.Balance,
	transfer *types.Transfer,
	_approvals []*types.CollectionApproval,
	toAddress string,
	initiatedBy string,
	approvalLevel string,
	approverAddress string,
) ([]*UserApprovalsToCheck, error)

All in one approval deduction function. We also return the user approvals to check (only used when collection approvals)

func (Keeper) DeductCollectionApprovalsAndGetUserApprovalsToCheck

func (k Keeper) DeductCollectionApprovalsAndGetUserApprovalsToCheck(
	ctx sdk.Context,
	collection *types.BadgeCollection,
	transfer *types.Transfer,
	toAddress string,
	initiatedBy string,
) ([]*UserApprovalsToCheck, error)

DeductCollectionApprovalsAndGetUserApprovalsToCheck will check if the current transfer is allowed via the collection's approved transfers and handle any tallying accordingly

func (Keeper) DeductUserIncomingApprovals

func (k Keeper) DeductUserIncomingApprovals(
	ctx sdk.Context,
	collection *types.BadgeCollection,
	originalTransferBalances []*types.Balance,
	transfer *types.Transfer,
	to string,
	initiatedBy string,
	userBalance *types.UserBalanceStore,
) error

DeductUserIncomingApprovals will check if the current transfer is approved from the to's outgoing approvals and handle the approval tallying accordingly

func (Keeper) DeductUserOutgoingApprovals

func (k Keeper) DeductUserOutgoingApprovals(
	ctx sdk.Context,
	collection *types.BadgeCollection,
	originalTransferBalances []*types.Balance,
	transfer *types.Transfer,
	from string,
	to string,
	requester string,
	userBalance *types.UserBalanceStore,
) error

DeductUserOutgoingApprovals will check if the current transfer is approved from the from's outgoing approvals and handle the approval tallying accordingly

func (Keeper) DeleteAddressListFromStore

func (k Keeper) DeleteAddressListFromStore(ctx sdk.Context, addressListId string)

func (Keeper) DeleteApprovalTrackerFromStore

func (k Keeper) DeleteApprovalTrackerFromStore(ctx sdk.Context, collectionId sdkmath.Uint, addressForApproval string, approvalId, amountTrackerId string, level string, trackerType string, address string)

func (Keeper) DeleteCollectionFromStore

func (k Keeper) DeleteCollectionFromStore(ctx sdk.Context, collectionId sdkmath.Uint)

DeleteCollectionFromStore deletes a badge from the store.

func (Keeper) DeleteUserBalanceFromStore

func (k Keeper) DeleteUserBalanceFromStore(ctx sdk.Context, balanceKey string)

DeleteUserBalanceFromStore deletes a user balance from the store.

func (Keeper) GetAddressList

Queries a balance for the given address and badgeId and returns its contents.

func (Keeper) GetAddressListById

func (k Keeper) GetAddressListById(ctx sdk.Context, addressListId string) (*types.AddressList, error)

func (Keeper) GetAddressListFromStore

func (k Keeper) GetAddressListFromStore(ctx sdk.Context, addressListId string) (types.AddressList, bool)

func (Keeper) GetAddressListsFromStore

func (k Keeper) GetAddressListsFromStore(ctx sdk.Context) (addressLists []*types.AddressList)

func (Keeper) GetApprovalTracker

Queries a balance for the given address and badgeId and returns its contents.

func (Keeper) GetApprovalTrackerFromStore

func (k Keeper) GetApprovalTrackerFromStore(ctx sdk.Context, collectionId sdkmath.Uint, addressForApproval string, approvalId string, amountTrackerId string, level string, trackerType string, address string) (types.ApprovalTracker, bool)

func (Keeper) GetApprovalTrackersFromStore

func (k Keeper) GetApprovalTrackersFromStore(ctx sdk.Context) (approvalTrackers []*types.ApprovalTracker, ids []string)

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the module's authority.

func (Keeper) GetBalance

Queries a balance for the given address and badgeId and returns its contents.

func (Keeper) GetBalanceOrApplyDefault

func (k Keeper) GetBalanceOrApplyDefault(ctx sdk.Context, collection *types.BadgeCollection, userAddress string) *types.UserBalanceStore

func (Keeper) GetChallengeTracker

Queries how many times a leaf has been used for a challenge

func (Keeper) GetChallengeTrackerFromStore

func (k Keeper) GetChallengeTrackerFromStore(ctx sdk.Context, collectionId sdkmath.Uint, addressForChallenge string, approvalLevel string, approvalId, challengeId string, leafIndex sdkmath.Uint) (sdkmath.Uint, error)

func (Keeper) GetChallengeTrackersFromStore

func (k Keeper) GetChallengeTrackersFromStore(ctx sdk.Context) (numUsed []sdkmath.Uint, ids []string)

func (Keeper) GetCollection

Queries a collection by its ID and returns its contents.

func (Keeper) GetCollectionFromStore

func (k Keeper) GetCollectionFromStore(ctx sdk.Context, collectionId sdkmath.Uint) (*types.BadgeCollection, bool)

Gets a badge from the store according to the collectionId.

func (Keeper) GetCollectionsFromStore

func (k Keeper) GetCollectionsFromStore(ctx sdk.Context) (collections []*types.BadgeCollection)

GetCollectionsFromStore defines a method for returning all badges information by key.

func (Keeper) GetDetailsToCheck

func (k Keeper) GetDetailsToCheck(ctx sdk.Context, collection *types.BadgeCollection, oldApprovals []*types.CollectionApproval, newApprovals []*types.CollectionApproval) ([]*types.UniversalPermissionDetails, error)

func (Keeper) GetMaxPossible

func (k Keeper) GetMaxPossible(
	ctx sdk.Context,
	collection *types.BadgeCollection,
	approval *types.CollectionApproval,
	transfer *types.Transfer,
	originalTransferBalances []*types.Balance,
	approvedAmount sdkmath.Uint,
	challengeNumIncrements sdkmath.Uint,
	approverAddress string,
	approvalLevel string,
	trackerType string,
	address string,
	simulate bool,
) ([]*types.Balance, error)

GetMaxPossible calculates the maximum possible transfer amounts based on approval criteria

func (Keeper) GetNextAddressListCounter

func (k Keeper) GetNextAddressListCounter(ctx sdk.Context) sdkmath.Uint

Gets the next collection ID.

func (Keeper) GetNextCollectionId

func (k Keeper) GetNextCollectionId(ctx sdk.Context) sdkmath.Uint

Gets the next collection ID.

func (Keeper) GetParams

func (k Keeper) GetParams(ctx context.Context) (params types.Params)

GetParams get all parameters as types.Params

func (Keeper) GetPredeterminedBalancesForPrecalculationId

func (k Keeper) GetPredeterminedBalancesForPrecalculationId(
	ctx sdk.Context,
	collection *types.BadgeCollection,
	approvals []*types.CollectionApproval,
	transfer *types.Transfer,
	precalcDetails *types.ApprovalIdentifierDetails,
	to string,
	initiatedBy string,
) ([]*types.Balance, error)

func (Keeper) GetTrackerListById

func (k Keeper) GetTrackerListById(ctx sdk.Context, trackerListId string) (*types.AddressList, error)

func (Keeper) GetUserBalanceFromStore

func (k Keeper) GetUserBalanceFromStore(ctx sdk.Context, balanceKey string) (*types.UserBalanceStore, bool)

Gets a user balance from the store according to the balanceID.

func (Keeper) GetUserBalanceIdsFromStore

func (k Keeper) GetUserBalanceIdsFromStore(ctx sdk.Context) (ids []string)

GetUserBalanceIdsFromStore defines a method for returning all keys of all user balances.

func (Keeper) GetUserBalancesFromStore

func (k Keeper) GetUserBalancesFromStore(ctx sdk.Context) (balances []*types.UserBalanceStore, addresses []string, ids []sdkmath.Uint)

GetUserBalancesFromStore defines a method for returning all user balances information by key.

func (Keeper) HandleCoinTransfers

func (k Keeper) HandleCoinTransfers(ctx sdk.Context, coinTransfers []*types.CoinTransfer, initiatedBy string, simulate bool) error

func (Keeper) HandleMerkleChallenges

func (k Keeper) HandleMerkleChallenges(
	ctx sdk.Context,
	collectionId sdkmath.Uint,
	transfer *types.Transfer,
	approval *types.CollectionApproval,
	creatorAddress string,
	approverAddress string,
	approvalLevel string,
	simulation bool,
) (sdkmath.Uint, error)

func (Keeper) HandleTransfer

func (k Keeper) HandleTransfer(
	ctx sdk.Context,
	collection *types.BadgeCollection,
	transfer *types.Transfer,
	fromUserBalance *types.UserBalanceStore,
	toUserBalance *types.UserBalanceStore,
	from string,
	to string,
	initiatedBy string,
) (*types.UserBalanceStore, *types.UserBalanceStore, error)

Step 1: Check if transfer is allowed on collection level (deducting collection approvals if needed). Will return what userApprovals we need to check. Step 2: Check necessary approvals on user level (deducting corresponding approvals if needed) Step 3: If all good, we can transfer the balances

func (Keeper) HandleTransfers

func (k Keeper) HandleTransfers(ctx sdk.Context, collection *types.BadgeCollection, transfers []*types.Transfer, initiatedBy string) error

func (Keeper) IncrementApprovalsAndAssertWithinThreshold

func (k Keeper) IncrementApprovalsAndAssertWithinThreshold(
	ctx sdk.Context,
	collection *types.BadgeCollection,
	approval *types.CollectionApproval,
	originalTransferBalances []*types.Balance,
	approvedAmount sdkmath.Uint,
	maxNumTransfers sdkmath.Uint,
	transferBalances []*types.Balance,
	challengeNumIncrements sdkmath.Uint,
	approverAddress string,
	approvalLevel string,
	trackerType string,
	address string,
	simulate bool,
) error

IncrementApprovalsAndAssertWithinThreshold handles approval tracking and threshold checks

func (Keeper) IncrementChallengeTrackerInStore

func (k Keeper) IncrementChallengeTrackerInStore(ctx sdk.Context, collectionId sdkmath.Uint, addressForChallenge string, approvalLevel string, approvalId, challengeId string, leafIndex sdkmath.Uint) (sdkmath.Uint, error)

****************************************************************************** Sets a usedClaimData in the store using UsedClaimDataKey ([]byte{0x07}) as the prefix. No check if store has key already.

func (Keeper) IncrementNextAddressListCounter

func (k Keeper) IncrementNextAddressListCounter(ctx sdk.Context)

Increments the next collection ID by 1.

func (Keeper) IncrementNextCollectionId

func (k Keeper) IncrementNextCollectionId(ctx sdk.Context)

Increments the next collection ID by 1.

func (Keeper) Logger

func (k Keeper) Logger() log.Logger

Logger returns a module-specific logger.

func (Keeper) Params

func (Keeper) SetAddressListInStore

func (k Keeper) SetAddressListInStore(ctx sdk.Context, addressList types.AddressList) error

func (Keeper) SetApprovalTrackerInStore

func (k Keeper) SetApprovalTrackerInStore(ctx sdk.Context, collectionId sdkmath.Uint, addressForApproval string, approvalId, amountTrackerId string, approvalTracker types.ApprovalTracker, level string, trackerType string, address string) error

func (Keeper) SetApprovalTrackerInStoreViaKey

func (k Keeper) SetApprovalTrackerInStoreViaKey(ctx sdk.Context, key string, approvalTracker types.ApprovalTracker) error

func (Keeper) SetBalanceForAddress

func (k Keeper) SetBalanceForAddress(ctx sdk.Context, collection *types.BadgeCollection, userAddress string, balance *types.UserBalanceStore) error

func (Keeper) SetChallengeTrackerInStore

func (k Keeper) SetChallengeTrackerInStore(ctx sdk.Context, key string, numUsed sdkmath.Uint) error

func (Keeper) SetCollectionInStore

func (k Keeper) SetCollectionInStore(ctx sdk.Context, collection *types.BadgeCollection) error

Sets a badge in the store using BadgeKey ([]byte{0x01}) as the prefix. No check if store has key already.

func (Keeper) SetNextAddressListCounter

func (k Keeper) SetNextAddressListCounter(ctx sdk.Context, nextID sdkmath.Uint)

Sets the next asset ID. Should only be used in InitGenesis. Everything else should call IncrementNextAssetID()

func (Keeper) SetNextCollectionId

func (k Keeper) SetNextCollectionId(ctx sdk.Context, nextID sdkmath.Uint)

Sets the next asset ID. Should only be used in InitGenesis. Everything else should call IncrementNextAssetID()

func (Keeper) SetParams

func (k Keeper) SetParams(ctx context.Context, params types.Params) error

SetParams set the params

func (Keeper) SetUserBalanceInStore

func (k Keeper) SetUserBalanceInStore(ctx sdk.Context, balanceKey string, UserBalance *types.UserBalanceStore) error

Sets a user balance in the store using UserBalanceKey ([]byte{0x02}) as the prefix. No check if store has key already.

func (Keeper) StoreHasAddressList

func (k Keeper) StoreHasAddressList(ctx sdk.Context, addressListId string) bool

func (Keeper) StoreHasApprovalTracker

func (k Keeper) StoreHasApprovalTracker(ctx sdk.Context, collectionId sdkmath.Uint, addressForApproval string, approvalId, amountTrackerId string, level string, trackerType string, address string) bool

func (Keeper) StoreHasCollectionID

func (k Keeper) StoreHasCollectionID(ctx sdk.Context, collectionId sdkmath.Uint) bool

StoreHasCollectionID determines whether the specified collectionId exists

func (Keeper) StoreHasUserBalance

func (k Keeper) StoreHasUserBalance(ctx sdk.Context, balanceKey string) bool

StoreHasUserBalanceID determines whether the specified user balanceID exists in the store

func (Keeper) UniversalValidate

func (k Keeper) UniversalValidate(ctx sdk.Context, collection *types.BadgeCollection, params UniversalValidationParams) error

Validates everything about the Msg is valid and returns (creatorNum, collection, permissions, error).

func (Keeper) ValidateActionPermissionUpdate

func (k Keeper) ValidateActionPermissionUpdate(ctx sdk.Context, oldPermissions []*types.ActionPermission, newPermissions []*types.ActionPermission) error

func (Keeper) ValidateBadgeIdsActionPermissionUpdate

func (k Keeper) ValidateBadgeIdsActionPermissionUpdate(ctx sdk.Context, oldPermissions []*types.BadgeIdsActionPermission, newPermissions []*types.BadgeIdsActionPermission) error

func (Keeper) ValidateBadgeMetadataUpdate

func (k Keeper) ValidateBadgeMetadataUpdate(ctx sdk.Context, oldBadgeMetadata []*types.BadgeMetadataTimeline, newBadgeMetadata []*types.BadgeMetadataTimeline, canUpdateBadgeMetadata []*types.TimedUpdateWithBadgeIdsPermission) error

func (Keeper) ValidateCollectionApprovalPermissionsUpdate

func (k Keeper) ValidateCollectionApprovalPermissionsUpdate(ctx sdk.Context, oldPermissions []*types.CollectionApprovalPermission, newPermissions []*types.CollectionApprovalPermission) error

func (Keeper) ValidateCollectionApprovalsUpdate

func (k Keeper) ValidateCollectionApprovalsUpdate(ctx sdk.Context, collection *types.BadgeCollection, oldApprovals []*types.CollectionApproval, newApprovals []*types.CollectionApproval, CanUpdateCollectionApprovals []*types.CollectionApprovalPermission) error

func (Keeper) ValidateCollectionMetadataUpdate

func (k Keeper) ValidateCollectionMetadataUpdate(ctx sdk.Context, oldCollectionMetadata []*types.CollectionMetadataTimeline, newCollectionMetadata []*types.CollectionMetadataTimeline, canUpdateCollectionMetadata []*types.TimedUpdatePermission) error

func (Keeper) ValidateCustomDataUpdate

func (k Keeper) ValidateCustomDataUpdate(ctx sdk.Context, oldCustomData []*types.CustomDataTimeline, newCustomData []*types.CustomDataTimeline, canUpdateCustomData []*types.TimedUpdatePermission) error

func (Keeper) ValidateIsArchivedUpdate

func (k Keeper) ValidateIsArchivedUpdate(ctx sdk.Context, oldIsArchived []*types.IsArchivedTimeline, newIsArchived []*types.IsArchivedTimeline, canUpdateIsArchived []*types.TimedUpdatePermission) error

func (Keeper) ValidateManagerUpdate

func (k Keeper) ValidateManagerUpdate(ctx sdk.Context, oldManager []*types.ManagerTimeline, newManager []*types.ManagerTimeline, canUpdateManager []*types.TimedUpdatePermission) error

func (Keeper) ValidateOffChainBalancesMetadataUpdate

func (k Keeper) ValidateOffChainBalancesMetadataUpdate(ctx sdk.Context, collection *types.BadgeCollection, oldOffChainBalancesMetadata []*types.OffChainBalancesMetadataTimeline, newOffChainBalancesMetadata []*types.OffChainBalancesMetadataTimeline, canUpdateOffChainBalancesMetadata []*types.TimedUpdatePermission) error

func (Keeper) ValidatePermissionsUpdate

func (k Keeper) ValidatePermissionsUpdate(ctx sdk.Context, oldPermissions *types.CollectionPermissions, newPermissions *types.CollectionPermissions) error

Validate that the new permissions are valid and is not changing anything that they can't.

func (Keeper) ValidateStandardsUpdate

func (k Keeper) ValidateStandardsUpdate(ctx sdk.Context, oldStandards []*types.StandardsTimeline, newStandards []*types.StandardsTimeline, canUpdateStandards []*types.TimedUpdatePermission) error

func (Keeper) ValidateTimedUpdatePermissionUpdate

func (k Keeper) ValidateTimedUpdatePermissionUpdate(ctx sdk.Context, oldPermissions []*types.TimedUpdatePermission, newPermissions []*types.TimedUpdatePermission) error

func (Keeper) ValidateTimedUpdateWithBadgeIdsPermissionUpdate

func (k Keeper) ValidateTimedUpdateWithBadgeIdsPermissionUpdate(ctx sdk.Context, oldPermissions []*types.TimedUpdateWithBadgeIdsPermission, newPermissions []*types.TimedUpdateWithBadgeIdsPermission) error

func (Keeper) ValidateUserIncomingApprovalPermissionsUpdate

func (k Keeper) ValidateUserIncomingApprovalPermissionsUpdate(ctx sdk.Context, oldPermissions []*types.UserIncomingApprovalPermission, newPermissions []*types.UserIncomingApprovalPermission) error

func (Keeper) ValidateUserIncomingApprovalsUpdate

func (k Keeper) ValidateUserIncomingApprovalsUpdate(ctx sdk.Context, collection *types.BadgeCollection, oldApprovals []*types.UserIncomingApproval, newApprovals []*types.UserIncomingApproval, CanUpdateCollectionApprovals []*types.UserIncomingApprovalPermission, toAddress string) error

func (Keeper) ValidateUserOutgoingApprovalPermissionsUpdate

func (k Keeper) ValidateUserOutgoingApprovalPermissionsUpdate(ctx sdk.Context, oldPermissions []*types.UserOutgoingApprovalPermission, newPermissions []*types.UserOutgoingApprovalPermission) error

func (Keeper) ValidateUserOutgoingApprovalsUpdate

func (k Keeper) ValidateUserOutgoingApprovalsUpdate(ctx sdk.Context, collection *types.BadgeCollection, oldApprovals []*types.UserOutgoingApproval, newApprovals []*types.UserOutgoingApproval, CanUpdateCollectionApprovals []*types.UserOutgoingApprovalPermission, fromAddress string) error

func (Keeper) ValidateUserPermissionsUpdate

func (k Keeper) ValidateUserPermissionsUpdate(ctx sdk.Context, oldPermissions *types.UserPermissions, newPermissions *types.UserPermissions) error

type UniversalValidationParams

type UniversalValidationParams struct {
	Creator       string
	MustBeManager bool
}

Determines what to validate for each Msg

type UserApprovalsToCheck

type UserApprovalsToCheck struct {
	Address  string
	Balances []*types.Balance
	Outgoing bool
}

The UserApprovalsToCheck struct is used to keep track of which incoming / outgoing approvals for which addresses we need to check.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL