In Nami’s former API implementation, a very useful function was implemented to handle user’s account change / network change and I miss it in the current CIP30 standard.
Here is how using it looked like :
await cardano_api.onAccountChange (
async function (addresses) {
const b32_addresses = addresses.map (
function (address) {
const address_bytes = Buffer.from(address, 'hex');
return (
Loader.Cardano
.Address
.from_bytes(address_bytes)
.to_bech32()
);
}
);
// ... Do anything with new addresses
console.log("User account changed :")
console.log(b32_addresses)
}
);
Maybe CIP30 standard should include such a function ? CIP1 indicates that I should post here for the proposition to be weighed in by the community.