Skip to content

Commit

Permalink
fix: changelog conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
poomthiti committed Feb 2, 2023
2 parents 29a9a47 + 047ab7d commit 6a400b6
Show file tree
Hide file tree
Showing 124 changed files with 3,482 additions and 2,562 deletions.
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Features

- [#93](https://github.com/alleslabs/celatone-frontend/pull/93) Add filter code by instantiate permission in all codes page
- [#141](https://github.com/alleslabs/celatone-frontend/pull/141) Add 404 not found page, catch network params error
- [#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
- [#112](https://github.com/alleslabs/celatone-frontend/pull/112) Refactor past transactions page, support new messages including Migration, Instantiate2, Update Admin, Clear Admin, and change filter actions to dropdown selection. Add redo modal for instantiate2 and create component for tokens used in past tx page.
- [#113](https://github.com/alleslabs/celatone-frontend/pull/113) Update admin page ui and wireup
- [#98](https://github.com/alleslabs/celatone-frontend/pull/98) Add migrate, update admin, clear admin menu on contract list and detail
- [#121](https://github.com/alleslabs/celatone-frontend/pull/121) Fix code snippet for query axios
- [#102](https://github.com/alleslabs/celatone-frontend/pull/102) Add quick menu in overview and add highlighted in left sidebar
- [#125](https://github.com/alleslabs/celatone-frontend/pull/125) Add connect wallet alert in instantiate page
- [#126](https://github.com/alleslabs/celatone-frontend/pull/126) Add port id copier for IBC port id
Expand Down Expand Up @@ -100,6 +107,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#145](https://github.com/alleslabs/celatone-frontend/pull/145/) Disable closing on some modal when click on modal overlay.
- [#147](https://github.com/alleslabs/celatone-frontend/pull/147) Add empty state for select code modal
- [#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
- [#115](https://github.com/alleslabs/celatone-frontend/pull/115) (Contract Details Page) Show no admin and correctly handle explorer link by address type
Expand All @@ -111,6 +124,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [#137](https://github.com/alleslabs/celatone-frontend/pull/137) Throw error instead of returning undefined in query function
- [#148](https://github.com/alleslabs/celatone-frontend/pull/148) Fix scrolling to table header on first land
- [#146](https://github.com/alleslabs/celatone-frontend/pull/146) Fix contract select always fetch when theres no contract address, edit query keys
- [#143](https://github.com/alleslabs/celatone-frontend/pull/143) Use dummy address only when getting execute cmds
- [#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
- [#124](https://github.com/alleslabs/celatone-frontend/pull/124) Fix public project query, display project image in contract details page
- [#125](https://github.com/alleslabs/celatone-frontend/pull/125) Fix incorrect CosmJS execute snippet
- [#117](https://github.com/alleslabs/celatone-frontend/pull/117) Fix native token label formatting
Expand Down
3 changes: 3 additions & 0 deletions src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export const getMainnetApiPath = (chainId: string) => {
case "osmo-test-4":
case "osmosis-1":
return "osmosis-1";
case "pisco-1":
case "phoenix-1":
return "phoenix-1";
default:
return undefined;
}
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
85 changes: 85 additions & 0 deletions src/lib/app-fns/tx/migrate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { Icon } from "@chakra-ui/react";
import type {
MigrateResult,
SigningCosmWasmClient,
} from "@cosmjs/cosmwasm-stargate";
import type { StdFee } from "@cosmjs/stargate";
import { pipe } from "@rx-stream/pipe";
import { MdCheckCircle } from "react-icons/md";
import type { Observable } from "rxjs";

import { ExplorerLink } from "lib/components/ExplorerLink";
import type { ContractAddr, TxResultRendering } from "lib/types";
import { TxStreamPhase } from "lib/types";
import { formatUFee } from "lib/utils";

import { catchTxError } from "./common/catchTxError";
import { postTx } from "./common/post";
import { sendingTx } from "./common/sending";

interface MigrateTxParams {
sender: string;
contractAddress: ContractAddr;
codeId: number;
migrateMsg: object;
fee: StdFee;
client: SigningCosmWasmClient;
onTxSucceed?: (txHash: string) => void;
onTxFailed?: () => void;
}

export const migrateContractTx = ({
sender,
contractAddress,
codeId,
migrateMsg,
fee,
client,
onTxSucceed,
onTxFailed,
}: MigrateTxParams): Observable<TxResultRendering> => {
return pipe(
sendingTx(fee),
postTx<MigrateResult>({
postFn: () =>
client.migrate(
sender,
contractAddress,
codeId,
migrateMsg,
fee,
undefined
),
}),
({ value: txInfo }) => {
onTxSucceed?.(txInfo.transactionHash);
return {
value: null,
phase: TxStreamPhase.SUCCEED,
receipts: [
{
title: "Tx Hash",
value: txInfo.transactionHash,
html: (
<ExplorerLink type="tx_hash" value={txInfo.transactionHash} />
),
},
{
title: "Tx Fee",
value: `${formatUFee(
txInfo.events.find((e) => e.type === "tx")?.attributes[0].value ??
"0u"
)}`,
},
],
receiptInfo: {
header: "Migration Completed",
headerIcon: (
<Icon as={MdCheckCircle} fontSize="24px" color="success.main" />
),
},
actionVariant: "migrate",
} as TxResultRendering;
}
)().pipe(catchTxError(onTxFailed));
};
8 changes: 5 additions & 3 deletions src/lib/app-fns/tx/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface UploadTxParams {
memo?: string;
client: SigningCosmWasmClient;
onTxSucceed?: (codeId: number) => void;
isMigrate: boolean;
}

export const uploadContractTx = ({
Expand All @@ -37,6 +38,7 @@ export const uploadContractTx = ({
memo,
client,
onTxSucceed,
isMigrate,
}: UploadTxParams): Observable<TxResultRendering> => {
return pipe(
sendingTx(fee),
Expand Down Expand Up @@ -80,15 +82,15 @@ export const uploadContractTx = ({
<span style={{ fontWeight: 700 }}>
{codeDesc || `${wasmFileName}(${txInfo.codeId})`}
</span>{" "}
is available on your stored code. Would you like to instantiate
your code now?
is available on your stored code. Would you like to{" "}
{isMigrate ? "migrate" : "instantiate"} your code now?
</>
),
headerIcon: (
<Icon as={MdCloudUpload} fontSize="24px" color="text.dark" />
),
},
actionVariant: "upload",
actionVariant: isMigrate ? "upload-migrate" : "upload",
} as TxResultRendering;
}
)().pipe(catchTxError());
Expand Down
20 changes: 4 additions & 16 deletions src/lib/app-provider/contexts/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@ import { useWallet } from "@cosmos-kit/react";
import big from "big.js";
import { GraphQLClient } from "graphql-request";
import { observer } from "mobx-react-lite";
import { useRouter } from "next/router";
import type { ReactNode } from "react";
import { useEffect, useContext, useMemo, createContext } from "react";

import { useNetworkChange } from "../hooks/useNetworkChange";
import { getIndexerGraphClient } from "../query-client";
import type { AppConstants } from "../types";
import {
getExplorerTxUrl,
getExplorerUserAddressUrl,
} from "lib/app-fns/explorer";
import { LoadingOverlay } from "lib/components/LoadingOverlay";
import { DEFAULT_ADDRESS, getChainNameByNetwork } from "lib/data";
import { DEFAULT_ADDRESS } from "lib/data";
import {
useCodeStore,
useContractStore,
Expand Down Expand Up @@ -64,8 +64,7 @@ export const AppProvider = <ContractAddress, Constants extends AppConstants>({
appContractAddressMap,
constants,
}: AppProviderProps<ContractAddress, Constants>) => {
const router = useRouter();
const { currentChainName, currentChainRecord, setCurrentChain } = useWallet();
const { currentChainName, currentChainRecord } = useWallet();
const { setCodeUserKey, isCodeUserKeyExist } = useCodeStore();
const { setContractUserKey, isContractUserKeyExist } = useContractStore();
const { setProjectUserKey, isProjectUserKeyExist } = usePublicProjectStore();
Expand Down Expand Up @@ -120,18 +119,7 @@ export const AppProvider = <ContractAddress, Constants extends AppConstants>({
}
}, [currentChainName, setCodeUserKey, setContractUserKey, setProjectUserKey]);

useEffect(() => {
/**
* @remarks Condition checking varies by chain
* @todos Change default to mainnet later (currently is testnet)
* @todos Support localnet case later
*/
if (router.query.network === "mainnet") {
setCurrentChain(getChainNameByNetwork("mainnet"));
} else {
setCurrentChain(getChainNameByNetwork("testnet"));
}
}, [router.query.network, setCurrentChain]);
useNetworkChange();

const AppContent = observer(() => {
if (
Expand Down
1 change: 1 addition & 0 deletions src/lib/app-provider/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from "./useQueryCmds";
export * from "./useExecuteCmds";
export * from "./useTokensInfo";
export * from "./useInternalNavigate";
export * from "./useNetworkChange";
9 changes: 3 additions & 6 deletions src/lib/app-provider/hooks/useExecuteCmds.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useWallet } from "@cosmos-kit/react";
import { useState } from "react";

import { useSimulateFeeQuery } from "../queries";
Expand All @@ -9,16 +8,14 @@ import { composeMsg } from "lib/utils";

export const useExecuteCmds = (contractAddress: ContractAddr) => {
const [execCmds, setExecCmds] = useState<[string, string][]>([]);
const { address } = useWallet();
const { dummyAddress } = useDummyWallet();

const userAddress = address || dummyAddress;

const { isFetching } = useSimulateFeeQuery({
enabled: !!contractAddress && !!userAddress,
isDummyUser: true,
enabled: !!contractAddress && !!dummyAddress,
messages: [
composeMsg(MsgType.EXECUTE, {
sender: (address || dummyAddress) as HumanAddr,
sender: dummyAddress as HumanAddr,
contract: contractAddress as ContractAddr,
msg: Buffer.from('{"": {}}'),
funds: [],
Expand Down
31 changes: 31 additions & 0 deletions src/lib/app-provider/hooks/useNetworkChange.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { useWallet } from "@cosmos-kit/react";
import { useRouter } from "next/router";
import { useEffect, useRef } from "react";

import { getChainNameByNetwork } from "lib/data";

export const useNetworkChange = () => {
const router = useRouter();
const { currentChainName, setCurrentChain } = useWallet();
const networkRef = useRef<string>();

/**
* @todos Change default to mainnet later (currently is testnet)
*/

useEffect(() => {
const networkRoute = (router.query.network as string) || "testnet";

if (networkRoute !== networkRef.current) {
networkRef.current = networkRoute;
try {
const chainName = getChainNameByNetwork(networkRoute);
if (currentChainName !== chainName) setCurrentChain(chainName);
} catch {
/**
* @remarks Allows false chain name, will continue to operate as testnet
*/
}
}
}, [router, currentChainName, setCurrentChain]);
};
20 changes: 11 additions & 9 deletions src/lib/app-provider/queries/simulateFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,40 @@ import type { ComposedMsg, Gas } from "lib/types";
interface SimulateQueryParams {
enabled: boolean;
messages: ComposedMsg[];
isDummyUser?: boolean;
onSuccess?: (gas: Gas<number> | undefined) => void;
onError?: (err: Error) => void;
}

export const useSimulateFeeQuery = ({
enabled,
messages,
isDummyUser,
onSuccess,
onError,
}: SimulateQueryParams) => {
const { address, getCosmWasmClient, currentChainName, currentChainRecord } =
useWallet();
const { dummyWallet, dummyAddress } = useDummyWallet();

const userAddress = address || dummyAddress;
const userAddress = isDummyUser ? dummyAddress : address || dummyAddress;

const simulateFn = async (msgs: ComposedMsg[]) => {
let client = await getCosmWasmClient();
// TODO: revisit this logic
if (!currentChainRecord?.preferredEndpoints?.rpc?.[0] || !userAddress) {
throw new Error("No RPC endpoint or user address");
}

if (!client && !address && dummyWallet) {
client = await SigningCosmWasmClient.connectWithSigner(
currentChainRecord.preferredEndpoints.rpc[0],
dummyWallet
);
}
const client =
dummyWallet && (isDummyUser || !address)
? await SigningCosmWasmClient.connectWithSigner(
currentChainRecord.preferredEndpoints.rpc[0],
dummyWallet
)
: await getCosmWasmClient();

if (!client) {
throw new Error("No client");
throw new Error("Fail to get SigningCosmWasmClient");
}

return (await client.simulate(userAddress, msgs, undefined)) as Gas;
Expand Down
Loading

0 comments on commit 6a400b6

Please sign in to comment.