zklighter-perps 1.0.86 → 1.0.88

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.
@@ -1,29 +1,88 @@
1
1
  version: 2.1
2
2
 
3
3
  jobs:
4
- load_openapi:
4
+ update_openapi:
5
5
  docker:
6
- - image: cimg/base:2024.07
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: Clone Python SDK
34
+ name: openapi.json Post Process
13
35
  command: |
14
- git clone https://${GITHUB_TOKEN}@github.com/elliottech/zklighter-perps-python.git
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-python
49
+ root: ~/project/zklighter-perps/service/apiserver
18
50
  paths:
19
51
  - openapi.json
20
52
 
21
- update_ts_sdk_job:
53
+ openapi_postprocess:
22
54
  docker:
23
- - image: cimg/openjdk:21.0.2
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
 
@@ -44,10 +103,17 @@ jobs:
44
103
  name: Generate TS client using OpenAPI Generator
45
104
  command: |
46
105
  java -jar openapi-generator-cli.jar generate -i ./openapi.json -g typescript-fetch -o . -c config.yaml
106
+ - run:
107
+ name: git status
108
+ command: |
109
+ if git status | grep -q "nothing to commit"; then
110
+ exit 1;
111
+ fi
47
112
  - run:
48
113
  name: Increase package version
49
114
  command: |
50
115
  jq '.version |= (split(".") | .[2] = ((.[2] | tonumber) + 1 | tostring) | join("."))' package.json > tmp.json && mv tmp.json package.json
116
+
51
117
  - run:
52
118
  name: push to new branch
53
119
  command: |
@@ -71,7 +137,11 @@ jobs:
71
137
 
72
138
  steps:
73
139
  - checkout
74
-
140
+ - run:
141
+ name: Remove binaries
142
+ command: |
143
+ rm -rf goctl-swagger-amd
144
+ rm -rf openapi-generator-cli.jar
75
145
  - run:
76
146
  name: Publish npm package
77
147
  command: |
@@ -91,18 +161,23 @@ workflows:
91
161
  update_ts_sdk:
92
162
  when: << pipeline.parameters.update_ts_sdk >>
93
163
  jobs:
94
- - load_openapi:
164
+ - update_openapi:
165
+ filters:
166
+ branches:
167
+ only: main
168
+ - openapi_postprocess:
95
169
  filters:
96
170
  branches:
97
171
  only: main
98
-
99
- - update_ts_sdk_job:
100
172
  requires:
101
- - load_openapi
173
+ - update_openapi
174
+ - update_ts_sdk:
102
175
  filters:
103
176
  branches:
104
177
  only: main
105
-
178
+ requires:
179
+ - openapi_postprocess
180
+
106
181
  update_npm_package:
107
182
  when:
108
183
  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
@@ -2972,7 +2972,8 @@
2972
2972
  "enum": [
2973
2973
  "failed",
2974
2974
  "pending",
2975
- "completed"
2975
+ "completed",
2976
+ "claimable"
2976
2977
  ]
2977
2978
  }
2978
2979
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zklighter-perps",
3
- "version": "1.0.86",
3
+ "version": "1.0.88",
4
4
  "description": "zkLighter Perps SDK",
5
5
  "main": "index.ts",
6
6
  "directories": {
Binary file