Signal user if the networks are not supported

This commit is contained in:
Andrea Maria Piana 2024-02-12 17:23:58 +00:00
parent 5e905518aa
commit 598e3217ba
2 changed files with 15 additions and 11 deletions

View File

@ -9,9 +9,10 @@ import (
) )
type CheckPermissionsResponse struct { type CheckPermissionsResponse struct {
Satisfied bool `json:"satisfied"` Satisfied bool `json:"satisfied"`
Permissions map[string]*PermissionTokenCriteriaResult `json:"permissions"` Permissions map[string]*PermissionTokenCriteriaResult `json:"permissions"`
ValidCombinations []*AccountChainIDsCombination `json:"validCombinations"` ValidCombinations []*AccountChainIDsCombination `json:"validCombinations"`
NetworksNotSupported bool `json:"networksNotSupported"`
} }
type CheckPermissionToJoinResponse = CheckPermissionsResponse type CheckPermissionToJoinResponse = CheckPermissionsResponse
@ -93,17 +94,19 @@ func calculateRolesAndHighestRole(permissions map[string]*PermissionTokenCriteri
func (c *CheckPermissionsResponse) MarshalJSON() ([]byte, error) { func (c *CheckPermissionsResponse) MarshalJSON() ([]byte, error) {
type CheckPermissionsTypeAlias struct { type CheckPermissionsTypeAlias struct {
Satisfied bool `json:"satisfied"` Satisfied bool `json:"satisfied"`
Permissions map[string]*PermissionTokenCriteriaResult `json:"permissions"` Permissions map[string]*PermissionTokenCriteriaResult `json:"permissions"`
ValidCombinations []*AccountChainIDsCombination `json:"validCombinations"` ValidCombinations []*AccountChainIDsCombination `json:"validCombinations"`
Roles []*HighestRoleResponse `json:"roles"` Roles []*HighestRoleResponse `json:"roles"`
HighestRole *HighestRoleResponse `json:"highestRole"` HighestRole *HighestRoleResponse `json:"highestRole"`
NetworksNotSupported bool `json:"networksNotSupported"`
} }
c.calculateSatisfied() c.calculateSatisfied()
item := &CheckPermissionsTypeAlias{ item := &CheckPermissionsTypeAlias{
Satisfied: c.Satisfied, Satisfied: c.Satisfied,
Permissions: c.Permissions, Permissions: c.Permissions,
ValidCombinations: c.ValidCombinations, ValidCombinations: c.ValidCombinations,
NetworksNotSupported: c.NetworksNotSupported,
} }
rolesAndHighestRole := calculateRolesAndHighestRole(c.Permissions) rolesAndHighestRole := calculateRolesAndHighestRole(c.Permissions)

View File

@ -236,6 +236,7 @@ func (p *DefaultPermissionChecker) CheckPermissions(permissions []*CommunityToke
// if there are no chain IDs that match token criteria chain IDs // if there are no chain IDs that match token criteria chain IDs
// we aren't able to check balances on selected networks // we aren't able to check balances on selected networks
if len(erc20ChainIDsMap) > 0 && len(chainIDsForERC20) == 0 { if len(erc20ChainIDsMap) > 0 && len(chainIDsForERC20) == 0 {
response.NetworksNotSupported = true
return response, nil return response, nil
} }