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

✨ (signer-eth) [DSDK-652]: Add web3checks support #656

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

aussedatlo
Copy link
Contributor

📝 Description

Add web3checks support:

  • create a web3checks loader in the context-module
  • add a web3checks step in the signTransactionDA
  • add the web3checks provider url param available to edit in the sample

❓ Context

  • JIRA or GitHub link:
  • Feature:

✅ Checklist

Pull Requests must pass CI checks and undergo code review. Set the PR as Draft if it is not yet ready for review.

  • Covered by automatic tests
  • Changeset is provided
  • Impact of the changes:
    • list of the changes

🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.

@aussedatlo aussedatlo requested a review from a team as a code owner February 3, 2025 09:40
Copy link

vercel bot commented Feb 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
device-sdk-ts-sample ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 11, 2025 5:00pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
doc-device-management-kit ⬜️ Ignored (Inspect) Visit Preview Feb 11, 2025 5:00pm

Copy link
Contributor

github-actions bot commented Feb 3, 2025

Messages
Danger: All checks passed successfully! 🎉

Generated by 🚫 dangerJS against 85c3a5e

if (web3Checks.isLeft()) {
return null;
} else {
const web3ChecksValue = web3Checks.unsafeCoerce();
Copy link
Member

@valpinkman valpinkman Feb 5, 2025

Choose a reason for hiding this comment

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

[COULD] I think you could simplify this using the caseOf functions on the Either:

return web3Checks.caseOf({
  Right: checks => ({
    type: ClearSignContectType.WEB3_CHECK,
    payload: checks.descriptor,
    certificate: checks.certificates
  }),
  Left: () => null,
});

WDYT ?

);
}

const certificate = await this._certificateLoader.loadCertificate({
Copy link
Member

Choose a reason for hiding this comment

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

[ASK] Can this async method fail ? If yes, probably should wrap it in a try catch or something ?

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 method may fail, but explicit result checking is unnecessary as failure is handled later


async load(
web3CheckContext: Web3CheckContext,
): Promise<Either<Error, Web3Checks>> {
Copy link
Member

Choose a reason for hiding this comment

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

[ASK] Vanilla Errors here ? (new Error())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These errors are used only internally, what do you suggest ?

import { type Web3CheckContext, type Web3Checks } from "./web3CheckTypes";

export interface Web3CheckContextLoader {
load(web3CheckContext: Web3CheckContext): Promise<Either<Error, Web3Checks>>;
Copy link
Member

Choose a reason for hiding this comment

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

[ASK] I guess same question, vanilla Errors here ?

const { deviceModelId } = this.api.getDeviceSessionState();

const parsed = mapper.mapTransactionToSubset(transaction);
parsed.ifLeft((err) => {
Copy link
Member

@valpinkman valpinkman Feb 5, 2025

Choose a reason for hiding this comment

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

[COULD] Same here, you could leverage the Either caseOf functions

const { subset, serializedTransaction } = mapper
  .mapTransactionToSubset(transaction) 
  .caseOf({
    Right: parsed => parsed,
    Left: (err) => { throw err }
});

I feel it's better than using unsafeCoerce. WDYT ?

I'm not so sure on this one as we do a throw here so.... maybe there is a better solution

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Throwing on tasks is safe since the device action catches it. this method avoid using unsafeCoerce and is an equivalent so can add it 👍

Copy link
Contributor

@paoun-ledger paoun-ledger left a comment

Choose a reason for hiding this comment

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

lgtm

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.

3 participants