Skip to content

Commit bf7a3c0

Browse files
committed
chore: remove console logs, few code smells
1 parent 2e5d2a7 commit bf7a3c0

File tree

3 files changed

+3
-16
lines changed

3 files changed

+3
-16
lines changed

web/src/pages/Cases/CaseDetails/Voting/Shutter/Reveal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const Reveal: React.FC<IReveal> = ({ voteIDs, setIsOpen }) => {
4141
if (isUndefined(storedData)) return undefined;
4242
try {
4343
const data = JSON.parse(storedData);
44-
if (!data.salt || !data.choice || !data.justification) {
44+
if (isUndefined(data.salt) || isUndefined(data.choice) || isUndefined(data.justification)) {
4545
throw new Error("Invalid stored data");
4646
}
4747
return data;

web/src/pages/Cases/CaseDetails/Voting/Shutter/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useAccount } from "wagmi";
44

55
import { useDrawQuery } from "hooks/queries/useDrawQuery";
66
import { useVotingContext } from "hooks/useVotingContext";
7-
import { DisputeDetailsQuery, useDisputeDetailsQuery } from "queries/useDisputeDetailsQuery";
7+
import { DisputeDetailsQuery } from "queries/useDisputeDetailsQuery";
88

99
import ShutterCommit from "./Commit";
1010
import Reveal from "./Reveal";
@@ -19,8 +19,7 @@ interface IShutter {
1919
const Shutter: React.FC<IShutter> = ({ arbitrable, setIsOpen, dispute, currentPeriodIndex }) => {
2020
const { id } = useParams();
2121
const { address } = useAccount();
22-
const { data: disputeData } = useDisputeDetailsQuery(id);
23-
const { data: drawData, refetch } = useDrawQuery(address?.toLowerCase(), id, disputeData?.dispute?.currentRound.id);
22+
const { data: drawData, refetch } = useDrawQuery(address?.toLowerCase(), id, dispute?.currentRound.id);
2423
const { isCommitPeriod, isVotingPeriod, commited } = useVotingContext();
2524
const voteIDs = useMemo(() => drawData?.draws?.map((draw) => draw.voteIDNum) as string[], [drawData]);
2625

web/src/utils/shutter.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ interface ShutterDecryptionKeyData {
2727
*/
2828
async function fetchShutterData(decryptionTimestamp: number): Promise<ShutterApiMessageData> {
2929
try {
30-
console.log(`Sending request to Shutter API with decryption timestamp: ${decryptionTimestamp}`);
31-
3230
// Generate a random identity prefix
3331
const identityPrefix = generateRandomBytes32();
34-
console.log(`Generated identity prefix: ${identityPrefix}`);
3532

3633
const response = await fetch("https://shutter-api.shutter.network/api/register_identity", {
3734
method: "POST",
@@ -46,7 +43,6 @@ async function fetchShutterData(decryptionTimestamp: number): Promise<ShutterApi
4643
});
4744

4845
// Log the response status
49-
console.log(`API response status: ${response.status}`);
5046

5147
// Get the response text
5248
const responseText = await response.text();
@@ -81,8 +77,6 @@ async function fetchShutterData(decryptionTimestamp: number): Promise<ShutterApi
8177
* @returns Promise with the decryption key data
8278
*/
8379
async function fetchDecryptionKey(identity: string): Promise<ShutterDecryptionKeyData> {
84-
console.log(`Fetching decryption key for identity: ${identity}`);
85-
8680
const response = await fetch(`https://shutter-api.shutter.network/api/get_decryption_key?identity=${identity}`, {
8781
method: "GET",
8882
headers: {
@@ -160,7 +154,6 @@ export async function encrypt(
160154
const decryptionTimestamp = Math.floor(Date.now() / 1000) + decryptionDelay;
161155

162156
// Fetch encryption data from Shutter API
163-
console.log(`Fetching encryption data for decryption at timestamp ${decryptionTimestamp}...`);
164157
const shutterData = await fetchShutterData(decryptionTimestamp);
165158

166159
// Extract the eon key and identity from the response and ensure they have the correct format
@@ -173,10 +166,6 @@ export async function encrypt(
173166
// Generate a random sigma
174167
const sigmaHex = generateRandomBytes32();
175168

176-
console.log("Eon Key:", eonKeyHex);
177-
console.log("Identity:", identityHex);
178-
console.log("Sigma:", sigmaHex);
179-
180169
// Encrypt the message
181170
const encryptedCommitment = await encryptData(msgHex, identityHex, eonKeyHex, sigmaHex);
182171

@@ -192,7 +181,6 @@ export async function encrypt(
192181
export async function decrypt(encryptedMessage: string, identity: string): Promise<string> {
193182
// Fetch the decryption key
194183
const decryptionKeyData = await fetchDecryptionKey(identity);
195-
console.log("Decryption key:", decryptionKeyData.decryption_key);
196184

197185
// Ensure the decryption key is properly formatted
198186
const decryptionKey = ensureHexString(decryptionKeyData.decryption_key);

0 commit comments

Comments
 (0)