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

Problem: Missing support for validator, consensus address

Open cdc-Hitesh opened this issue 4 years ago • 2 comments

  • Rename account() function of class Address to be more aesthetical something like getAddress
  • Add support for address making for AddressType.USER , AddressType.VALIDATOR
    • This can be added to function arguments

cdc-Hitesh avatar Nov 11 '20 19:11 cdc-Hitesh

@cdc-Hitesh I think there was a thread on this where @calvinaco suggested doing the way it's currently done. https://github.com/crypto-com/chain-jslib/pull/63#issuecomment-722937899

We can definitely revisit that.

So basically there are 2 main approaches :

  • The current
const acct = new Address(keypair)
acct.account() // returns normal address
acct.validator()
acct.consensus() 
  • The proposed
const acct = new Account(keypair)
acct.getAddress() // returns normal address
acct.getValidatorAddress()
acct.getConsensusAddress() 

crypto-eddy avatar Nov 12 '20 07:11 crypto-eddy

I am ok with both way, to me I think making it a method (i.e. getAccountAddress(), getValidatorAddress() is more trivial than enum. For most modern IDE, this can be easily auto-completed, while using enum would require me an extra step to fill the enum and another round of auto-completion for the enum.

However, when naming the methods/params, it is important that we don't interchange or misuse the keywords account and address. Reference: https://docs.cosmos.network/master/basics/accounts.html#addresses There are three types of address

  • Account
  • Validator
  • Consensus

So in the context of address, when we use the name account, we should always be referring account address.

calvinaco avatar Nov 14 '20 07:11 calvinaco