From 5dc891f4813594a01b4778e8f79c417de562dead Mon Sep 17 00:00:00 2001 From: Trevor Miller Date: Thu, 4 Jan 2024 20:08:32 -0500 Subject: [PATCH] remove expandcollectionapprovals --- x/badges/keeper/approved_transfers.go | 2 +- x/badges/keeper/transfers_expanders.go | 11 ----------- x/badges/keeper/update_checks_helpers.go | 4 ++-- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/x/badges/keeper/approved_transfers.go b/x/badges/keeper/approved_transfers.go index 49a58ae..710eef9 100644 --- a/x/badges/keeper/approved_transfers.go +++ b/x/badges/keeper/approved_transfers.go @@ -85,7 +85,7 @@ func (k Keeper) DeductAndGetUserApprovals(overallTransferBalances []*types.Balan //HACK: We first expand all transfers to have just a len == 1 AllowedCombination[] so that we can easily check IsApproved later // This is because GetFirstMatchOnly will break down the transfers into smaller parts and without expansion, fetching if a certain transfer is allowed is impossible. - expandedApprovals := ExpandCollectionApprovals(approvals) + expandedApprovals := approvals unhandled := []*types.UniversalPermissionDetails{} for _, badgeId := range badgeIds { for _, time := range times { diff --git a/x/badges/keeper/transfers_expanders.go b/x/badges/keeper/transfers_expanders.go index 34cc628..ecebe39 100644 --- a/x/badges/keeper/transfers_expanders.go +++ b/x/badges/keeper/transfers_expanders.go @@ -7,17 +7,6 @@ import ( "github.com/bitbadges/bitbadgeschain/x/badges/types" ) -// Little hack to make AllowedCombinations a 1-element array so we know if disallowed/allowed for ArbitraryValue -func ExpandCollectionApprovals(approvals []*types.CollectionApproval) []*types.CollectionApproval { - newCurrApprovals := []*types.CollectionApproval{} - //TODO: delete this; relic of old interface design - for _, approval := range approvals { - newCurrApprovals = append(newCurrApprovals, approval) - } - - return newCurrApprovals -} - // By default, we approve all transfers if to === initiatedBy func AppendDefaultForIncoming(currApprovals []*types.UserIncomingApproval, userAddress string) []*types.UserIncomingApproval { currApprovals = append([]*types.UserIncomingApproval{ diff --git a/x/badges/keeper/update_checks_helpers.go b/x/badges/keeper/update_checks_helpers.go index 7c88223..8fb43b4 100644 --- a/x/badges/keeper/update_checks_helpers.go +++ b/x/badges/keeper/update_checks_helpers.go @@ -194,8 +194,8 @@ func (k Keeper) GetDetailsToCheck(ctx sdk.Context, collection *types.BadgeCollec //This is a little different from the other functions because it is not first match only //Expand all collection approved transfers so that they are manipulated according to options and approvalCriteria / allowedCombinations are len 1 - oldApprovals := ExpandCollectionApprovals(oldValue.([]*types.CollectionApproval)) - newApprovals := ExpandCollectionApprovals(newValue.([]*types.CollectionApproval)) + oldApprovals := oldValue.([]*types.CollectionApproval) + newApprovals := newValue.([]*types.CollectionApproval) //Step 1: Merge so we get approvalCriteria arrays of proper length such that it is first match and each (to, from, init, time, ids, ownershipTimes) is only seen once //Step 2: Compare as we had previously