cardano-foundation / CIPs

Cardano Improvement Proposals (CIPs)
https://cips.cardano.org/
Creative Commons Attribution 4.0 International
507 stars 319 forks source link

CIP-30: Add getNetworkName() Function to API #489

Open Crypto2099 opened 1 year ago

Crypto2099 commented 1 year ago

CIP-30 was originally written and implemented during the time of a singular testnet and mainnet.

With the new era of multiple testnets and a cross-chain future on the horizon, I propose that we introduce a new function in order to maintain backwards compatibility with existing implementations while providing for a more robust and feature-rich future.

Enter the getNetworkName() function.

api.getNetworkName(): Promise\<string> Errors: APIError

Returns a string identifier of the network of the wallet. "preprod" is Pre-Production Testnet, "preview" is Preview Testnet, "cardano" is Cardano Mainnet.

In this way, future test networks and/or side chain networks (i.e. Midnight, Shareslake, etc) can be determined by application developers without breaking backwards compatibility with existing solutions relying on the binary true/false returned by getNetworkId().

rphair commented 1 year ago

cc @Ryun1 - also looks related to pending CIP-0030 update https://github.com/cardano-foundation/CIPs/pull/323

Crypto2099 commented 1 year ago

Just noticed that and left a comment there as well, thanks!

latheesan-k commented 1 year ago

Yes, there's no optimisation to be had by returning a numeric identifier, why not just be literal and say the currently connected network's name

Ryun1 commented 1 year ago

This seems to be a long standing issue, with both #323 and #209 seeking to amend it.

Instead of altering CIP-30 more, I would suggest we use the extendibility mechanism present. Perhaps this end point could be bundled with other CIP-30 additions, such as #443 and/or maybe #206? - to form a CIP-30 extension.