keeper

package
v0.0.0-...-a2f4e79 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: MIT Imports: 27 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")
)
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

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

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, permissionDetails []*types.UniversalPermissionDetails, detailsToCheck []*types.UniversalPermissionDetails, permissionStr string) error

func ConstructAddressListKey

func ConstructAddressListKey(addressListId string) string

func ConstructApprovalTrackerKey

func ConstructApprovalTrackerKey(collectionId sdkmath.Uint, addressForApproval string, amountTrackerId string, level string, trackerType string, 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, challengeLevel 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 GetFirstMatchOnlyWithApprovalCriteria

func GetFirstMatchOnlyWithApprovalCriteria(permissions []*types.UniversalPermission) []*types.UniversalPermissionDetails

func GetLeafIndex

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

func GetPotentialUpdatesForTimelineValues

func GetPotentialUpdatesForTimelineValues(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

We do this by getting from GetPotentialUpdatesForTimelineValues

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 are the only ones that changed

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

func GetUpdatedBoolCombinations

func GetUpdatedBoolCombinations(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 IncrementBalances

func IncrementBalances(startBalances []*types.Balance, numIncrements sdkmath.Uint, incrementOwnershipTimesBy sdkmath.Uint, incrementBadgeIdsBy sdkmath.Uint) ([]*types.Balance, error)

func IsInheritedBalances

func IsInheritedBalances(collection *types.BadgeCollection) bool

func IsNonIndexedBalances

func IsNonIndexedBalances(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.

Types

type ApprovalCriteriaWithIsApproved

type ApprovalCriteriaWithIsApproved struct {
	ApprovalCriteria *types.ApprovalCriteria
}

Make a struct witha 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,
	storeKey,
	memKey storetypes.StoreKey,
	ps paramtypes.Subspace,
	channelKeeper types.ChannelKeeper,
	portKeeper types.PortKeeper,
	scopedKeeper exported.ScopedKeeper,

	accKeeper types.AccountKeeper,
) *Keeper

func (Keeper) AssertValidSolutionForEveryChallenge

func (k Keeper) AssertValidSolutionForEveryChallenge(ctx sdk.Context, collectionId sdkmath.Uint, challengeId string, challenges []*types.MerkleChallenge, merkleProofs []*types.MerkleProof, creatorAddress string, simulation bool, approverAddress string, challengeLevel string, challengeIdsIncremented *[]string, approval *types.CollectionApproval) (sdkmath.Uint, error)

func (Keeper) AuthenticateCapability

func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool

AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function

func (Keeper) BindPort

func (k Keeper) BindPort(ctx sdk.Context, portID string) error

BindPort defines a wrapper function for the port Keeper's function in order to expose it to module's InitGenesis function

func (Keeper) CastActionPermissionToUniversalPermission

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

func (Keeper) CastBadgeMetadataToUniversalPermission

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

func (Keeper) CastBalancesActionPermissionToUniversalPermission

func (k Keeper) CastBalancesActionPermissionToUniversalPermission(BalancesActionPermission []*types.BalancesActionPermission) ([]*types.UniversalPermission, error)

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) ChanCloseInit

func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error

ChanCloseInit defines a wrapper function for the channel Keeper's function.

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

Note addresses matching does not mean the transfer is allowed. It just means the addresses match. All other criteria must also be met.

func (Keeper) CheckIfBalancesActionPermissionPermits

func (k Keeper) CheckIfBalancesActionPermissionPermits(ctx sdk.Context, detailsToCheck []*types.UniversalPermissionDetails, permissions []*types.BalancesActionPermission, 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) ClaimCapability

func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error

ClaimCapability allows the IBC app module to claim a capability that core IBC passes to it

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, badgesToCreate []*types.Balance) (*types.BadgeCollection, error)

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

func (Keeper) DeductAndGetUserApprovals

func (k Keeper) DeductAndGetUserApprovals(overallTransferBalances []*types.Balance, _approvals []*types.CollectionApproval, ctx sdk.Context, collection *types.BadgeCollection, badgeIds []*types.UintRange, times []*types.UintRange, fromAddress string, toAddress string, initiatedBy string, amount sdkmath.Uint, solutions []*types.MerkleProof, approvalLevel string, approverAddress string, challengeIdsIncremented *[]string, trackerIdsIncremented *[]string, prioritizedApprovals []*types.ApprovalIdentifierDetails, onlyCheckPrioritized bool) ([]*UserApprovalsToCheck, error)

func (Keeper) DeductCollectionApprovalsAndGetUserApprovalsToCheck

func (k Keeper) DeductCollectionApprovalsAndGetUserApprovalsToCheck(ctx sdk.Context, overallTransferBalances []*types.Balance, collection *types.BadgeCollection, badgeIds []*types.UintRange, times []*types.UintRange, fromAddress string, toAddress string, initiatedBy string, amount sdkmath.Uint, solutions []*types.MerkleProof, challengeIdsIncremented *[]string, trackerIdsIncremented *[]string, prioritizedApprovals []*types.ApprovalIdentifierDetails, onlyCheckPrioritized bool) ([]*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, overallTransferBalances []*types.Balance, collection *types.BadgeCollection, userBalance *types.UserBalanceStore, badgeIds []*types.UintRange, times []*types.UintRange, from string, to string, requester string, amount sdkmath.Uint, solutions []*types.MerkleProof, challengeIdsIncremented *[]string, trackerIdsIncremented *[]string, prioritizedApprovals []*types.ApprovalIdentifierDetails, onlyCheckPrioritized bool) 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, overallTransferBalances []*types.Balance, collection *types.BadgeCollection, userBalance *types.UserBalanceStore, badgeIds []*types.UintRange, times []*types.UintRange, from string, to string, requester string, amount sdkmath.Uint, solutions []*types.MerkleProof, challengeIdsIncremented *[]string, trackerIdsIncremented *[]string, prioritizedApprovals []*types.ApprovalIdentifierDetails, onlyCheckPrioritized bool) 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, 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, 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) GetBalance

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

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, challengeLevel string, 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,
	transferVal *types.CollectionApproval,
	approvalCriteria *types.ApprovalCriteria,
	overallTransferBalances []*types.Balance,
	collection *types.BadgeCollection,
	approvedAmount sdkmath.Uint,
	maxNumTransfers sdkmath.Uint,
	transferBalances []*types.Balance,
	challengeNumIncrements sdkmath.Uint,
	approverAddress string,
	approvalLevel string,
	trackerType string,
	address string,
	simulate bool,
	trackerIdsIncremented *[]string,
) ([]*types.Balance, error)

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 sdk.Context) types.Params

GetParams get all parameters as types.Params

func (Keeper) GetPort

func (k Keeper) GetPort(ctx sdk.Context) string

GetPort returns the portID for the IBC app module. Used in ExportGenesis

func (Keeper) GetPredeterminedBalancesForPrecalculationId

func (k Keeper) GetPredeterminedBalancesForPrecalculationId(ctx sdk.Context, approvals []*types.CollectionApproval, collection *types.BadgeCollection, approverAddress string, precalculationId string, approvalLevel string, address string, solutions []*types.MerkleProof, 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) HandleTransfer

func (k Keeper) HandleTransfer(ctx sdk.Context, collection *types.BadgeCollection, transferBalances []*types.Balance, fromUserBalance *types.UserBalanceStore, toUserBalance *types.UserBalanceStore, from string, to string, initiatedBy string, solutions []*types.MerkleProof, challengeIdsIncremented *[]string, trackerIdsIncremented *[]string, prioritizedApprovals []*types.ApprovalIdentifierDetails, onlyCheckPrioritized bool) (*types.UserBalanceStore, *types.UserBalanceStore, error)

Step 1: Check if transfer is allowed on collection level (deducting approvals if needed) Step 2: If not overriden by collection, check necessary approvals on user level (deducting 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,
	transferVal *types.CollectionApproval,
	approvalCriteria *types.ApprovalCriteria,
	overallTransferBalances []*types.Balance,
	collection *types.BadgeCollection,
	approvedAmount sdkmath.Uint,
	maxNumTransfers sdkmath.Uint,
	transferBalances []*types.Balance,
	challengeNumIncrements sdkmath.Uint,
	approverAddress string,
	approvalLevel string,
	trackerType string,
	address string,
	simulate bool,
	trackerIdsIncremented *[]string,
) error

func (Keeper) IncrementChallengeTrackerInStore

func (k Keeper) IncrementChallengeTrackerInStore(ctx sdk.Context, collectionId sdkmath.Uint, addressForChallenge string, challengeLevel string, 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) IsBound

func (k Keeper) IsBound(ctx sdk.Context, portID string) bool

IsBound checks if the IBC app module is already bound to the desired port

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.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, 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) 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 sdk.Context, params types.Params)

SetParams set the params

func (Keeper) SetPort

func (k Keeper) SetPort(ctx sdk.Context, portID string)

SetPort sets the portID for the IBC app module. Used in InitGenesis

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, 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(oldPermissions []*types.ActionPermission, newPermissions []*types.ActionPermission) error

func (Keeper) ValidateBadgeMetadataUpdate

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

func (Keeper) ValidateBalancesActionPermissionUpdate

func (k Keeper) ValidateBalancesActionPermissionUpdate(oldPermissions []*types.BalancesActionPermission, newPermissions []*types.BalancesActionPermission) 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(oldPermissions []*types.TimedUpdatePermission, newPermissions []*types.TimedUpdatePermission) error

func (Keeper) ValidateTimedUpdateWithBadgeIdsPermissionUpdate

func (k Keeper) ValidateTimedUpdateWithBadgeIdsPermissionUpdate(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