cosmos / chain-registry

Creative Commons Attribution 4.0 International
509 stars 1.22k forks source link

Add bech32 HRP prefixes to chain.json #665

Closed ValarDragon closed 1 year ago

ValarDragon commented 2 years ago

We should add some data around HRP prefixes (e.g. osmo1..., cosmos1...) in the address formats to the chain registry. Not sure how it would best look / be formatted

JeremyParish69 commented 2 years ago

just to make sure I understand, are you talking about defining things like this?: Bech32 Acc: cosmos Bech32 Val: cosmosvaloper are there any other examples?

Here's an example:

"bech32_prefixes": {
  "account": "terra"
  "validator": "terravaloper"
  "slip173_coin": "Terra" 
}

note: "slip173_coin" acts as a 'key' for finding the registration in the SLIP173 registration, which makes validation more robust. (Terra and Terra 2.0 both use 'terra', so using pretty_name won't suffice without exceptions)

this would be an easy conversion, although I'm not sure if all cosmos chains' validator prefix is the same as their account prefix + "valoper"...

Reecepbcups commented 2 years ago

Yes this would be so awesome, really needing this for a project I am working on

chains have the ability to specify an entirely different validator prefix, pretty sure cro does this

sunnya97 commented 2 years ago

@ValarDragon isn't bech32 prefix already in the chain registry? example

chains have the ability to specify an entirely different validator prefix, pretty sure cro does this

Yeah we should have an optional field to specify an overridden validator prefix, but lets leave the default as assuming it follows the standard convention

JeremyParish69 commented 1 year ago

Is this an exhaustive list?:

{
  bech32PrefixAccAddr: "cosmos",
  bech32PrefixAccPub: "cosmos" + "pub",
  bech32PrefixValAddr: "cosmos" + "valoper",
  bech32PrefixValPub: "cosmos" + "valoperpub",
  bech32PrefixConsAddr: "cosmos" + "valcons",
  bech32PrefixConsPub: "cosmos" + "valconspub"
}

although, would probably have to do it more like this:

{
  bech32PrefixAccAddr: "cosmos",
  bech32PrefixAccPub: "cosmospub",
  bech32PrefixValAddr: "cosmosvaloper",
  bech32PrefixValPub: "cosmosvaloperpub",
  bech32PrefixConsAddr: "cosmosvalcons",
  bech32PrefixConsPub: "cosmosvalconspub"
}

I don't know what all of these really mean, so I don't have an equivalent word like 'account' and 'validator' and all 6.

this would completely replace 'bech32_prefix', while 5/6 of these can be assumed as a default (combo of given prefix + default suffix). I also might like to include a Slip173registration key.

I imagine it perhaps looking like this:

"bech32": {
  "bech32PrefixAccAddr": "cosmos",
  "bech32PrefixAccPub": "cosmospub",
  "bech32PrefixValAddr": "cosmosvaloper",
  "bech32PrefixValPub": "cosmosvaloperpub",
  "bech32PrefixConsAddr": "cosmosvalcons",
  "bech32PrefixConsPub": "cosmosvalconspub",
  "slip173_key": "Cosmos Hub"
}

Thoughts?

pyramation commented 1 year ago

Yeah we should have an optional field to specify an overridden validator prefix, but lets leave the default as assuming it follows the standard convention

agree with this!

pyramation commented 1 year ago
"bech32": {
  "bech32PrefixAccAddr": "cosmos",
  "bech32PrefixAccPub": "cosmospub",
  "bech32PrefixValAddr": "cosmosvaloper",
  "bech32PrefixValPub": "cosmosvaloperpub",
  "bech32PrefixConsAddr": "cosmosvalcons",
  "bech32PrefixConsPub": "cosmosvalconspub",
  "slip173_key": "Cosmos Hub"
}

Thoughts?

Does it need to be embedded? I'd prefer to move slip stuff out to keep the bech32 object in sync with keplr's readonly bech32Config: Bech32Config;: https://docs.keplr.app/api/suggest-chain.html

Also maybe to keep similar, we can call it bech32_config? just a thought

JeremyParish69 commented 1 year ago

Actually ya I agree with these points, @pyramation. This better?

"bech32_config": {
  "bech32PrefixAccAddr": "cosmos",
  "bech32PrefixAccPub": "cosmospub",
  "bech32PrefixValAddr": "cosmosvaloper",
  "bech32PrefixValPub": "cosmosvaloperpub",
  "bech32PrefixConsAddr": "cosmosvalcons",
  "bech32PrefixConsPub": "cosmosvalconspub"
},
"slip173_key": "Cosmos Hub"

also, we don't need the slip key, but I think it serves a handy function for validation and as a great reminder to register the prefix (something many submitters forget to do)

JeremyParish69 commented 1 year ago

should we completely nuke the "bech32_prefix" and just require this object with at least "bech32PrefixAccAddr"? In every chain.json file so far, we'd have to replace: "bech32_prefix": "cosmos" becomes:

"bech32_config": {
  "bech32PrefixAccAddr": "cosmos"
}