Merge pull request #35 from cosmos/samepant/chain-select-fix

This commit is contained in:
samepant
2022-02-17 16:49:26 -07:00
committed by GitHub
7 changed files with 15 additions and 6 deletions
+1
View File
@@ -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
+1
View File
@@ -15,6 +15,7 @@
.DS_Store
.env
.env.local
.env.local2
npm-debug.log*
yarn-debug.log*
yarn-error.log*
+1 -1
View File
@@ -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)
+9 -4
View File
@@ -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 () => {
@@ -63,7 +65,7 @@ const ChainSelect = () => {
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 +73,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];
}
@@ -98,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 = "";
@@ -134,6 +137,7 @@ const ChainSelect = () => {
gasPrice,
chainId,
chainDisplayName,
registryName,
addressPrefix,
explorerLink,
},
@@ -186,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) {
+1 -1
View File
@@ -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) => (
+1
View File
@@ -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")),
};
+1
View File
@@ -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,
},