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

web3.js: remove Buffer from PublicKeyInitData #27888

Merged

Conversation

macalinao
Copy link
Contributor

@macalinao macalinao commented Sep 18, 2022

Problem

Removes a redundant Buffer declaration

Addresses solana-labs/solana-web3.js#1100.

@mergify mergify bot added the community Community contribution label Sep 18, 2022
@mergify mergify bot requested a review from a team September 18, 2022 00:03
Copy link
Contributor

@steveluscher steveluscher left a comment

Choose a reason for hiding this comment

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

Once something is added to the public interface, it's very difficult to remove. In particular, if anyone tries to pass a Buffer into the PublicKey constructor, this change will make Typescript newly fail on their project.

Thoughts on that?

@macalinao macalinao force-pushed the igm/remove-buffer-from-init branch from e64bcdf to 974794b Compare September 18, 2022 00:06
@mergify mergify bot dismissed steveluscher’s stale review September 18, 2022 00:06

Pull request has been modified.

@mergify mergify bot requested a review from a team September 18, 2022 00:06
@macalinao
Copy link
Contributor Author

Once something is added to the public interface, it's very difficult to remove. In particular, if anyone tries to pass a Buffer into the PublicKey constructor, this change will make Typescript newly fail on their project.

Thoughts on that?

This is not true because Buffer implements Uint8Array

@steveluscher
Copy link
Contributor

Right! I had that backwards; you're right.


const buffer: Buffer = null as any;
function takesAUint8Array(thing: Uint8Array) {}
takesAUint8Array(buffer); // OK

const byteArray: Uint8Array = null as any;
function takesABuffer(thing: Buffer) {}
takesABuffer(byteArray); // ERROR

@steveluscher steveluscher merged commit 98dfc2b into solana-labs:master Sep 18, 2022
@macalinao
Copy link
Contributor Author

macalinao commented Sep 18, 2022

Finally my first PR into Solana core!! :D thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants