Skip to content

Commit

Permalink
Merge branch 'develop' into fix/overview-spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
songwongtp committed Feb 1, 2023
2 parents 718a315 + a302a3e commit 8bfe409
Show file tree
Hide file tree
Showing 35 changed files with 218 additions and 98 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased

### Features

- [#134](https://github.com/alleslabs/celatone-frontend/pull/134) Fix un-align sub-page with sidebar
- [#144](https://github.com/alleslabs/celatone-frontend/pull/144) Add `Assign me` for admin address on instantiate form
- [#131](https://github.com/alleslabs/celatone-frontend/pull/131) Add CW2-related information to contract details page
- [#120](https://github.com/alleslabs/celatone-frontend/pull/120) Add simulate migrate fee and the final migration step
- [#108](https://github.com/alleslabs/celatone-frontend/pull/108) Add migrate options on migrate page and upload new code for migration
- [#130](https://github.com/alleslabs/celatone-frontend/pull/130) Add support for Terra public projects
Expand Down Expand Up @@ -102,6 +105,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#140](https://github.com/alleslabs/celatone-frontend/pull/140) Add placeholder texts to upload&instantiate, save code, and save&edit contract
- [#139](https://github.com/alleslabs/celatone-frontend/pull/139) Fix Date to Dayjs
- [#135](https://github.com/alleslabs/celatone-frontend/pull/135) Invalidate queries after update/clear admin tx
- [#123](https://github.com/alleslabs/celatone-frontend/pull/123) Refactor tables to use custom components
- [#128](https://github.com/alleslabs/celatone-frontend/pull/128) Rewrite add to other list state and add default list to save to
- [#114](https://github.com/alleslabs/celatone-frontend/pull/114) Handle wallet connection cases in instantiate button
Expand All @@ -114,6 +120,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#142](https://github.com/alleslabs/celatone-frontend/pull/142) Fix migration table row duplicate and add key to port id render
- [#138](https://github.com/alleslabs/celatone-frontend/pull/138) Remove execute table in contract details page (due to data issue)
- [#136](https://github.com/alleslabs/celatone-frontend/pull/136) Fix decode message from query param in execute page
- [#132](https://github.com/alleslabs/celatone-frontend/pull/132) Fix permission field in upload simulation
- [#121](https://github.com/alleslabs/celatone-frontend/pull/121) Fix code snippet for query axios
- [#129](https://github.com/alleslabs/celatone-frontend/pull/129) Fix wallet disconnection on network query change
Expand Down
4 changes: 2 additions & 2 deletions src/lib/app-fns/tx/clearAdmin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface ClearAdminTxParams {
fee: StdFee;
memo?: string;
client: SigningCosmWasmClient;
onTxSucceed?: (txHash: string) => void;
onTxSucceed?: () => void;
}

export const clearAdminTx = ({
Expand All @@ -40,7 +40,7 @@ export const clearAdminTx = ({
postFn: () => client.clearAdmin(address, contractAddress, fee, memo),
}),
({ value: txInfo }) => {
onTxSucceed?.(txInfo.transactionHash);
onTxSucceed?.();
return {
value: null,
phase: TxStreamPhase.SUCCEED,
Expand Down
3 changes: 2 additions & 1 deletion src/lib/app-fns/tx/execute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
} from "@cosmjs/cosmwasm-stargate";
import type { Coin, StdFee } from "@cosmjs/stargate";
import { pipe } from "@rx-stream/pipe";
import dayjs from "dayjs";
import { MdCheckCircle } from "react-icons/md";
import type { Observable } from "rxjs";

Expand Down Expand Up @@ -52,7 +53,7 @@ export const executeContractTx = ({
sender: address,
contractAddress,
msg: encode(JSON.stringify(msg)), // base64
timestamp: new Date(),
timestamp: dayjs(),
});
return {
value: null,
Expand Down
18 changes: 15 additions & 3 deletions src/lib/app-provider/tx/clearAdmin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useWallet } from "@cosmos-kit/react";
import { useQueryClient } from "@tanstack/react-query";
import { useCallback } from "react";

import { useFabricateFee } from "../hooks";
Expand All @@ -7,11 +8,12 @@ import { CLEAR_ADMIN_GAS } from "lib/data";
import type { ContractAddr } from "lib/types";

export interface ClearAdminStreamParams {
onTxSucceed?: (txHash: string) => void;
onTxSucceed?: () => void;
}

export const useClearAdminTx = (contractAddress: ContractAddr) => {
const { address, getCosmWasmClient } = useWallet();
const queryClient = useQueryClient();
const fabricateFee = useFabricateFee();
const clearAdminFee = fabricateFee(CLEAR_ADMIN_GAS);

Expand All @@ -26,9 +28,19 @@ export const useClearAdminTx = (contractAddress: ContractAddr) => {
contractAddress,
fee: clearAdminFee,
client,
onTxSucceed,
onTxSucceed: () => {
onTxSucceed?.();
Promise.all([
queryClient.invalidateQueries({
queryKey: ["admin_by_contracts"],
}),
queryClient.invalidateQueries({
queryKey: ["query", "instantiate_info"],
}),
]);
},
});
},
[address, clearAdminFee, contractAddress, getCosmWasmClient]
[address, clearAdminFee, queryClient, contractAddress, getCosmWasmClient]
);
};
2 changes: 1 addition & 1 deletion src/lib/components/ContractSelectSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const ContractSelectSection = observer(
});

const { refetch } = useQuery(
["query", "instantiateInfo", endpoint, contractAddress],
["query", "instantiate_info", endpoint, contractAddress],
async () =>
queryInstantiateInfo(endpoint, indexerGraphClient, contractAddress),
{
Expand Down
9 changes: 6 additions & 3 deletions src/lib/components/OffChainForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface OffchainDetail {

interface OffChainFormProps<T extends OffchainDetail> {
state: OffchainDetail;
contractLabel: string;
control: Control<T>;
setTagsValue: (options: string[]) => void;
setContractListsValue: (options: LVPair[]) => void;
Expand All @@ -33,6 +34,7 @@ interface OffChainFormProps<T extends OffchainDetail> {

export const OffChainForm = <T extends OffchainDetail>({
state,
contractLabel,
control,
setTagsValue,
setContractListsValue,
Expand All @@ -45,6 +47,7 @@ export const OffChainForm = <T extends OffchainDetail>({
name={"name" as FieldPath<T>}
control={control}
label="Name"
placeholder={contractLabel}
helperText="Set name for your contract"
variant="floating"
rules={{
Expand All @@ -57,7 +60,7 @@ export const OffChainForm = <T extends OffchainDetail>({
name={"description" as FieldPath<T>}
control={control}
label="Description"
helperText="Help understanding what this contract do and how it works"
placeholder="Help understanding what this contract do and how it works ..."
variant="floating"
rules={{
maxLength: MAX_CONTRACT_DESCRIPTION_LENGTH,
Expand All @@ -71,13 +74,13 @@ export const OffChainForm = <T extends OffchainDetail>({
<TagSelection
result={state.tags}
setResult={setTagsValue}
placeholder="Tags"
placeholder="Select tags or create new ones"
helperText="Add tag to organize and manage your contracts"
labelBgColor={labelBgColor}
/>
<ListSelection
result={state.lists}
placeholder="Add to contract lists"
placeholder="Not listed"
helperText="Grouping your contracts by adding to your existing list or create
a new list"
setResult={setContractListsValue}
Expand Down
26 changes: 14 additions & 12 deletions src/lib/components/forms/ControllerInput.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import {
Flex,
FormControl,
FormErrorMessage,
FormHelperText,
FormLabel,
Input,
InputGroup,
InputRightElement,
Text,
} from "@chakra-ui/react";
import type { ReactNode } from "react";
import type {
Control,
FieldPath,
Expand All @@ -27,6 +28,7 @@ interface ControllerInputProps<T extends FieldValues>
rules?: UseControllerProps["rules"];
status?: FormStatus;
maxLength?: number;
helperAction?: ReactNode;
}

export const ControllerInput = <T extends FieldValues>({
Expand All @@ -42,6 +44,7 @@ export const ControllerInput = <T extends FieldValues>({
rules = {},
status,
maxLength,
helperAction,
...componentProps
}: ControllerInputProps<T>) => {
const watcher = useWatch({
Expand Down Expand Up @@ -83,17 +86,16 @@ export const ControllerInput = <T extends FieldValues>({
{status && getStatusIcon(status.state)}
</InputRightElement>
</InputGroup>
{isError ? (
<FormErrorMessage className="error-text">{error}</FormErrorMessage>
) : (
<FormHelperText className="helper-text">
{status?.message ? (
getResponseMsg(status, helperText)
) : (
<Text color="text.dark">{helperText}</Text>
)}
</FormHelperText>
)}
<Flex gap={1} alignItems="center" mt={1}>
{isError ? (
<FormErrorMessage className="error-text">{error}</FormErrorMessage>
) : (
<FormHelperText className="helper-text">
{status?.message ? getResponseMsg(status, helperText) : helperText}
</FormHelperText>
)}
{helperAction}
</Flex>
</FormControl>
);
};
2 changes: 1 addition & 1 deletion src/lib/components/forms/ListSelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export const ListSelection = forwardRef<HTMLInputElement, ListSelectionProps>(
lineHeight="1.2"
transform="scale(0.75) translateY(-24px)"
>
Add to lists
Listed on
</FormLabel>
</Flex>
<FormHelperText ml={3} mt={1} fontSize="12px" color="text.dark">
Expand Down
8 changes: 5 additions & 3 deletions src/lib/components/modal/code/SaveNewCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function SaveNewCodeModal({ buttonProps }: ModalProps) {
const [codeIdStatus, setCodeIdStatus] = useState<FormStatus>({
state: "init",
});
const [uploader, setUploader] = useState("No Description");
const [uploader, setUploader] = useState("");
const [uploaderStatus, setUploaderStatus] = useState<FormStatus>({
state: "init",
});
Expand Down Expand Up @@ -175,20 +175,21 @@ export function SaveNewCodeModal({ buttonProps }: ModalProps) {
otherBtnTitle="Cancel"
>
<FormControl display="flex" flexDir="column" gap="36px">
Save other stored Codes to your &quot;Saved Codes&quot; list
Save other stored codes to your &ldquo;Saved Codes&rdquo; list
<NumberInput
variant="floating"
value={codeId}
onInputChange={setCodeId}
label="Code ID"
labelBgColor="gray.800"
status={codeIdStatus}
helperText="ex. 1150"
placeholder="ex. 1234"
/>
<TextInput
value={uploader}
label="Uploader"
labelBgColor="gray.800"
placeholder="Uploader address will display here"
setInputState={() => {}}
status={uploaderStatus}
isDisabled
Expand All @@ -199,6 +200,7 @@ export function SaveNewCodeModal({ buttonProps }: ModalProps) {
setInputState={setDescription}
label="Code Description"
labelBgColor="gray.800"
placeholder="No Description"
helperText="Fill in code description to define its use as a reminder"
status={descriptionStatus}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/modal/contract/AddToOtherList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const AddToOtherList = observer(
<Box my="16px">
<ListSelection
result={contractLists}
placeholder="Add to contract lists"
placeholder="Not listed"
helperText="Grouping your contracts by adding to your existing list or create
a new list"
setResult={setContractLists}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/modal/contract/ClearAdminContract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ClearAdminContract = ({
const clearAdminTx = useClearAdminTx(contractAddress);

const proceed = useCallback(async () => {
const stream = await clearAdminTx({ onTxSucceed: () => {} });
const stream = await clearAdminTx({});
if (stream) broadcast(stream);
}, [broadcast, clearAdminTx]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export const ContractDetailsTemplate = ({
>
<OffChainForm<OffchainDetail>
state={offchainState}
contractLabel={contractLocalInfo.label}
control={control}
setTagsValue={setTagsValue}
setContractListsValue={setContractListsValue}
Expand Down
5 changes: 3 additions & 2 deletions src/lib/components/modal/contract/SaveNewContract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function SaveNewContract({ list, buttonProps }: SaveNewContractProps) {

// TODO: Abstract query
const { refetch } = useQuery(
["query", "instantiateInfo", endpoint, contractAddressState],
["query", "instantiate_info", endpoint, contractAddressState],
async () =>
queryInstantiateInfo(
endpoint,
Expand Down Expand Up @@ -194,7 +194,7 @@ export function SaveNewContract({ list, buttonProps }: SaveNewContractProps) {
control={control}
label="Contract Address"
variant="floating"
helperText={`ex. ${exampleContractAddress}`}
placeholder={`ex. ${exampleContractAddress}`}
status={status}
labelBgColor="gray.800"
/>
Expand All @@ -209,6 +209,7 @@ export function SaveNewContract({ list, buttonProps }: SaveNewContractProps) {

<OffChainForm<SaveNewContractDetail>
state={offchainState}
contractLabel={labelState}
control={control}
setTagsValue={setTagsValue}
setContractListsValue={setContractListsValue}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Heading,
} from "@chakra-ui/react";
import { useWallet } from "@cosmos-kit/react";
import dayjs from "dayjs";
import { MdList, MdSwapHoriz } from "react-icons/md";

import { ADMIN_SPECIAL_SLUG } from "lib/data";
Expand Down Expand Up @@ -42,7 +43,7 @@ export const SelectContractAdmin = ({
...contract,
...getContractLocalInfo(contract.contractAddress),
})),
lastUpdated: new Date(),
lastUpdated: dayjs(),
isInfoEditable: false,
isContractRemovable: false,
};
Expand Down
3 changes: 2 additions & 1 deletion src/lib/components/upload/UploadSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ export const UploadSection = ({
name="codeDesc"
control={control}
label="Code Description (Optional)"
helperText="Short description of your code. You can add or change this later."
placeholder="No Description"
helperText="Define what your code works on in one sentence which visible to you only. You can add this later."
rules={{
maxLength: MAX_CODE_DESCRIPTION_LENGTH,
}}
Expand Down
1 change: 1 addition & 0 deletions src/lib/hooks/useAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const validateAddress = (
return null;
};

// TODO: refactor
export const useValidateAddress = () => {
const { currentChainRecord } = useWallet();

Expand Down
Loading

0 comments on commit 8bfe409

Please sign in to comment.