near-api-js icon indicating copy to clipboard operation
near-api-js copied to clipboard

Document usage of requestSignTransactions

Open ilblackdragon opened this issue 4 years ago • 2 comments

WalletConnection.requestSignTransactions function has unclear signature, as it's requires transaction with signer_id and signer_pk. Developers are not sure what to fill in when signing a transaction.

We should document usage of this function in more detail, as these arguments are not required because wallet will be replacing them.

ilblackdragon avatar Feb 16 '21 13:02 ilblackdragon

as these arguments are not required because wallet will be replacing them.

This is not correct. You'd then have to select account manually each time you send transaction which would be terrible UX.

It's possible to make these optional however, to basically provide "checkout flow"

I think makes sense to discuss it here: https://github.com/near/NEPs/blob/c1947120f6b651bb1d0678ab1805c4628a418db4/text/0000-walletapi.md

where what you describe is listed in future possibilities

vgrichina avatar Feb 17 '21 04:02 vgrichina

We used requestSignTransactions here: https://github.com/ref-finance/ref-ui/blob/main/src/services/near.ts#L78 and it worked pretty well!

It may be nice to bring some of the logic we used int near-api-js so it is a bit easier for developers to create transactions.

See:

  • https://github.com/ref-finance/ref-ui/blob/main/src/services/SpecialWallet.ts#L43
  • https://github.com/ref-finance/ref-ui/blob/main/src/services/near.ts#L78

It may be nice to create a method that (instead of taking a Transaction[]) takes an array of receiverId and actions, and then constructs transactions for the developer (https://github.com/ref-finance/ref-ui/blob/main/src/services/near.ts#L69)

mehtaphysical avatar Apr 07 '21 14:04 mehtaphysical