From f439645731d1704ac02c69035da773c433901b71 Mon Sep 17 00:00:00 2001 From: samepant Date: Thu, 17 Feb 2022 11:46:13 -0700 Subject: [PATCH 1/2] adds registry to env and state --- .env.sample | 1 + .gitignore | 1 + README.md | 2 +- components/chainSelect/ChainSelect.js | 9 ++++++--- components/head.js | 2 +- context/AppContext.js | 1 + context/AppReducer.js | 1 + 7 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.env.sample b/.env.sample index cb99d73..62868aa 100644 --- a/.env.sample +++ b/.env.sample @@ -6,6 +6,7 @@ NEXT_PUBLIC_DISPLAY_DENOM_EXPONENT=6 NEXT_PUBLIC_GAS_PRICE=0.03uatom NEXT_PUBLIC_CHAIN_ID=cosmoshub-4 NEXT_PUBLIC_ADDRESS_PREFIX=cosmos +NEXT_PUBLIC_REGISTRY_NAME=cosmoshub NEXT_PUBLIC_EXPLORER_LINK_TX="https://www.mintscan.io/cosmos/txs/\${txHash}" NEXT_PUBLIC_CHAIN_DISPLAY_NAME="Cosmos Hub" NEXT_PUBLIC_MULTICHAIN=true diff --git a/.gitignore b/.gitignore index b39b9e9..5e489ce 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ .DS_Store .env .env.local +.env.local2 npm-debug.log* yarn-debug.log* yarn-error.log* diff --git a/README.md b/README.md index 9c61315..ce8244a 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ This app allows for multisig users to create, sign and broadcast transactions on any stargate enabled chain. It's built with Cosmjs, Next.js, FaunaDB and Vercel. -[The app is live here](https://cosmoshub-legacy-multisig.vercel.app/). +[The app is live here](https://cosmos-multisig-ui-kohl.vercel.app/). [Here is a user guide on how to use the app](https://github.com/samepant/cosmoshub-legacy-multisig/blob/master/docs/App%20User%20Guide.md) diff --git a/components/chainSelect/ChainSelect.js b/components/chainSelect/ChainSelect.js index e46e734..4bffd60 100644 --- a/components/chainSelect/ChainSelect.js +++ b/components/chainSelect/ChainSelect.js @@ -30,6 +30,7 @@ const ChainSelect = () => { ); const [tempGasPrice, setGasPrice] = useState(state.chain.gasPrice); const [tempChainName, setChainName] = useState(state.chain.chainDisplayName); + const [tempRegistryName, setRegistryName] = useState(state.chain.registryName); const [tempExplorerLink, setExplorerLink] = useState(state.chain.explorerLink); let url = "https://api.github.com/repos/cosmos/chain-registry/contents"; @@ -49,6 +50,7 @@ const ChainSelect = () => { setGasPrice(state.chain.gasPrice); setChainName(state.chain.chainDisplayName); setExplorerLink(state.chain.explorerLink); + setRegistryName(state.chain.registryName); }, [state]); const getGhJson = async () => { @@ -59,11 +61,12 @@ const ChainSelect = () => { return item.type == "dir" && item.name != ".github"; }); setChainArray(chains); + console.log(chains); const options = chains.map(({ name }, index) => { return { label: name, value: index }; }); setChainOptions(options); - setSelectValue(findExistingOption(options, state.chain.chainDisplayName)); + setSelectValue(findExistingOption(options, state.chain.registryName)); } catch (error) { console.log(error); setShowSettings(true); @@ -71,8 +74,8 @@ const ChainSelect = () => { } }; - const findExistingOption = (options, chainName) => { - const index = options.findIndex((option) => option.label === chainName); + const findExistingOption = (options, registryName) => { + const index = options.findIndex((option) => option.label === registryName); if (index >= 0) { return options[index]; } diff --git a/components/head.js b/components/head.js index cc17cab..5e70665 100644 --- a/components/head.js +++ b/components/head.js @@ -2,7 +2,7 @@ import React from "react"; import NextHead from "next/head"; import { string } from "prop-types"; -const defaultDescription = "*:;;;:*:;;;:**:;;;:*:;;;:*COSMOS MULTISIGN*:;;;:*:;;;:**:;;;:*:;;;:*"; +const defaultDescription = "Create multisigs and send tokens on any cosmos based chain"; const defaultOGURL = ""; const Head = (props) => ( diff --git a/context/AppContext.js b/context/AppContext.js index 6b28c97..b02fc5e 100644 --- a/context/AppContext.js +++ b/context/AppContext.js @@ -15,6 +15,7 @@ function getChainInfoFromUrl() { gasPrice: params.get("gasPrice"), chainId: params.get("chainId"), chainDisplayName: decodeURIComponent(params.get("chainDisplayName")), + registryName: params.get("registryName"), addressPrefix: params.get("addressPrefix"), explorerLink: decodeURIComponent(params.get("explorerLink")), }; diff --git a/context/AppReducer.js b/context/AppReducer.js index c932e52..3c5033e 100644 --- a/context/AppReducer.js +++ b/context/AppReducer.js @@ -7,6 +7,7 @@ export const initialState = { gasPrice: process.env.NEXT_PUBLIC_GAS_PRICE, chainId: process.env.NEXT_PUBLIC_CHAIN_ID, chainDisplayName: process.env.NEXT_PUBLIC_CHAIN_DISPLAY_NAME, + registryName: process.env.NEXT_PUBLIC_REGISTRY_NAME, addressPrefix: process.env.NEXT_PUBLIC_ADDRESS_PREFIX, explorerLink: process.env.NEXT_PUBLIC_EXPLORER_LINK_TX, }, From bed58afb81c5af99bfa8d42ddbfc98ff07c34da6 Mon Sep 17 00:00:00 2001 From: samepant Date: Thu, 17 Feb 2022 11:50:17 -0700 Subject: [PATCH 2/2] setting chain from form fix --- components/chainSelect/ChainSelect.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/chainSelect/ChainSelect.js b/components/chainSelect/ChainSelect.js index 4bffd60..14a92b8 100644 --- a/components/chainSelect/ChainSelect.js +++ b/components/chainSelect/ChainSelect.js @@ -61,7 +61,6 @@ const ChainSelect = () => { return item.type == "dir" && item.name != ".github"; }); setChainArray(chains); - console.log(chains); const options = chains.map(({ name }, index) => { return { label: name, value: index }; }); @@ -101,6 +100,7 @@ const ChainSelect = () => { const addressPrefix = chainData["bech32_prefix"]; const chainId = chainData["chain_id"]; const chainDisplayName = chainData["pretty_name"]; + const registryName = chainOption.name; const explorerLink = getExplorerFromArray(chainData.explorers); let asset = ""; let denom = ""; @@ -137,6 +137,7 @@ const ChainSelect = () => { gasPrice, chainId, chainDisplayName, + registryName, addressPrefix, explorerLink, }, @@ -189,11 +190,12 @@ const ChainSelect = () => { gasPrice: tempGasPrice, chainId: tempChainId, chainDisplayName: tempChainName, + registryName: tempRegistryName, addressPrefix: tempAddressPrefix, explorerLink: tempExplorerLink, }, }); - const selectedOption = findExistingOption(chainOptions, tempChainName); + const selectedOption = findExistingOption(chainOptions, tempRegistryName); setSelectValue(selectedOption); setShowSettings(false); } catch (error) {