zklighter-perps 1.0.85 → 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.
@@ -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
 
@@ -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
- - load_openapi:
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
- - load_openapi
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)
@@ -31,6 +31,18 @@ export interface AccountTradeStats {
31
31
  * @memberof AccountTradeStats
32
32
  */
33
33
  total_volume: number;
34
+ /**
35
+ *
36
+ * @type {number}
37
+ * @memberof AccountTradeStats
38
+ */
39
+ daily_trades_count: number;
40
+ /**
41
+ *
42
+ * @type {number}
43
+ * @memberof AccountTradeStats
44
+ */
45
+ daily_volume: number;
34
46
  }
35
47
 
36
48
  /**
@@ -39,6 +51,8 @@ export interface AccountTradeStats {
39
51
  export function instanceOfAccountTradeStats(value: object): value is AccountTradeStats {
40
52
  if (!('total_trades_count' in value) || value['total_trades_count'] === undefined) return false;
41
53
  if (!('total_volume' in value) || value['total_volume'] === undefined) return false;
54
+ if (!('daily_trades_count' in value) || value['daily_trades_count'] === undefined) return false;
55
+ if (!('daily_volume' in value) || value['daily_volume'] === undefined) return false;
42
56
  return true;
43
57
  }
44
58
 
@@ -54,6 +68,8 @@ export function AccountTradeStatsFromJSONTyped(json: any, ignoreDiscriminator: b
54
68
 
55
69
  'total_trades_count': json['total_trades_count'],
56
70
  'total_volume': json['total_volume'],
71
+ 'daily_trades_count': json['daily_trades_count'],
72
+ 'daily_volume': json['daily_volume'],
57
73
  };
58
74
  }
59
75
 
@@ -65,6 +81,8 @@ export function AccountTradeStatsToJSON(value?: AccountTradeStats | null): any {
65
81
 
66
82
  'total_trades_count': value['total_trades_count'],
67
83
  'total_volume': value['total_volume'],
84
+ 'daily_trades_count': value['daily_trades_count'],
85
+ 'daily_volume': value['daily_volume'],
68
86
  };
69
87
  }
70
88
 
@@ -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
@@ -2466,12 +2466,24 @@
2466
2466
  "type": "number",
2467
2467
  "format": "double",
2468
2468
  "example": "235.25"
2469
+ },
2470
+ "daily_trades_count": {
2471
+ "type": "integer",
2472
+ "format": "int64",
2473
+ "example": "68"
2474
+ },
2475
+ "daily_volume": {
2476
+ "type": "number",
2477
+ "format": "double",
2478
+ "example": "235.25"
2469
2479
  }
2470
2480
  },
2471
2481
  "title": "AccountTradeStats",
2472
2482
  "required": [
2473
2483
  "total_trades_count",
2474
- "total_volume"
2484
+ "total_volume",
2485
+ "daily_trades_count",
2486
+ "daily_volume"
2475
2487
  ]
2476
2488
  },
2477
2489
  "Accounts": {
@@ -2960,7 +2972,8 @@
2960
2972
  "enum": [
2961
2973
  "failed",
2962
2974
  "pending",
2963
- "completed"
2975
+ "completed",
2976
+ "claimable"
2964
2977
  ]
2965
2978
  }
2966
2979
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zklighter-perps",
3
- "version": "1.0.85",
3
+ "version": "1.0.87",
4
4
  "description": "zkLighter Perps SDK",
5
5
  "main": "index.ts",
6
6
  "directories": {