cardano-js-sdk
cardano-js-sdk copied to clipboard
feat!: add a new function to generate and track unused addresses in ObservableWallets
Context
Our CIP-30 getUnusedAddresses
implementation currently always returns an empty array. Particular DApps require wallets to use a freshly created address, as such we must enable this feature in our CIP-30 implementation.
Proposed Solution
BaseWallet now implements a new getNextUnusedAddress
method, which tries to find and track the next unused wallet, it does this by first listing all known addresses, picking the address with the highest derivation index and checking whether this is an empty address or not, if it is an unused address, it returns this address, otherwise, it generates a new unused address, adds it to the tracked addresses and returns it. This guarantees that we are always tracking our next unused address if it is ever requested.
Important Changes Introduced
- BaseWallet implementes a new
getNextUnusedAddress
method that returns the next empty address. - CIP-30
getUnusedAddresses
now return an array with the next unused address.