input-output-hk / js-cardano-wasm

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

Testnet address generation #79

Closed rooooooooob closed 4 years ago

rooooooooob commented 4 years ago

The motivation to change this part of the deprecated wallet-wasm library was the simple introduction of testnet address support in yoroi-mobile. The alternative is to migrate all of yoroi-mobile away to use the new cardano-wallet module, but this would be significant work in comparison and can be delayed. Directly adapting react-native-cardano to use cardano-wallet was not feasible either as the API is quite different and would be exceptionally awkward to try and force into the react-native-cardano API that was built on top of wallet-wasm with its API in mind.

Only xwallet_account() was changed, as the other function lacking support for testnet, wallet_public_to_address() does not seem to be used anywhere in react-native-cardano, which was the motivation for this change. Changing wallet_public_to_address() would also be more difficult as it requires a hard API change or an additional function to allow overloading.

On the other hand, xwallet_account() supports a JSON API, which conveniently allows us to be backwards compatible, as the absence of the protocol_magic field will revert to the previous behavior of default (mainnet) protocol magic.

Additionally, the rust-cardano dependency here was updated as verification of testnet addresses was not working properly in the very old of rust-cardano that was used.

rooooooooob commented 4 years ago

@NicolasDP Does this need a second reviewer or something, or can it be merged now? I don't have access to the repo so I can't do it myself.