ecency / hivesigner-ui

Hivesigner UI, website component
MIT License
4 stars 3 forks source link

Generic signTx #82

Closed reichert-splinterlands closed 1 year ago

reichert-splinterlands commented 1 year ago

It would be great if hivesigner.com/signs would also support a generic signTx function, similar to keychains requestSignTx (https://github.com/hive-keychain/hive-keychain-extension/blob/master/documentation/README.md#requestsigntx)

Example: https://hivesigner.com/sign/tx?authority=posting&account=wolf&tx=STRINGIFIED_TX&redirect_uri=http://localhost:8000?tx={{tx}}

feruzm commented 1 year ago

You can already sign/request multiple operations/transactions with Hivesigner SDK Example:

import hs from "hivesigner";

const op: Operation = [
    "transfer_from_savings",
    {
      from,
      to,
      amount,
      memo,
      request_id: rid
    }
  ];
  const cop: Operation = [
    "cancel_transfer_from_savings",
    {
      from,
      request_id: rid
    }
  ];

  const params: Parameters = { callback: `https://ecency.com/@${from}/wallet` };
  return hs.sendOperations([op, cop], params, () => {});

This does create special url to sign and broadcast operation/transaction.

tre-dev commented 1 year ago

But this works via a token received, right? I need a UX flow where the user broadcasts it himself

feruzm commented 1 year ago

@tre-dev actually no it doesn't require token, underlying library keychain uses also used by hivesigner which is hive-uri and hivesigner sdk helps you to generate unique link for any option, above script is just example you can see it will generate hivesigner link for you to sign, since Active operations are hot sign meaning it should be signed by user, you should be able to generate any transaction signing with above snippet. You can use hive-uri to generate link as well and just replace hive:// with https://hivesigner.com/ and hivesigner will recognize transactions and allow you to sign.