cosmjs
cosmjs copied to clipboard
EthSecp
Please also see: https://github.com/confio/cosmjs-types/pull/30
cc: @fedekunze
Hope we can merge it ASAP.
Is tendermint/PubKeyEthSecp256k1 a type that exists in Tendermint? At least it uses a Tendermint namespace. But I don't see it in the codebase. I would like to avoid adding code for forked Tendermint/Cosmos SDK tech.
It's introduced By EVMOS, we need it if we want to integrate Evmos stuffs into Cosmjs.
For example:
export class EthereumLedgerSigner implements OfflineAminoSigner{
app: Eth
hdpath: string = "44'/60'/0'/0/0"
public async getAccounts(): Promise<readonly AccountData[]> {
return this.app.getAddress(this.hdpath).then(x => {
const x1: AccountData = {
pubkey: Secp256k1.compressPubkey(fromHex(x.publicKey)),
address: x.address,
algo: "secp256k1" // should set to 'ethsecp256k1'
}
const x2: AccountData = {
pubkey: Secp256k1.compressPubkey(fromHex(x.publicKey)),
address: ethToCosmos(x.address),
algo: "secp256k1" // // should set to 'ethsecp256k1'
}
return [x1, x2]
})
};
There are many scenarios that we need to extend something like pubkey
Is
tendermint/PubKeyEthSecp256k1a type that exists in Tendermint? At least it uses a Tendermint namespace. But I don't see it in the codebase. I would like to avoid adding code for forked Tendermint/Cosmos SDK tech.
@webmaster128 So this PR will not be accepted?
I think the underlying problem is that comsjs currently can't be extended in Application Land to support this. In some way I think this is very special for the type of an Account. If it would be just messages, we could add them to the registry.
I think short term, it might make sense to support evmos accounts in cosmjs. If there are too many of those incidents, it might make more sense to allow users hooking into the account parsing.
@StregoFren @webmaster128 In fact it is introduced by Ethermint: https://github.com/tharsis/ethermint
The open source library is used and maintained by the Evmos core team, in addition to being used in for a number of other chains; Cronos, Kava, GenesisL1, etc.
Supporting Ethermint types in cosmjs will ensure support for a growing number of chains in the Cosmos ecosystem that rely on Ethermint's EVM.
I have no issue adding support for evmos types where this is possible in a clean way. But looking at the diffs people send for evmos support, it feels like big time hackery in the deepest core of CosmJS. If evmos changes those things, it is no surprise Cosmos SDK client libraries don't work anymore.
We'll certainly not add chain ID checks to change internal logic. There should also be a different Amino prefix for the different pubkey type. AccountData does not support the ethermint pubkey type, but this could be changed.
Adding ethermint types in cosmjs-types seems useful. But not in src/cosmos/crypto/ethsecp256k1/keys.ts as there is a separate ethermint protobuf package already.
So as dapp developers, how can we interact with evmos?
is there any hacky way to do that dAPP side instead of cosmjs side?
As soon as I have some time I will update the code to import the ethermint types directly into cosmjs (without having to go through the chain-id, but via the coinType). Before that I'll update the code with my last changes (chain-id updated) and I'll publish the package on npm so that it's possible to take advantage of it now (since there is absolutely no chance that's the Amino prefix will be changed imho). I let you know.
Thank you for this PR. It was a very helpful contribution to https://github.com/cosmos/cosmjs/issues/1351. For now it is undecided if Ethermint is in scope of this project.
Hey~ Im interested in the ethermint support too. Im willing to contribute and push this forward. So the blockers is how to ideal with the same prefix of secp256k1 and ethsecp256k1. And the chain-id issue can be solved by using the coin_type=60. Those are the blockers. Am I right?