2023-04-20 15:28:35 +08:00

135 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 徽章活动相关接口
### 说明
1. 通用返回格式, errcode=0 表示无错误
2. 如无特别说明, 以下接口的 Response 格式指的是 data 字段
3. 接口名中带\*的表示, 需要验证 token, token 可以设置 header 的 Authorization: Bearer JWT_token, 或 Post body 的 token 字段, 或 Get 的 query token
```json
{
"errcode": Number,
"errmsg": String,
"data": {}
}
```
### 1. 钱包预登录
#### Request
- URL`/api/user/login`
- 方法:`GET`
#### Response
```json
{
"nonce": String,
"tips": String
}
```
### 2. 钱包登录
客户端在获得钱包地址后,须先调用预登录方法获取 nonce 和 tips, 然后调用钱包进行 EIP-721 签名.
登录成功后返回的 jwt 需要保存至本地存储, 再次载入后, 可解析并获取 exp 字段, 判断当前 token 是否已经过期
#### Request
- URL`/api/user/login`
- 方法:`POST`
- 头部:
- Content-type: application/json
- Body:
```json
{
"nonce": Number,
"signature": String,
"account": String
}
```
#### Response
```json
{
"token": String,
}
```
### 3. \*检查当前用户 claim 状态
#### Request
- URL`/api/user/status`
- 方法:`GET`
- 头部:
- Authorization: Bearer JWT_token
- 参数:
- `uid`(用户 ID
#### Response
```json
[
{
"id": String,
"status": Number
}
]
```
status: 0: 不可以 claim, 1: 可 claim, 9: 已经 claim
### 4. \*用户申请 claim
调用该方法后, 服务端会检查是否符合相关条件, 如果符合, 那么会立即返回一个 taskId, 客户端需凭借此 taskId 轮询该任务的状态
#### Request
- URL`/api/user/claim`
- 方法:`POST`
- 头部:
- Authorization: Bearer JWT_token
- Body: 空对象 `{}`
#### Response
```json
{
"taskId": String,
}
```
### 5.\* 检查 claim 任务的状态
#### Request
- URL`/api/user/claim/:taskId`
- 方法:`GET`
- 头部:
- Authorization: Bearer JWT_token
#### Response
```json
{
"status": Number,
"txHashList": [String],
}
```
status 说明
0: 队列中, 等待上链
1: 成功上链, 等待确认
9: 已确认成功(成功的最终状态)
10: 失败