-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: translateAddress should not rely on PublicKey constructor nam #1138
fix: translateAddress should not rely on PublicKey constructor nam #1138
Conversation
to remove after coral-xyz/anchor#1138 is merged
to remove after coral-xyz/anchor#1138 is merged
63bd1f3
to
cad856e
Compare
|
||
import { translateAddress } from "../src/program/common"; | ||
|
||
describe("program/common", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for these tests!
0xCryptoSheik we are now back to the failing test that led to his hacky implementation of i have added a check that just returns the input if it already has a |
Sorry @paul-schaaf I'm not sure I follow but I'll try. This is the problem you describe in #1101 right, with my patch we're expecting that a PublicKey created before (where / how ?) after going through the It's very well possible you have 2 different version of To check this, inside the package you can do:
If you have a single version / hoisted, then it might not be the case of 2 different versions, or at least, not the simple case. If the publicKey is generated / verified in a package that bundles
which version could we release first exactly? Hope this makes sense & helps a bit, lmk. |
actually, if we cannot find a fix for this soon, we can first roll back to the impl before #1098 and release that as part of the thing is even if we have 2 different versions of Pubkey, I dont see how that should fail your tests. Ive logged the inputs to the running
seems to be just one version |
I wonder if it would help to not bundle |
continued my debugging and it turns out it's not the |
@paul-schaaf sgtm. |
@paul-schaaf thank you for the explanation, sorry, I don't have time to follow-up as thoroughly as I'd like on this issue. |
Not sure it'd change anything for this particular issue, but yes I believe it'd be best to have it as a |
Since anchor is used in web projects which will minify/mangle function names, checking an input object for a custom constructor name is unsafe. Moreover, checking the type of the input Address is unnecessary since `PublicKey`'s constructor handles: - `string` - `array` - object with a `{ _bn }` shape (like `PublicKey` itself)
310a2ac
to
7712004
Compare
@paul-schaaf, had to force-push to the branch to sign the commit |
Temp fix before coral-xyz/anchor#1138 is merged to master
@armaniferrante can we please release a patch version of the anchor client that includes this commit? |
Done v0.19.1-beta.1 |
Since anchor is used in web projects which will minify/mangle function
names, checking an input object for a custom constructor name is unsafe.
Moreover, checking the type of the input Address is unnecessary since
PublicKey
's constructor handles:string
array
{ _bn }
shape (likePublicKey
itself)For additional safety, a unit test should be added to prevent
PublicKey
to stop supporting this unexpectedly.
See
PublicKey
implementation: