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

Wallet adapter v2 #197

Merged
merged 4 commits into from
Nov 16, 2023
Merged

Wallet adapter v2 #197

merged 4 commits into from
Nov 16, 2023

Conversation

0xmaayan
Copy link
Collaborator

Wallet Adapter V2

  • Dapp to support SDK V2 and use only @aptos-labs/ts-sdk package.
  • Add 3 different transaction flows - Single signer, Fee payer, Multi Agent. See attached video.
    • Single signer has the same functionality with the option to signAndSubmitTransction, signMessage, signMessageAndVerify. For signTransaction we had to keep both V1 and V2 "ways" as we can't really change the function signature without introducing wallet plugin breaking changes. We can technically just use a new function with a different name only for V2 but rather to use the same function to support both v1 and v2 to easy ecosystem adoption
    • Fee payer flow supports sign as sender, then need to switch wallet to sign as sponsor, and then submit transaction (everything implemented in the V2 way)
    • Multi agent flow supports sign as sender, then you would get a private key you can import to the wallet to sign as secondary signer, and then submit transaction (everything implemented in the V2 way)

Note: I chose this way so users can experience the use of signing with a wallet and can experience the e2e flow with a wallet.

  • Wallet core conversion layer from signAndSubmitTransaction with V2 inputs -> V1 signAndSubmitTransaction or V2 signAndSubmitBCSTransaction
  • Wallet core conversion layer to return V2 AccountAuthenticator from signTransaction
  • submitTransaction to only support V2 expected flow
Screen.Recording.2023-11-09.at.10.41.25.PM.mov

deserializedSignature.authenticator as TxnBuilderTypes.TransactionAuthenticatorEd25519;

const publicKey = transactionAuthenticator.public_key.value;
const signature = transactionAuthenticator.signature.value;
Copy link
Collaborator Author

@0xmaayan 0xmaayan Nov 12, 2023

Choose a reason for hiding this comment

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

this is where it is a bit weird. When trying to use this publicKey, signature and message to verifyMessage - verification fails. Failure is happening in both SDK V1 and V2.

const ed25519 = new Ed25519PublicKey(publicKey);
const verify = ed25519.verifyMessage(response, signature);

Consider the signTransaction function is being used with wallets we can assume it works? so 2 failure options

  1. verifyMessage is wrong
  2. something in the deserialization process is wrong

cc @xbtmatt @hardsetting

Copy link
Contributor

Choose a reason for hiding this comment

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

We can look together at the derserialized bytes to see what's going on here, but it should be pretty simple to separate and determine.

The other possibility is if this is a signed message and not a transaction, is it might not have all of the data for the message to verify.

packages/wallet-adapter-core/src/WalletCoreV1.ts Outdated Show resolved Hide resolved
apps/nextjs-example/components/transactionFlow/Sponsor.tsx Outdated Show resolved Hide resolved
apps/nextjs-example/components/transactionFlow/Sponsor.tsx Outdated Show resolved Hide resolved
apps/nextjs-example/package.json Outdated Show resolved Hide resolved
packages/wallet-adapter-core/package.json Outdated Show resolved Hide resolved
deserializedSignature.authenticator as TxnBuilderTypes.TransactionAuthenticatorEd25519;

const publicKey = transactionAuthenticator.public_key.value;
const signature = transactionAuthenticator.signature.value;
Copy link
Contributor

Choose a reason for hiding this comment

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

We can look together at the derserialized bytes to see what's going on here, but it should be pretty simple to separate and determine.

The other possibility is if this is a signed message and not a transaction, is it might not have all of the data for the message to verify.

@0xmaayan 0xmaayan merged commit 31e0084 into main Nov 16, 2023
6 checks passed
@0xmaayan 0xmaayan deleted the adapter_v2 branch November 16, 2023 15:37
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