ts: better public key error msgs#1098
Conversation
|
my guess is that it fails because something that is neither a string nor a public key is passed into translateAddress. whatever it is can also be made into a pubkey but it's the wrong pubkey. will investigate later |
|
it works now, hacky solution but think this is good enough for now and we can try finding the source and fixing it in the other issue I linked |
| const pk = new PublicKey(address); | ||
| return pk; | ||
| } else { | ||
| } else if (address.constructor.prototype.constructor.name === "PublicKey") { |
There was a problem hiding this comment.
This has introduced some bugs in our production build. I believe this is because JS is minifying the code and changing the name of constructors.
A couple suggestions to avoid this:
- check if the method
toBase58exists on the object - add a
nameortypeto thePublicKeyconstructor object similar to how Phantom addsisPhantomtowindow.solana
What do you think? Happy to open a PR that fixes this :)
cc @paul-schaaf
There was a problem hiding this comment.
sorry for that, didnt consider this, my mistake!
fix is already on the way #1138
There was a problem hiding this comment.
Awesome, thanks for the pointer there @paul-schaaf :)
There was a problem hiding this comment.
I don't have the full picture of the codebase and the issue, just wanted to chime in that some time ago I fixed precisely the same bug replacing such a clause with an instanceof — address instanceof PublicKey.
There was a problem hiding this comment.
we can try again but it didnt work for us before #1101
when you add a non publickey/string to the accounts object for an instruction you currently get this error.
This PR changes the code so you get a more helpful error