perawallet / pera-wallet

Source code for Pera Wallet, simply the best Algorand wallet.
https://perawallet.app
Other
178 stars 62 forks source link

WalletConnect/iOS: Misleading error when sending transaction with incorrect payload #39

Closed ivnsch closed 1 year ago

ivnsch commented 2 years ago

I happened to send a transaction group with one already signed tx:

{
      txn: Buffer.from(signedTxMsgPack).toString("base64"),
      message: "",
      signers: [],
}    

The wallet returns this error:

Error: Signing Error: Network mismatch between dApp and Wallet. For example, Wallet is connected to TestNet and dApp connected to MainNet (or vice versa).

I dug a bit in the code, the problem seems to be that the incorrect payload is managed as a WCTransaction with no parsed details (WCTransactionDetail is nil). Later, there's a validation of the transaction list: https://github.com/algorand/algorand-wallet/blob/master/ios/Classes/Utility/WalletConnect/Transaction/WCTransactionValidator.swift#L32 where it validates first the network, and this: https://github.com/algorand/algorand-wallet/blob/master/ios/Classes/Models/WalletConnect/Transaction/WCTransaction.swift#L205 return false.

It could make sense to validate first WCTransactionDetail, or reject invalid transactions directly when parsing.

taylanpince commented 2 years ago

Thanks for this detailed feedback. cc @sakkaras

taylanpince commented 1 year ago

We've reviewed this case and confirmed that we are now properly handling this case.