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(credential-eip712): chainId for any did method #1334

Merged
merged 2 commits into from
Jan 31, 2024
Merged

Conversation

simonas-notcat
Copy link
Contributor

What issue is this PR fixing

Getting correct chainId for any did method

Quality

Check all that apply:

  • I want these changes to be integrated
  • I successfully ran pnpm i, pnpm build, pnpm test, pnpm test:browser locally.
  • I allow my PR to be updated by the reviewers (to speed up the review process).
  • I added unit tests.
  • I added integration tests.
  • I did not add automated tests because _________, and I am aware that a PR without tests will likely get rejected.

@codecov-commenter
Copy link

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (8e3b94c) 89.84% compared to head (7e9c4b6) 89.83%.

Files Patch % Lines
...es/credential-eip712/src/agent/CredentialEIP712.ts 75.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next    #1334      +/-   ##
==========================================
- Coverage   89.84%   89.83%   -0.02%     
==========================================
  Files         176      176              
  Lines       27278    27285       +7     
  Branches     2164     2164              
==========================================
+ Hits        24509    24512       +3     
- Misses       2769     2773       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@stanleyyconsensys stanleyyconsensys left a comment

Choose a reason for hiding this comment

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

LGTM, leave some comments

@@ -161,7 +161,7 @@ export function getEthereumAddress(verificationMethod: VerificationMethod): stri
*
* @beta This API may change without a BREAKING CHANGE notice.
*/
export function getChainIdForDidEthr(verificationMethod: _NormalizedVerificationMethod): number {
export function getChainId(verificationMethod: _NormalizedVerificationMethod): number {
if (verificationMethod.blockchainAccountId?.includes('@eip155')) {

Choose a reason for hiding this comment

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

may be we can also add is NAN as the parseInt result

if it is nan, then throw error, hence the Eip712 fallback to use chainId 1?

Copy link
Member

Choose a reason for hiding this comment

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

good point

Copy link
Member

@mirceanis mirceanis left a comment

Choose a reason for hiding this comment

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

Looks good.
It is worth handling the NaN case that @stanleyyconsensys mentioned.

The test would be against a malformed blockchainAccountId:
eip155:0xe708:0x197...
eip155:linea:0x197...
0x197...@eip155:0xe708
0x197...@eip155:linea

Copy link
Member

@mirceanis mirceanis left a comment

Choose a reason for hiding this comment

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

Looks good

@mirceanis mirceanis merged commit d5375bd into next Jan 31, 2024
9 checks passed
@mirceanis mirceanis deleted the fix/eip712-chainid branch January 31, 2024 16:38
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.

None yet

4 participants