Skip to content

Commit

Permalink
Merge branch 'feat/json-schema' into fix/bug-bash-minor
Browse files Browse the repository at this point in the history
  • Loading branch information
jennieramida committed Aug 29, 2023
2 parents 08b053b + 21ec814 commit 152c350
Show file tree
Hide file tree
Showing 132 changed files with 7,614 additions and 1,073 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

- [#492](https://github.com/alleslabs/celatone-frontend/pull/492) Add jsonschema actions on contract detail page
- [#486](https://github.com/alleslabs/celatone-frontend/pull/486) Switch to schema tab when available and prefill,expand,and scroll to the prefill msg
- [#483](https://github.com/alleslabs/celatone-frontend/pull/483) Add json schema functionality to execute page
- [#482](https://github.com/alleslabs/celatone-frontend/pull/482) Add json schema functionality to query page
- [#477](https://github.com/alleslabs/celatone-frontend/pull/477) Add json schema section on code detail page
- [#475](https://github.com/alleslabs/celatone-frontend/pull/475) Add json schema functionality to instantiate contract
- [#472](https://github.com/alleslabs/celatone-frontend/pull/472) Add json schema functionality to migrate contract
- [#461](https://github.com/alleslabs/celatone-frontend/pull/461) Add json schema form
- [#455](https://github.com/alleslabs/celatone-frontend/pull/455) Implement schema store and unit test
- [#453](https://github.com/alleslabs/celatone-frontend/pull/453) Attach schema feature on upload complete
- [#481](https://github.com/alleslabs/celatone-frontend/pull/481) Support Stargaze testnet
- [#471](https://github.com/alleslabs/celatone-frontend/pull/471) Add proposal config, use Hasura admin secret
- [#467](https://github.com/alleslabs/celatone-frontend/pull/467) Dynamic wallet by network, add disableAnyofAddress config
Expand All @@ -52,6 +62,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#505](https://github.com/alleslabs/celatone-frontend/pull/505) Adjust attach funds form label and icon styling for schema section
- [#501](https://github.com/alleslabs/celatone-frontend/pull/501) Add more JSON Schema state, e.g. empty object state, boolean field
- [#502](https://github.com/alleslabs/celatone-frontend/pull/502) Display queried time and add json/schema output switch
- [#500](https://github.com/alleslabs/celatone-frontend/pull/500) Disable estimated fee when input is invalid
- [#498](https://github.com/alleslabs/celatone-frontend/pull/498) Automatically switch to schema tab and show 404 not found error
- [#491](https://github.com/alleslabs/celatone-frontend/pull/491) Improve scrolling into view by delaying scroll function
- [#489](https://github.com/alleslabs/celatone-frontend/pull/489) Improve jsonschema query response UI and fix jsonschema incorrect oneOf behavior
- [#484](https://github.com/alleslabs/celatone-frontend/pull/484) Fix text size consistency in txs message
- [#480](https://github.com/alleslabs/celatone-frontend/pull/480) Update chain registry package and add attach funds in code snippet
- [#478](https://github.com/alleslabs/celatone-frontend/pull/478) Fix pool txs icon and style
Expand All @@ -75,6 +92,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Bug fixes

- [#499](https://github.com/alleslabs/celatone-frontend/pull/499) Fix responsive for icns and add cl pool icon
- [#506](https://github.com/alleslabs/celatone-frontend/pull/506) Fix simulation bugs
- [#504](https://github.com/alleslabs/celatone-frontend/pull/504) Fix response Json schema UI
- [#503](https://github.com/alleslabs/celatone-frontend/pull/503) Fix assets `view more` button in account detail and fix txs row
- [#496](https://github.com/alleslabs/celatone-frontend/pull/496) Fix icns bech32 prefix searchbar display and schema switch highlight on query page
- [#499](https://github.com/alleslabs/celatone-frontend/pull/499) Fix sometimes select widget input not full, manual schema upload max lines, and expand/collapse all chevron
- [#497](https://github.com/alleslabs/celatone-frontend/pull/497) Fix stored codes route and navbar behavior from dev to normal mode
- [#470](https://github.com/alleslabs/celatone-frontend/pull/470) Fix json schema array field default behavior
- [#476](https://github.com/alleslabs/celatone-frontend/pull/476) Fix terra rpc
- [#473](https://github.com/alleslabs/celatone-frontend/pull/473) Fix wording on upload code modal
- [#465](https://github.com/alleslabs/celatone-frontend/pull/465) Fix wrong access queryKey in validator info
Expand Down
1 change: 0 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ const nextConfig = {
"project",
"contract-list",
"past-tx",
"my-code",
"pool",
];

Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
"@emotion/styled": "^11",
"@graphql-codegen/cli": "^2.13.12",
"@graphql-codegen/client-preset": "^1.1.4",
"@rjsf/chakra-ui": "v5.0.0-beta.10",
"@rjsf/core": "v5.0.0-beta.10",
"@rjsf/utils": "v5.0.0-beta.10",
"@rjsf/validator-ajv8": "v5.0.0-beta.10",
"@rx-stream/pipe": "^0.7.1",
"@sentry/nextjs": "7.37.0",
"@tanstack/react-query": "^4.16.1",
Expand All @@ -51,13 +55,15 @@
"big.js": "^6.2.1",
"camelcase": "^7.0.0",
"chain-registry": "^1.19.0",
"chakra-react-select": "^4.7.0",
"cosmjs-types": "^0.7.2",
"dayjs": "^1.11.6",
"framer-motion": "^7.6.12",
"graphql": "^16.6.0",
"graphql-request": "^5.0.0",
"js-base64": "^3.7.4",
"localforage": "^1.10.0",
"lodash": "^4.17.21",
"long": "^5.2.1",
"map-obj": "^5.0.2",
"match-sorter": "^6.3.1",
Expand Down
6 changes: 2 additions & 4 deletions src/lib/app-fns/tx/execute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ interface ExecuteTxParams {
msg: object;
funds: Coin[];
client: SigningCosmWasmClient;
userKey: string;
onTxSucceed?: (userKey: string, activity: Activity) => void;
onTxSucceed?: (activity: Activity) => void;
onTxFailed?: () => void;
}

Expand All @@ -35,7 +34,6 @@ export const executeContractTx = ({
msg,
funds,
client,
userKey,
onTxSucceed,
onTxFailed,
}: ExecuteTxParams): Observable<TxResultRendering> => {
Expand All @@ -47,7 +45,7 @@ export const executeContractTx = ({
}),
({ value: txInfo }) => {
AmpTrack(AmpEvent.TX_SUCCEED);
onTxSucceed?.(userKey, {
onTxSucceed?.({
type: "execute",
action: Object.keys(msg)[0],
sender: address,
Expand Down
3 changes: 2 additions & 1 deletion src/lib/app-fns/tx/submitProposal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import type { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
import type { EncodeObject } from "@cosmjs/proto-signing";
import type { StdFee, logs } from "@cosmjs/stargate";
import { pipe } from "@rx-stream/pipe";
import { capitalize } from "lodash";
import type { Observable } from "rxjs";

import { ExplorerLink } from "lib/components/ExplorerLink";
import { CustomIcon } from "lib/components/icon";
import { AmpEvent, AmpTrack } from "lib/services/amplitude";
import type { HumanAddr, TxResultRendering } from "lib/types";
import { TxStreamPhase } from "lib/types";
import { capitalize, findAttr, formatUFee } from "lib/utils";
import { findAttr, formatUFee } from "lib/utils";

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

Expand Down
114 changes: 61 additions & 53 deletions src/lib/app-fns/tx/upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { DeliverTxResponse, logs, StdFee } from "@cosmjs/stargate";
import { pipe } from "@rx-stream/pipe";
import type { Observable } from "rxjs";

import type { UploadSucceedCallback } from "lib/app-provider";
import { ExplorerLink } from "lib/components/ExplorerLink";
import { CustomIcon } from "lib/components/icon";
import { AmpEvent, AmpTrack } from "lib/services/amplitude";
Expand All @@ -23,7 +24,7 @@ interface UploadTxParams {
fee: StdFee;
memo?: string;
client: SigningCosmWasmClient;
onTxSucceed?: (codeId: number) => void;
onTxSucceed: UploadSucceedCallback;
isMigrate: boolean;
}

Expand Down Expand Up @@ -52,60 +53,67 @@ export const uploadContractTx = ({
};

const codeId = findAttr(mimicLog, "store_code", "code_id") ?? "0";

onTxSucceed?.(parseInt(codeId, 10));
const codeHash = findAttr(mimicLog, "store_code", "code_checksum") ?? "";
const txFee = txInfo.events.find((e) => e.type === "tx")?.attributes[0]
.value;
return {
value: null,
phase: TxStreamPhase.SUCCEED,
receipts: [
{
title: "Code ID",
value: codeId,
html: (
<div style={{ display: "inline-flex", alignItems: "center" }}>
<ExplorerLink type="code_id" value={codeId} openNewTab />
</div>
),
},
{
title: "Tx Hash",
value: txInfo.transactionHash,
html: (
<ExplorerLink
type="tx_hash"
value={txInfo.transactionHash}
openNewTab
/>
),
},
{
title: "Tx Fee",
value: txFee ? formatUFee(txFee) : "N/A",
},
],
receiptInfo: {
header: "Upload Wasm Complete!",
description: (
<>
<span style={{ fontWeight: 700 }}>
{codeName || `${wasmFileName}(${codeId})`}
</span>{" "}
has been uploaded. Would you like to{" "}
{isMigrate ? "migrate" : "instantiate"} your code now?
</>
),
headerIcon: (
<CustomIcon
name="upload-cloud-solid"
boxSize={5}
color="gray.600"
/>
),
},
actionVariant: isMigrate ? "upload-migrate" : "upload",
} as TxResultRendering;
const formattedFee = txFee ? formatUFee(txFee) : "N/A";

onTxSucceed({
codeId: parseInt(codeId, 10).toString(),
codeHash,
codeDisplayName: codeName || `${wasmFileName}(${codeId})`,
txHash: txInfo.transactionHash,
formattedFee,
});

return isMigrate
? ({
value: null,
phase: TxStreamPhase.SUCCEED,
receipts: [
{
title: "Code ID",
value: codeId,
html: (
<div style={{ display: "inline-flex", alignItems: "center" }}>
<ExplorerLink type="code_id" value={codeId} openNewTab />
</div>
),
},
{
title: "Tx Hash",
value: txInfo.transactionHash,
html: (
<ExplorerLink
type="tx_hash"
value={txInfo.transactionHash}
openNewTab
/>
),
},
{
title: "Tx Fee",
value: formattedFee,
},
],
receiptInfo: {
header: "Upload Wasm Complete!",
description: (
<>
<span style={{ fontWeight: 700 }}>
{codeName || `${wasmFileName}(${codeId})`}
</span>{" "}
is has been uploaded. Would you like to migrate your code now?
</>
),
headerIcon: (
<CustomIcon name="upload-cloud" boxSize={5} color="gray.600" />
),
},
actionVariant: "upload-migrate",
} as TxResultRendering)
: // TODO: this is type hack
(null as unknown as TxResultRendering);
}
)().pipe(catchTxError());
};
25 changes: 2 additions & 23 deletions src/lib/app-provider/contexts/app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useModalTheme } from "@cosmos-kit/react";
import { GraphQLClient } from "graphql-request";
import { observer } from "mobx-react-lite";
import type { Dispatch, ReactNode, SetStateAction } from "react";
import type { ReactNode } from "react";
import {
useCallback,
useState,
Expand All @@ -20,13 +20,11 @@ import { HASURA_ADMIN_SECRET, SUPPORTED_CHAIN_IDS } from "env";
import { LoadingOverlay } from "lib/components/LoadingOverlay";
import { NetworkErrorState } from "lib/components/state/NetworkErrorState";
import { DEFAULT_ADDRESS } from "lib/data";
import { useLocalStorage } from "lib/hooks/useLocalStorage";
import {
useCodeStore,
useContractStore,
usePublicProjectStore,
} from "lib/providers/store";
import type { Option } from "lib/types";
import { formatUserKey } from "lib/utils";

interface AppProviderProps {
Expand All @@ -39,10 +37,6 @@ interface AppContextInterface {
chainConfig: ChainConfig;
indexerGraphClient: GraphQLClient;
constants: ProjectConstants;
isExpand: boolean;
isDevMode: Option<boolean>;
setIsExpand: Dispatch<SetStateAction<boolean>>;
setIsDevMode: Dispatch<SetStateAction<Option<boolean>>>;
}

const AppContext = createContext<AppContextInterface>({
Expand All @@ -51,10 +45,6 @@ const AppContext = createContext<AppContextInterface>({
chainConfig: DEFAULT_CHAIN_CONFIG,
indexerGraphClient: new GraphQLClient(DEFAULT_CHAIN_CONFIG.indexer),
constants: PROJECT_CONSTANTS,
isExpand: false,
isDevMode: undefined,
setIsExpand: () => {},
setIsDevMode: () => {},
});

export const AppProvider = observer(({ children }: AppProviderProps) => {
Expand All @@ -66,13 +56,6 @@ export const AppProvider = observer(({ children }: AppProviderProps) => {
const [currentChainName, setCurrentChainName] = useState<string>();
const [currentChainId, setCurrentChainId] = useState("");

// TODO - Revisit localstorage
const [isDevMode, setIsDevMode] = useLocalStorage<Option<boolean>>(
"devMode",
undefined
);
const [isExpand, setIsExpand] = useLocalStorage("navbar", false);

// Remark: this function is only used in useSelectChain. Do not use in other places.
const handleOnChainIdChange = useCallback((newChainId: string) => {
const config = CHAIN_CONFIGS[newChainId];
Expand All @@ -93,12 +76,8 @@ export const AppProvider = observer(({ children }: AppProviderProps) => {
},
}),
constants: PROJECT_CONSTANTS,
isDevMode,
isExpand,
setIsDevMode,
setIsExpand,
};
}, [currentChainId, isDevMode, isExpand, setIsDevMode, setIsExpand]);
}, [currentChainId]);

useEffect(() => {
if (currentChainName) {
Expand Down
1 change: 1 addition & 0 deletions src/lib/app-provider/contexts/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./app";
export * from "./nav";
42 changes: 42 additions & 0 deletions src/lib/app-provider/contexts/nav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type { Dispatch, ReactNode, SetStateAction } from "react";
import { useContext, createContext, useMemo } from "react";

import { useLocalStorage } from "lib/hooks/useLocalStorage";
import type { Option } from "lib/types";

interface NavContextInterface {
isExpand: boolean;
isDevMode: Option<boolean>;
setIsExpand: Dispatch<SetStateAction<boolean>>;
setIsDevMode: Dispatch<SetStateAction<Option<boolean>>>;
}
const NavContext = createContext<NavContextInterface>({
isExpand: false,
isDevMode: undefined,
setIsExpand: () => {},
setIsDevMode: () => {},
});

export const NavProvider = ({ children }: { children: ReactNode }) => {
const [isDevMode, setIsDevMode] = useLocalStorage<Option<boolean>>(
"devMode",
undefined
);
const [isExpand, setIsExpand] = useLocalStorage("navbar", false);

const states = useMemo<NavContextInterface>(
() => ({
isDevMode,
isExpand,
setIsDevMode,
setIsExpand,
}),
[isDevMode, isExpand, setIsDevMode, setIsExpand]
);

return <NavContext.Provider value={states}>{children}</NavContext.Provider>;
};

export const useNavContext = (): NavContextInterface => {
return useContext(NavContext);
};
Loading

0 comments on commit 152c350

Please sign in to comment.