CAFECA-IO / BAIFA

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

[討論] API - 022 拆分合併至其他的 API #359

Closed godmmt closed 11 months ago

godmmt commented 11 months ago

API 規格文件位置: API v1.1.0

討論: 022 拆分合併至其他的 API

022 - Transaction History from Addresses / Transaction List form a block

HTTP Request:

Parameters: address or block_id (Cannot choose both) - required*

Request Example: GET /app/transactions?address=${114007},${110029},...

Response Example:

[
  {
    "id": "916841",
    "chainId": "btc",
    "createdTimestamp": 1678057313,
    "type": "Crypto Currency",
    "status": "SUCCESS"
  },
  {
    "id": "910237",
    "chainId": "btc",
    "createdTimestamp": 1681731057,
    "type": "Evidence",
    "status": "SUCCESS"
  },
  {
    "id": "910237",
    "chainId": "btc",
    "createdTimestamp": 1683905718,
    "type": "Crypto Currency",
    "status": "SUCCESS"
  },
  {
    "id": "919472",
    "chainId": "btc",
    "createdTimestamp": 1689732890,
    "type": "Evidence",
    "status": "FAILED"
  },
  {
    "id": "911837",
    "chainId": "btc",
    "createdTimestamp": 1690209183,
    "type": "Crypto Currency",
    "status": "PENDING"
  }
  // ...other transactions
]

007 - Select period for transactions

HTTP Request: GET /app/chains/:chainId/transactions?start_date=${startTimestamp}&end_date=${endTimestamp}

Parameters: start_date and end_date - required* (根據時間區段回傳資料)

Request Example: GET /app/chains/isun/transactions?start_date=1680176231&end_date=1679978900

Response Example:

{
  "chainId": "isun",
  "chainName": "iSunCloud",
  "chainIcon": "/currencies/isun.svg",
  "blockData": [
    {
      "id": "230020",
      "chainId": "isun",
      "createdTimestamp": 1673940795,
      "stability": "MEDIUM"
    },
    {
      "id": "230021",
      "chainId": "isun",
      "createdTimestamp": 1679978900,
      "stability": "HIGH"
    },
    {
      "id": "230022",
      "chainId": "isun",
      "createdTimestamp": 1680176231,
      "stability": "LOW"
    }
    //...
  ],
  "transactionData": [
    {
      "id": "930071",
      "chainId": "isun",
      "createdTimestamp": 1607957394,
      "type": "Crypto Currency",
      "status": "SUCCESS"
    },
    {
      "id": "930072",
      "chainId": "isun",
      "createdTimestamp": 1679978900,
      "type": "Evidence",
      "status": "FAILED"
    },
    {
      "id": "930073",
      "chainId": "usdt",
      "createdTimestamp": 1680176231,
      "type": "NFT",
      "status": "PENDING"
    }
    //...
  ]
}

008 - Get a block data from a chain

HTTP Request: GET /app/chains/:chainId/blocks/:blockId

Parameters: none

Request Example: GET /app/chains/isun/blocks/230021

Response Example:

{
  "id": "230021",
  "chainId": "isun",
  "chainIcon": "/currencies/isun.svg",
  "stability": "HIGH", //"MEDIUM" | "HIGH" | "LOW"
  "createdTimestamp": 1679978900,
  "managementTeam": ["Alice", "Bob", "Charlie"],
  "transactionCount": 25,
  "miner": "0x1234567890",
  "reward": 2.5,
  "size": 3523, //bytes
  "previousBlockId": "230020",
  "nextBlockId": "230022"
}
godmmt commented 11 months ago

Website URL

為了方便這裡暫時先將 022 區分為 022-1、022-2

godmmt commented 11 months ago

變更計畫

022-1 - GET /app/transactions?address=${address1},${address2},...

預計改成: GET /app/chains/:chainId/transactions?address=${address1},${address2},... (與 007 合併)

022-2 - GET /app/transactions?block_id=${blockId}

預計改成: GET /app/chains/:chainId/blocks/:blockId/transactions (新增為單獨一支 API,預計編號為 009)

godmmt commented 11 months ago

預計文件修改內容(007)

007 - Select period for transactions / Transaction History from Addresses

HTTP Request: GET /app/chains/:chainId/transactions

  1. GET /app/chains/:chainId/transactions?start_date=${startTimestamp}&end_date=${endTimestamp}
  2. GET /app/chains/:chainId/transactions?address=${address1},${address2},...

Parameters:

  1. start_date and end_date - required* (根據時間區段回傳資料)
  2. address - required* (根據地址回傳交易清單)

Request Example: GET /app/chains/isun/transactions?start_date=1680176231&end_date=1679978900

Response Example:

{
  "chainId": "isun",
  "chainName": "iSunCloud",
  "chainIcon": "/currencies/isun.svg",
  "blockData": [
    {
      "id": "230020",
      "chainId": "isun",
      "createdTimestamp": 1673940795,
      "stability": "MEDIUM"
    },
    {
      "id": "230021",
      "chainId": "isun",
      "createdTimestamp": 1679978900,
      "stability": "HIGH"
    },
    {
      "id": "230022",
      "chainId": "isun",
      "createdTimestamp": 1680176231,
      "stability": "LOW"
    }
    //...
  ],
  "transactionData": [
    {
      "id": "930071",
      "chainId": "isun",
      "createdTimestamp": 1607957394,
      "type": "Crypto Currency",
      "status": "SUCCESS"
    },
    {
      "id": "930072",
      "chainId": "isun",
      "createdTimestamp": 1679978900,
      "type": "Evidence",
      "status": "FAILED"
    },
    {
      "id": "930073",
      "chainId": "usdt",
      "createdTimestamp": 1680176231,
      "type": "NFT",
      "status": "PENDING"
    }
    //...
  ]
}

Request Example: GET /app/transactions?address=${114007},${110029},...

Response Example:

[
  {
    "id": "916841",
    "chainId": "btc",
    "createdTimestamp": 1678057313,
    "type": "Crypto Currency",
    "status": "SUCCESS"
  },
  {
    "id": "910237",
    "chainId": "btc",
    "createdTimestamp": 1681731057,
    "type": "Evidence",
    "status": "SUCCESS"
  },
  {
    "id": "910237",
    "chainId": "btc",
    "createdTimestamp": 1683905718,
    "type": "Crypto Currency",
    "status": "SUCCESS"
  },
  {
    "id": "919472",
    "chainId": "btc",
    "createdTimestamp": 1689732890,
    "type": "Evidence",
    "status": "FAILED"
  },
  {
    "id": "911837",
    "chainId": "btc",
    "createdTimestamp": 1690209183,
    "type": "Crypto Currency",
    "status": "PENDING"
  }
  // ...other transactions
]
godmmt commented 11 months ago

預計文件新增內容(009 NEW)

(NEW) 009 - Transaction List form a block

HTTP Request: GET /app/chains/:chainId/blocks/:blockId/transactions

Parameters: none

Request Example: GET /app/chains/btc/blocks/230021/transactions

Response Example:

[
  {
    "id": "916841",
    "chainId": "btc",
    "createdTimestamp": 1678057313,
    "type": "Crypto Currency",
    "status": "SUCCESS"
  },
  {
    "id": "910237",
    "chainId": "btc",
    "createdTimestamp": 1681731057,
    "type": "Evidence",
    "status": "SUCCESS"
  },
  {
    "id": "910237",
    "chainId": "btc",
    "createdTimestamp": 1683905718,
    "type": "Crypto Currency",
    "status": "SUCCESS"
  },
  {
    "id": "919472",
    "chainId": "btc",
    "createdTimestamp": 1689732890,
    "type": "Evidence",
    "status": "FAILED"
  },
  {
    "id": "911837",
    "chainId": "btc",
    "createdTimestamp": 1690209183,
    "type": "Crypto Currency",
    "status": "PENDING"
  }
  // ...other transactions
]
godmmt commented 11 months ago

預計文件刪除內容 (delete 022)

022 - Transaction History from Addresses / Transaction List form a block HTTP Request:

GET /app/transactions?address=${address1},${address2},...

GET /app/transactions?block_id=${blockId}

Parameters: address or block_id (Cannot choose both) - required*

Request Example: GET /app/transactions?address=${114007},${110029},...

Response Example:

[
  {
    "id": "916841",
    "chainId": "btc",
    "createdTimestamp": 1678057313,
    "type": "Crypto Currency",
    "status": "SUCCESS"
  },
  {
    "id": "910237",
    "chainId": "btc",
    "createdTimestamp": 1681731057,
    "type": "Evidence",
    "status": "SUCCESS"
  },
  {
    "id": "910237",
    "chainId": "btc",
    "createdTimestamp": 1683905718,
    "type": "Crypto Currency",
    "status": "SUCCESS"
  },
  {
    "id": "919472",
    "chainId": "btc",
    "createdTimestamp": 1689732890,
    "type": "Evidence",
    "status": "FAILED"
  },
  {
    "id": "911837",
    "chainId": "btc",
    "createdTimestamp": 1690209183,
    "type": "Crypto Currency",
    "status": "PENDING"
  }
  // ...other transactions
]
godmmt commented 11 months ago

took 2 pt need more 1 pt

godmmt commented 11 months ago

TODO:

godmmt commented 11 months ago

If this issue has been done, go update these issues below:

godmmt commented 11 months ago

update API document #350 - took 1 pt update Mock API #351 - took 2 pt

godmmt commented 11 months ago

update Postman mock server settings #352 & TEST #355 - took 0.5 pt

godmmt commented 11 months ago

done.

Total time: 5.5 hours