madfish-solutions / templewallet-extension

🔐💰Cryptocurrency wallet for Tezos blockchain as Web extension for your Browser.
https://templewallet.com
MIT License
184 stars 62 forks source link

Show Michelson expression instead of raw data in the signing preview #574

Closed skubarenko closed 2 years ago

skubarenko commented 2 years ago

Hello👋

Sometimes users need to sign some Michelson data. When users sign such data via Temple, it shows raw data that is a bit not user-friendly. It'd be great if Temple could show decoded Michelson data like Kukai. For example:

Let's imagine we have a contract that verifies a signature of pair of some string and nat (Pair string nat). Like this: https://ide.ligolang.org/p/gvtsX0KZn42XScTPXHEznw And we have a client application that allows a user to enter signing values and sign them using their favorite wallet via Beacon SDK:

import { packDataBytes } from '@taquito/michel-codec';
// ...

// Account is connected
// const dAppClient: DAppClient = ...

const signingMichelsonData = packDataBytes({
  prim: 'Pair', args: [
    { string: 'some text' }, // We've hardcoded the data for simplicity
    { int: '123456789' }
  ]
}).bytes;

const walletSignedData = await dAppClient.requestSignPayload({
  signingType: SigningType.MICHELINE,
  payload: signingMichelsonData
});
console.log(walletSignedData.signature);
When the app requests to sign from the wallet, the wallet will show the user a signing popup. Temple Kukai
temple kukai

Tested Account

const account = {
  address: 'tz1dzNhmfwGHLLyQhmD9XRqfsTwU4NEAihRv',
  secretKey: 'edskRs5nrtPgFpUSXFtNhq1HBuAVG2sKDDeor3bAFE5ZpZ1NJh6yYGm4fX3qrGScW9HYjTXpkLobJEaGABpdg5zw4LPUocWrec',
  publicKey: 'edpkv9MW8Ddpg3SqAd5yncr26thhNTtm9Rz7qVf1aE1kGNepo1RJp3'
}

Test the contract in Ligo IDE

  1. Select Dry Run
  2. Enter ("some text", (123456789, ("edpkv9MW8Ddpg3SqAd5yncr26thhNTtm9Rz7qVf1aE1kGNepo1RJp3", "edsigtpbrj7fJJCg7q7u9UgKAiVsK6KWEcgtcAzAjNQy1aQ4pqdnnAUuEw63c7AQy5aqJ6CbyUH1Q7ZGKhcCNFUjPB3Ho7UJvNH"))) as the parameter
  3. Enter false to the storage input
  4. Run
  5. Output: ( LIST_EMPTY() , True(unit) )

What do you think?

TreeOfSelf commented 2 years ago

Yeah, having this same issue. It's really strange too. Using the example message "Tezos Signed Message: mydapp.com 2021-01-14T15:16:04Z Hello world!" from a tutorial it shows the string totally fine. However, if I change the Tezos to all-caps like "TEZOS Signed Message: mydapp.com 2021-01-14T15:16:04Z Hello world!" It suddenly only shows the raw.

Works flawlessly in kukai, but I much prefer temple. I know signing isn't very often used right now in the tezosphere, but would be nice as signing allows me to verify ownership of wallets without having people pay any gas fees in tez. Thanks.

VolodymyrGR commented 2 years ago

Hey, thanks, we will investigate it and back to you.

unixvb commented 2 years ago

Hi, should be available in 1.14.10. Could you check, please?

skubarenko commented 2 years ago

Hi guys! Sorry for the late response. I've checked, it works fine now. Thank you!