Skip to content

Commit ea75940

Browse files
committed
Merge branch 'main' into release/v1.0.5v2
2 parents e1db5be + daf3e57 commit ea75940

File tree

6 files changed

+71
-33
lines changed

6 files changed

+71
-33
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3737

3838
## Unreleased
3939

40+
## v1.0.5
41+
4042
### Features
4143

44+
- [#346](https://github.com/alleslabs/celatone-frontend/pull/346) Apply initial condition to my stored codes upload button
4245
- [#327](https://github.com/alleslabs/celatone-frontend/pull/327) Update logic to enable upload wasm code
4346
- [#317](https://github.com/alleslabs/celatone-frontend/pull/317) Add amplitude for proposal list page and pagination
4447

@@ -93,7 +96,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9396

9497
### Improvements
9598

96-
- [#298](https://github.com/alleslabs/celatone-frontend/pull/298) Show deposit/voting period from gov params and add minimum required alert
9799
- [#309](https://github.com/alleslabs/celatone-frontend/pull/309) Add public account name and description in account detail page
98100
- [#289](https://github.com/alleslabs/celatone-frontend/pull/289) Add public accounts to public projects
99101
- [#308](https://github.com/alleslabs/celatone-frontend/pull/308) Adjust view more button to full width and fix empty state layout in contract history

src/lib/layout/navbar/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ const Navbar = observer(({ isExpand, setIsExpand }: NavbarProps) => {
3333
slug: "/past-txs",
3434
icon: "history",
3535
},
36-
{
37-
name: "Proposals",
38-
slug: "/proposals",
39-
icon: "proposal",
40-
},
36+
// {
37+
// name: "Proposals",
38+
// slug: "/proposals",
39+
// icon: "proposal",
40+
// },
4141
// {
4242
// name: "Osmosis Pools",
4343
// slug: "/pools",
Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { Box, Heading, HStack } from "@chakra-ui/react";
2+
import { useWallet } from "@cosmos-kit/react";
23

34
import { MyStoredCodesTable } from "lib/components/table";
4-
import type { CodeInfo } from "lib/types";
5+
import { useUploadAccessParams } from "lib/services/proposalService";
6+
import type { Addr, CodeInfo } from "lib/types";
7+
import { AccessConfigPermission } from "lib/types";
58

69
import { UploadButton } from "./UploadButton";
710

@@ -19,21 +22,31 @@ export const MyStoredCodesSection = ({
1922
onRowSelect,
2023
disconnectedMessage,
2124
isSearching,
22-
}: MyStoredCodesSectionProps) => (
23-
<Box mb={8}>
24-
<HStack alignItems="center" justifyContent="space-between" mb="18px">
25-
<Heading as="h6" variant="h6">
26-
My Stored Codes
27-
</Heading>
28-
<UploadButton />
29-
</HStack>
30-
<MyStoredCodesTable
31-
codes={codes}
32-
isLoading={isLoading}
33-
onRowSelect={onRowSelect}
34-
emptyMessage="Your uploaded Wasm files will display as My Stored Codes."
35-
disconnectedMessage={disconnectedMessage}
36-
isSearching={isSearching}
37-
/>
38-
</Box>
39-
);
25+
}: MyStoredCodesSectionProps) => {
26+
const { data } = useUploadAccessParams();
27+
const { address } = useWallet();
28+
const isAllowed = Boolean(data?.addresses?.includes(address as Addr));
29+
30+
const isPermissionedNetwork =
31+
data?.permission !== AccessConfigPermission.EVERYBODY;
32+
33+
return (
34+
<Box mb={8}>
35+
<HStack alignItems="center" justifyContent="space-between" mb="18px">
36+
<Heading as="h6" variant="h6">
37+
My Stored Codes
38+
</Heading>
39+
{/* TODO: overwrite this logic when merging proposal feature */}
40+
<UploadButton isAllowed={!isPermissionedNetwork || isAllowed} />
41+
</HStack>
42+
<MyStoredCodesTable
43+
codes={codes}
44+
isLoading={isLoading}
45+
onRowSelect={onRowSelect}
46+
emptyMessage="Your uploaded Wasm files will display as My Stored Codes."
47+
disconnectedMessage={disconnectedMessage}
48+
isSearching={isSearching}
49+
/>
50+
</Box>
51+
);
52+
};

src/lib/pages/codes/components/UploadButton.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@ import { Button } from "@chakra-ui/react";
22

33
import { useInternalNavigate } from "lib/app-provider";
44
import { CustomIcon } from "lib/components/icon";
5+
import { Tooltip } from "lib/components/Tooltip";
56

6-
export const UploadButton = () => {
7+
interface UploadButtonProps {
8+
isAllowed: boolean;
9+
}
10+
export const UploadButton = ({ isAllowed }: UploadButtonProps) => {
711
const navigate = useInternalNavigate();
12+
813
return (
9-
<Button
10-
onClick={() => navigate({ pathname: "/upload" })}
11-
leftIcon={<CustomIcon name="plus" boxSize="12px" />}
14+
<Tooltip
15+
label="Only allowed address can upload Wasm file without opening proposal"
16+
isDisabled={isAllowed}
1217
>
13-
Upload New Code
14-
</Button>
18+
<Button
19+
disabled={!isAllowed}
20+
onClick={() => navigate({ pathname: "/upload" })}
21+
rightIcon={<CustomIcon name="upload" boxSize="12px" />}
22+
>
23+
Upload New Code
24+
</Button>
25+
</Tooltip>
1526
);
1627
};

src/lib/pages/proposal/whitelist/index.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { getAlert } from "../utils";
2121
import {
2222
useCurrentNetwork,
2323
useFabricateFee,
24+
useInternalNavigate,
2425
useSimulateFeeQuery,
2526
useSubmitProposalTx,
2627
} from "lib/app-provider";
@@ -88,6 +89,7 @@ const ProposalToWhitelist = () => {
8889
name: "addresses",
8990
});
9091
const { isTestnet } = useCurrentNetwork();
92+
const navigate = useInternalNavigate();
9193

9294
const addressesArray = addresses.map((addressObj) => addressObj.address);
9395
const formErrorsKey = Object.keys(formErrors);
@@ -189,6 +191,11 @@ const ProposalToWhitelist = () => {
189191
submitProposalTx,
190192
]);
191193

194+
useEffect(() => {
195+
// remark: disable proposal whitelist and redirect to home page
196+
navigate({ pathname: "/" });
197+
}, [navigate]);
198+
192199
useEffect(() => {
193200
if (minDeposit)
194201
reset({

src/lib/pages/proposals/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useRouter } from "next/router";
44
import type { ChangeEvent } from "react";
55
import { useState, useEffect } from "react";
66

7-
import { useChainId } from "lib/app-provider";
7+
import { useChainId, useInternalNavigate } from "lib/app-provider";
88
import { NewProposalButton } from "lib/components/button/NewProposalButton";
99
import InputWithIcon from "lib/components/InputWithIcon";
1010
import PageContainer from "lib/components/PageContainer";
@@ -63,9 +63,14 @@ const Proposals = () => {
6363
proposer
6464
);
6565

66+
const navigate = useInternalNavigate();
67+
6668
useEffect(() => {
69+
// remark: disable proposal and redirect to home page
70+
navigate({ pathname: "/" });
71+
6772
if (router.isReady) AmpTrack(AmpEvent.TO_PROPOSAL_LIST);
68-
}, [router.isReady]);
73+
}, [navigate, router.isReady]);
6974

7075
useEffect(() => {
7176
setPageSize(10);

0 commit comments

Comments
 (0)