ensdomains / address-encoder

Encodes and decodes address formats for various cryptocurrencies
MIT License
149 stars 128 forks source link

Return any non registered evmchain coin types as ETH #374

Closed makoto closed 1 year ago

makoto commented 1 year ago

This change extends formatsByCoinType to return ETH encoder/decoder even when specific evm chain id is not registered.

Example:

// registered
encoder.formatsByCoinType[encoder.convertEVMChainIdToCoinType(100)]
{
  coinType: 2147483748,
  decoder: [Function (anonymous)],
  encoder: [Function (anonymous)],
  name: 'GNO'
}
// non registered
encoder.formatsByCoinType[encoder.convertEVMChainIdToCoinType(100123)]
{
  coinType: 2147583771,
  decoder: [Function (anonymous)],
  encoder: [Function (anonymous)],
  name: ''
}

Additionally convertEVMChainIdToCoinType and convertCoinTypeToEVMChainId throws an error if too small/large numbers are passed

makoto commented 1 year ago

Can you also please lint/format the code consistently?

lint is part of CI and it did pass. Maybe need to add new rules?

makoto commented 1 year ago

@Arachnid PTAL

Arachnid commented 1 year ago

lint is part of CI and it did pass. Maybe need to add new rules?

Great - but the formatting is very inconsistent. Can you prettyprint it?