Skip to content

Commit

Permalink
Merge pull request #872 from alleslabs/feat/cfe-393-combine-query-exe…
Browse files Browse the repository at this point in the history
…cute

Feat/cfe 393 combine query execute
  • Loading branch information
evilpeach committed Apr 29, 2024
2 parents 524222f + c56b800 commit b062897
Show file tree
Hide file tree
Showing 36 changed files with 479 additions and 354 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#872](https://github.com/alleslabs/celatone-frontend/pull/872) Change Query/Execute page to Interact Contract
- [#895](https://github.com/alleslabs/celatone-frontend/pull/895) Show collection address and creator on the collection list page

### Bug fixes
Expand Down
4 changes: 1 addition & 3 deletions src/lib/components/ContractSelectSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,7 @@ export const ContractSelectSection = observer(
label: data.label,
});
},
() => {
reset(defaultValues);
}
() => reset(defaultValues)
);

useEffect(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/MobileGuard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const MobileGuard = ({ children }: MobileGuardProps) => {
pathName.includes(`/txs`) ||
pathName.includes(`/blocks`) ||
pathName.includes(`/projects`) ||
pathName.includes(`/query`) ||
pathName.includes(`/interact-contract`) ||
pathName.includes(`/404`) ||
pathName.includes(`/proposals`) ||
pathName.includes(`/nft-collections`) ||
Expand Down
9 changes: 7 additions & 2 deletions src/lib/components/table/contracts/ContractsTableRowCTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
RemoveContractModal,
SaveContractDetailsModal,
} from "lib/components/modal";
import { ContractInteractionTabs } from "lib/types";
import type { ContractInfo, LVPair, Option } from "lib/types";
import { dateFromNow, formatUTC } from "lib/utils";

Expand Down Expand Up @@ -67,12 +68,16 @@ export const ContractsTableRowCTA = ({
justifyContent="flex-end"
onClick={(e) => e.stopPropagation()}
>
<AppLink href={`/execute?contract=${contractInfo.contractAddress}`}>
<AppLink
href={`/interact-contract?selectedType=${ContractInteractionTabs.Execute}&contract=${contractInfo.contractAddress}`}
>
<Button variant="outline-gray" size="sm">
Execute
</Button>
</AppLink>
<AppLink href={`/query?contract=${contractInfo.contractAddress}`}>
<AppLink
href={`/interact-contract?selectedType=${ContractInteractionTabs.Query}&contract=${contractInfo.contractAddress}`}
>
<Button variant="outline-gray" size="sm">
Query
</Button>
Expand Down
10 changes: 8 additions & 2 deletions src/lib/hooks/useRedo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback } from "react";

import { useInternalNavigate } from "lib/app-provider";
import { ContractInteractionTabs } from "lib/types";
import type { Msg, Option } from "lib/types";
import { camelToSnake, libEncode } from "lib/utils";

Expand All @@ -19,8 +20,13 @@ export const useRedo = () => {
if (type === "MsgExecuteContract") {
const encodeMsg = libEncode(JSON.stringify(camelToSnake(msg)));
navigate({
pathname: "/execute",
query: { chainName, contract: msg.contract, msg: encodeMsg },
pathname: "/interact-contract",
query: {
chainName,
selectedType: ContractInteractionTabs.Execute,
contract: msg.contract,
msg: encodeMsg,
},
});
} else if (
type === "MsgInstantiateContract" ||
Expand Down
2 changes: 1 addition & 1 deletion src/lib/layout/mobile/NavDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const NavDrawer = () => {
},
{
name: "Query",
slug: "/query",
slug: "/interact-contract",
icon: "query" as IconKeys,
},
]
Expand Down
9 changes: 2 additions & 7 deletions src/lib/layout/navbar/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,10 @@ export const getDevSubmenuWasm = (isWasm: boolean) =>
icon: "add-new" as IconKeys,
},
{
name: "Query",
slug: "/query",
name: "Query / Execute",
slug: "/interact-contract",
icon: "query" as IconKeys,
},
{
name: "Execute",
slug: "/execute",
icon: "execute" as IconKeys,
},
{
name: "Migrate",
slug: "/migrate",
Expand Down
36 changes: 23 additions & 13 deletions src/lib/pages/contract-details/components/ContractTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
IconButton,
Image,
Text,
Tooltip,
} from "@chakra-ui/react";

import { useInternalNavigate, useMobile } from "lib/app-provider";
Expand All @@ -21,6 +22,7 @@ import {
import { TotalValue } from "lib/components/TotalValue";
import type { Contract } from "lib/services/contract";
import type { ContractLocalInfo } from "lib/stores/contract";
import { ContractInteractionTabs } from "lib/types";
import type {
BechAddr32,
Nullable,
Expand All @@ -32,12 +34,12 @@ import { truncate } from "lib/utils";

interface ContractTopProps {
contractAddress: BechAddr32;

projectInfo: Nullable<ProjectInfo>;
publicInfo: Nullable<PublicContractInfo>;
contract: Contract;
contractLocalInfo: Option<ContractLocalInfo>;
}

export const ContractTop = ({
contractAddress,
projectInfo,
Expand All @@ -52,16 +54,13 @@ export const ContractTop = ({
contractLocalInfo?.name || publicInfo?.name || contract.label;
const projectName = projectInfo?.name;

const goToQuery = () => {
navigate({
pathname: "/query",
query: { ...(contractAddress && { contract: contractAddress }) },
});
};
const goToExecute = () => {
const goToInteractContract = (type: ContractInteractionTabs) => {
navigate({
pathname: "/execute",
query: { ...(contractAddress && { contract: contractAddress }) },
pathname: "/interact-contract",
query: {
selectedType: type,
...(contractAddress && { contract: contractAddress }),
},
});
};

Expand Down Expand Up @@ -237,7 +236,9 @@ export const ContractTop = ({
variant="outline-primary"
w={{ base: "full", md: "auto" }}
leftIcon={<CustomIcon name="query" />}
onClick={goToQuery}
onClick={() =>
goToInteractContract(ContractInteractionTabs.Query)
}
size={{ base: "sm", md: "md" }}
>
Query
Expand All @@ -246,10 +247,19 @@ export const ContractTop = ({
variant="outline-primary"
w={{ base: "full", md: "auto" }}
leftIcon={<CustomIcon name="execute" />}
onClick={goToExecute}
onClick={() => {
goToInteractContract(ContractInteractionTabs.Execute);
}}
size={{ base: "sm", md: "md" }}
isDisabled={isMobile}
>
Execute
{isMobile ? (
<Tooltip label="Sorry, this feature is currently not supported on mobile.">
<span>Execute</span>
</Tooltip>
) : (
"Execute"
)}
</Button>
{!isMobile && (
<Flex>
Expand Down
139 changes: 0 additions & 139 deletions src/lib/pages/execute/index.tsx

This file was deleted.

15 changes: 11 additions & 4 deletions src/lib/pages/instantiate/completed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ExplorerLink } from "lib/components/ExplorerLink";
import { CustomIcon } from "lib/components/icon";
import { TxReceiptRender } from "lib/components/tx";
import WasmPageContainer from "lib/components/WasmPageContainer";
import { ContractInteractionTabs } from "lib/types";
import type { BechAddr32 } from "lib/types";
import { feeFromStr } from "lib/utils";

Expand Down Expand Up @@ -76,8 +77,11 @@ const Completed = ({ txInfo }: CompletedProps) => {
variant="outline-gray"
onClick={() =>
navigate({
pathname: "/execute",
query: { contract: txInfo.contractAddress },
pathname: "/interact-contract",
query: {
selectedType: ContractInteractionTabs.Execute,
contract: txInfo.contractAddress,
},
})
}
>
Expand All @@ -88,8 +92,11 @@ const Completed = ({ txInfo }: CompletedProps) => {
variant="outline-gray"
onClick={() =>
navigate({
pathname: "/query",
query: { contract: txInfo.contractAddress },
pathname: "/interact-contract",
query: {
selectedType: ContractInteractionTabs.Query,
contract: txInfo.contractAddress,
},
})
}
>
Expand Down
Loading

0 comments on commit b062897

Please sign in to comment.