Skip to content

Commit

Permalink
fix: include grantedBy in fetch allowances query (#382)
Browse files Browse the repository at this point in the history
Prevent PHANTOM_READ conflicts
  • Loading branch information
sentientforest authored Sep 30, 2024
1 parent e04dcf0 commit c360a5f
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions chaincode/src/allowances/fetchAllowances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,24 @@ export async function fetchAllowances(
data.type,
data.additionalKey,
data.instance,
data.allowanceType?.toString()
data.allowanceType?.toString(),
data.grantedBy
);

const getObjectsResponse = await getObjectsByPartialCompositeKey(
const getObjectsResponse: TokenAllowance[] = await getObjectsByPartialCompositeKey(
ctx,
TokenAllowance.INDEX_KEY,
queryParams,
TokenAllowance
);

const results = filterByGrantedBy(getObjectsResponse, data.grantedBy);
// ChainKeys 0 through 7 already provided, `grantedBy` included in query, skip filtering
if (queryParams.length >= 8) {
sort(getObjectsResponse);
return getObjectsResponse;
}

const results: TokenAllowance[] = filterByGrantedBy(getObjectsResponse, data.grantedBy);
sort(results);

return results;
Expand Down

0 comments on commit c360a5f

Please sign in to comment.