From da05388b0cc1e77cac4e54f1fb9d5b0d5c42942d Mon Sep 17 00:00:00 2001 From: Misha Kushka Date: Tue, 2 May 2023 22:36:45 +0800 Subject: [PATCH 01/10] Allow adding user emails as signers or observers (only UI) --- .../Steps/StepThree/validationUtils.ts | 7 +++++++ .../CreateAgreement/Steps/StepTwo/index.tsx | 16 +++++++++++----- components/CreateAgreement/index.tsx | 1 + components/ModalEditObservers/index.tsx | 2 +- modules/createAgreementProvider.tsx | 1 - 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/components/CreateAgreement/Steps/StepThree/validationUtils.ts b/components/CreateAgreement/Steps/StepThree/validationUtils.ts index 66345fc..e0e1811 100644 --- a/components/CreateAgreement/Steps/StepThree/validationUtils.ts +++ b/components/CreateAgreement/Steps/StepThree/validationUtils.ts @@ -11,3 +11,10 @@ export const validateAddress = (value: string): string | undefined => { return "Invalid wallet address"; } }; + +export const validateEmail = (value: string): string | undefined => { + const isValidEmail = value.match(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/); + if (!isValidEmail) { + return "Invalid email address"; + } +}; diff --git a/components/CreateAgreement/Steps/StepTwo/index.tsx b/components/CreateAgreement/Steps/StepTwo/index.tsx index d1fc26c..f3fe392 100644 --- a/components/CreateAgreement/Steps/StepTwo/index.tsx +++ b/components/CreateAgreement/Steps/StepTwo/index.tsx @@ -8,7 +8,7 @@ import { addMeBtn, plus, } from "../../styles"; -import { validateAddress, validateEnsDomains } from "../StepThree/validationUtils"; +import { validateAddress, validateEmail, validateEnsDomains } from "../StepThree/validationUtils"; import { useCreateAgreement } from "../../../../hooks/useCreateAgreement"; import { useEditAgreement } from "../../../../hooks/useEditAgreement"; import FieldErrorMessage from "../../../Form/FieldErrorMessage"; @@ -130,6 +130,7 @@ export default function StepTwo({ page }: { page: string }) { if (userAlreadyObserver) { return userRole === "signer" ? "Already exists as Observer" : "Observer is already added"; } + const isEns = value?.includes(".eth"); if (isEns) { const error = validateEnsDomains(value); @@ -140,13 +141,18 @@ export default function StepTwo({ page }: { page: string }) { } const isAddress = value?.startsWith("0x"); - if (isAddress) { const error = validateAddress(value); if (error) return error; } - if (!isEns && !isAddress) { + const isEmail = value?.includes("@"); + if (isEmail) { + const error = validateEmail(value); + if (error) return error; + } + + if (!isEns && !isAddress && !isEmail) { return "Invalid value"; } @@ -212,7 +218,7 @@ export default function StepTwo({ page }: { page: string }) { sx={{ position: "relative", justifyContent: "space-between", alignItems: "center" }} > - Signers (ENS name or address) * + Signers (ENS name, Ethereum address, or email) * - Observers (ENS name or adderess){" "} + Observers (ENS name, Ethereum adderess, or email){" "} { return ( - Observers (ENS name or adderess) + Observers (ENS name, Ethereum adderess, or email) Date: Wed, 3 May 2023 20:58:34 +0800 Subject: [PATCH 02/10] Add createUserByEmailMutation --- .../CreateAgreement/Steps/StepTwo/index.tsx | 36 ++++++++++++++-- modules/graphql/gql/gql.ts | 10 +++++ modules/graphql/gql/graphql.ts | 43 ++++++++++++++++--- modules/graphql/mutations/user.ts | 16 +++++++ 4 files changed, 95 insertions(+), 10 deletions(-) diff --git a/components/CreateAgreement/Steps/StepTwo/index.tsx b/components/CreateAgreement/Steps/StepTwo/index.tsx index f3fe392..b0ea2b3 100644 --- a/components/CreateAgreement/Steps/StepTwo/index.tsx +++ b/components/CreateAgreement/Steps/StepTwo/index.tsx @@ -1,5 +1,5 @@ import React, { useRef, useMemo, useState } from "react"; -import { Container, Flex, Input, Text, Button, Box, Switch, Label } from "theme-ui"; +import { Container, Flex, Input, Text, Button, Box } from "theme-ui"; import { inputCreateAgreementWithRightButton, inputCreateAgreementError, @@ -23,6 +23,12 @@ import Icon from "../../../icon"; import { PlusIcon } from "./svg"; import styles from "./styles"; import { notifComingSoon } from "../../../../utils/notification"; +import { createUserByEmail, sendInvitationEmail } from "../../../agreements/helpers"; +import { + createUserByEmailMutation, + sendEmailVerificationLinkMutation, +} from "../../../../modules/graphql/mutations"; +import { useMutation } from "urql"; interface VerificationInfo { title: string; @@ -30,6 +36,8 @@ interface VerificationInfo { description: string; } +const isEmail = (x: string) => x?.includes("@"); + const verifications: VerificationInfo[] = [ { title: "Anonymous", @@ -63,6 +71,8 @@ export default function StepTwo({ page }: { page: string }) { const edit = useEditAgreement(); const { values, changeValue } = page === "create" ? create : edit; const { account, resolveEns } = useWeb3(); + const [, createUserByEmailRequest] = useMutation(createUserByEmailMutation); + const [, sendEmailVerificationLinkRequest] = useMutation(sendEmailVerificationLinkMutation); const signersInputErrorStyles = values?.errors?.signers ? inputCreateAgreementError : {}; const observersInputErrorStyles = values?.errors?.observers ? inputCreateAgreementError : {}; @@ -146,13 +156,12 @@ export default function StepTwo({ page }: { page: string }) { if (error) return error; } - const isEmail = value?.includes("@"); - if (isEmail) { + if (isEmail(value)) { const error = validateEmail(value); if (error) return error; } - if (!isEns && !isAddress && !isEmail) { + if (!isEns && !isAddress && !isEmail(value)) { return "Invalid value"; } @@ -172,6 +181,16 @@ export default function StepTwo({ page }: { page: string }) { changeValue("errors", { ...values.errors, signers: validationError }); return; } + + if (isEmail(value)) { + await createUserByEmailRequest({ email: value }); + await sendEmailVerificationLinkRequest({ + email: value, + isSigner: true, + agreementNumber: 12345, // TODO: replace with a real agreement number + }); + } + changeValue("signers", [ ...values.signers, { value: value.toLocaleLowerCase(), id: uniqueId() }, @@ -194,6 +213,15 @@ export default function StepTwo({ page }: { page: string }) { return; } + if (isEmail(value)) { + await createUserByEmailRequest({ email: value }); + await sendEmailVerificationLinkRequest({ + email: value, + isSigner: false, + agreementNumber: 12345, // TODO: replace with a real agreement number + }); + } + changeValue("observers", [ ...values.observers, { value: value.toLocaleLowerCase(), id: uniqueId() }, diff --git a/modules/graphql/gql/gql.ts b/modules/graphql/gql/gql.ts index 94332d6..bfcebd5 100644 --- a/modules/graphql/gql/gql.ts +++ b/modules/graphql/gql/gql.ts @@ -20,6 +20,8 @@ const documents = { "\n mutation EditObservers($agreementId: Int, $observers: [String!]) {\n editObservers(agreementId: $agreementId, observers: $observers) {\n message\n }\n }\n": types.EditObserversDocument, "\n mutation login($address: String!, $signature: String) {\n login(address: $address, signature: $signature) {\n message\n payload\n token\n }\n }\n": types.LoginDocument, "\n mutation Mutation {\n logout {\n message\n }\n }\n": types.MutationDocument, + "\n mutation createUserByEmail($email: String!) {\n createUserByEmail(email: $email)\n }\n": types.CreateUserByEmailDocument, + "\n mutation sendEmailVerificationLink(\n $email: String!\n $isSigner: Boolean!\n $agreementNumber: String!\n ) {\n sendEmailVerificationLink(email: $email, isSigner: $isSigner, agreementNumber: $agreementNumber)\n }\n": types.SendEmailVerificationLinkDocument, "\n mutation verifyMyEmail($emailVerificationSalt: String!, $email: String!) {\n verifyMyEmail(emailVerificationSalt: $emailVerificationSalt, email: $email)\n }\n": types.VerifyMyEmailDocument, "\n query Query($agreementId: Int!) {\n agreement(agreementId: $agreementId) {\n agreementId\n snapshotProposalUrl\n agreementFile {\n agreementFileId\n agreementHash\n createdAt\n filePath\n }\n agreementLocation {\n agreementLocationId\n isActive\n name\n }\n agreementPrivacy {\n name\n }\n agreementStatus {\n name\n }\n authorWallet {\n address\n networkId\n userId\n walletId\n }\n observers {\n email\n observerId\n wallet {\n address\n }\n ens {\n name\n }\n }\n signers {\n email\n wallet {\n address\n }\n ens {\n name\n }\n }\n title\n content\n isWaitingForMySignature\n snapshotProposalUrl\n isAllowedToEditObservers\n createdAt\n signProofs {\n signature\n cid\n signerWalletId\n signerWallet {\n address\n }\n }\n agreementFileProof {\n cid\n signature\n signers\n }\n agreementProof {\n cid\n signedAt\n }\n }\n }\n": types.QueryDocument, "\n query MyAgreements($take: Int, $filterBy: [String!], $search: String, $skip: Int) {\n myAgreements(take: $take, filterBy: $filterBy, search: $search, skip: $skip) {\n agreements {\n agreementId\n title\n content\n isWaitingForMySignature\n createdAt\n agreementLocation {\n name\n isActive\n }\n agreementPrivacy {\n name\n }\n agreementFile {\n filePath\n createdAt\n }\n authorWallet {\n address\n user {\n name\n email\n phone\n twitterVerificationCode\n twitterVerificationSig\n bio\n }\n }\n signers {\n email\n wallet {\n address\n user {\n name\n }\n }\n }\n observers {\n email\n wallet {\n address\n user {\n name\n }\n }\n }\n agreementStatus {\n name\n }\n signProofs {\n cid\n signature\n }\n }\n count\n }\n }\n": types.MyAgreementsDocument, @@ -72,6 +74,14 @@ export function graphql(source: "\n mutation login($address: String!, $signatur * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function graphql(source: "\n mutation Mutation {\n logout {\n message\n }\n }\n"): (typeof documents)["\n mutation Mutation {\n logout {\n message\n }\n }\n"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "\n mutation createUserByEmail($email: String!) {\n createUserByEmail(email: $email)\n }\n"): (typeof documents)["\n mutation createUserByEmail($email: String!) {\n createUserByEmail(email: $email)\n }\n"]; +/** + * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. + */ +export function graphql(source: "\n mutation sendEmailVerificationLink(\n $email: String!\n $isSigner: Boolean!\n $agreementNumber: String!\n ) {\n sendEmailVerificationLink(email: $email, isSigner: $isSigner, agreementNumber: $agreementNumber)\n }\n"): (typeof documents)["\n mutation sendEmailVerificationLink(\n $email: String!\n $isSigner: Boolean!\n $agreementNumber: String!\n ) {\n sendEmailVerificationLink(email: $email, isSigner: $isSigner, agreementNumber: $agreementNumber)\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/modules/graphql/gql/graphql.ts b/modules/graphql/gql/graphql.ts index d506890..42376cf 100644 --- a/modules/graphql/gql/graphql.ts +++ b/modules/graphql/gql/graphql.ts @@ -273,13 +273,14 @@ export type LogoutResponse = { export type Mutation = { __typename?: 'Mutation'; + createUserByEmail: Scalars['Boolean']; deleteAgreement: DeleteAgreementResponse; - editObservers?: Maybe; + editObservers?: Maybe; login: LoginResponse; logout: LogoutResponse; saveAgreement?: Maybe; - sendAgreementInvitation: SendAgreementInvitationResponseResponse; - sendEmailVerificationLink: User; + sendAgreementInvitation: SendAgreementInvitationResponse; + sendEmailVerificationLink: Scalars['Boolean']; sendSignedFileProofData?: Maybe; sendSignedSignProofData?: Maybe; setAgreementReadyToSign: SetAgreementReadyToSignResponse; @@ -288,6 +289,11 @@ export type Mutation = { }; +export type MutationCreateUserByEmailArgs = { + email: Scalars['String']; +}; + + export type MutationDeleteAgreementArgs = { agreementId: Scalars['Int']; }; @@ -326,6 +332,13 @@ export type MutationSendAgreementInvitationArgs = { }; +export type MutationSendEmailVerificationLinkArgs = { + agreementNumber: Scalars['String']; + email: Scalars['String']; + isSigner: Scalars['Boolean']; +}; + + export type MutationSendSignedFileProofDataArgs = { agreementId: Scalars['Int']; data: AgreementFileProofDataInput; @@ -509,8 +522,8 @@ export type QueryWalletsArgs = { search?: InputMaybe; }; -export type SendAgreementInvitationResponseResponse = { - __typename?: 'SendAgreementInvitationResponseResponse'; +export type SendAgreementInvitationResponse = { + __typename?: 'SendAgreementInvitationResponse'; message: Scalars['String']; }; @@ -629,7 +642,7 @@ export type EditObserversMutationVariables = Exact<{ }>; -export type EditObserversMutation = { __typename?: 'Mutation', editObservers?: { __typename?: 'SendAgreementInvitationResponseResponse', message: string } | null }; +export type EditObserversMutation = { __typename?: 'Mutation', editObservers?: { __typename?: 'SendAgreementInvitationResponse', message: string } | null }; export type LoginMutationVariables = Exact<{ address: Scalars['String']; @@ -644,6 +657,22 @@ export type MutationMutationVariables = Exact<{ [key: string]: never; }>; export type MutationMutation = { __typename?: 'Mutation', logout: { __typename?: 'LogoutResponse', message: string } }; +export type CreateUserByEmailMutationVariables = Exact<{ + email: Scalars['String']; +}>; + + +export type CreateUserByEmailMutation = { __typename?: 'Mutation', createUserByEmail: boolean }; + +export type SendEmailVerificationLinkMutationVariables = Exact<{ + email: Scalars['String']; + isSigner: Scalars['Boolean']; + agreementNumber: Scalars['String']; +}>; + + +export type SendEmailVerificationLinkMutation = { __typename?: 'Mutation', sendEmailVerificationLink: boolean }; + export type VerifyMyEmailMutationVariables = Exact<{ emailVerificationSalt: Scalars['String']; email: Scalars['String']; @@ -719,6 +748,8 @@ export const SendSignedSignProofDataDocument = {"kind":"Document","definitions": export const EditObserversDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"EditObservers"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"observers"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"editObservers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"agreementId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}}},{"kind":"Argument","name":{"kind":"Name","value":"observers"},"value":{"kind":"Variable","name":{"kind":"Name","value":"observers"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}}]}}]}}]} as unknown as DocumentNode; export const LoginDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"login"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"address"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"signature"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"login"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"address"},"value":{"kind":"Variable","name":{"kind":"Name","value":"address"}}},{"kind":"Argument","name":{"kind":"Name","value":"signature"},"value":{"kind":"Variable","name":{"kind":"Name","value":"signature"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}},{"kind":"Field","name":{"kind":"Name","value":"payload"}},{"kind":"Field","name":{"kind":"Name","value":"token"}}]}}]}}]} as unknown as DocumentNode; export const MutationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"Mutation"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"logout"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}}]}}]}}]} as unknown as DocumentNode; +export const CreateUserByEmailDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"createUserByEmail"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createUserByEmail"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}}]}]}}]} as unknown as DocumentNode; +export const SendEmailVerificationLinkDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"sendEmailVerificationLink"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"isSigner"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agreementNumber"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"sendEmailVerificationLink"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}},{"kind":"Argument","name":{"kind":"Name","value":"isSigner"},"value":{"kind":"Variable","name":{"kind":"Name","value":"isSigner"}}},{"kind":"Argument","name":{"kind":"Name","value":"agreementNumber"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agreementNumber"}}}]}]}}]} as unknown as DocumentNode; export const VerifyMyEmailDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"verifyMyEmail"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emailVerificationSalt"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"verifyMyEmail"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"emailVerificationSalt"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emailVerificationSalt"}}},{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}}]}]}}]} as unknown as DocumentNode; export const QueryDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Query"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreement"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"agreementId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreementId"}},{"kind":"Field","name":{"kind":"Name","value":"snapshotProposalUrl"}},{"kind":"Field","name":{"kind":"Name","value":"agreementFile"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreementFileId"}},{"kind":"Field","name":{"kind":"Name","value":"agreementHash"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"filePath"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementLocation"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreementLocationId"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementPrivacy"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementStatus"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"authorWallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}},{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"walletId"}}]}},{"kind":"Field","name":{"kind":"Name","value":"observers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"observerId"}},{"kind":"Field","name":{"kind":"Name","value":"wallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}}]}},{"kind":"Field","name":{"kind":"Name","value":"ens"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"wallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}}]}},{"kind":"Field","name":{"kind":"Name","value":"ens"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"isWaitingForMySignature"}},{"kind":"Field","name":{"kind":"Name","value":"snapshotProposalUrl"}},{"kind":"Field","name":{"kind":"Name","value":"isAllowedToEditObservers"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"signProofs"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"signature"}},{"kind":"Field","name":{"kind":"Name","value":"cid"}},{"kind":"Field","name":{"kind":"Name","value":"signerWalletId"}},{"kind":"Field","name":{"kind":"Name","value":"signerWallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementFileProof"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cid"}},{"kind":"Field","name":{"kind":"Name","value":"signature"}},{"kind":"Field","name":{"kind":"Name","value":"signers"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementProof"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cid"}},{"kind":"Field","name":{"kind":"Name","value":"signedAt"}}]}}]}}]}}]} as unknown as DocumentNode; export const MyAgreementsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"MyAgreements"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"take"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filterBy"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"search"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"skip"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"myAgreements"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"take"},"value":{"kind":"Variable","name":{"kind":"Name","value":"take"}}},{"kind":"Argument","name":{"kind":"Name","value":"filterBy"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filterBy"}}},{"kind":"Argument","name":{"kind":"Name","value":"search"},"value":{"kind":"Variable","name":{"kind":"Name","value":"search"}}},{"kind":"Argument","name":{"kind":"Name","value":"skip"},"value":{"kind":"Variable","name":{"kind":"Name","value":"skip"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreements"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreementId"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"isWaitingForMySignature"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"agreementLocation"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementPrivacy"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementFile"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"filePath"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"authorWallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"phone"}},{"kind":"Field","name":{"kind":"Name","value":"twitterVerificationCode"}},{"kind":"Field","name":{"kind":"Name","value":"twitterVerificationSig"}},{"kind":"Field","name":{"kind":"Name","value":"bio"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"wallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"observers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"wallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementStatus"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"signProofs"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cid"}},{"kind":"Field","name":{"kind":"Name","value":"signature"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"count"}}]}}]}}]} as unknown as DocumentNode; diff --git a/modules/graphql/mutations/user.ts b/modules/graphql/mutations/user.ts index fe3e04e..c35d1ba 100644 --- a/modules/graphql/mutations/user.ts +++ b/modules/graphql/mutations/user.ts @@ -18,6 +18,22 @@ export const logoutMutation = graphql(` } `); +export const createUserByEmailMutation = graphql(` + mutation createUserByEmail($email: String!) { + createUserByEmail(email: $email) + } +`); + +export const sendEmailVerificationLinkMutation = graphql(` + mutation sendEmailVerificationLink( + $email: String! + $isSigner: Boolean! + $agreementNumber: String! + ) { + sendEmailVerificationLink(email: $email, isSigner: $isSigner, agreementNumber: $agreementNumber) + } +`); + export const verifyMyEmailMutation = graphql(` mutation verifyMyEmail($emailVerificationSalt: String!, $email: String!) { verifyMyEmail(emailVerificationSalt: $emailVerificationSalt, email: $email) From 3112bc4f7dc3a62af64549230419b7da08bd1d28 Mon Sep 17 00:00:00 2001 From: Misha Kushka Date: Wed, 3 May 2023 20:58:53 +0800 Subject: [PATCH 03/10] Remove createUserByEmailMutation --- modules/graphql/gql/gql.ts | 5 ----- modules/graphql/gql/graphql.ts | 8 -------- modules/graphql/mutations/user.ts | 6 ------ 3 files changed, 19 deletions(-) diff --git a/modules/graphql/gql/gql.ts b/modules/graphql/gql/gql.ts index bfcebd5..7ecb91d 100644 --- a/modules/graphql/gql/gql.ts +++ b/modules/graphql/gql/gql.ts @@ -20,7 +20,6 @@ const documents = { "\n mutation EditObservers($agreementId: Int, $observers: [String!]) {\n editObservers(agreementId: $agreementId, observers: $observers) {\n message\n }\n }\n": types.EditObserversDocument, "\n mutation login($address: String!, $signature: String) {\n login(address: $address, signature: $signature) {\n message\n payload\n token\n }\n }\n": types.LoginDocument, "\n mutation Mutation {\n logout {\n message\n }\n }\n": types.MutationDocument, - "\n mutation createUserByEmail($email: String!) {\n createUserByEmail(email: $email)\n }\n": types.CreateUserByEmailDocument, "\n mutation sendEmailVerificationLink(\n $email: String!\n $isSigner: Boolean!\n $agreementNumber: String!\n ) {\n sendEmailVerificationLink(email: $email, isSigner: $isSigner, agreementNumber: $agreementNumber)\n }\n": types.SendEmailVerificationLinkDocument, "\n mutation verifyMyEmail($emailVerificationSalt: String!, $email: String!) {\n verifyMyEmail(emailVerificationSalt: $emailVerificationSalt, email: $email)\n }\n": types.VerifyMyEmailDocument, "\n query Query($agreementId: Int!) {\n agreement(agreementId: $agreementId) {\n agreementId\n snapshotProposalUrl\n agreementFile {\n agreementFileId\n agreementHash\n createdAt\n filePath\n }\n agreementLocation {\n agreementLocationId\n isActive\n name\n }\n agreementPrivacy {\n name\n }\n agreementStatus {\n name\n }\n authorWallet {\n address\n networkId\n userId\n walletId\n }\n observers {\n email\n observerId\n wallet {\n address\n }\n ens {\n name\n }\n }\n signers {\n email\n wallet {\n address\n }\n ens {\n name\n }\n }\n title\n content\n isWaitingForMySignature\n snapshotProposalUrl\n isAllowedToEditObservers\n createdAt\n signProofs {\n signature\n cid\n signerWalletId\n signerWallet {\n address\n }\n }\n agreementFileProof {\n cid\n signature\n signers\n }\n agreementProof {\n cid\n signedAt\n }\n }\n }\n": types.QueryDocument, @@ -74,10 +73,6 @@ export function graphql(source: "\n mutation login($address: String!, $signatur * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ export function graphql(source: "\n mutation Mutation {\n logout {\n message\n }\n }\n"): (typeof documents)["\n mutation Mutation {\n logout {\n message\n }\n }\n"]; -/** - * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. - */ -export function graphql(source: "\n mutation createUserByEmail($email: String!) {\n createUserByEmail(email: $email)\n }\n"): (typeof documents)["\n mutation createUserByEmail($email: String!) {\n createUserByEmail(email: $email)\n }\n"]; /** * The graphql function is used to parse GraphQL queries into a document that can be used by GraphQL clients. */ diff --git a/modules/graphql/gql/graphql.ts b/modules/graphql/gql/graphql.ts index 42376cf..e24740e 100644 --- a/modules/graphql/gql/graphql.ts +++ b/modules/graphql/gql/graphql.ts @@ -657,13 +657,6 @@ export type MutationMutationVariables = Exact<{ [key: string]: never; }>; export type MutationMutation = { __typename?: 'Mutation', logout: { __typename?: 'LogoutResponse', message: string } }; -export type CreateUserByEmailMutationVariables = Exact<{ - email: Scalars['String']; -}>; - - -export type CreateUserByEmailMutation = { __typename?: 'Mutation', createUserByEmail: boolean }; - export type SendEmailVerificationLinkMutationVariables = Exact<{ email: Scalars['String']; isSigner: Scalars['Boolean']; @@ -748,7 +741,6 @@ export const SendSignedSignProofDataDocument = {"kind":"Document","definitions": export const EditObserversDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"EditObservers"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"observers"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"editObservers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"agreementId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}}},{"kind":"Argument","name":{"kind":"Name","value":"observers"},"value":{"kind":"Variable","name":{"kind":"Name","value":"observers"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}}]}}]}}]} as unknown as DocumentNode; export const LoginDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"login"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"address"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"signature"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"login"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"address"},"value":{"kind":"Variable","name":{"kind":"Name","value":"address"}}},{"kind":"Argument","name":{"kind":"Name","value":"signature"},"value":{"kind":"Variable","name":{"kind":"Name","value":"signature"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}},{"kind":"Field","name":{"kind":"Name","value":"payload"}},{"kind":"Field","name":{"kind":"Name","value":"token"}}]}}]}}]} as unknown as DocumentNode; export const MutationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"Mutation"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"logout"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}}]}}]}}]} as unknown as DocumentNode; -export const CreateUserByEmailDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"createUserByEmail"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createUserByEmail"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}}]}]}}]} as unknown as DocumentNode; export const SendEmailVerificationLinkDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"sendEmailVerificationLink"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"isSigner"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agreementNumber"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"sendEmailVerificationLink"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}},{"kind":"Argument","name":{"kind":"Name","value":"isSigner"},"value":{"kind":"Variable","name":{"kind":"Name","value":"isSigner"}}},{"kind":"Argument","name":{"kind":"Name","value":"agreementNumber"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agreementNumber"}}}]}]}}]} as unknown as DocumentNode; export const VerifyMyEmailDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"verifyMyEmail"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emailVerificationSalt"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"verifyMyEmail"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"emailVerificationSalt"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emailVerificationSalt"}}},{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}}]}]}}]} as unknown as DocumentNode; export const QueryDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Query"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreement"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"agreementId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreementId"}},{"kind":"Field","name":{"kind":"Name","value":"snapshotProposalUrl"}},{"kind":"Field","name":{"kind":"Name","value":"agreementFile"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreementFileId"}},{"kind":"Field","name":{"kind":"Name","value":"agreementHash"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"filePath"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementLocation"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreementLocationId"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementPrivacy"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementStatus"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"authorWallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}},{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"walletId"}}]}},{"kind":"Field","name":{"kind":"Name","value":"observers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"observerId"}},{"kind":"Field","name":{"kind":"Name","value":"wallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}}]}},{"kind":"Field","name":{"kind":"Name","value":"ens"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"wallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}}]}},{"kind":"Field","name":{"kind":"Name","value":"ens"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"isWaitingForMySignature"}},{"kind":"Field","name":{"kind":"Name","value":"snapshotProposalUrl"}},{"kind":"Field","name":{"kind":"Name","value":"isAllowedToEditObservers"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"signProofs"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"signature"}},{"kind":"Field","name":{"kind":"Name","value":"cid"}},{"kind":"Field","name":{"kind":"Name","value":"signerWalletId"}},{"kind":"Field","name":{"kind":"Name","value":"signerWallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementFileProof"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cid"}},{"kind":"Field","name":{"kind":"Name","value":"signature"}},{"kind":"Field","name":{"kind":"Name","value":"signers"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementProof"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cid"}},{"kind":"Field","name":{"kind":"Name","value":"signedAt"}}]}}]}}]}}]} as unknown as DocumentNode; diff --git a/modules/graphql/mutations/user.ts b/modules/graphql/mutations/user.ts index c35d1ba..846267b 100644 --- a/modules/graphql/mutations/user.ts +++ b/modules/graphql/mutations/user.ts @@ -18,12 +18,6 @@ export const logoutMutation = graphql(` } `); -export const createUserByEmailMutation = graphql(` - mutation createUserByEmail($email: String!) { - createUserByEmail(email: $email) - } -`); - export const sendEmailVerificationLinkMutation = graphql(` mutation sendEmailVerificationLink( $email: String! From 6e6488bdc621706c3e747c8cda036cad1d5ab63f Mon Sep 17 00:00:00 2001 From: Misha Kushka Date: Fri, 5 May 2023 15:10:56 +0100 Subject: [PATCH 04/10] User sign up by email works --- components/Connect/index.tsx | 4 ++++ .../CreateAgreement/Steps/StepTwo/index.tsx | 12 +++--------- modules/authProvider.tsx | 17 ++++++++++++----- modules/graphql/gql/gql.ts | 8 ++++---- modules/graphql/gql/graphql.ts | 15 +++++---------- modules/graphql/mutations/user.ts | 8 ++++---- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/components/Connect/index.tsx b/components/Connect/index.tsx index e082d32..c5488e1 100644 --- a/components/Connect/index.tsx +++ b/components/Connect/index.tsx @@ -38,6 +38,10 @@ export default function Connect() { init(); }, []); + // useEffect(() => { + // await login(name, query.email as string, query.salt as string); + // }, []); // eslint-disable-line react-hooks/exhaustive-deps + return ( >) => { profile: null, //isTrezor: false, }); - const { push, pathname } = useRouter(); + const { push, pathname, query } = useRouter(); const [, loginRequest] = useMutation(loginMutation); const [, verifyMyEmailRequest] = useMutation(verifyMyEmailMutation); @@ -77,6 +77,10 @@ const AuthProvider = (props?: Partial>) => { const web3ProviderRef = useRef(); async function login(connector?: ConnectorType, email?: string, emailVerificationSalt?: string) { + console.log(`Login. ${email}`); + email = email ?? (query.email as string); + emailVerificationSalt = emailVerificationSalt ?? (query.emailVerificationSalt as string); + console.log({ query }); // Prevent double loginRequest due to react dev useEffect[] runs twice if (loginStarted.current) return; loginStarted.current = true; @@ -122,10 +126,11 @@ const AuthProvider = (props?: Partial>) => { } async function onAfterConnect(account: string, email?: string, emailVerificationSalt?: string) { + console.log(`onAfterConnect. ${email}`); if (!account) return; if (getToken()) return; // user already has a token - const res = await loginRequest({ address: account }); + const res = await loginRequest({ address: account, email }); const payload = res?.data?.login?.payload; if (!payload) return; @@ -133,6 +138,7 @@ const AuthProvider = (props?: Partial>) => { const signature = await sign(payload); const tokenRes = await loginRequest({ address: account, + email, signature: signature, }); @@ -142,6 +148,7 @@ const AuthProvider = (props?: Partial>) => { setToken(token); // Sign up by email + console.log({ email }); if (email) { const isVerified = await verifyMyEmailRequest({ email, @@ -296,9 +303,9 @@ const AuthProvider = (props?: Partial>) => { return await web3ProviderRef.current?.resolveName(name); } - useEffect(() => { - login(); - }, []); // eslint-disable-line react-hooks/exhaustive-deps + // useEffect(() => { + // login(); + // }, []); // eslint-disable-line react-hooks/exhaustive-deps return ( ; login: LoginResponse; @@ -289,11 +288,6 @@ export type Mutation = { }; -export type MutationCreateUserByEmailArgs = { - email: Scalars['String']; -}; - - export type MutationDeleteAgreementArgs = { agreementId: Scalars['Int']; }; @@ -333,7 +327,7 @@ export type MutationSendAgreementInvitationArgs = { export type MutationSendEmailVerificationLinkArgs = { - agreementNumber: Scalars['String']; + agreementTitle: Scalars['String']; email: Scalars['String']; isSigner: Scalars['Boolean']; }; @@ -646,6 +640,7 @@ export type EditObserversMutation = { __typename?: 'Mutation', editObservers?: { export type LoginMutationVariables = Exact<{ address: Scalars['String']; + email?: InputMaybe; signature?: InputMaybe; }>; @@ -660,7 +655,7 @@ export type MutationMutation = { __typename?: 'Mutation', logout: { __typename?: export type SendEmailVerificationLinkMutationVariables = Exact<{ email: Scalars['String']; isSigner: Scalars['Boolean']; - agreementNumber: Scalars['String']; + agreementTitle: Scalars['String']; }>; @@ -739,9 +734,9 @@ export const DeleteAgreementMutationDocument = {"kind":"Document","definitions": export const SendSignedFileProofDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"sendSignedFileProofData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"data"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"AgreementFileProofDataInput"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"signature"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"sendSignedFileProofData"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"data"},"value":{"kind":"Variable","name":{"kind":"Name","value":"data"}}},{"kind":"Argument","name":{"kind":"Name","value":"signature"},"value":{"kind":"Variable","name":{"kind":"Name","value":"signature"}}},{"kind":"Argument","name":{"kind":"Name","value":"agreementId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cid"}}]}}]}}]} as unknown as DocumentNode; export const SendSignedSignProofDataDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"sendSignedSignProofData"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"data"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"AgreementSignProofDataInput"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"signature"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"sendSignedSignProofData"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"data"},"value":{"kind":"Variable","name":{"kind":"Name","value":"data"}}},{"kind":"Argument","name":{"kind":"Name","value":"signature"},"value":{"kind":"Variable","name":{"kind":"Name","value":"signature"}}},{"kind":"Argument","name":{"kind":"Name","value":"agreementId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cid"}}]}}]}}]} as unknown as DocumentNode; export const EditObserversDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"EditObservers"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"observers"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"editObservers"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"agreementId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}}},{"kind":"Argument","name":{"kind":"Name","value":"observers"},"value":{"kind":"Variable","name":{"kind":"Name","value":"observers"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}}]}}]}}]} as unknown as DocumentNode; -export const LoginDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"login"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"address"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"signature"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"login"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"address"},"value":{"kind":"Variable","name":{"kind":"Name","value":"address"}}},{"kind":"Argument","name":{"kind":"Name","value":"signature"},"value":{"kind":"Variable","name":{"kind":"Name","value":"signature"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}},{"kind":"Field","name":{"kind":"Name","value":"payload"}},{"kind":"Field","name":{"kind":"Name","value":"token"}}]}}]}}]} as unknown as DocumentNode; +export const LoginDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"login"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"address"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"signature"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"login"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"address"},"value":{"kind":"Variable","name":{"kind":"Name","value":"address"}}},{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}},{"kind":"Argument","name":{"kind":"Name","value":"signature"},"value":{"kind":"Variable","name":{"kind":"Name","value":"signature"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}},{"kind":"Field","name":{"kind":"Name","value":"payload"}},{"kind":"Field","name":{"kind":"Name","value":"token"}}]}}]}}]} as unknown as DocumentNode; export const MutationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"Mutation"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"logout"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"message"}}]}}]}}]} as unknown as DocumentNode; -export const SendEmailVerificationLinkDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"sendEmailVerificationLink"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"isSigner"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agreementNumber"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"sendEmailVerificationLink"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}},{"kind":"Argument","name":{"kind":"Name","value":"isSigner"},"value":{"kind":"Variable","name":{"kind":"Name","value":"isSigner"}}},{"kind":"Argument","name":{"kind":"Name","value":"agreementNumber"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agreementNumber"}}}]}]}}]} as unknown as DocumentNode; +export const SendEmailVerificationLinkDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"sendEmailVerificationLink"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"isSigner"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agreementTitle"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"sendEmailVerificationLink"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}},{"kind":"Argument","name":{"kind":"Name","value":"isSigner"},"value":{"kind":"Variable","name":{"kind":"Name","value":"isSigner"}}},{"kind":"Argument","name":{"kind":"Name","value":"agreementTitle"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agreementTitle"}}}]}]}}]} as unknown as DocumentNode; export const VerifyMyEmailDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"verifyMyEmail"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"emailVerificationSalt"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"email"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"verifyMyEmail"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"emailVerificationSalt"},"value":{"kind":"Variable","name":{"kind":"Name","value":"emailVerificationSalt"}}},{"kind":"Argument","name":{"kind":"Name","value":"email"},"value":{"kind":"Variable","name":{"kind":"Name","value":"email"}}}]}]}}]} as unknown as DocumentNode; export const QueryDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"Query"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreement"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"agreementId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"agreementId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreementId"}},{"kind":"Field","name":{"kind":"Name","value":"snapshotProposalUrl"}},{"kind":"Field","name":{"kind":"Name","value":"agreementFile"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreementFileId"}},{"kind":"Field","name":{"kind":"Name","value":"agreementHash"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"filePath"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementLocation"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreementLocationId"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementPrivacy"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementStatus"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"authorWallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}},{"kind":"Field","name":{"kind":"Name","value":"networkId"}},{"kind":"Field","name":{"kind":"Name","value":"userId"}},{"kind":"Field","name":{"kind":"Name","value":"walletId"}}]}},{"kind":"Field","name":{"kind":"Name","value":"observers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"observerId"}},{"kind":"Field","name":{"kind":"Name","value":"wallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}}]}},{"kind":"Field","name":{"kind":"Name","value":"ens"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"wallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}}]}},{"kind":"Field","name":{"kind":"Name","value":"ens"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"isWaitingForMySignature"}},{"kind":"Field","name":{"kind":"Name","value":"snapshotProposalUrl"}},{"kind":"Field","name":{"kind":"Name","value":"isAllowedToEditObservers"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"signProofs"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"signature"}},{"kind":"Field","name":{"kind":"Name","value":"cid"}},{"kind":"Field","name":{"kind":"Name","value":"signerWalletId"}},{"kind":"Field","name":{"kind":"Name","value":"signerWallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementFileProof"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cid"}},{"kind":"Field","name":{"kind":"Name","value":"signature"}},{"kind":"Field","name":{"kind":"Name","value":"signers"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementProof"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cid"}},{"kind":"Field","name":{"kind":"Name","value":"signedAt"}}]}}]}}]}}]} as unknown as DocumentNode; export const MyAgreementsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"MyAgreements"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"take"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"filterBy"}},"type":{"kind":"ListType","type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"search"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"skip"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Int"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"myAgreements"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"take"},"value":{"kind":"Variable","name":{"kind":"Name","value":"take"}}},{"kind":"Argument","name":{"kind":"Name","value":"filterBy"},"value":{"kind":"Variable","name":{"kind":"Name","value":"filterBy"}}},{"kind":"Argument","name":{"kind":"Name","value":"search"},"value":{"kind":"Variable","name":{"kind":"Name","value":"search"}}},{"kind":"Argument","name":{"kind":"Name","value":"skip"},"value":{"kind":"Variable","name":{"kind":"Name","value":"skip"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreements"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"agreementId"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"content"}},{"kind":"Field","name":{"kind":"Name","value":"isWaitingForMySignature"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"agreementLocation"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"isActive"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementPrivacy"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementFile"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"filePath"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}}]}},{"kind":"Field","name":{"kind":"Name","value":"authorWallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"phone"}},{"kind":"Field","name":{"kind":"Name","value":"twitterVerificationCode"}},{"kind":"Field","name":{"kind":"Name","value":"twitterVerificationSig"}},{"kind":"Field","name":{"kind":"Name","value":"bio"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"signers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"wallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"observers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"email"}},{"kind":"Field","name":{"kind":"Name","value":"wallet"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"address"}},{"kind":"Field","name":{"kind":"Name","value":"user"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"agreementStatus"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}}]}},{"kind":"Field","name":{"kind":"Name","value":"signProofs"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cid"}},{"kind":"Field","name":{"kind":"Name","value":"signature"}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"count"}}]}}]}}]} as unknown as DocumentNode; diff --git a/modules/graphql/mutations/user.ts b/modules/graphql/mutations/user.ts index 846267b..ae93e28 100644 --- a/modules/graphql/mutations/user.ts +++ b/modules/graphql/mutations/user.ts @@ -1,8 +1,8 @@ import { graphql } from "../gql"; export const loginMutation = graphql(` - mutation login($address: String!, $signature: String) { - login(address: $address, signature: $signature) { + mutation login($address: String!, $email: String, $signature: String) { + login(address: $address, email: $email, signature: $signature) { message payload token @@ -22,9 +22,9 @@ export const sendEmailVerificationLinkMutation = graphql(` mutation sendEmailVerificationLink( $email: String! $isSigner: Boolean! - $agreementNumber: String! + $agreementTitle: String! ) { - sendEmailVerificationLink(email: $email, isSigner: $isSigner, agreementNumber: $agreementNumber) + sendEmailVerificationLink(email: $email, isSigner: $isSigner, agreementTitle: $agreementTitle) } `); From 7c58ec0b37ca43b5d240882a83619e04adca63de Mon Sep 17 00:00:00 2001 From: Misha Kushka Date: Fri, 5 May 2023 15:17:37 +0100 Subject: [PATCH 05/10] Auto redirect to /connect page from the home page when needed --- modules/authProvider.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/modules/authProvider.tsx b/modules/authProvider.tsx index 4fc348f..696436a 100644 --- a/modules/authProvider.tsx +++ b/modules/authProvider.tsx @@ -76,6 +76,8 @@ const AuthProvider = (props?: Partial>) => { const web3ProviderRef = useRef(); + // const redirectToConnectScreenIfNeeded = () => {} + async function login(connector?: ConnectorType, email?: string, emailVerificationSalt?: string) { console.log(`Login. ${email}`); email = email ?? (query.email as string); @@ -303,9 +305,18 @@ const AuthProvider = (props?: Partial>) => { return await web3ProviderRef.current?.resolveName(name); } - // useEffect(() => { - // login(); - // }, []); // eslint-disable-line react-hooks/exhaustive-deps + useEffect(() => { + // Auto redirect to /connect page from the home page when needed + (async () => { + const hasToken = Boolean(getToken()); + const loadedConnector = await auth.getConnector(); + if ((!loadedConnector || !hasToken) && pathname !== "/connect") { + clearToken(); + await push("/connect"); + loginStarted.current = false; + } + })(); + }); return ( Date: Fri, 5 May 2023 15:22:02 +0100 Subject: [PATCH 06/10] Fixes --- components/Connect/index.tsx | 4 ---- components/CreateAgreement/Steps/StepTwo/index.tsx | 1 - modules/authProvider.tsx | 10 +--------- 3 files changed, 1 insertion(+), 14 deletions(-) diff --git a/components/Connect/index.tsx b/components/Connect/index.tsx index c5488e1..e082d32 100644 --- a/components/Connect/index.tsx +++ b/components/Connect/index.tsx @@ -38,10 +38,6 @@ export default function Connect() { init(); }, []); - // useEffect(() => { - // await login(name, query.email as string, query.salt as string); - // }, []); // eslint-disable-line react-hooks/exhaustive-deps - return ( >) => { const [, verifyMyEmailRequest] = useMutation(verifyMyEmailMutation); const auth = useLock(); - const loginStarted = useRef(false); - const web3ProviderRef = useRef(); - // const redirectToConnectScreenIfNeeded = () => {} - async function login(connector?: ConnectorType, email?: string, emailVerificationSalt?: string) { - console.log(`Login. ${email}`); email = email ?? (query.email as string); emailVerificationSalt = emailVerificationSalt ?? (query.emailVerificationSalt as string); - console.log({ query }); // Prevent double loginRequest due to react dev useEffect[] runs twice if (loginStarted.current) return; loginStarted.current = true; @@ -128,7 +122,6 @@ const AuthProvider = (props?: Partial>) => { } async function onAfterConnect(account: string, email?: string, emailVerificationSalt?: string) { - console.log(`onAfterConnect. ${email}`); if (!account) return; if (getToken()) return; // user already has a token @@ -150,7 +143,6 @@ const AuthProvider = (props?: Partial>) => { setToken(token); // Sign up by email - console.log({ email }); if (email) { const isVerified = await verifyMyEmailRequest({ email, @@ -236,7 +228,7 @@ const AuthProvider = (props?: Partial>) => { //@ts-ignore provider.value?.wc?.peerMeta?.name || null; } catch (e) { - console.log("ERROR load web3", e); + console.error("ERROR load web3", e); //setState((state) => ({ ...state, account: "" })); loadedState.account = ""; From 44dcaf4ff4e3c20e812829f1b58a794450c9e5c3 Mon Sep 17 00:00:00 2001 From: Misha Kushka Date: Mon, 8 May 2023 12:43:47 +0100 Subject: [PATCH 07/10] Fix redirect to /connect or re-login --- modules/authProvider.tsx | 43 ++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/modules/authProvider.tsx b/modules/authProvider.tsx index a14fc53..c35edc0 100644 --- a/modules/authProvider.tsx +++ b/modules/authProvider.tsx @@ -66,7 +66,7 @@ const AuthProvider = (props?: Partial>) => { profile: null, //isTrezor: false, }); - const { push, pathname, query } = useRouter(); + const { push, pathname, query, isReady } = useRouter(); const [, loginRequest] = useMutation(loginMutation); const [, verifyMyEmailRequest] = useMutation(verifyMyEmailMutation); @@ -75,8 +75,14 @@ const AuthProvider = (props?: Partial>) => { const web3ProviderRef = useRef(); async function login(connector?: ConnectorType, email?: string, emailVerificationSalt?: string) { + console.log("login()"); + console.log({ query }); email = email ?? (query.email as string); emailVerificationSalt = emailVerificationSalt ?? (query.emailVerificationSalt as string); + console.log({ + email, + emailVerificationSalt, + }); // Prevent double loginRequest due to react dev useEffect[] runs twice if (loginStarted.current) return; loginStarted.current = true; @@ -125,6 +131,9 @@ const AuthProvider = (props?: Partial>) => { if (!account) return; if (getToken()) return; // user already has a token + console.log("onAfterConnect"); + console.log({ email, emailVerificationSalt }); + const res = await loginRequest({ address: account, email }); const payload = res?.data?.login?.payload; @@ -297,18 +306,25 @@ const AuthProvider = (props?: Partial>) => { return await web3ProviderRef.current?.resolveName(name); } - useEffect(() => { - // Auto redirect to /connect page from the home page when needed - (async () => { - const hasToken = Boolean(getToken()); - const loadedConnector = await auth.getConnector(); - if ((!loadedConnector || !hasToken) && pathname !== "/connect") { - clearToken(); - await push("/connect"); - loginStarted.current = false; + async function loginWhenNecessary() { + const hasToken = Boolean(getToken()); + const loadedConnector = await auth.getConnector(); + if ((!loadedConnector || !hasToken) && pathname !== "/connect") { + // Redirect to the connect page + clearToken(); + await push("/connect"); + loginStarted.current = false; + } else { + // Perform user login + if (isReady && pathname !== "/connect") { + login(); } - })(); - }); + } + } + + useEffect(() => { + loginWhenNecessary(); + }, [isReady]); // eslint-disable-line react-hooks/exhaustive-deps return ( >) => { signTypedData, _signTypedData, resolveEns, - //loadProvider, - //handleChainChanged, - //web3: state, ...state, }} /> From bedded183cb8372c2d0b519c6da3c674fddd2585 Mon Sep 17 00:00:00 2001 From: Misha Kushka Date: Mon, 8 May 2023 13:44:37 +0100 Subject: [PATCH 08/10] Send user invitation emails only when agreement editing is done --- components/CreateAgreement/NavPanel.tsx | 45 ++++++++++++++++++- .../CreateAgreement/Steps/StepTwo/index.tsx | 27 +++-------- components/CreateAgreement/utils/index.ts | 1 + 3 files changed, 50 insertions(+), 23 deletions(-) create mode 100644 components/CreateAgreement/utils/index.ts diff --git a/components/CreateAgreement/NavPanel.tsx b/components/CreateAgreement/NavPanel.tsx index 561f144..ef6312f 100644 --- a/components/CreateAgreement/NavPanel.tsx +++ b/components/CreateAgreement/NavPanel.tsx @@ -22,7 +22,10 @@ import { fW, } from "./styles"; import { useMutation } from "urql"; -import { saveAgreementMutation } from "../../modules/graphql/mutations"; +import { + saveAgreementMutation, + sendEmailVerificationLinkMutation, +} from "../../modules/graphql/mutations"; import { LOCATION_CLOUD, LOCATION_PUBLIC_IPFS, @@ -44,6 +47,7 @@ import { uploadFile, uploadToIpfs } from "../../modules/rest"; import { notifError } from "../../utils/notification"; import ModalConfirmAgreementDeletion from "../ModalConfirmAgreementDeletion/ModalConfirmAgreementDeletion"; import { getToken } from "../../utils/token"; +import { isEmail } from "./utils"; const FILE_UPLOAD_ERROR_DEFAULT_MESSAGE = "Failed to upload file"; @@ -64,9 +68,9 @@ export default function NavPanel({ setLoading, page }: { setLoading: any; page: const [isLoadingNextStep, setIsLoadingNextStep] = useState(false); const [isAuthorNotAddedPopupVisible, setIsAuthorNotAddedPopupVisible] = useState(false); - const [isConfirmAgreementDeletionPopupVisible, setIsConfirmAgreementDeletionPopupVisible] = useState(false); + const [, sendEmailVerificationLinkRequest] = useMutation(sendEmailVerificationLinkMutation); const validateFields = (values: CreationState, isSavingDraft: boolean = false): boolean => { const errors: CreateAgreementFieldErrors = {}; @@ -203,8 +207,41 @@ export default function NavPanel({ setLoading, page }: { setLoading: any; page: }); }; + const sendEmailVerificationEmails = async (signers: string[], observers: string[]) => { + console.log("sendEmailVerificationEmails"); + console.log({ signers, observers }); + + signers.forEach(async signer => { + if (isEmail(signer)) { + console.log(`seding an email to ${signer}`); + await sendEmailVerificationLinkRequest({ + email: signer, + isSigner: true, + agreementTitle: values.title, + }); + } + }); + + observers.forEach(async observer => { + if (isEmail(observer)) { + console.log(`seding an email to ${observer}`); + await sendEmailVerificationLinkRequest({ + email: observer, + isSigner: false, + agreementTitle: values.title, + }); + } + }); + }; + const handleSaveDraft = async () => { + console.log("handleSaveDraft"); const areFieldsValid = validateFields(values, true); + await sendEmailVerificationEmails( + values.signers.map(x => x.value), + values.observers.map(x => x.value) + ); + console.log({ values }); if (areFieldsValid) { const uploadFileData: any = await preuploadFile(); await handleCreateAgreement(uploadFileData?.filePath, uploadFileData?.agreementHash); @@ -348,6 +385,10 @@ export default function NavPanel({ setLoading, page }: { setLoading: any; page: const areFieldsValid = validateFields({ ...values, ...uploadedFileData }); if (areFieldsValid) { if (isFinishButton) { + await sendEmailVerificationEmails( + values.signers.map(x => x.value), + values.observers.map(x => x.value) + ); await handleCreateAgreement(); } else { handleNextStep(); diff --git a/components/CreateAgreement/Steps/StepTwo/index.tsx b/components/CreateAgreement/Steps/StepTwo/index.tsx index d6cdeb4..33c0068 100644 --- a/components/CreateAgreement/Steps/StepTwo/index.tsx +++ b/components/CreateAgreement/Steps/StepTwo/index.tsx @@ -23,8 +23,7 @@ import Icon from "../../../icon"; import { PlusIcon } from "./svg"; import styles from "./styles"; import { notifComingSoon } from "../../../../utils/notification"; -import { sendEmailVerificationLinkMutation } from "../../../../modules/graphql/mutations"; -import { useMutation } from "urql"; +import { isEmail } from "../../utils"; interface VerificationInfo { title: string; @@ -32,8 +31,6 @@ interface VerificationInfo { description: string; } -const isEmail = (x: string) => x?.includes("@"); - const verifications: VerificationInfo[] = [ { title: "Anonymous", @@ -67,7 +64,6 @@ export default function StepTwo({ page }: { page: string }) { const edit = useEditAgreement(); const { values, changeValue } = page === "create" ? create : edit; const { account, resolveEns } = useWeb3(); - const [, sendEmailVerificationLinkRequest] = useMutation(sendEmailVerificationLinkMutation); const signersInputErrorStyles = values?.errors?.signers ? inputCreateAgreementError : {}; const observersInputErrorStyles = values?.errors?.observers ? inputCreateAgreementError : {}; @@ -177,14 +173,6 @@ export default function StepTwo({ page }: { page: string }) { return; } - if (isEmail(value)) { - await sendEmailVerificationLinkRequest({ - email: value, - isSigner: true, - agreementTitle: values.title, - }); - } - changeValue("signers", [ ...values.signers, { value: value.toLocaleLowerCase(), id: uniqueId() }, @@ -207,14 +195,6 @@ export default function StepTwo({ page }: { page: string }) { return; } - if (isEmail(value)) { - await sendEmailVerificationLinkRequest({ - email: value, - isSigner: false, - agreementTitle: values.title, - }); - } - changeValue("observers", [ ...values.observers, { value: value.toLocaleLowerCase(), id: uniqueId() }, @@ -234,6 +214,7 @@ export default function StepTwo({ page }: { page: string }) { return ( <> + {/* Signers */} + + {/* Observers */} + + {/* Required Verifications */} x?.includes("@"); From c28ab8a99c0f980a252e5a172a9949c57556a4e4 Mon Sep 17 00:00:00 2001 From: Misha Kushka Date: Tue, 9 May 2023 10:45:24 +0100 Subject: [PATCH 09/10] Show user email on view agreement --- components/ViewAgreement/AgreementSignersList.tsx | 4 ++-- components/ViewAgreement/ObserverRow.tsx | 6 +++--- components/ViewAgreement/index.tsx | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/ViewAgreement/AgreementSignersList.tsx b/components/ViewAgreement/AgreementSignersList.tsx index a6ea3d1..e3ccce6 100644 --- a/components/ViewAgreement/AgreementSignersList.tsx +++ b/components/ViewAgreement/AgreementSignersList.tsx @@ -35,8 +35,8 @@ export const AgreementSignersList = ({ signers }: Props) => { - - + + diff --git a/components/ViewAgreement/ObserverRow.tsx b/components/ViewAgreement/ObserverRow.tsx index ae87f2c..62ea830 100644 --- a/components/ViewAgreement/ObserverRow.tsx +++ b/components/ViewAgreement/ObserverRow.tsx @@ -26,10 +26,10 @@ export const ObserverRow = ({ observer }: Props) => { const address = useMemo( () => - observer?.wallet?.address - ? observer.wallet.address - : !!observer?.email?.startsWith("0x") + !!observer?.email?.length ? observer?.email + : observer?.wallet?.address + ? observer?.wallet?.address : "", [observer] ); diff --git a/components/ViewAgreement/index.tsx b/components/ViewAgreement/index.tsx index adcbfc6..a62c6ed 100644 --- a/components/ViewAgreement/index.tsx +++ b/components/ViewAgreement/index.tsx @@ -2,7 +2,7 @@ import React, { useCallback, useEffect, useMemo, useState } from "react"; import { Box, Button, Flex } from "theme-ui"; import { useRouter } from "next/router"; -import { useMutation, useQuery, useClient } from "urql"; +import { useClient } from "urql"; import { agreementById } from "../../modules/graphql/queries"; import { From cf442445dffafca95f760a2519d898627e5d3064 Mon Sep 17 00:00:00 2001 From: Misha Kushka Date: Mon, 15 May 2023 19:13:19 +0200 Subject: [PATCH 10/10] Agreement View: Display signer/observer address/email correctly --- components/ViewAgreement/AgreementObserversList.tsx | 4 ++-- components/ViewAgreement/AgreementSignersList.tsx | 2 +- components/ViewAgreement/SignerRow.tsx | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/ViewAgreement/AgreementObserversList.tsx b/components/ViewAgreement/AgreementObserversList.tsx index 5b20155..bc73d80 100644 --- a/components/ViewAgreement/AgreementObserversList.tsx +++ b/components/ViewAgreement/AgreementObserversList.tsx @@ -33,8 +33,8 @@ export const AgreementObserversList = ({ observers }: Props) => {
Signer NameSigner AddressNameAddress/Email Signature status Proof of signature
- - + + diff --git a/components/ViewAgreement/AgreementSignersList.tsx b/components/ViewAgreement/AgreementSignersList.tsx index e3ccce6..4b53f3e 100644 --- a/components/ViewAgreement/AgreementSignersList.tsx +++ b/components/ViewAgreement/AgreementSignersList.tsx @@ -36,7 +36,7 @@ export const AgreementSignersList = ({ signers }: Props) => { - + diff --git a/components/ViewAgreement/SignerRow.tsx b/components/ViewAgreement/SignerRow.tsx index 931d852..3509dad 100644 --- a/components/ViewAgreement/SignerRow.tsx +++ b/components/ViewAgreement/SignerRow.tsx @@ -35,10 +35,10 @@ export const SignerRow = ({ signer, signProof, viewProof }: Props) => { const address = useMemo( () => - signer?.wallet?.address - ? signer.wallet.address - : !!signer?.email?.startsWith("0x") + !!signer?.email?.length ? signer?.email + : signer?.wallet?.address + ? signer?.wallet?.address : "", [signer] );
Observer NameObserver AddressNameAddress/Email/ENS
NameAddress/EmailAddress/Email/ENS Signature status Proof of signature