Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added checking for home_domain, fixed bugs at display network, display auth, and console warns and errors by font-awesome #45

Merged
merged 10 commits into from
Aug 18, 2024
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ The repository is a part of the [Montelibero Organization](https://github.com/mo
- [Radix Themes](https://www.radix-ui.com) - An open source component library optimized for fast development, easy maintenance, and accessibility.
- [Tailwind CSS](https://tailwindcss.com) - A utility-first CSS framework packed with classes like flex, pt-4, text-center and rotate-90 that can be composed to build any design, directly in your markup.
- [Axios](https://github.com/axios/axios) - A simple HTTP client for the browser and Node.js.
- [React icons](https://react-icons.github.io/react-icons) - A library of SVG React icons.
- [JS Stellar SDK](https://github.com/stellar/js-stellar-sdk) - A JavaScript library for communicating with a Stellar Horizon server and Soroban RPC. It is used for building Stellar apps either on Node.js or in the browser, though it can be used in other environments with some tinkering.
- [Zustand](https://github.com/pmndrs/zustand) - A state management library for React.
- [TypeScript](https://www.typescriptlang.org) - A typed superset of JavaScript that compiles to plain JavaScript.
- [Eslint](https://eslint.org) - A static and automatic code checker for your JavaScript projects.
- [Font-Awesome](https://fontawesome.com) - A library that provides scalable vector icons.

## Contributing

Expand Down
2 changes: 2 additions & 0 deletions app/globals.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import url("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css");

.blue-ribbon {
border-top: 3px solid #08b5e5;
}
Expand Down
10 changes: 1 addition & 9 deletions src/pages/Layout/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useStore } from "@/features/store";
import { Footer, Header } from "@/widgets";
import { useShallow } from "zustand/react/shallow";
import AddAccountModal from "@/widgets/shared/layouts/Header/ui/AddAccountModal";
import Script from "next/script";
import Head from "next/head";

type Props = {
Expand Down Expand Up @@ -51,6 +50,7 @@ const PageLayout: FC<Props> = ({ children }) => {
);
}, [accounts, net, setIsAuth]);


const themeLS: string | undefined | null = isWindowDefined
? window.localStorage.getItem("theme")
? window.localStorage.getItem("theme")
Expand All @@ -65,10 +65,6 @@ const PageLayout: FC<Props> = ({ children }) => {
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<meta
name="commit-hash"
content={process.env.NEXT_PUBLIC_COMMIT_HASH || ""}
/>
<title>Stellar Multisig</title>
</Head>
<body></body>
Expand Down Expand Up @@ -98,10 +94,6 @@ const PageLayout: FC<Props> = ({ children }) => {
<Footer />
</main>
{isOpenAddAccountModal && <AddAccountModal />}
<Script
src="https://kit.fontawesome.com/b02b92140a.js"
crossOrigin="anonymous"
/>
</body>
</html>
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/public/account/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const Page: FC = () => {
);
}

return <PublicNet id={id} />;
return typeof id === "string" && <PublicNet id={id} />;
};

export default Page;
74 changes: 54 additions & 20 deletions src/pages/public/account/publicnet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import BalanceItem from "@/pages/public/account/(BalanceItem)";
import ignoredHomeDomains from "@/shared/configs/ignored-home-domains.json";

interface Props {
id: string | undefined | null;
id: string;
}

export const collapseAccount = (accountId: string) => {
Expand All @@ -33,15 +33,19 @@ export const collapseAccount = (accountId: string) => {
};

const PublicNet: FC<Props> = ({ id }) => {
const account = id;
const { net } = useStore(useShallow((state) => ({ net: state.net })));
const account: string = id;
const { net }: { net: string } = useStore(
useShallow((state) => ({ net: state.net }))
);
const [information, setInformation] = useState<Information>(
{} as Information
);
const [exists, setExists] = useState(true);
const [tabIndex, setTabIndex] = useState(1);
const [errorvalid, setErrorvalid] = useState("");
const [loading, setLoading] = useState(false);
const [exists, setExists] = useState<boolean>(true);
const [tabIndex, setTabIndex] = useState<number>(1);
const [errorvalid, setErrorvalid] = useState<string>("");
const [loading, setLoading] = useState<boolean>(false);
const [isVisibleHomeDomainInfo, setIsVisibleHomeDomainInfo] =
useState<boolean>(true);

useEffect(() => {
const checkAccount = async () => {
Expand Down Expand Up @@ -136,6 +140,36 @@ const PublicNet: FC<Props> = ({ id }) => {
handler();
}, [account]);

useEffect(() => {
if (information.tomlInfo) {
const accountsMatch = information.tomlInfo.match(
/ACCOUNTS=\[([\s\S]*?)\]/
);
if (accountsMatch && accountsMatch[1]) {
const newAccounts = accountsMatch[1]
.split("\n")
.map((line) => line.trim())
.filter((line) => line && !line.startsWith("#"))
.map((line) => line.replace(/^"|"$|,$|"$/g, ""))
.map((line) => line.replace(/"$/, ""));
/**
* Logic to create an array of strings where item is an accountID
* that is not fake in the home_domain set by the account
*/
const foundAccount = newAccounts.find((accountId) => accountId === id);
if (foundAccount) {
setIsVisibleHomeDomainInfo(true);
} else {
setIsVisibleHomeDomainInfo(false);
}
} else {
setIsVisibleHomeDomainInfo(false);
}
} else {
setIsVisibleHomeDomainInfo(false);
}
}, [information.tomlInfo, id]);

return (
<MainLayout>
<div className="container">
Expand Down Expand Up @@ -184,22 +218,23 @@ const PublicNet: FC<Props> = ({ id }) => {
<h3>Summary</h3>
<hr className="flare"></hr>
<dl>
{information?.home_domain == undefined ? (
""
) : (
{information?.home_domain !== undefined &&
isVisibleHomeDomainInfo &&
information.home_domain &&
!ignoredHomeDomains.includes(information.home_domain) ? (
<>
<dt>Home domain:</dt>
<dd>
<a
href={`${
information?.home_domain == undefined
information?.home_domain === undefined
? "#"
: information?.home_domain
}`}
rel="noreferrer noopener"
target="_blank"
>
{information?.home_domain == undefined
{information?.home_domain === undefined
? "none"
: information?.home_domain}
</a>
Expand Down Expand Up @@ -233,7 +268,7 @@ const PublicNet: FC<Props> = ({ id }) => {
</i>
</dd>
</>
)}
) : null}
<dt>Account lock status:</dt>
<dd>
unlocked
Expand Down Expand Up @@ -535,7 +570,7 @@ const PublicNet: FC<Props> = ({ id }) => {
);
return (
<li className="word-break" key={key}>
{processedKey}: {" "}{processedValue}
{processedKey}: {processedValue}
</li>
);
}
Expand Down Expand Up @@ -633,9 +668,8 @@ const PublicNet: FC<Props> = ({ id }) => {
information?.meta_data["ORG_NAME"] !== undefined &&
ignoredHomeDomains &&
information?.home_domain &&
ignoredHomeDomains.includes(information?.home_domain) ? (
""
) : (
!ignoredHomeDomains.includes(information.home_domain) &&
isVisibleHomeDomainInfo ? (
<div className="toml-props">
<div className="tabs space inline-right">
<div className="tabs-header">
Expand All @@ -646,7 +680,7 @@ const PublicNet: FC<Props> = ({ id }) => {
tabIndex === 1 ? "selected" : ""
}`}
onClick={(e) => {
e.preventDefault(); // Prevent the default anchor tag behavior
e.preventDefault();
setTabIndex(1);
}}
>
Expand All @@ -658,7 +692,7 @@ const PublicNet: FC<Props> = ({ id }) => {
tabIndex === 2 ? "selected" : ""
}`}
onClick={(e) => {
e.preventDefault(); // Prevent the default anchor tag behavior
e.preventDefault();
setTabIndex(2);
}}
>
Expand Down Expand Up @@ -842,7 +876,7 @@ const PublicNet: FC<Props> = ({ id }) => {
</div>
</div>
</div>
)}
) : null}
</>
) : (
<div className="cotainer">
Expand Down
5 changes: 0 additions & 5 deletions src/shared/configs/trusted-mtl-assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@
"issuer": "GACKTN5DAZGWXRWB2WLM6OPBDHAMT6SJNGLJZPQMEZBUR4JUGBX2UK7V",
"tag": "stablecoin"
},
{
"code": "SATSMTL",
"issuer": "GACKTN5DAZGWXRWB2WLM6OPBDHAMT6SJNGLJZPQMEZBUR4JUGBX2UK7V",
"tag": "stablecoin"
},
{
"code": "MTL",
"issuer": "GACKTN5DAZGWXRWB2WLM6OPBDHAMT6SJNGLJZPQMEZBUR4JUGBX2UK7V",
Expand Down
1 change: 1 addition & 0 deletions src/widgets/shared/layouts/Header/ui/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ header {
margin-top: 5px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
z-index: 1;
width: max-content
}

.dropdown-menu-light {
Expand Down
Loading