Skip to content

Commit 0280e58

Browse files
authored
fix(wallet): crash when spend limit not set
(#651)
1 parent 68063f1 commit 0280e58

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

apps/deploy-web/src/components/authorizations/AllowanceGrantedRow.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type Props = {
1616
};
1717

1818
export const AllowanceGrantedRow: React.FunctionComponent<Props> = ({ allowance, selected, onSelect }) => {
19-
const limit = allowance?.allowance.spend_limit[0];
19+
const limit = allowance?.allowance?.spend_limit?.[0];
2020
return (
2121
<TableRow className="[&>td]:px-2 [&>td]:py-1">
2222
<TableCell>
@@ -25,8 +25,13 @@ export const AllowanceGrantedRow: React.FunctionComponent<Props> = ({ allowance,
2525
<TableCell>{getAllowanceTitleByType(allowance)}</TableCell>
2626
<TableCell>{allowance.granter && <Address address={allowance.granter} isCopyable />}</TableCell>
2727
<TableCell>
28-
{limit && <AKTAmount uakt={coinToUDenom(limit)} />}
29-
{limit && "AKT"}
28+
{limit ? (
29+
<>
30+
<AKTAmount uakt={coinToUDenom(limit)} /> AKT
31+
</>
32+
) : (
33+
<span>Unlimited</span>
34+
)}
3035
</TableCell>
3136
<TableCell align="right">{<FormattedTime year="numeric" month={"numeric"} day={"numeric"} value={allowance.allowance.expiration} />}</TableCell>
3237
</TableRow>

apps/deploy-web/src/components/authorizations/AllowanceIssuedRow.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,22 @@ type Props = {
1919
};
2020

2121
export const AllowanceIssuedRow: React.FunctionComponent<Props> = ({ allowance, checked, onEditAllowance, setDeletingAllowance, onSelectAllowance }) => {
22+
const limit = allowance?.allowance?.spend_limit?.[0];
23+
2224
return (
2325
<TableRow className="[&>td]:px-2 [&>td]:py-1">
2426
<TableCell>{getAllowanceTitleByType(allowance)}</TableCell>
2527
<TableCell align="center">
2628
<Address address={allowance.grantee} isCopyable />
2729
</TableCell>
2830
<TableCell align="center">
29-
<AKTAmount uakt={coinToUDenom(allowance.allowance.spend_limit[0])} /> AKT
31+
{limit ? (
32+
<>
33+
<AKTAmount uakt={coinToUDenom(limit)} /> AKT
34+
</>
35+
) : (
36+
<span>Unlimited</span>
37+
)}
3038
</TableCell>
3139
<TableCell align="center">
3240
<FormattedTime year="numeric" month={"numeric"} day={"numeric"} value={allowance.allowance.expiration} />

apps/deploy-web/src/components/authorizations/GranteeRow.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,22 @@ type Props = {
1414
};
1515

1616
export const GranteeRow: React.FunctionComponent<Props> = ({ grant }) => {
17-
const denomData = useDenomData(grant.authorization.spend_limit.denom);
17+
const limit = grant?.authorization?.spend_limit;
18+
const denomData = limit ? useDenomData(limit.denom) : null;
1819

1920
return (
2021
<TableRow className="[&>td]:px-2 [&>td]:py-1">
2122
<TableCell>
2223
<Address address={grant.granter} isCopyable />
2324
</TableCell>
2425
<TableCell align="right">
25-
<AKTAmount uakt={coinToUDenom(grant.authorization.spend_limit)} /> {denomData?.label}
26+
{limit ? (
27+
<>
28+
<AKTAmount uakt={coinToUDenom(limit)} /> {denomData?.label}
29+
</>
30+
) : (
31+
<span>Unlimited</span>
32+
)}
2633
</TableCell>
2734
<TableCell align="right">
2835
<FormattedTime year="numeric" month={"numeric"} day={"numeric"} value={grant.expiration} />

0 commit comments

Comments
 (0)