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

chore(sdk): Refactor the SDK to avoid passing the full context to the DataMappers #738

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

alainncls
Copy link
Collaborator

What does this PR do?

  • Refactors the SDK to simplify its internal mechanics and improve maintainability
  • Adds unit tests to cover core SDK functionalities

Related ticket

Fixes #728

Type of change

  • Chore
  • Bug fix
  • New feature
  • Documentation update

Check list

  • Unit tests for any smart contract change
  • Contracts and functions are documented

@alainncls alainncls self-assigned this Sep 16, 2024
this.portal = new PortalDataMapper(conf, this.web3Client, this, this.walletClient);
this.utils = new UtilsDataMapper(conf, this.web3Client, this, this.walletClient);
this.schema = new SchemaDataMapper(conf, this.web3Client, this.walletClient);
const findOneSchemaById = this.schema.findOneById.bind(this.schema);
Copy link

Choose a reason for hiding this comment

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

Not sure if it's correct to pass this.schema as the function parameter to findOneById.bind(), iiuc, the function parameter should be an string given that async findOneById(id: string), not sure why here it was passed with the SchemaDataMapper object, also bind would not do any type check, so better avoid to use it if possible, see here

const matchingSchema = await this.veraxSdk.schema.findOneById(attestationPayload.schemaId);
const matchingSchema = this.findOneSchemaById
? await this.findOneSchemaById(attestationPayload.schemaId)
: undefined;
Copy link

Choose a reason for hiding this comment

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

More percise, !matchingSchema return true can now be either "No matching Schema" or the given findOneSchemaById is undefined, and if that's the case, I think the msg inthrow new Error("No matching Schema") need to change accordingly

@alainncls alainncls force-pushed the chore/refactor-the-sdk-to-avoid-passing-the-full-context-to-the-datamappers branch from c7d77a9 to 0250e98 Compare September 17, 2024 21:03
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.

[TASK] Refactor the SDK to avoid passing the full context to the DataMappers
2 participants