Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added required changes for log messages #18

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Girishbari
Copy link
Contributor

Description

I have added required changes as per my knowledge and understanding for below ISSUE

PR for #6

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist:

@Girishbari
Copy link
Contributor Author

Girishbari commented Nov 4, 2024

@Kushal7788
Copy link
Collaborator

@Girishbari Added few comments for the PR. Please resolve them.

Also please post a demo video showcasing different log types when each of the log level is set while initialising the object. It will serve as a proof of functionality and help us to merge the PR readily.

@Girishbari
Copy link
Contributor Author

where have you added comments in PR @Kushal7788

@Girishbari
Copy link
Contributor Author

In prev PR there were some comments so I made changes accordingly and pushed new changes

src/Reclaim.ts Outdated
@@ -59,7 +59,7 @@ export async function verifyProof(proof: Proof): Promise<boolean> {
proof.claimData.timestampS
)
}
// then hash the claim info with the encoded ctx to get the identifier
// then hash the claim error with the encoded ctx to get the identifier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change the comments details. This is not related to logging and serves a different purpose

src/Reclaim.ts Outdated
return false
}

return true
}

export function transformForOnchain(proof: Proof): { claimInfo: any, signedClaim: any } {
const claimInfoBuilder = new Map([
export function transformForOnchain(proof: Proof): { claimerror: any, signedClaim: any } {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter name should not be updated here. Please make sure you are not find & replacing all Info keywords with error keywords

src/Reclaim.ts Outdated
export function transformForOnchain(proof: Proof): { claimInfo: any, signedClaim: any } {
const claimInfoBuilder = new Map([
export function transformForOnchain(proof: Proof): { claimerror: any, signedClaim: any } {
const claimerrorBuilder = new Map([
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be changes

src/Reclaim.ts Outdated
['context', proof.claimData.context],
['parameters', proof.claimData.parameters],
['provider', proof.claimData.provider],
]);
const claimInfo = Object.fromEntries(claimInfoBuilder);
const claimerror = Object.fromEntries(claimerrorBuilder);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change. Please revert

src/Reclaim.ts Outdated
@@ -108,7 +108,7 @@ export function transformForOnchain(proof: Proof): { claimInfo: any, signedClaim
claim: Object.fromEntries(claimBuilder),
signatures: proof.signatures,
};
return { claimInfo, signedClaim };
return { claimerror, signedClaim };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary change. Please revert

src/Reclaim.ts Outdated
@@ -296,7 +304,8 @@ export class ReclaimProofRequest {
validateFunctionParams([{ input: this.sessionId, paramName: 'sessionId', isString: true }], 'getAppCallbackUrl');
return this.appCallbackUrl || `${constants.DEFAULT_RECLAIM_CALLBACK_URL}${this.sessionId}`
} catch (error) {
logger.info("Error getting app callback url", error)
logger.error("Error getting app callback url", error)
logger.info(`Make sure to pass URL and as a string`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This info log should be not be in the catch block. Better to move it at top inside the try block

src/Reclaim.ts Outdated
@@ -306,7 +315,8 @@ export class ReclaimProofRequest {
validateFunctionParams([{ input: this.sessionId, paramName: 'sessionId', isString: true }], 'getStatusUrl');
return `${constants.DEFAULT_RECLAIM_STATUS_URL}${this.sessionId}`
} catch (error) {
logger.info("Error fetching Status Url", error)
logger.error("Error fetching Status Url", error)
logger.info(`Make sure to pass URL and as a string`)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This info log should be not be in the catch block. Better to move it at top inside the try block

this.level = level;
}

private shouldLog(messageLevel: LogLevel): boolean {
const levels: LogLevel[] = ['error', 'warn', 'info', 'silent'];
const levels: ExtendedLog[] = ['error', 'warn', 'info', 'all'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this log all there types of log 'error', 'warn', 'info' when logLevel is set to info ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didnt get your question

import { ProofRequestOptions } from "./types";
const logger = loggerModule.logger;

const REFERENCE_FOR_DASHBOARD = "https://dev.reclaimprotocol.org/dashboard"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed will remove it

@@ -39,7 +44,8 @@ export function validateURL(url: string, functionName: string): void {
try {
new URL(url);
} catch (e) {
logger.info(`URL validation failed for ${url} in ${functionName}: ${(e as Error).message}`);
logger.error(`URL validation failed for ${url} in ${functionName}: ${(e as Error).message}`);
logger.info('Make sure to pass URL as string')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This info log should be not be in the catch block. Better to move it at top inside the try block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants