---
# System prepended metadata

title: Mint Server 更新 20221125

---

# Mint Server 更新 20221125

## API

### 建立MintInfo

- POST `/rest/nft/mint-info`
- Request
    - 移除`txHash`
    - 當MintInfo不存在或是`status==MINT`時才能使用
- Response 
    [[MintInfo]](#MintInfo)
    - 移除`txHash`
    - 移除`pending`
    - 移除`minted`
    - 新增`status` (`MINT`/`PENDING_MINT`/`MINTED`)

### 更新MintInfo

使用者**確認交易**後將狀態更新成PENDING_MINT

- PATCH `/mint-info/{tokenId}/{env}?address={address}&apiToken={apiToken}`
- Request
    ```json
    {
      "status":"PENDING_MINT"
    }
    ```
- Response
    [[MintInfo]](#MintInfo)

### 刪除MintInfo

使用者**取消交易**後將MintInfo刪除

- DELETE `/mint-info/{tokenId}/{env}?address={address}&apiToken={apiToken}`
- Response
    `OK`

### MintInfo
```json
  "tokenId":"string",
  "env":"srting",
  "projectKey":"string",
  "ownerAddress":"string",
  "mintTimestamp":0,
  "ownerAmount":0,
  "contractAddress":"string",
  "status":"string",
```

### 轉發 前端->websocket
- POST `/rest/forward/websocket?connectionToken={connectionToken}&address={address}&apiToken={apiToken}`
    - 使用方式如下面兩種
        - `?connectionToken={connectionToken}`
            - websocket dest: `/user/frontend/{connectionToken}`
        - `?address={address}&apiToken={apiToken}`
            - websocket dest: `/user/frontend/{apiToken}`
- Request
    ```json
    {
      "request":"CLOSE_WEB_VIEW"
    }
    ```
- Response `OK`

## Server排程
- 移除檢查txHash排程
- 新增檢查超時排程
    - 檢查對象: `mintInfo.status == MINT`
    - 更新條件: `balanceOf(mintInfo.ownerAddress, mintInfo.tokenId) != 0`
        - mintInfo.setStatus(MINTED)
    - 移除條件: `mintInfo.mintTimestamp + 30min > now`
- 新增檢查balanceOf排程
    - 檢查對象: `mintInfo.status == PENDING_MINT`
    - 更新條件: `balanceOf(mintInfo.ownerAddress, mintInfo.tokenId) != 0`
        - mintInfo.setStatus(MINTED)