Skip to content

Commit

Permalink
fix deployment deposit multi denom
Browse files Browse the repository at this point in the history
  • Loading branch information
baktun14 committed Sep 8, 2023
1 parent 7a09464 commit f8ce4be
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import compareAsc from "date-fns/compareAsc";
import { coinToUDenom, uaktToAKT } from "@src/utils/priceUtils";
import { Snackbar } from "../shared/Snackbar";
import { uAktDenom } from "@src/utils/constants";
import { Alert, Box, Checkbox, FormControl, FormControlLabel, InputAdornment, MenuItem, Select, TextField } from "@mui/material";
import { Alert, Box, Checkbox, FormControl, FormControlLabel, InputAdornment, InputLabel, MenuItem, Select, TextField } from "@mui/material";
import { useKeplr } from "@src/context/KeplrWalletProvider";
import { LinkTo } from "../shared/LinkTo";
import { event } from "nextjs-google-analytics";
Expand All @@ -19,6 +19,7 @@ import { denomToUdenom, udenomToDenom } from "@src/utils/mathHelpers";
import { Popup } from "../shared/Popup";
import { useDenomData } from "@src/hooks/useWalletBalance";
import { useUsdcDenom } from "@src/hooks/useDenom";
import { GranteeDepositMenuItem } from "./GranteeDepositMenuItem";

type Props = {
infoText?: string | ReactNode;
Expand Down Expand Up @@ -155,6 +156,8 @@ export const DeploymentDepositModal: React.FunctionComponent<Props> = ({ handleC
onDeploymentDeposit(deposit, depositorAddress);
};

console.log(denom)

return (
<Popup
fullWidth
Expand Down Expand Up @@ -221,7 +224,7 @@ export const DeploymentDepositModal: React.FunctionComponent<Props> = ({ handleC
/>
</FormControl>

<FormControl fullWidth>
<FormControl>
<Controller
control={control}
name="useDepositor"
Expand All @@ -232,7 +235,8 @@ export const DeploymentDepositModal: React.FunctionComponent<Props> = ({ handleC
</FormControl>

{useDepositor && (
<FormControl fullWidth>
<FormControl fullWidth sx={{ marginTop: ".5rem" }}>
<InputLabel id="deposit-grantee-address">Address</InputLabel>
<Controller
control={control}
name="depositorAddress"
Expand All @@ -242,20 +246,12 @@ export const DeploymentDepositModal: React.FunctionComponent<Props> = ({ handleC
}}
render={({ fieldState, field }) => {
return (
<Select {...field} label="Theme" size="small" error={!!fieldState.error}>
<Select {...field} labelId="deposit-grantee-address" label="Address" error={!!fieldState.error}>
{granteeGrants
.filter(x => compareAsc(new Date(), x.authorization.expiration) !== 1)
.filter(x => compareAsc(new Date(), x.authorization.expiration) !== 1 && x.authorization.spend_limit.denom === denom)
.map(grant => (
<MenuItem key={grant.granter} value={grant.granter}>
<Address address={grant.granter} />
&nbsp;&nbsp;&nbsp;
<AKTAmount uakt={coinToUDenom(grant.authorization.spend_limit)} />
AKT &nbsp;
<small>
(Exp:&nbsp;
<FormattedDate value={new Date(grant.expiration)} />
</small>
)
<GranteeDepositMenuItem grant={grant} />
</MenuItem>
))}
</Select>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { ReactNode } from "react";
import { Box, MenuItem } from "@mui/material";
import { Address } from "../shared/Address";
import { FormattedDate } from "react-intl";
import { coinToUDenom } from "@src/utils/priceUtils";
import { GrantType } from "@src/types/grant";
import { AKTAmount } from "../shared/AKTAmount";
import { useDenomData } from "@src/hooks/useWalletBalance";

type Props = {
grant: GrantType;
children?: ReactNode;
};

export const GranteeDepositMenuItem: React.FunctionComponent<Props> = ({ grant }) => {
const denomData = useDenomData(grant.authorization.spend_limit.denom);

return (
<Box sx={{ fontSize: ".9rem" }}>
<Address address={grant.granter} />
&nbsp;|&nbsp;
<AKTAmount uakt={coinToUDenom(grant.authorization.spend_limit)} />
&nbsp;
{denomData?.label}
&nbsp;
<small>
(Exp:&nbsp;
<FormattedDate value={new Date(grant.expiration)} />
</small>
)
</Box>
);
};
6 changes: 3 additions & 3 deletions deploy-web/src/pages/settings/authorizations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NextSeo } from "next-seo";
import PageContainer from "@src/components/shared/PageContainer";
import SettingsLayout, { SettingsTabs } from "@src/components/settings/SettingsLayout";
import { Fieldset } from "@src/components/shared/Fieldset";
import { Box, Button, CircularProgress, Table, TableBody, TableCell, TableContainer, TableRow } from "@mui/material";
import { Box, Button, CircularProgress, Table, TableBody, TableCell, TableContainer, TableRow, Typography } from "@mui/material";
import { useState } from "react";
import { useKeplr } from "@src/context/KeplrWalletProvider";
import { CustomTableHeader } from "@src/components/shared/CustomTable";
Expand Down Expand Up @@ -100,7 +100,7 @@ const SettingsSecurityPage: React.FunctionComponent<Props> = ({}) => {
</Table>
</TableContainer>
) : (
<p>No authorizations given</p>
<Typography variant="caption">No authorizations given.</Typography>
)}
</>
)}
Expand Down Expand Up @@ -132,7 +132,7 @@ const SettingsSecurityPage: React.FunctionComponent<Props> = ({}) => {
</Table>
</TableContainer>
) : (
<p>No authorizations received</p>
<Typography variant="caption">No authorizations received.</Typography>
)}
</>
)}
Expand Down

0 comments on commit f8ce4be

Please sign in to comment.