zklighter-perps 1.0.86 → 1.0.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.circleci/config.yml +87 -15
- package/.circleci/openapi_postprocess.py +42 -0
- package/models/DepositHistoryItem.ts +2 -1
- package/openapi.json +2 -1
- package/package.json +1 -1
package/.circleci/config.yml
CHANGED
|
@@ -1,29 +1,88 @@
|
|
|
1
1
|
version: 2.1
|
|
2
2
|
|
|
3
3
|
jobs:
|
|
4
|
-
|
|
4
|
+
update_openapi:
|
|
5
5
|
docker:
|
|
6
|
-
- image: cimg/
|
|
7
|
-
|
|
6
|
+
- image: cimg/go:1.22.5
|
|
7
|
+
|
|
8
8
|
working_directory: ~/project
|
|
9
9
|
|
|
10
10
|
steps:
|
|
11
|
+
- checkout
|
|
12
|
+
|
|
13
|
+
- run:
|
|
14
|
+
name: Clone zklighter-perps repository
|
|
15
|
+
command: |
|
|
16
|
+
git clone https://${GITHUB_TOKEN}@github.com/elliottech/zklighter-perps.git
|
|
17
|
+
|
|
18
|
+
- run:
|
|
19
|
+
name: Download goctl-swagger binary
|
|
20
|
+
command: |
|
|
21
|
+
mv goctl-swagger-amd zklighter-perps/service/apiserver
|
|
22
|
+
cd zklighter-perps/service/apiserver
|
|
23
|
+
chmod +x goctl-swagger-amd
|
|
24
|
+
|
|
25
|
+
- run:
|
|
26
|
+
name: Run goctl api plugin
|
|
27
|
+
command: |
|
|
28
|
+
cd zklighter-perps/service/apiserver
|
|
29
|
+
GO111MODULE=on go install github.com/zeromicro/go-zero/tools/goctl@v1.6.6
|
|
30
|
+
sed 's/struct{}/{}/g' server.api > temp.txt && cp temp.txt server.api && rm temp.txt
|
|
31
|
+
goctl api plugin --plugin ./goctl-swagger-amd="swagger -filename openapi.json -host mainnet.zklighter.elliot.ai -schemes https" --api server.api --dir .
|
|
32
|
+
|
|
11
33
|
- run:
|
|
12
|
-
name:
|
|
34
|
+
name: openapi.json Post Process
|
|
13
35
|
command: |
|
|
14
|
-
|
|
36
|
+
cd zklighter-perps/service/apiserver
|
|
37
|
+
jq 'del(.paths["/api/v1/feedback"], .definitions["ReqSendFeedback"], .paths["/api/v1/ws_status"], .paths["/stream"], .paths["/api/v1/permission"])' openapi.json > temp.json && mv temp.json openapi.json
|
|
38
|
+
jq 'walk(if type == "object" then with_entries(select(.key != "")) else . end)' openapi.json > temp.json && mv temp.json openapi.json
|
|
39
|
+
jq 'walk(if type == "object" and has("summary") then .description = .summary else . end)' openapi.json > temp.json && mv temp.json openapi.json
|
|
40
|
+
jq 'walk(if type == "object" and has("operationId") then .summary = .operationId else . end)' openapi.json > temp.json && mv temp.json openapi.json
|
|
41
|
+
jq 'walk(if type == "object" and has("responses") then .responses["400"] = { "description": "Bad request", "schema": { "$ref": "#/definitions/ResultCode" } } else . end)' openapi.json > tmp.json && mv tmp.json openapi.json
|
|
42
|
+
jq 'walk(if type == "object" and .name == "types" then .type="array" | .items={"type":"integer", "format":"uint8"} | del(.format) else . end)' openapi.json > tmp.json && mv tmp.json openapi.json
|
|
43
|
+
sed 's/"-",//g' openapi.json > temp.txt && mv temp.txt openapi.json
|
|
44
|
+
|
|
45
|
+
- store_artifacts:
|
|
46
|
+
path: ~/project/zklighter-perps/service/apiserver/openapi.json
|
|
15
47
|
|
|
16
48
|
- persist_to_workspace:
|
|
17
|
-
root: ~/project/zklighter-perps
|
|
49
|
+
root: ~/project/zklighter-perps/service/apiserver
|
|
18
50
|
paths:
|
|
19
51
|
- openapi.json
|
|
20
52
|
|
|
21
|
-
|
|
53
|
+
openapi_postprocess:
|
|
22
54
|
docker:
|
|
23
|
-
- image: cimg/
|
|
55
|
+
- image: cimg/python:3.10.0
|
|
56
|
+
working_directory: ~/project
|
|
57
|
+
steps:
|
|
58
|
+
- checkout
|
|
59
|
+
|
|
60
|
+
- attach_workspace:
|
|
61
|
+
at: /tmp/workspace
|
|
62
|
+
|
|
63
|
+
- run:
|
|
64
|
+
name: Get openapi.json from workspace
|
|
65
|
+
command: |
|
|
66
|
+
cp /tmp/workspace/openapi.json ./.circleci
|
|
67
|
+
|
|
68
|
+
- run:
|
|
69
|
+
name: Run postprocess script
|
|
70
|
+
command: |
|
|
71
|
+
cd ./.circleci
|
|
72
|
+
python3 openapi_postprocess.py
|
|
24
73
|
|
|
74
|
+
- store_artifacts:
|
|
75
|
+
path: ~/project/.circleci/openapi.json
|
|
76
|
+
|
|
77
|
+
- persist_to_workspace:
|
|
78
|
+
root: ~/project/.circleci
|
|
79
|
+
paths:
|
|
80
|
+
- openapi.json
|
|
81
|
+
|
|
82
|
+
update_ts_sdk:
|
|
83
|
+
docker:
|
|
84
|
+
- image: cimg/openjdk:21.0.2
|
|
25
85
|
working_directory: ~/project
|
|
26
|
-
|
|
27
86
|
steps:
|
|
28
87
|
- checkout
|
|
29
88
|
|
|
@@ -48,6 +107,11 @@ jobs:
|
|
|
48
107
|
name: Increase package version
|
|
49
108
|
command: |
|
|
50
109
|
jq '.version |= (split(".") | .[2] = ((.[2] | tonumber) + 1 | tostring) | join("."))' package.json > tmp.json && mv tmp.json package.json
|
|
110
|
+
|
|
111
|
+
- run:
|
|
112
|
+
name: git status
|
|
113
|
+
command: |
|
|
114
|
+
git status
|
|
51
115
|
- run:
|
|
52
116
|
name: push to new branch
|
|
53
117
|
command: |
|
|
@@ -71,7 +135,10 @@ jobs:
|
|
|
71
135
|
|
|
72
136
|
steps:
|
|
73
137
|
- checkout
|
|
74
|
-
|
|
138
|
+
- run:
|
|
139
|
+
name: Remove binary
|
|
140
|
+
command: |
|
|
141
|
+
rm -rf goctl-swagger-amd
|
|
75
142
|
- run:
|
|
76
143
|
name: Publish npm package
|
|
77
144
|
command: |
|
|
@@ -91,18 +158,23 @@ workflows:
|
|
|
91
158
|
update_ts_sdk:
|
|
92
159
|
when: << pipeline.parameters.update_ts_sdk >>
|
|
93
160
|
jobs:
|
|
94
|
-
-
|
|
161
|
+
- update_openapi:
|
|
162
|
+
filters:
|
|
163
|
+
branches:
|
|
164
|
+
only: main
|
|
165
|
+
- openapi_postprocess:
|
|
95
166
|
filters:
|
|
96
167
|
branches:
|
|
97
168
|
only: main
|
|
98
|
-
|
|
99
|
-
- update_ts_sdk_job:
|
|
100
169
|
requires:
|
|
101
|
-
-
|
|
170
|
+
- update_openapi
|
|
171
|
+
- update_ts_sdk:
|
|
102
172
|
filters:
|
|
103
173
|
branches:
|
|
104
174
|
only: main
|
|
105
|
-
|
|
175
|
+
requires:
|
|
176
|
+
- openapi_postprocess
|
|
177
|
+
|
|
106
178
|
update_npm_package:
|
|
107
179
|
when:
|
|
108
180
|
not: << pipeline.parameters.update_ts_sdk >>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
FILE = "./openapi.json"
|
|
5
|
+
with open(FILE, "r") as f:
|
|
6
|
+
data = json.load(f)
|
|
7
|
+
for path in data["paths"]:
|
|
8
|
+
for method in data["paths"][path]:
|
|
9
|
+
if "api/v1/" in path:
|
|
10
|
+
data["paths"][path][method]["summary"] = path.split("api/v1/")[
|
|
11
|
+
1
|
|
12
|
+
].replace("/", "_")
|
|
13
|
+
data["paths"][path][method]["operationId"] = path.split("api/v1/")[
|
|
14
|
+
1
|
|
15
|
+
].replace("/", "_")
|
|
16
|
+
else:
|
|
17
|
+
data["paths"][path][method]["summary"] = path.split("/")[-1]
|
|
18
|
+
data["paths"][path][method]["operationId"] = path.split("/")[-1]
|
|
19
|
+
|
|
20
|
+
if data["paths"][path][method]["summary"] == "":
|
|
21
|
+
data["paths"][path][method]["summary"] = "status"
|
|
22
|
+
data["paths"][path][method]["operationId"] = "status"
|
|
23
|
+
|
|
24
|
+
for path in data["definitions"]:
|
|
25
|
+
if not path.startswith("Req"):
|
|
26
|
+
required_fields = list(data["definitions"][path]["properties"].keys())
|
|
27
|
+
if "message" in required_fields:
|
|
28
|
+
required_fields.remove("message")
|
|
29
|
+
|
|
30
|
+
if "next" in required_fields:
|
|
31
|
+
required_fields.remove("next")
|
|
32
|
+
|
|
33
|
+
if "next_cursor" in required_fields:
|
|
34
|
+
required_fields.remove("next_cursor")
|
|
35
|
+
|
|
36
|
+
if len(required_fields) > 0:
|
|
37
|
+
data["definitions"][path]["required"] = required_fields
|
|
38
|
+
else:
|
|
39
|
+
data["definitions"][path].pop("required", None)
|
|
40
|
+
|
|
41
|
+
with open(FILE, "w") as f:
|
|
42
|
+
json.dump(data, f, indent=2)
|
|
@@ -52,7 +52,8 @@ export interface DepositHistoryItem {
|
|
|
52
52
|
export const DepositHistoryItemStatusEnum = {
|
|
53
53
|
Failed: 'failed',
|
|
54
54
|
Pending: 'pending',
|
|
55
|
-
Completed: 'completed'
|
|
55
|
+
Completed: 'completed',
|
|
56
|
+
Claimable: 'claimable'
|
|
56
57
|
} as const;
|
|
57
58
|
export type DepositHistoryItemStatusEnum = typeof DepositHistoryItemStatusEnum[keyof typeof DepositHistoryItemStatusEnum];
|
|
58
59
|
|
package/openapi.json
CHANGED