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

Add supporting Versioned Transaction signing #9

Merged

Conversation

bergusman
Copy link

Add field transaction for solana_signTransaction method with serialized transaction.

For 0 and next version of transaction used only transaction parameter.

For Transaction and legacy VersionedTransaction put old WalletConnect specification parameters and new transaction parameter.

Updated @solana/web3.js to 1.63.0 version to support addSignature for VersionedTransaction.

Comment on lines 131 to 132
params: { ...legacyTransaction, transaction: rawTransaction },
},

Choose a reason for hiding this comment

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

Hmm, why are the transaction properties passed as params? I realize this isn't a change from how it's currently being done, but the transaction bytes are all that should be needed, right?

Copy link

Choose a reason for hiding this comment

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

@jordansexton It was old way of doing this implemented by WalletConnect. So we are keeping for backward compatibility and introducing a new way that could support both legacy and v0 transactions.

Comment on lines 140 to 143
request: {
method: WalletConnectRPCMethods.signTransaction,
params: { transaction: rawTransaction },
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

this whole block looks identical to the same request for the legacy transaction, i'd suggest combining the two blocks and just create the parameters differently depending on the incoming transaction

topic: this._session.topic,
request: {
method: WalletConnectRPCMethods.signTransaction,
params: { ...transaction, transaction: rawTransaction },
Copy link
Collaborator

Choose a reason for hiding this comment

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

the previous version did not require an explicit serialization of the transaction, is there a particular reason why that's needed for the existing non-versioned transactions?

Copy link

Choose a reason for hiding this comment

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

@jnwng Versioned Transaction and legacy Transaction have completely different set of properties. Passing non-serialized transaction will require to create different methods for the future changes of Transaction class.

Also it makes its much harder to consume deconstructed transactions on the wallet side.

To make API future proof and easy to use we believe that moving to serialized transaction is a better approach, which is similar to approach of Solana Pay.

request: {
method: WalletConnectRPCMethods.signTransaction,
params: {
...legacyTransaction, // Legacy sign transaction request format
Copy link

Choose a reason for hiding this comment

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

@bergusman make a comment here. That it is deprecated and in the future versions only transaction will be sent.

if (transaction.version === 'legacy') {
// Build Transaction for legacy sign transaction request format
legacyTransaction = Transaction.from(transaction.serialize());
} else {
Copy link

Choose a reason for hiding this comment

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

@bergusman @jnwng This "else" block I think should be completely removed.

We can't create legacy transaction from non-legacy one. So legacyTransaction should be undefined here.

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.

4 participants