CAFECA-IO / BAIFA

https://baifa.vercel.app
GNU General Public License v3.0
0 stars 0 forks source link

API 內容調整 #387

Closed Julian0701 closed 11 months ago

Julian0701 commented 11 months ago

Update steps:


1. 調整 transactionData / transactionHistoryData 格式

"transactionData": [
    {
      "id": "930918",
      "chainId": "btc",
      "createdTimestamp": 1689957331,
      "toAddressId": "329013",
      "type": "Crypto Currency",
      "status": "SUCCESS"
    },
    //...
  ]

"transactionHistoryData": [
    {
      "id": "930154",
      "chainId": "eth",
      "createdTimestamp": 1679978987,
      "toAddressId": "331831",
      "type": "Evidence",
      "status": "FAILED"
    },
    //...
  ],

2. 調整 blockProducedData 格式

  "blockProducedData": [
    {
      "id": "230976",
      "createdTimestamp": 1678940724,
      "stability": "MEDIUM",
      "reward": 2.4,
      "uint": "btc",
      "chainIcon": "/currencies/btc.svg"
    },
    //...
  ]

3. 007 - Get a block data from a chain 新增 uint

{
  "id": "230021",
  "chainId": "isun",
  "chainIcon": "/currencies/isun.svg",
  "stability": "HIGH",
  "createdTimestamp": 1679978900,
  "managementTeam": ["Alice", "Bob", "Charlie"],
  "transactionCount": 25,
  "miner": "0x1234567890",
  "reward": 2.5,
  "uint": "isun", // Add this
  "size": 3523,
  "previousBlockId": "230020",
  "nextBlockId": "230022"
}

4. 012 - Reviews of an address 新增 chainIcon

{
  "id": "115588",
  "address": "0x2775D3190693fEc256d156f9f74Cd8843A79",
  "score": 2.8,
  "chainIcon": "/currencies/eth.svg" // Add this
  "reviewData": [
    {
      "id": "T99283100001",
      "transactionId": "992831",
      "chainId": "eth",
      "createdTimestamp": 1675289690,
      "authorAddressId": "392801",
      "content": "This is a review",
      "stars": 3
    },
    //...
  ]
}

5. 011 - Get an address data from a chain 關聯地址的格式須調整

relatedAddressIds 改成 relatedAddresses

{
   ...,
   "relatedAddresses": [
       {
          "id": "214134",
          "chainId": "btc"
       },
       {
          "id": "234143"
          "chainId": "eth"
       },
       // ...
    ],
}
godmmt commented 11 months ago

✅ Check list - API Document:

godmmt commented 11 months ago

1. 調整 transactionData / transactionHistoryData 格式

transactionData :

transactionHistoryData :

godmmt commented 11 months ago

1. 範例

transactionData :

e.g. 005 :

Before:

  "transactionData": [
    {
      "id": "930071",
      "chainId": "isun",
      "createdTimestamp": 1607957394,
      "type": "Crypto Currency",
      "status": "SUCCESS"
    }
    //...
  ]

After:

  "transactionData": [
    {
      "id": "930071",
      "chainId": "isun",
      "createdTimestamp": 1607957394,
      "from": [
        { "type": "address", "address": "130294" }
        // ...
        // FIXME:address like 0x356f9537631A773Ab9069fEc25f74Cd884132776
      ],
      "to": [
        { "type": "contract", "address": "310071" }
        // ...
        // FIXME:address like 0x356f9537631A773Ab9069fEc25f74Cd884132776
      ],
      "type": "Crypto Currency",
      "status": "SUCCESS"
    },
    {
      "id": "930291",
      "chainId": "isun",
      "createdTimestamp": 1679978900,
      "from": [
        { "type": "address", "address": "130682" }
        // ...
        // FIXME:address like 0x356f9537631A773Ab9069fEc25f74Cd884132776
      ],
      "to": [
        { "type": "contract", "address": "310071" }
        // ...
        // FIXME:address like 0x356f9537631A773Ab9069fEc25f74Cd884132776
      ],
      "type": "Evidence",
      "status": "FAILED"
    },
    {
      "id": "930032",
      "chainId": "isun",
      "createdTimestamp": 1680176231,
      "from": [
        { "type": "address", "address": "130008" }
        // ...
        // FIXME:address like 0x356f9537631A773Ab9069fEc25f74Cd884132776
      ],
      "to": [
        { "type": "contract", "address": "310029" }
        // ...
        // FIXME:address like 0x356f9537631A773Ab9069fEc25f74Cd884132776
      ],
      "type": "NFT",
      "status": "PENDING"
    }
    //...
  ]

transactionHistoryData :

e.g. 011 :

Before:

  "transactionHistoryData": [
    {
      "id": "930154",
      "createdTimestamp": 1679978987,
      "type": "Crypto Currency",
      "status": "SUCCESS"
    },
    {
      "id": "930785",
      "createdTimestamp": 1687909392,
      "type": "Evidence",
      "status": "FAILED"
    }
    //...
  ]

After:

  "transactionHistoryData": [
    {
      "id": "918402",
      "chainId": "btc",
      "createdTimestamp": 1679978987,
      "from": [{ "type": "address", "address": "114007" }], // FIXME:address like 0x356f9537631A773Ab9069fEc25f74Cd884132776
      "to": [{ "type": "contract", "address": "110132" }],
      "type": "Crypto Currency",
      "status": "SUCCESS"
    },
    {
      "id": "912299",
      "chainId": "btc",
      "createdTimestamp": 1687909392,
      "from": [{ "type": "address", "address": "110132" }], // FIXME:address like 0x356f9537631A773Ab9069fEc25f74Cd884132776
      "to": [{ "type": "contract", "address": "310683" }],
      "type": "Evidence",
      "status": "FAILED"
    }
    //...
  ]
godmmt commented 11 months ago

瀏覽器畫面對照:(資料來源 #364

005 - GET /app/chains/:chain_id 006 - GET /app/chains/:chain_id/blocks?start_date=${startTimestamp}&end_date=${endTimestamp} https://baifa-1dmwoz781-cafeca.vercel.app/en/app/chains/isun

011 - GET /app/chains/:chain_id/addresses/:address_id https://baifa-1dmwoz781-cafeca.vercel.app/en/app/chains/isun/address/130294

godmmt commented 11 months ago

1 -> 173c6c9 2 -> 4813ef3 3 -> cf2a5d1 4 + 5 -> cf2a5d1

godmmt commented 11 months ago

✅ Check list - Mock API codes:

  1. 調整 transactionData / transactionHistoryData 格式
  2. 調整 blockProducedData 格式
  3. 007 - Get a block data from a chain 新增 uint
  4. 012 - Reviews of an address 新增 chainIcon
  5. 011 - Get an address data from a chain 關聯地址的格式須調整

Total api updated:

godmmt commented 11 months ago

Check Postman Response:

Total api updated:

godmmt commented 11 months ago

done.

took 5 hours.