forked from LaconicNetwork/icns-frontend
Change chain list when changed keplr account
This commit is contained in:
parent
11a17e64b8
commit
7b8f4910bb
@ -53,7 +53,7 @@ import {
|
||||
TWITTER_LOGIN_ERROR,
|
||||
} from "../../constants/error-message";
|
||||
import { makeClaimMessage, makeSetRecordMessage } from "../../messages";
|
||||
import Axios, { AxiosError } from "axios";
|
||||
import Axios from "axios";
|
||||
import { BackButton } from "../../components/back-button";
|
||||
|
||||
export default function VerificationPage() {
|
||||
@ -82,6 +82,57 @@ export default function VerificationPage() {
|
||||
const [isAgree, setIsAgree] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
init();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (wallet) {
|
||||
window.addEventListener("keplr_keystorechange", async () => {
|
||||
init();
|
||||
});
|
||||
}
|
||||
}, [wallet]);
|
||||
|
||||
useEffect(() => {
|
||||
setAllChains({
|
||||
chainId: "all chains",
|
||||
chainName: "all chains",
|
||||
prefix: `all chains(${chainList.length})`,
|
||||
address: chainList.map((chain) => chain.chainName).join(", "),
|
||||
chainImageUrl: AllChainsIcon,
|
||||
});
|
||||
}, [chainList]);
|
||||
|
||||
useEffect(() => {
|
||||
const disabledChainList = chainList.filter((chain) => {
|
||||
for (const registeredChain of registeredChainList) {
|
||||
if (
|
||||
chain.prefix === registeredChain.bech32_prefix &&
|
||||
chain.address === registeredChain.address
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
const filteredChainList = chainList.filter(
|
||||
(chain) => !disabledChainList.includes(chain),
|
||||
);
|
||||
|
||||
setAllChains({
|
||||
chainId: "all chains",
|
||||
chainName: "all chains",
|
||||
prefix: `all chains(${filteredChainList.length})`,
|
||||
address: filteredChainList.map((chain) => chain.chainName).join(", "),
|
||||
chainImageUrl: AllChainsIcon,
|
||||
});
|
||||
|
||||
setChainList(filteredChainList);
|
||||
setDisabledChainList(disabledChainList);
|
||||
}, [registeredChainList]);
|
||||
|
||||
const init = async () => {
|
||||
if (window.location.search) {
|
||||
try {
|
||||
@ -133,49 +184,6 @@ export default function VerificationPage() {
|
||||
}
|
||||
};
|
||||
|
||||
init();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setAllChains({
|
||||
chainId: "all chains",
|
||||
chainName: "all chains",
|
||||
prefix: `all chains(${chainList.length})`,
|
||||
address: chainList.map((chain) => chain.chainName).join(", "),
|
||||
chainImageUrl: AllChainsIcon,
|
||||
});
|
||||
}, [chainList]);
|
||||
|
||||
useEffect(() => {
|
||||
const disabledChainList = chainList.filter((chain) => {
|
||||
for (const registeredChain of registeredChainList) {
|
||||
if (
|
||||
chain.prefix === registeredChain.bech32_prefix &&
|
||||
chain.address === registeredChain.address
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
const filteredChainList = chainList.filter(
|
||||
(chain) => !disabledChainList.includes(chain),
|
||||
);
|
||||
|
||||
setAllChains({
|
||||
chainId: "all chains",
|
||||
chainName: "all chains",
|
||||
prefix: `all chains(${filteredChainList.length})`,
|
||||
address: filteredChainList.map((chain) => chain.chainName).join(", "),
|
||||
chainImageUrl: AllChainsIcon,
|
||||
});
|
||||
|
||||
setChainList(filteredChainList);
|
||||
setDisabledChainList(disabledChainList);
|
||||
}, [registeredChainList]);
|
||||
|
||||
const initWallet = async () => {
|
||||
const keplr = await getKeplrFromWindow();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user