aptos-labs / petra-wallet-types

A typescript types package for the Petra wallet's dapp interface.
Apache License 2.0
5 stars 3 forks source link

Why signTransaction uses TransactionPayload ? #2

Open NorbertBodziony opened 1 year ago

NorbertBodziony commented 1 year ago

As in title. Seems like API is limiting "creation" of transaction too much and also forces wallet to work in online mode since it needs to fetch data like sequence number. There are a bunch of limitation that are caused by it long term.

I propose to use RawTransaction instead of TransactionPayload as main parameter for signing transactions. It gives full flexibility to developers and does not limit API in any way.

kent-white commented 1 year ago

I responded to you in the discord/telegram but I’m happy to have the conversation here too.

To sum up my points, we shouldn’t make every dapp developer have to get sequence number, calculate gas, etc. At that point we are just offloading work to every dapp for no benefit of anyone.

There may be some niche cases where a dapp wants to provide some values like the abi to save network calls from the wallet and make their transactions show up milliseconds faster. We should allow the optional passing of things like the Abi of a transaction, and possibly even a bcs serialized transaction. But those shouldn’t be the default, we would just be making the dapps life more difficult for little to no benefit.

As far as offline mode and specifically signTransaction(not signAndSubmitTransaction because offline mode doesn’t work for that).

I don’t really see the use case of offline mode for a wallet? This would also mean you are just having users blind sign transactions if you are planning on having an offline mode. Seems like a bad idea.

signTransaction is already a bad idea, and most wallets from other chains consider the function very unsafe.