aeternity / ae_mdw

Aeternity Middleware in Elixir
26 stars 10 forks source link

"register" type different in `/oracles` and `/oracles/{id}` #1872

Open davidyuk opened 1 month ago

davidyuk commented 1 month ago

In /oracles it is a transaction object as per specification.

// 20240726165838
// https://mainnet.aeternity.io/mdw/v3/oracles
{
  "data": [
    {
      "active": true,
      "register": {
        "block_hash": "mh_2f1gyBmtMMb8Sd3kbSu95cADRMwsYE8171KXP4W8wa2osRp4tZ",
        "block_height": 289005,
        "encoded_tx": "tx_+JELAfhCuEBX6CvfGClpszz2kg4qjUL8BtvNE0JpCtuwBHbZwGfTd6O6cQ9fr723QhuML50EIzZlFafB6UUi1y5S6RpZH2wJuEn4RxYBoQFtrWD1RJ5rxuHksnEXADAPHPT2jRT6uqVIr8X45BNYqgGFcXVlcnmIcmVzcG9uc2UAAIOYloCHBowmEhDKAIMEauEAmOjXSw==",
        "hash": "th_K5aPLdEN4H6QduiFtqdkv61gUCvaQpDjX3z9pHKNopD8F65LJ",
        "micro_index": 20,
        "micro_time": 1595571086808,
        "signatures": [
          "sg_CW3T2W6Ryi2kcDcSTeuwvL8xGhKYUDnGHygBCPLrF2aqfWA1RiybKqRRafrctK4c9vvL9DS9kCYzWkWSmD8mN9g6yhQPG"
        ],
        "tx": {
          "abi_version": 0,
          "account_id": "ak_qJZPXvWPC7G9kFVEqNjj9NAmwMsQcpRu6E3SSCvCQuwfqpMtN",
          "fee": 1842945000000000,
          "nonce": 1,
          "oracle_id": "ok_qJZPXvWPC7G9kFVEqNjj9NAmwMsQcpRu6E3SSCvCQuwfqpMtN",
          "oracle_ttl": {
            "type": "delta",
            "value": 10000000
          },
          "query_fee": 0,
          "query_format": "query",
          "response_format": "response",
          "ttl": 289505,
          "type": "OracleRegisterTx",
          "version": 1
        },
        "tx_hash": "th_K5aPLdEN4H6QduiFtqdkv61gUCvaQpDjX3z9pHKNopD8F65LJ"
      },
      "format": {
        "response": "response",
        "query": "query"
      },
      "oracle": "ok_qJZPXvWPC7G9kFVEqNjj9NAmwMsQcpRu6E3SSCvCQuwfqpMtN",
      "query_fee": 0,
      "expire_height": 10289005,
      "active_from": 289005,
      "approximate_expire_time": 3397648769385,
      "register_time": 1595571086808,
      "register_tx_hash": "th_K5aPLdEN4H6QduiFtqdkv61gUCvaQpDjX3z9pHKNopD8F65LJ"
    },

https://github.com/aeternity/ae_mdw/blob/517cfc683d8ac778340f68c328ec6cdf32a024b3/docs/swagger_v3/oracles.spec.yaml#L442-L446

In /oracles/{id} it is some transaction id.

// 20240726165850
// https://mainnet.aeternity.io/mdw/v3/oracles/ok_qJZPXvWPC7G9kFVEqNjj9NAmwMsQcpRu6E3SSCvCQuwfqpMtN
{
  "active": true,
  "register": 13749762,
  "format": {
    "response": "response",
    "query": "query"
  },
  "extends": [

  ],
  "oracle": "ok_qJZPXvWPC7G9kFVEqNjj9NAmwMsQcpRu6E3SSCvCQuwfqpMtN",
  "query_fee": 0,
  "expire_height": 10289005,
  "active_from": 289005,
  "approximate_expire_time": 3397648769385,
  "register_time": 1595571086808,
  "register_tx_hash": "th_K5aPLdEN4H6QduiFtqdkv61gUCvaQpDjX3z9pHKNopD8F65LJ"
}

https://github.com/aeternity/ae_mdw/blob/517cfc683d8ac778340f68c328ec6cdf32a024b3/docs/swagger_v3/oracles.spec.yaml#L473

The best would be to use the same value type in both cases.

davidyuk commented 1 month ago

Also, extends provided in /oracles/{id} and missed in /oracles