input-output-hk / js-cardano-wasm

various cardano javascript using wasm bindings
MIT License
31 stars 21 forks source link

Make txs copyable #71

Closed SebastienGllmt closed 5 years ago

SebastienGllmt commented 5 years ago

For Yoroi the Send screen allows the user to author a transaction. Once they've specified the receiver and the amount, they can press the "send" button to broadcast the transaction.

They way I would like this to work internally (currently it's a big hack job) is that the Send page creates a Transaction and when they press the "send" button it tries to create a SignedTransaction. The problem is that creating a SignedTransaction frees the original Transaction object so it's not easy to provide a fallback if a tx fails. The cleanest way to solve this is when you press the "send" button, it clones the transaction and tries to sign the clone. If signing fails, it falls back to the original Transaction.

I also added from_json in here since probably this will be useful for unit tests once I finish this part of Yoroi refactoring.