telescope
telescope copied to clipboard
telescope: ethermint support
This will be a tracking issue on the progress of developing support for transpiling evmos messages.
Context on EVM messages (Thanks to @hanchon for context)
The general idea to convert the cosmos messages to EVM is to get the transaction in Animo format: https://github.com/evmos/evmos/blob/32e76bd281553e0225d6ff4454db323189847812/ethereum/eip712/encoding.go#L124 (If you already have the transaction in amino format, you can ignore the first step)
Then you use the signdoc bytes to generate the EVM payload, in the evmos code they verify the message before encoding it: https://github.com/evmos/evmos/blob/32e76bd281553e0225d6ff4454db323189847812/ethereum/eip712/encoding.go#L76
The last step is to wrap the transaction in a EIP712 object: https://github.com/evmos/evmos/blob/32e76bd281553e0225d6ff4454db323189847812/ethereum/eip712/eip712.go#L11
One of the Evmos developers made a helper in EvmosJS, but it only supports 3 messages and the types structure is not automatically generated: https://github.com/evmos/evmosjs/blob/main/packages/eip712/src/encoding/decodeAmino.ts#L61
The function that they call to generate the types is: https://github.com/evmos/evmosjs/blob/main/packages/eip712/src/messages/base.ts#L52 (That one has the types required by the EIP712 format, but is missing the specifics for each message, for example: MsgSend uses:
{
MsgValue: [
{ name: 'from_address', type: 'string' },
{ name: 'to_address', type: 'string' },
{ name: 'amount', type: 'TypeAmount[]' },
],
TypeAmount: [
{ name: 'denom', type: 'string' },
{ name: 'amount', type: 'string' },
],
}
)
IMPORTANT: the values must be in the correct order, because the array is hashed to generate the payload that needs to be signed!
The complex part is to get the EIP712 types right automatically.
Then the actual transactions values (that are also included in the EIP712 transaction), are just the json amino encoded values: https://github.com/evmos/evmosjs/blob/main/packages/eip712/src/messages/bank/send.ts#L12
Can I work on this ?
hey @hoangdv2429! I was planning to work on this myself, but there have been some circumstances, so I won't be able to pick it up any time soon, so if you are down, feel free, please!
Got ya 🔥
https://github.com/hoangdv2429/Cosmos-grcp-playground/tree/feat/evmos_ibc_transfer this one is working using keplr signing style.
this create signDoc, if we intend to sign it metamask EIP712 style then
- wrap signDoc to EIP712 obj
- signEIP712 instead of signDirect
note: as for getting types, we should have typeUrl/ type@ together with the message. This is also for getting the json fields order right.
https://github.com/cosmos/cosmjs/pull/1107/files this PR have code that handle ethAccount type as a reference.
multiple messages https://github.com/evmos/evmosjs/blob/e47e44b1683ffa57737cee2f6abbd138436d9fc3/packages/proto/src/transaction/transaction.ts#L192