-
Notifications
You must be signed in to change notification settings - Fork 14
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
New Turnkey signer: @turnkey/solana
#195
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
* @param tx Transaction object (native @solana/web3.js type) | ||
* @param fromAddress Solana address (base58 encoded) | ||
*/ | ||
public async addSignature(tx: Transaction, fromAddress: string) { |
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.
supporting just addSignature
makes sense given this is all a user needs support for, at least for now. (when we implement a signer interface, then things might change as we support sign
and partialSign
, etc)
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.
Yeah definitely agree. We can extend the interface as needed in the future. There's also the "sign message" functionality; this can be added fairly easily but I've left it out for now since it's not been requested just yet.
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.
looks good to me! functional, and definitely a whole lot cleaner abstraction for users :)
Summary & Motivation
This is an attempt at wrapping signing logic with Solana.
The example code for signing with Solana (
examples/with-solana/src/createSolanaTransfer.ts
) is now a lot shorter / cleaner, I think that's a win:Open to feedback on naming and structure of course; unfortunately
@solana/web3.js
doesn't have ready-to-use abstract signer interfaces so this is a wrapper rather than a concrete implementation of a supported abstraction.I've briefly looked at https://github.com/solana-labs/solana-web3.js/tree/master/packages/signers but this is experimental (only committed 2 months ago) so unlikely to be useful right away. We don't want to force people to upgrade all the way to experimental releases . FWIW
@solana/signers
takes the same approach than what I have here and creates wrappers. If we were to go this route we'd choose to implement theTransactionPartialSigner
andMessagePartialSigner
interfaces. Pretty easy to add down the road if we want to!I've also seen https://github.com/solana-labs/wallet-adapter: seems like a useful library used by many projects. I think we should try to implement our own "wallet" in https://github.com/solana-labs/wallet-adapter/tree/master/packages/wallets? Not sure if that'd be useful?
Oh and: this branch also updates the Solana demo to work with wallets rather than private keys!
How I Tested These Changes
with-solana
demo manually