perawallet / connect

JavaScript SDK for integrating Pera Wallet to web applications.
https://perawallet.app
Other
64 stars 20 forks source link

Multiple Transaction Signers issue #125

Closed bigbulb closed 1 year ago

bigbulb commented 1 year ago

Hello,

I am working an a Dapp and I have 3 transactions that need to happen:

Transaction 1: send algo from Address 1 (user) to Address 2 (dapp automated account) Transaction 2: send a specific Algo ASA from Address 1 (user) to Address 2 (dapp automated account) Transaction 3: send a specific Algo ASA from Address 2 (dapp automated account) to Address 1 (user)

Transactions 1 & 2 need to be signed by Pera by the user. Transaction 3 is already "pre-signed" on the backend.

In my Dapp, the 3 transactions specifications (from, to, amount, assetID, etc.) are obtained from the backend as an array of 3 transactions. Since they are generated from the backend, all 3 transactions belong to the same group.

If I try to submit Transactions 1 and 2 to Pera as is, I get an error message: "It looks like the transaction group contains one or more missing transactions...".

Is there any workaround around this? On the user side, Transaction3 cannot be signed on Pera since it is the dapp automated account, not accessible by the user.

I thought of manually removing the group property for both Transaction 1 and 2 on only submit those 2 transactions to Pera:

multipleTxnGroups.forEach(transac =>  {
   transac.txn.group = undefined;
});

They can be signed, but when submitting them to the Algorand api using sendRawTransaction the following occur:

URLTokenBaseHTTPError: Network request error. Received status 400 (): TransactionPool.Remember: transactionGroup: [0] had zero Group but was submitted in a group of 3

Any idea? Is there a way to manually redefine the group for a transaction after they were signed?