Skip to content

Commit

Permalink
remove expandcollectionapprovals
Browse files Browse the repository at this point in the history
  • Loading branch information
trevormil committed Jan 5, 2024
1 parent f54b528 commit 5dc891f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
2 changes: 1 addition & 1 deletion x/badges/keeper/approved_transfers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 0 additions & 11 deletions x/badges/keeper/transfers_expanders.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
4 changes: 2 additions & 2 deletions x/badges/keeper/update_checks_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5dc891f

Please sign in to comment.