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

New Turnkey signer: @turnkey/solana #195

Merged
merged 6 commits into from
Jan 18, 2024
Merged

New Turnkey signer: @turnkey/solana #195

merged 6 commits into from
Jan 18, 2024

Conversation

r-n-o
Copy link
Contributor

@r-n-o r-n-o commented Jan 9, 2024

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:
image

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 the TransactionPartialSigner and MessagePartialSigner 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

  • New unit tests (created a fresh production org to test against -- I've set the CI variable already)
  • Ran the with-solana demo manually

Copy link

codesandbox-ci bot commented Jan 9, 2024

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) {
Copy link
Collaborator

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)

Copy link
Contributor Author

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.

Copy link
Collaborator

@andrewkmin andrewkmin left a 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 :)

@r-n-o r-n-o merged commit a209220 into main Jan 18, 2024
5 checks passed
@r-n-o r-n-o deleted the rno/solana-signer branch January 18, 2024 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants