lorisleiva / solana-wallets-vue

Solana wallet integration for Vue 3
https://solana-wallets-vue-demo.netlify.app/
173 stars 65 forks source link

Unable to use signMessage #45

Closed beargrilo closed 1 year ago

beargrilo commented 2 years ago

Hi,

in any wallet I connect (phantom, slope, solflare), I'm unable to signMessage.

...
const message = 'A nice message'
const { signMessage } = useWallet()
const signature = await signMessage(message)
...

Error:

app.js:35644 Uncaught (in promise) TypeError: signMessage is not a function

What am I doing wrong?

roguzh commented 2 years ago
if (wallet.publicKey.value && wallet.signMessage.value) {
  const encodedMessage = new TextEncoder().encode("Message content");
  const signatureBuffer = await wallet.signMessage.value(encodedMessage);
  const signature = bs58.encode(signatureBuffer);
  console.log(`Public Key: ${wallet.publicKey}\nSignature: ${signature}`);
}

That's what I use. I guess depending on the wallet, it may not have signMessage implementation.

beargrilo commented 2 years ago

Will give it a try, ty.

lorisleiva commented 1 year ago

Hi there, signMessage is a computed property and therefore needs to be accessed via .value.