Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,9 @@
"tabWidth": 2
}
}
]
],
"importOrder": ["<THIRD_PARTY_MODULES>", "^@app-gov/(.*)$", "^[./]"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true,
"importOrderCaseInsensitive": true
}
7 changes: 4 additions & 3 deletions apps/gov-website/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
/* eslint-disable react/jsx-key */
import { SessionProvider } from "next-auth/react";
import type { AppProps } from "next/app";
import Head from "next/head";
import { FC } from "react";

import { CENNZ_NETWORK } from "@app-gov/service/constants";
import {
MainProvider,
CENNZApiProvider,
CENNZExtensionProvider,
CENNZWalletProvider,
MainProvider,
UserAgentProvider,
} from "@app-gov/web/providers";
import { FC } from "react";
import { SessionProvider } from "next-auth/react";

import "../globals.css";

Expand Down
2 changes: 1 addition & 1 deletion apps/gov-website/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Html, Head, Main, NextScript } from "next/document";
import { Head, Html, Main, NextScript } from "next/document";
import { FC } from "react";

const NextDocument: FC = () => {
Expand Down
3 changes: 2 additions & 1 deletion apps/gov-website/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import NextAuth from "next-auth";
import TwitterProvider from "next-auth/providers/twitter";
import DiscordProvider from "next-auth/providers/discord";
import TwitterProvider from "next-auth/providers/twitter";

import { DISCORD_CLIENT, TWITTER_CLIENT } from "@app-gov/service/constants";

export default NextAuth({
Expand Down
5 changes: 3 additions & 2 deletions apps/gov-website/pages/api/identity/judgement.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { getToken } from "next-auth/jwt";

import { NEXTAUTH_SECRET } from "@app-gov/node/constants";
import { fetchRequiredRegistrars, withMethodGuard } from "@app-gov/node/utils";
import {
fetchIdentityOf,
getApiInstance,
isIdentityValueMatched,
getProvideJudgementExtrinsic,
isIdentityValueMatched,
signAndSendPromise,
} from "@app-gov/service/cennznet";
import { CENNZ_NETWORK } from "@app-gov/service/constants";
import { getToken } from "next-auth/jwt";

export default withMethodGuard(
async function identityConnectRoute(req, res) {
Expand Down
2 changes: 1 addition & 1 deletion apps/gov-website/pages/api/proposals/[pid].ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import mongoose from "mongoose";
import type { NextApiRequest, NextApiResponse } from "next";

import mongoose from "mongoose";
import { MONGODB_SERVER } from "@app-gov/service/constants";

export default async function handler(
Expand Down
31 changes: 16 additions & 15 deletions apps/gov-website/pages/identity/connect.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
import type { GetStaticProps, NextPage } from "next";
import { FormEvent, useCallback, useEffect } from "react";
import {
DiscordLogo,
TwitterLogo,
Spinner,
X,
CheckCircle,
ExclamationCircle,
} from "@app-gov/web/vectors";
import { useSocialSignIn, useIdentityConnectForm } from "@app-gov/web/hooks";
import { Choose, If } from "react-extras";

import { fetchRequiredRegistrars } from "@app-gov/node/utils";
import { getApiInstance } from "@app-gov/service/cennznet";
import { CENNZ_NETWORK } from "@app-gov/service/constants";
import {
Button,
TextField,
WalletSelect,
Layout,
Header,
Layout,
TextField,
TransactionDialog,
useTransactionDialog,
WalletSelect,
} from "@app-gov/web/components";
import { getApiInstance } from "@app-gov/service/cennznet";
import { CENNZ_NETWORK } from "@app-gov/service/constants";
import { fetchRequiredRegistrars } from "@app-gov/node/utils";
import { useIdentityConnectForm, useSocialSignIn } from "@app-gov/web/hooks";
import {
CheckCircle,
DiscordLogo,
ExclamationCircle,
Spinner,
TwitterLogo,
X,
} from "@app-gov/web/vectors";

interface StaticProps {
twitterRegistrarIndex: number;
Expand Down
1 change: 1 addition & 0 deletions apps/gov-website/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { NextPage } from "next";

import { Header, Layout } from "@app-gov/web/components";

const Home: NextPage = () => {
Expand Down
9 changes: 5 additions & 4 deletions apps/gov-website/pages/popup/signin.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { capitalize } from "lodash-es";
import type { NextPage } from "next";
import { Layout } from "@app-gov/web/components";
import { BuiltInProviderType } from "next-auth/providers";
import { signIn } from "next-auth/react";
import { useRouter } from "next/router";
import { useEffect } from "react";
import { signIn } from "next-auth/react";
import { BuiltInProviderType } from "next-auth/providers";
import { capitalize } from "lodash-es";

import { Layout } from "@app-gov/web/components";

const SignIn: NextPage = () => {
const {
Expand Down
10 changes: 5 additions & 5 deletions apps/gov-website/pages/proposals/[pid].tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import type { NextPage, NextPageContext } from "next";
import type { SubmittableResult } from "@cennznet/api";
import type { ProposalVote, ProposalInterface } from "@app-gov/node/types";

import { If } from "react-extras";
import type { NextPage, NextPageContext } from "next";
import { useCallback, useEffect, useState } from "react";
import { If } from "react-extras";

import type { ProposalInterface, ProposalVote } from "@app-gov/node/types";
import {
Button,
Header,
Layout,
ProposalDetailsDisplay,
WalletSelect,
} from "@app-gov/web/components";
import { useCENNZApi, useCENNZWallet } from "@app-gov/web/providers";
import { fetchProposal } from "@app-gov/web/utils";
import { Spinner } from "@app-gov/web/vectors";
import { useCENNZApi, useCENNZWallet } from "@app-gov/web/providers";

export const getServerSideProps = (context: NextPageContext) => {
return {
Expand Down
14 changes: 7 additions & 7 deletions apps/gov-website/pages/proposals/new.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import type { NextPage } from "next";
import type { ProposalCall } from "@app-gov/web/types";
import type { Api, SubmittableResult } from "@cennznet/api";
import type { NextPage } from "next";
import { FormEventHandler, useCallback, useState } from "react";
import { If } from "react-extras";

import { PINATA_GATEWAY } from "@app-gov/service/constants";
import { pinProposal } from "@app-gov/service/pinata";
import {
Button,
Header,
Expand All @@ -11,13 +14,10 @@ import {
TextField,
WalletSelect,
} from "@app-gov/web/components";
import { If } from "react-extras";
import { Spinner } from "@app-gov/web/vectors";
import { pinProposal } from "@app-gov/service/pinata";
import { useControlledInput } from "@app-gov/web/hooks";
import { PINATA_GATEWAY } from "@app-gov/service/constants";
import { FormEventHandler, useCallback, useState } from "react";
import { useCENNZApi, useCENNZWallet } from "@app-gov/web/providers";
import type { ProposalCall } from "@app-gov/web/types";
import { Spinner } from "@app-gov/web/vectors";

const NewProposal: NextPage = () => {
const { value: proposalTitle, onChange: onProposalTitleChange } =
Expand Down
2 changes: 1 addition & 1 deletion apps/gov-website/specs/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { render } from "@testing-library/react";
import React from "react";

import Index from "../pages/index";

Expand Down
11 changes: 6 additions & 5 deletions libs/node/utils/src/fetchRequiredRegistrars.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Api } from "@cennznet/api";
import {
fetchIdentityRegistrars,
getKeyringPairFromSeed,
} from "@app-gov/service/cennznet";
import { KeyringPair } from "@polkadot/keyring/types";

import {
DISCORD_REGISTRAR_SEED,
TWITTER_REGISTRAR_SEED,
} from "@app-gov/node/constants";
import { KeyringPair } from "@polkadot/keyring/types";
import {
fetchIdentityRegistrars,
getKeyringPairFromSeed,
} from "@app-gov/service/cennznet";

interface Registrar {
address: string;
Expand Down
5 changes: 3 additions & 2 deletions libs/service/cennznet/src/Transaction.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { GenericEvent } from "@cennznet/types";
import { SubmittableResult } from "@cennznet/api";
import { CENNZ_NETWORK } from "@app-gov/service/constants";
import type { GenericEvent } from "@cennznet/types";
import Emittery from "emittery";

import { CENNZ_NETWORK } from "@app-gov/service/constants";

interface EmitEvents {
txCreated: undefined;
txHashed: string;
Expand Down
1 change: 1 addition & 0 deletions libs/service/cennznet/src/getSetIdentityExtrinsic.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Api } from "@cennznet/api";
import { SubmittableExtrinsic } from "@cennznet/api/types";
import { ISubmittableResult } from "@cennznet/types";

import { hasIdentityValue, IdentityHash } from "./hashIdentityValue";

export function getSetIdentityExtrinsic(
Expand Down
3 changes: 2 additions & 1 deletion libs/service/cennznet/src/signAndSendTx.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { SubmittableResult } from "@cennznet/api";
import type { Signer, SubmittableExtrinsic } from "@cennznet/api/types";
import { Transaction } from "./Transaction";
import { KeyringPair } from "@polkadot/keyring/types";

import { Transaction } from "./Transaction";

export const signAndSendTx = async (
extrinsic: SubmittableExtrinsic<"promise">,
signer: KeyringPair | Signer,
Expand Down
2 changes: 1 addition & 1 deletion libs/service/constants/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { OAuthUserConfig } from "next-auth/providers";
import { CENNZNetNetwork } from "@cennznet/api/types";
import { OAuthUserConfig } from "next-auth/providers";

export const CENNZ_NETWORK = {
local: {
Expand Down
4 changes: 2 additions & 2 deletions libs/web/components/src/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { PropsWithChildren, IntrinsicElements } from "@app-gov/web/types";

import { FC, ReactNode } from "react";
import { classNames, If } from "react-extras";

import type { IntrinsicElements, PropsWithChildren } from "@app-gov/web/types";

interface ButtonProps extends PropsWithChildren {
variant?: "hero" | "white";
size?: "small" | "medium";
Expand Down
5 changes: 3 additions & 2 deletions libs/web/components/src/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { PropsWithChildren } from "@app-gov/web/types";
import { Dialog as BaseDialog, Transition } from "@headlessui/react";
import { FC, MutableRefObject, Fragment } from "react";
import { FC, Fragment, MutableRefObject } from "react";
import { classNames } from "react-extras";

import { PropsWithChildren } from "@app-gov/web/types";

export interface DialogProps extends PropsWithChildren {
className?: string;
panelClassName?: string;
Expand Down
4 changes: 2 additions & 2 deletions libs/web/components/src/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PropsWithChildren, IntrinsicElements } from "@app-gov/web/types";

import { FC } from "react";

import type { IntrinsicElements, PropsWithChildren } from "@app-gov/web/types";
import { CENNZNetLogoSrc } from "@app-gov/web/vectors";

interface HeaderProps extends PropsWithChildren {}
Expand Down
4 changes: 2 additions & 2 deletions libs/web/components/src/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { PropsWithChildren, IntrinsicElements } from "@app-gov/web/types";

import { FC } from "react";

import type { IntrinsicElements, PropsWithChildren } from "@app-gov/web/types";

interface LayoutProps extends PropsWithChildren {}

export const Layout: FC<IntrinsicElements["div"] & LayoutProps> = ({
Expand Down
5 changes: 2 additions & 3 deletions libs/web/components/src/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { FC } from "react";

import RemarkGfm from "remark-gfm";
import RemarkBreaks from "remark-breaks";
import ReactMarkdown from "react-markdown";
import RemarkBreaks from "remark-breaks";
import RemarkGfm from "remark-gfm";

interface MarkdownProps {
input: string;
Expand Down
13 changes: 7 additions & 6 deletions libs/web/components/src/ProposalAdvanced.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import type { ChangeEvent, FC } from "react";
import type { ProposalCall } from "@app-gov/web/types";

import { useMemo, useState } from "react";
import { classNames, If } from "react-extras";
import { ChevronDown } from "@app-gov/web/vectors";

import { Extrinsics } from "@app-gov/service/cennznet";
import { TextField, Select } from "@app-gov/web/components";
import type { ProposalCall } from "@app-gov/web/types";
import { ChevronDown } from "@app-gov/web/vectors";

import { Select, TextField } from "./";

interface ProposalAdvancedProps {
proposalCall: ProposalCall | undefined;
Expand Down Expand Up @@ -128,7 +129,7 @@ const useExtrinsic = (proposalCall: ProposalCall | undefined) => {

const cennzCalls = useMemo(
() => selectedModule?.methods.map((method: ExtrinsicMethod) => method.name),
[selectedModule, proposalCall?.module]
[selectedModule]
);

const extrinsicArgs = useMemo<string[]>(() => {
Expand All @@ -141,7 +142,7 @@ const useExtrinsic = (proposalCall: ProposalCall | undefined) => {
.split(",")
.map((args: string) => args.split(":")[0])
.filter(Boolean);
}, [selectedModule, proposalCall]);
}, [proposalCall?.call, selectedModule?.methods]);

return { cennzModules, cennzCalls, extrinsicArgs };
};
3 changes: 2 additions & 1 deletion libs/web/components/src/ProposalDetailsDisplay.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { FC } from "react";

import type { ProposalDetails, ProposalInfo } from "@app-gov/node/types";

import { Markdown } from "@app-gov/web/components";
import { Markdown } from "./";

interface ProposalDetailsDisplayProps {
proposalDetails: ProposalDetails;
Expand Down
7 changes: 4 additions & 3 deletions libs/web/components/src/ProposalDetailsField.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ChangeEventHandler, FC } from "react";

import type { FC } from "react";
import { useState } from "react";
import { classNames, If } from "react-extras";

import { useControlledInput } from "@app-gov/web/hooks";
import { Button, Markdown, TextArea } from "@app-gov/web/components";

import { Button, Markdown, TextArea } from "./";

export const ProposalDetailsField: FC = () => {
const [showPreview, setShowPreview] = useState<boolean>(false);
Expand Down
4 changes: 2 additions & 2 deletions libs/web/components/src/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { PropsWithChildren, IntrinsicElements } from "@app-gov/web/types";

import { FC, ReactNode } from "react";
import { classNames, If } from "react-extras";

import type { IntrinsicElements, PropsWithChildren } from "@app-gov/web/types";

interface SelectProps extends PropsWithChildren {
placeholder?: string;
endAdornment?: ReactNode;
Expand Down
4 changes: 2 additions & 2 deletions libs/web/components/src/TextField.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { PropsWithChildren, IntrinsicElements } from "@app-gov/web/types";

import { FC, ReactNode } from "react";
import { classNames, If } from "react-extras";

import type { IntrinsicElements, PropsWithChildren } from "@app-gov/web/types";

interface TextFieldProps extends PropsWithChildren {
endAdornment?: ReactNode;
inputClassName?: string;
Expand Down
Loading