Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pociej committed Jun 14, 2024
1 parent b0e3daa commit f6368ec
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 201 deletions.
139 changes: 0 additions & 139 deletions frontend/src/components/homePage/modals/extendDepositForm.tsx

This file was deleted.

51 changes: 27 additions & 24 deletions frontend/src/components/providers/blockchainProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { createWeb3Modal } from "@web3modal/wagmi/react";
import { defaultWagmiConfig } from "@web3modal/wagmi/react/config";
import { SIWECreateMessageArgs, createSIWEConfig, formatMessage } from "@web3modal/siwe";
import {
SIWECreateMessageArgs,
createSIWEConfig,
formatMessage,
} from "@web3modal/siwe";
import { SiweMessage } from "siwe";

import { WagmiProvider, http } from "wagmi";
Expand Down Expand Up @@ -29,14 +33,7 @@ const wagmiConfig = defaultWagmiConfig({
metadata,
});




function createMessage({ nonce, address, chainId }: any) {
console.log('creating message ');
console.log('nonce', nonce);
console.log('address', address);
console.log('chainId', chainId);
const message = new SiweMessage({
version: "1",
domain: window.location.host,
Expand All @@ -46,8 +43,6 @@ function createMessage({ nonce, address, chainId }: any) {
nonce: nonce.toString(),
statement: "Sign in with ethereum",
});
console.log("message", message);
console.log("message.prepareMessage()", message.prepareMessage());
return message.prepareMessage();
}

Expand All @@ -59,17 +54,18 @@ console.log("message.prepareMessage()", message.prepareMessage());
// signOut
// })

async function getMessageParams(){
async function getMessageParams() {
return {
domain: window.location.host,
uri: window.location.origin,
chains: [1, 2020],
statement: 'Please sign with your account'
}
statement: "Please sign with your account",
};
}
// // @ts-ignore
const siweConfig = createSIWEConfig({
createMessage: ({ address, ...args }: SIWECreateMessageArgs) => formatMessage(args, address),
createMessage: ({ address, ...args }: SIWECreateMessageArgs) =>
formatMessage(args, address),
getMessageParams,
getNonce: async (address) => {
if (!address) {
Expand Down Expand Up @@ -97,12 +93,15 @@ const siweConfig = createSIWEConfig({
},
// @ts-ignore
async getSession() {
return new Promise((resolve) => setTimeout( ()=> {
resolve({
// @ts-ignore
address: localStorage.getItem("address"),
chainId: 1,
})}, 1000));
return new Promise((resolve) =>
setTimeout(() => {
resolve({
// @ts-ignore
address: localStorage.getItem("address"),
chainId: 1,
});
}, 1000)
);
},
verifyMessage: async ({ message, signature }) => {
const res = await fetch(`${import.meta.env.VITE_BACKEND_HTTP_URL}/login`, {
Expand All @@ -122,18 +121,22 @@ const siweConfig = createSIWEConfig({
localStorage.setItem("accessToken", data.accessToken);
localStorage.setItem("refreshToken", data.refreshToken);

window.dispatchEvent(new StorageEvent("storage", { key : 'accessToken', newValue : data.accessToken }));

window.dispatchEvent(
new StorageEvent("storage", {
key: "accessToken",
newValue: data.accessToken,
})
);

return true;
},
signOut: async () => {
localStorage.removeItem("accessToken");
localStorage.removeItem("refreshToken");
localStorage.removeItem("address");

return false;
}
},
});

createWeb3Modal({
Expand Down
1 change: 0 additions & 1 deletion frontend/src/components/providers/userProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ const withUserInterface = function (
return !!user.currentAllocation?.id;
},
hasAgreement() {
console.log("user.currentAgreement", user.currentAgreement);
return !!user.currentAgreement?.id;
},
};
Expand Down
1 change: 0 additions & 1 deletion frontend/src/hooks/GLM/useAllowanceTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export const useAllowanceTx = () => {
fetchLogs().then((logs) => {
const sortedLogs = logs.sort(compareBlockNumbers);
if (sortedLogs.length > 0) {
console.log("hh");
setTxHash(sortedLogs[logs.length - 1].transactionHash);
}
});
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/hooks/useSaveDeposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ async function saveDeposit({
nonce: number;
id: string;
}): Promise<{ result: boolean }> {
console.log("nonce", nonce);
console.log("funder", funder);
console.log("id", id);
const response = await fetch(
`${import.meta.env.VITE_BACKEND_HTTP_URL}/create-deposit`,
{
Expand All @@ -26,8 +23,6 @@ async function saveDeposit({
}
);

console.log("response", response);

if (!response.ok)
throw new Error(`Error registering user: ${response.statusText}`);

Expand Down
2 changes: 0 additions & 2 deletions frontend/src/hooks/useScanResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const useScanResults = () => {
const { emit, events$, clean } = useEvents({
key: "scanResults",
eventKind: (s: any) => {
console.log("Event kind", s);
return match(s)
.with(fileStatus.CLEAN, () => Event.FILE_SCAN_OK)
.with(fileStatus.INFECTED, () => Event.FILE_SCAN_ERROR)
Expand All @@ -26,7 +25,6 @@ export const useScanResults = () => {

eventSource.addEventListener("message", (event) => {
const file = JSON.parse(event.data);
console.log("Emmiting event", file);
removeFile(file.id);
emit(file, file.result);
});
Expand Down
22 changes: 0 additions & 22 deletions frontend/src/hooks/useWatchContractEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,8 @@ export const useContractEvent = ({
eventName,
onLogs: (logs: any[]) => {
logs.forEach((log) => {
console.log("log", log);
emit(log);
});
},
});
};
// import { config } from "config";
// import { holesky } from "viem/chains";
// import { useWatchContractEvent } from "wagmi";
// import { abi } from "./abi";
// import { useCallback } from "react";
// export const useWatchDepositPayments = () => {
// const onLogs = useCallback((logs: any) => {
// console.log("Deposit", logs);
// }, []);

// useWatchContractEvent({
// address: config.depositContractAddress[holesky.id],
// abi: abi,
// eventName: "DepositFeeTransfer",
// // args: {
// // owner: address,
// // spender: requestor?.wallet,
// // },
// onLogs: onLogs,
// });
// };
6 changes: 1 addition & 5 deletions frontend/src/hooks/yagna/useCurrentAgreement.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import axios from "axios";
import { useUser } from "hooks/useUser";
import { use } from "i18next";
import { useEffect } from "react";
import useSWR from "swr";

import * as YaTsClient from "ya-ts-client";
export type AgreementDTO = YaTsClient.MarketApi.AgreementDTO;

export const useCurrentAgreement = () => {
const { user } = useUser();

const { data, error } = useSWR<AgreementDTO>(
const { data } = useSWR<AgreementDTO>(
`${import.meta.env.VITE_BACKEND_HTTP_URL}/agreement`,
async (url) => {
const response = await axios.get(url);
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/hooks/yagna/useCurrentAllocation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import axios from "axios";
import { useUser } from "hooks/useUser";
import { use } from "i18next";
import { set } from "ramda";
import { useEffect, useState } from "react";
import useSWR from "swr";
import { parseEther } from "viem";
Expand Down

0 comments on commit f6368ec

Please sign in to comment.