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

feat(js-client): Update libp2p ecosystem [fixes DXJ-551] #393

Merged
merged 7 commits into from
Dec 6, 2023
Merged

Conversation

akim-bow
Copy link
Contributor

@akim-bow akim-bow commented Dec 5, 2023

No description provided.

@akim-bow akim-bow requested a review from shamsartem December 5, 2023 10:30
Copy link

linear bot commented Dec 5, 2023

@akim-bow akim-bow changed the title feat: Update libp2p ecosystem [fixes DXJ-551] feat(js-client): Update libp2p ecosystem [fixes DXJ-551] Dec 5, 2023
@akim-bow akim-bow added the e2e Run e2e workflow label Dec 5, 2023
formats: ["es"],
},
outDir: "./dist/browser",
rollupOptions: {
plugins: [
{
// @ts-ignore
// @ts-expect-error Types doesn't work here. Hack
Copy link
Contributor

@shamsartem shamsartem Dec 5, 2023

Choose a reason for hiding this comment

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

I tried in my VSCode and I don't even see any TS error here to disable
But I see enforce: "post", down below has error though
Are you sure enforce: "post", is working. I don't even know what it's doing.
Either way for me pnpm -r build works even if I remove this comment completely. The message in the comment doesn't give any value for the reader anyway in my opinion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My IDE show the error here for some reason. Looks like it doesn't affect anything, so yeah, i removed comment there.

Comment on lines 55 to 57
const buffer = Uint8Array.from(atob(wasmContent), (m) => {
return m.codePointAt(0) ?? 0;
});
Copy link
Contributor

@shamsartem shamsartem Dec 5, 2023

Choose a reason for hiding this comment

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

are you sure this operation is correct and safe? Looks a bit sketchy, I would at least move it to a separate function and give it a readable name so at least it's easier to understand what is happening really. Also you have several variables that contain the word buffer. Maybe rename it to something more useful (and it's not buffer anymore as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's still buffer. Buffer is an array of bytes and instances of Uint8Array are buffers.

Regarding this line: codePointAt can return undefined there if m variable is an empty string. But this should be impossible here, as a callback iterates over symbols. I will add comment there to make it clearer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for not noticing the comment. In Node.js terms actually the reverse is true: https://nodejs.org/api/buffer.html#buffer
Buffer is a subclass of Uint8Array - basically this is the reason I suggested the change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense i think. I can use different naming to separate it from node:buffer

@akim-bow akim-bow enabled auto-merge (squash) December 6, 2023 10:41
@akim-bow akim-bow merged commit 44eb149 into master Dec 6, 2023
8 checks passed
@akim-bow akim-bow deleted the DXJ-551 branch December 6, 2023 10:52
@fluencebot fluencebot mentioned this pull request Dec 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Run e2e workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants