noble-assets / noble-cctp-relayer

Apache License 2.0
15 stars 9 forks source link

`tx-info` command should emit human-readable dest'n {address, caller}, nonce, etc #70

Open boojamya opened 8 months ago

boojamya commented 8 months ago

This would be a nice to have to help troubleshoot tx.

It would intake a tx-hash and a source-domain and output things like:

Some of the above info is encoded so giving the ability for the relayer to make this info human readable could be very helpful.

Reecepbcups commented 7 months ago

An example to get the ETH address out of the Cosmos event logs

Query the Tx hash & get the logs

https://www.mintscan.io/noble/tx/5931A0DF16C0D29006CBAB3FD1762F31BF2AE61CE21E36899AC245FA046C867F?height=4593256 :

[{'events': [{'type': 'burn', 'attributes': [{'key': 'burner', 'value': 'noble1x74lhe0pqqv7rcg4pc4svtxhm9hnf79pxpfqfv'}, {'key': 'amount', 'value': '43060000000uusdc'}]}, {'type': 'circle.cctp.v1.DepositForBurn', 'attributes': [{'key': 'amount', 'value': '"43060000000"'}, {'key': 'burn_token', 'value': '"487039debedbf32d260137b0a6f66b90962bec777250910d253781de326a716d"'}, {'key': 'depositor', 'value': '"noble186kh7c0k0gh4ww0wh4jqc4yhzu7n7dhswppd63"'}, {'key': 'destination_caller', 'value': '""'}, {'key': 'destination_domain', 'value': '1'}, {'key': 'destination_token_messenger', 'value': '"AAAAAAAAAAAAAAAAayVTLhBgzhDMOwqZ5Wg7kb/eaYI="'}, {'key': 'mint_recipient', 'value': '"AAAAAAAAAAAAAAAAj7YDV80kNsJIP/pmD4ZR8jAsxV8="'}, {'key': 'nonce', 'value': '"3710"'}]}, {'type': 'circle.cctp.v1.MessageSent', 'attributes': [{'key': 'message', 'value': '"AAAAAAAAAAQAAAABAAAAAAAADn4AAAAAAAAAAAAAAABX1OrxCRV3prfRISAq+9KAgTTxFwAAAAAAAAAAAAAAAGslUy4QYM4QzDsKmeVoO5G/3mmCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASHA53r7b8y0mATewpvZrkJYr7HdyUJENJTeB3jJqcW0AAAAAAAAAAAAAAACPtgNXzSQ2wkg/+mYPhlHyMCzFXwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAoGk3UAAAAAAAAAAAAAAAAAPq1/YfZ6L1c57r1kDFSXFz0/NvA="'}]}, {'type': 'coin_received', 'attributes': [{'key': 'receiver', 'value': 'noble12l2w4ugfz4m6dd73yysz477jszqnfughxvkss5'}, {'key': 'amount', 'value': '43060000000uusdc'}, {'key': 'receiver', 'value': 'noble1x74lhe0pqqv7rcg4pc4svtxhm9hnf79pxpfqfv'}, {'key': 'amount', 'value': '43060000000uusdc'}]}, {'type': 'coin_spent', 'attributes': [{'key': 'spender', 'value': 'noble186kh7c0k0gh4ww0wh4jqc4yhzu7n7dhswppd63'}, {'key': 'amount', 'value': '43060000000uusdc'}, {'key': 'spender', 'value': 'noble12l2w4ugfz4m6dd73yysz477jszqnfughxvkss5'}, {'key': 'amount', 'value': '43060000000uusdc'}, {'key': 'spender', 'value': 'noble1x74lhe0pqqv7rcg4pc4svtxhm9hnf79pxpfqfv'}, {'key': 'amount', 'value': '43060000000uusdc'}]}, {'type': 'message', 'attributes': [{'key': 'action', 'value': '/circle.cctp.v1.MsgDepositForBurn'}, {'key': 'sender', 'value': 'noble186kh7c0k0gh4ww0wh4jqc4yhzu7n7dhswppd63'}, {'key': 'sender', 'value': 'noble12l2w4ugfz4m6dd73yysz477jszqnfughxvkss5'}]}, {'type': 'noble.fiattokenfactory.MsgBurn', 'attributes': [{'key': 'amount', 'value': '{"denom":"uusdc","amount":"43060000000"}'}, {'key': 'from', 'value': '"noble12l2w4ugfz4m6dd73yysz477jszqnfughxvkss5"'}]}, {'type': 'transfer', 'attributes': [{'key': 'recipient', 'value': 'noble12l2w4ugfz4m6dd73yysz477jszqnfughxvkss5'}, {'key': 'sender', 'value': 'noble186kh7c0k0gh4ww0wh4jqc4yhzu7n7dhswppd63'}, {'key': 'amount', 'value': '43060000000uusdc'}, {'key': 'recipient', 'value': 'noble1x74lhe0pqqv7rcg4pc4svtxhm9hnf79pxpfqfv'}, {'key': 'sender', 'value': 'noble12l2w4ugfz4m6dd73yysz477jszqnfughxvkss5'}, {'key': 'amount', 'value': '43060000000uusdc'}]}]}]

from the above mint_recipient:
echo AAAAAAAAAAAAAAAAj7YDV80kNsJIP/pmD4ZR8jAsxV8= | base64 --decode | od -A n -t x1

 00 00 00 00 00 00 00 00 00 00 00 00 8f b6 03 57
 cd 24 36 c2 48 3f fa 66 0f 86 51 f2 30 2c c5 5f

 Which is the destination address -> 0x8fb60357cd2436c2483ffa660f8651f2302cc55f shown in mintscan