chain-registry icon indicating copy to clipboard operation
chain-registry copied to clipboard

Add bech32 HRP prefixes to chain.json

Open ValarDragon opened this issue 3 years ago • 3 comments

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

ValarDragon avatar Aug 27 '22 18:08 ValarDragon

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"...

JeremyParish69 avatar Sep 11 '22 19:09 JeremyParish69

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

Reecepbcups avatar Sep 12 '22 14:09 Reecepbcups

@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

sunnya97 avatar Sep 16 '22 05:09 sunnya97

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?

JeremyParish69 avatar Dec 06 '22 19:12 JeremyParish69

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 avatar Dec 08 '22 04:12 pyramation

"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

pyramation avatar Dec 08 '22 04:12 pyramation

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 avatar Dec 08 '22 18:12 JeremyParish69

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"
}

JeremyParish69 avatar Dec 30 '22 01:12 JeremyParish69