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

Fix/sessionkey token validation #40

Merged
merged 8 commits into from
Oct 1, 2024

Conversation

kanthgithub
Copy link
Contributor

@kanthgithub kanthgithub commented Sep 20, 2024

Description

  • enableSessionKey and rotateSessionKey to validate the token address in the session data
    • does token exists on the chain
  • validate for a well formed tokenAddress

Types of changes

  • Bugfix (non-breaking change which fixes an issue)

@kanthgithub kanthgithub self-assigned this Sep 20, 2024
Copy link

Yooo! You forgot to bump the version in package.json!

@kanthgithub kanthgithub marked this pull request as draft September 20, 2024 09:12
Copy link

Yooo! You forgot to bump the version in package.json!

@kanthgithub kanthgithub added the enhancement New feature or request label Sep 23, 2024
@kanthgithub kanthgithub marked this pull request as ready for review September 24, 2024 04:11

const erc20 = new Contract(token, ERC20_ABI, this.provider);
const decimals = await erc20.decimals();
if (!decimals || decimals == null || decimals as number == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@kanthgithub !decimals will shadow decimals==null
i think we can skip decimals==null as it will get covered in !decimals

also can a erc20 token not have decimals as zero, is there a reason not to support it ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is just to check if it is atoken address that exists on this chain
calling the view function on it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated by removing redundant check

@@ -66,6 +67,12 @@ export class SessionKeyValidator {
throw new Error('Function Selector is required');
}

const isAValidTokenIndicator = await this.isAValidToken(token);
Copy link
Member

Choose a reason for hiding this comment

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

Can we rename it to isValidTokenIndicator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@@ -1,4 +1,9 @@
# Changelog
## [2.0.5] - 2024-09-23
### Breaking Changes
- validate the tokenAddress for `enableSessionKey` on `SessionKeyValidator` SDK instance
Copy link
Member

Choose a reason for hiding this comment

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

How is this a breaking change? Will it affect how existing users integrate our SDK?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated the change log

Copy link
Member

@ch4r10t33r ch4r10t33r left a comment

Choose a reason for hiding this comment

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

LGTM

@kanthgithub kanthgithub merged commit 6a2bec5 into master Oct 1, 2024
3 of 4 checks passed
@kanthgithub kanthgithub deleted the fix/sessionkey-token-validation branch October 1, 2024 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

Successfully merging this pull request may close these issues.

3 participants