Skip to content

Commit

Permalink
Proper error handling for non existing identity records key from an a…
Browse files Browse the repository at this point in the history
…ddress
  • Loading branch information
kiragpg committed Mar 18, 2024
1 parent 719d955 commit c066abd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions x/gov/keeper/identity_registrar.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,17 @@ func (k Keeper) GetIdRecordsByAddressAndKeys(ctx sdk.Context, address sdk.AccAdd
recordId := sdk.BigEndianToUint64(bz)
record := k.GetIdentityRecordById(ctx, recordId)
if record == nil {
return records, sdkerrors.Wrap(types.ErrInvalidIdentityRecordId, fmt.Sprintf("identity record with specified id does NOT exist: id=%d", recordId))
records = append(records, types.IdentityRecord{
Id: 0,
Address: address.String(),
Key: key,
Value: "",
Date: time.Time{},
Verifiers: []string{},
})
} else {
records = append(records, *record)
}
records = append(records, *record)
}
return records, nil
}
Expand Down Expand Up @@ -485,7 +493,7 @@ func (k Keeper) HandleIdentityRecordsVerifyRequest(ctx sdk.Context, verifier sdk
}
}

if approve == false {
if !approve {
k.DeleteIdRecordsVerifyRequest(ctx, requestId)
return nil
}
Expand Down

0 comments on commit c066abd

Please sign in to comment.