From 897ff94a6666df2df60f4db6b7b1ed124e97a868 Mon Sep 17 00:00:00 2001 From: cryptooda Date: Sun, 2 Jun 2024 15:56:52 +0700 Subject: [PATCH] Add test wallets --- src/Managing.Application/Users/UserService.cs | 4 ++-- .../src/components/mollecules/LogIn/LogIn.tsx | 14 ++++++++------ .../src/components/mollecules/Toast/Toast.tsx | 8 ++++++-- .../src/pages/backtestPage/backtestScanner.tsx | 15 +++++++++------ 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/Managing.Application/Users/UserService.cs b/src/Managing.Application/Users/UserService.cs index 84f2e4d..0b37d1a 100644 --- a/src/Managing.Application/Users/UserService.cs +++ b/src/Managing.Application/Users/UserService.cs @@ -11,7 +11,7 @@ public class UserService : IUserService private readonly IUserRepository _userRepository; private readonly IAccountService _accountService; - private string[] authorizedAddresses = new string[] { "0x6781920674dA695aa5120d95D80c4B1788046806" }; + private string[] authorizedAddresses = ["0x6781920674dA695aa5120d95D80c4B1788046806", "0xA2B43AFF0992a47838DF2e6099A8439981f0B717"]; public UserService( IEvmManager evmManager, @@ -29,7 +29,7 @@ public class UserService : IUserService if (!authorizedAddresses.Contains(recoveredAddress)) throw new Exception("Address not authorized"); - + if (recoveredAddress == null || !recoveredAddress.Equals(address)) throw new Exception("Address not corresponding"); diff --git a/src/Managing.WebApp/src/components/mollecules/LogIn/LogIn.tsx b/src/Managing.WebApp/src/components/mollecules/LogIn/LogIn.tsx index b80ff7a..92eca05 100644 --- a/src/Managing.WebApp/src/components/mollecules/LogIn/LogIn.tsx +++ b/src/Managing.WebApp/src/components/mollecules/LogIn/LogIn.tsx @@ -8,21 +8,24 @@ import { UserClient } from '../../../generated/ManagingApi' import type { ILoginFormInput } from '../../../global/type' import useCookie from '../../../hooks/useCookie' import { SecondaryNavbar } from '../NavBar/NavBar' +import Toast from '../Toast/Toast' const LogIn = () => { const { apiUrl } = useApiUrlStore() const { register, handleSubmit } = useForm() const { disconnect } = useDisconnect() const { address } = useAccount() - const { isLoading, signMessageAsync } = useSignMessage({}) + const { signMessageAsync } = useSignMessage({}) const { setCookie } = useCookie() const onSubmit: SubmitHandler = async (form) => { const message = 'wagmi' const signature = await signMessageAsync({ message }) + const t = new Toast('Creating token') if (signature && address) { const userClient = new UserClient({}, apiUrl) + await userClient .user_CreateToken({ address: address.toString(), @@ -34,11 +37,11 @@ const LogIn = () => { setCookie('token', data, 1) location.reload() }) - .catch((err) => { - // eslint-disable-next-line no-console - console.error(err) + .catch((err: any) => { + t.update('error', 'Error :' + err.message) }) - } else { + }else{ + t.update('error', 'Error : No signature') } } @@ -77,7 +80,6 @@ const LogIn = () => { - +