rooch-network / rooch

VApp Container with Move Language for Bitcoin ecosystem
https://rooch.network
Apache License 2.0
162 stars 85 forks source link

feat(cli): support query transaction #2556

Closed newraina closed 2 months ago

newraina commented 2 months ago

Summary

Closes #2239

Support query transaction.

Test Result

Without args

rooch transaction query

error: the following required arguments were not provided:
  <--sender <SENDER>|--tx-hashes <TX_HASHES>|--start-time <START_TIME>|--end-time <END_TIME>|--from-order <FROM_ORDER>|--to-order <TO_ORDER>>

Missing some args

rooch transaction query --from-order 1

error: the following required arguments were not provided:
  --to-order <TO_ORDER>

Normal case

rooch transaction query --sender tb1pegyjdeycwtwt9s05eafwmj4qf93qjkvujem8myhx5rwktxutfq5ss2ndms --limit 1
{
  "data": [
    {
      "transaction": {
        "data": {
          "type": "l2_tx",
          "sequence_number": "1060",
          "sender": "rooch1vlvfs806fd4dy64qjv87ek5h9jhgvkvctvcr8nwlmaqj34r9888ssm6jk2",
          "sender_bitcoin_address": "tb1pegyjdeycwtwt9s05eafwmj4qf93qjkvujem8myhx5rwktxutfq5ss2ndms",
          "action_type": "functioncall",
          "action": {
            "function_call": {
              "function_id": "0x0000000000000000000000000000000000000000000000000000000000000003::session_key::create_session_key_with_multi_scope_entry",
              "ty_args": [],
              "args": [
                "0x0c726f6f63682d706f7274616c",
                "0x14706f7274616c2e726f6f63682e6e6574776f726b",
                "0x20828a3f5f87e80f8efb8010d5a79e73af5a0e33d35e05b6a6b83cc1c13c3d87ca",
                "0x03000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000034938919590105e18ca080eeaf39441400a4687aba0fe44ef00e136027cc54eb7",
                "0x03012a012a012a",
                "0x03012a012a012a",
                "0x8070000000000000"
              ]
            }
          },
          "raw": "0x67d8981dfa4b6ad26aa0930fecda972cae8659985b3033cddfdf4128d46539cf2404000000000000020000000000000080f0fa02000000000100000000000000000000000000000000000000000000000000000000000000030b73657373696f6e5f6b6579296372656174655f73657373696f6e5f6b65795f776974685f6d756c74695f73636f70655f656e74727900070d0c726f6f63682d706f7274616c1514706f7274616c2e726f6f63682e6e6574776f726b2120828a3f5f87e80f8efb8010d5a79e73af5a0e33d35e05b6a6b83cc1c13c3d87ca6103000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000034938919590105e18ca080eeaf39441400a4687aba0fe44ef00e136027cc54eb70703012a012a012a0703012a012a012a0880700000000000000100000000000000f8024060cff0828ce2afc1199b1138a756127b9658df86d4f14dc7a0819ba421fd24d52658130a9f75af0e06e2da859e53bd8f55e9f2db76bed74121040aa19c40fc3c1a18426974636f696e205369676e6564204d6573736167653a0af9b901526f6f6368205472616e73616374696f6e3a0a57656c636f6d6520746f20726f6f63682d706f7274616c0a596f752077696c6c20617574686f72697a652073657373696f6e3a0a53636f70653a0a3078313a3a2a3a3a2a0a3078333a3a2a3a3a2a0a3078343933383931393539303130356531386361303830656561663339343431343030613436383761626130666534346566303065313336303237636335346562373a3a2a3a3a2a0a54696d654f75743a32383830300a21033cb8e4b6493203bf08060c3541c674b88d8cd9a36a0485e5cf83dd1342fd486d3e626331706567796a646579637774777439733035656166776d6a3471663933716a6b76756a656d386d7968783572776b7478757466713573387a397a706c"
        },
        "sequence_info": {
          "tx_order": "8953080",
          "tx_order_signature": "0x01fece7485fa3c12ac76f16f45038942c9352b993006be8d75394d33a8082edb5e479f1c78cbbfce2f2b638db58f8a0afac2fc0f63a27b992a9fbafc386644b4e7026c9e5a00643a706d3826424f766bbbb08adada4dc357c1b279ad4662d2fd1e2e",
          "tx_accumulator_root": "0xc0b0b053e43b5187a90ef2624c6d958fae996b7eafdea0ffcfb01856706f22a5",
          "tx_timestamp": "1722992038332"
        }
      },
      "execution_info": {
        "tx_hash": "0xe6adf0b82c89fd506c88a890b4eb0636c43ab20f190b47af8cfa94ad581391f0",
        "state_root": "0x17b6eddc12b978c5603d9b5f377d0c108cfff89cc7a324b45dd053a0104d2cd3",
        "event_root": "0x21e9d6f7aa539d1befd74a0d9afc7fa7999ad77a941fb6b9eb461ffa0f8464f7",
        "gas_used": "1271399",
        "status": {
          "type": "executed"
        }
      }
    }
  ],
  "next_cursor": "8953080",
  "has_next_page": true
}
vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rooch-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 2, 2024 8:19am
rooch-portal-v2.1 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 2, 2024 8:19am
1 Skipped Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **rooch** | ⬜️ Ignored ([Inspect](https://vercel.com/rooch/rooch/FkiUL7M287oV1xM6jetaFCX4E6dY)) | [Visit Preview](https://rooch-git-fork-newraina-2239-cli-query-transaction-rooch.vercel.app) | | Sep 2, 2024 8:19am |
newraina commented 2 months ago

TODO:

Add a test case for the query command, like

https://github.com/rooch-network/rooch/blob/4b23b700f337adc0adc7efbe20beedace7f7d145/crates/testsuite/features/cmd.feature#L69-L71

added in https://github.com/rooch-network/rooch/pull/2568