chain-jslib
chain-jslib copied to clipboard
Problem: Missing support for validator, consensus address
- Rename
account()
function of classAddress
to be more aesthetical something likegetAddress
- Add support for address making for
AddressType.USER
,AddressType.VALIDATOR
- This can be added to function arguments
@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()
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.