Skip to content

Commit

Permalink
fix: disable grantee grants temporarily
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrishajev committed Dec 27, 2024
1 parent 36a084f commit 1a992c1
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
9 changes: 1 addition & 8 deletions apps/deploy-web/src/components/layout/CreditCardBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { useWallet } from "@src/context/WalletProvider/WalletProvider";
import { ConnectManagedWalletButton } from "../wallet/ConnectManagedWalletButton";

export function CreditCardBanner() {
const { hasManagedWallet } = useWallet();

return (
<div className="fixed top-0 z-10 flex h-[40px] w-full items-center justify-center bg-primary px-3 py-2 md:space-x-4">
<span className="text-xs font-semibold text-white md:text-sm">Credit Card payments are now available!</span>

{!hasManagedWallet && <ConnectManagedWalletButton className="flex-shrink-0 text-white hover:text-white" size="sm" variant="text" />}
<span className="text-xs font-semibold text-white md:text-sm">Console is experiencing issues causing balance not being reflected accurately</span>
</div>
);
}
33 changes: 19 additions & 14 deletions apps/deploy-web/src/queries/useBalancesQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import axios from "axios";
import { UAKT_DENOM } from "@src/config/denom.config";
import { getUsdcDenom } from "@src/hooks/useDenom";
import { Balances } from "@src/types";
import { RestApiAuthzGrantsResponseType, RestApiBalancesResponseType } from "@src/types";
import { RestApiBalancesResponseType } from "@src/types";
import { RpcDeployment } from "@src/types/deployment";
import { ApiUrlService, loadWithPagination } from "@src/utils/apiUtils";
import { deploymentToDto } from "@src/utils/deploymentDetailUtils";
Expand All @@ -17,23 +17,28 @@ async function getBalances(apiEndpoint: string, address?: string): Promise<Balan
const usdcIbcDenom = getUsdcDenom();

const balancePromise = axios.get<RestApiBalancesResponseType>(ApiUrlService.balance(apiEndpoint, address));
const authzBalancePromise = axios.get<RestApiAuthzGrantsResponseType>(ApiUrlService.granteeGrants(apiEndpoint, address));
// const authzBalancePromise = axios.get<RestApiAuthzGrantsResponseType>(ApiUrlService.granteeGrants(apiEndpoint, address));
const activeDeploymentsPromise = loadWithPagination<RpcDeployment[]>(ApiUrlService.deploymentList(apiEndpoint, address, true), "deployments", 1000);

const [balanceResponse, authzBalanceResponse, activeDeploymentsResponse] = await Promise.all([balancePromise, authzBalancePromise, activeDeploymentsPromise]);
const [balanceResponse, activeDeploymentsResponse] = await Promise.all([balancePromise, activeDeploymentsPromise]);

// Authz Grants
const deploymentGrants = authzBalanceResponse.data.grants.filter(
b => b.authorization["@type"] === "/akash.deployment.v1beta3.DepositDeploymentAuthorization"
);
const deploymentGrantsUAKT = parseFloat(
deploymentGrants.find(b => b.authorization.spend_limit.denom === UAKT_DENOM)?.authorization.spend_limit.amount || "0"
);

const deploymentGrantsUUSDC = parseFloat(
deploymentGrants.find(b => b.authorization.spend_limit.denom === usdcIbcDenom)?.authorization.spend_limit.amount || "0"
);
// const deploymentGrants = authzBalanceResponse.data.grants.filter(
// b => b.authorization["@type"] === "/akash.deployment.v1beta3.DepositDeploymentAuthorization"
// );
// const deploymentGrants = authzBalanceResponse.data.grants.filter(
// b => b.authorization["@type"] === "/akash.deployment.v1beta3.DepositDeploymentAuthorization"
// );
// const deploymentGrantsUAKT = parseFloat(
// deploymentGrants.find(b => b.authorization.spend_limit.denom === UAKT_DENOM)?.authorization.spend_limit.amount || "0"
// );
//
// const deploymentGrantsUUSDC = parseFloat(
// deploymentGrants.find(b => b.authorization.spend_limit.denom === usdcIbcDenom)?.authorization.spend_limit.amount || "0"
// );
const deploymentGrantsUAKT = 0;

const deploymentGrantsUUSDC = 0;
// Balance
const balanceData = balanceResponse.data;
const balanceUAKT =
Expand All @@ -60,7 +65,7 @@ async function getBalances(apiEndpoint: string, address?: string): Promise<Balan
deploymentGrantsUAKT,
deploymentGrantsUUSDC,
activeDeployments,
deploymentGrants
deploymentGrants: []
};
}

Expand Down
3 changes: 2 additions & 1 deletion apps/deploy-web/src/queries/useGrantsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export function useGranterGrants(address: string, options = {}) {
async function getGranteeGrants(apiEndpoint: string, address: string) {
if (!address || !apiEndpoint) return undefined;

const grants = await loadWithPagination<GrantType[]>(ApiUrlService.granteeGrants(apiEndpoint, address), "grants", 1000);
// const grants = await loadWithPagination<GrantType[]>(ApiUrlService.granteeGrants(apiEndpoint, address), "grants", 1000);
const grants: GrantType[] = [];
const filteredGrants = grants.filter(
x =>
// TODO: this is not working
Expand Down
8 changes: 5 additions & 3 deletions packages/http-sdk/src/authz/authz-http.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ export class AuthzHttpService extends HttpService {
}
}

async getDepositDeploymentGrantsForGrantee(address: string) {
const response = this.extractData(await this.get<DepositDeploymentGrantResponse>(`cosmos/authz/v1beta1/grants/grantee/${address}`));
return response.grants.filter(grant => this.isValidDepositDeploymentGrant(grant));
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async getDepositDeploymentGrantsForGrantee(address: string): Promise<DepositDeploymentGrantResponse['grants']> {
// const response = this.extractData(await this.get<DepositDeploymentGrantResponse>(`cosmos/authz/v1beta1/grants/grantee/${address}`));
// return response.grants.filter(grant => this.isValidDepositDeploymentGrant(grant));
return []
}

async getDepositDeploymentGrantsForGranterAndGrantee(granter: string, grantee: string): Promise<ExactDepositDeploymentGrant | undefined> {
Expand Down

0 comments on commit 1a992c1

Please sign in to comment.