Skip to content

Commit

Permalink
fix(wallet): authz pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
baktun14 authored Oct 18, 2024
1 parent 51b5af0 commit 6193df5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion apps/deploy-web/src/components/layout/WalletStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function WalletStatus() {
)}
</div>

{(isManaged && isTrialing) || (!isManaged && <div className="px-2">|</div>)}
{((isManaged && isTrialing) || !isManaged) && <div className="px-2">|</div>}

<div className="text-xs">
<FormattedNumber
Expand Down
22 changes: 11 additions & 11 deletions apps/deploy-web/src/queries/useGrantsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import axios from "axios";

import { useSettings } from "@src/context/SettingsProvider";
import { AllowanceType, GrantType } from "@src/types/grant";
import { ApiUrlService } from "@src/utils/apiUtils";
import { ApiUrlService, loadWithPagination } from "@src/utils/apiUtils";
import { QueryKeys } from "./queryKeys";

async function getGranterGrants(apiEndpoint: string, address: string) {
if (!address || !apiEndpoint) return undefined;

const response = await axios.get(ApiUrlService.granterGrants(apiEndpoint, address));
const filteredGrants = response.data.grants.filter(
const grants = await loadWithPagination<GrantType[]>(ApiUrlService.granterGrants(apiEndpoint, address), "grants", 1000);
const filteredGrants = grants.filter(
x =>
x.authorization["@type"] === "/akash.deployment.v1beta2.DepositDeploymentAuthorization" ||
x.authorization["@type"] === "/akash.deployment.v1beta3.DepositDeploymentAuthorization"
);

return filteredGrants as GrantType[];
return filteredGrants;
}

export function useGranterGrants(address: string, options = {}) {
Expand All @@ -28,16 +28,16 @@ export function useGranterGrants(address: string, options = {}) {
async function getGranteeGrants(apiEndpoint: string, address: string) {
if (!address || !apiEndpoint) return undefined;

const response = await axios.get(ApiUrlService.granteeGrants(apiEndpoint, address));
const filteredGrants = response.data.grants.filter(
const grants = await loadWithPagination<GrantType[]>(ApiUrlService.granteeGrants(apiEndpoint, address), "grants", 1000);
const filteredGrants = grants.filter(
x =>
// TODO: this is not working
// Only the v1beta3 authorization are working
// x.authorization["@type"] === "/akash.deployment.v1beta2.DepositDeploymentAuthorization" ||
x.authorization["@type"] === "/akash.deployment.v1beta3.DepositDeploymentAuthorization"
);

return filteredGrants as GrantType[];
return filteredGrants;
}

export function useGranteeGrants(address: string, options = {}) {
Expand All @@ -49,9 +49,9 @@ export function useGranteeGrants(address: string, options = {}) {
async function getAllowancesIssued(apiEndpoint: string, address: string) {
if (!address || !apiEndpoint) return undefined;

const response = await axios.get(ApiUrlService.allowancesIssued(apiEndpoint, address));
const allowances = await loadWithPagination<AllowanceType[]>(ApiUrlService.allowancesIssued(apiEndpoint, address), "allowances", 1000);

return response.data.allowances as AllowanceType[];
return allowances;
}

export function useAllowancesIssued(address: string, options = {}) {
Expand All @@ -63,9 +63,9 @@ export function useAllowancesIssued(address: string, options = {}) {
async function getAllowancesGranted(apiEndpoint: string, address: string) {
if (!address || !apiEndpoint) return undefined;

const response = await axios.get(ApiUrlService.allowancesGranted(apiEndpoint, address));
const allowances = await loadWithPagination<AllowanceType[]>(ApiUrlService.allowancesGranted(apiEndpoint, address), "allowances", 1000);

return response.data.allowances as AllowanceType[];
return allowances;
}

export function useAllowancesGranted(address?: string, options = {}): QueryObserverResult<AllowanceType[]> {
Expand Down

0 comments on commit 6193df5

Please sign in to comment.