zklighter-perps 1.0.285 → 1.0.287

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.
@@ -156,11 +156,80 @@ jobs:
156
156
  - run:
157
157
  name: Publish npm package
158
158
  command: |
159
+ VERSION=$(jq -r .version package.json)
160
+ if npm view "zklighter-perps@${VERSION}" version > /dev/null 2>&1; then
161
+ echo "zklighter-perps@${VERSION} is already published; skipping"
162
+ exit 0
163
+ fi
159
164
  git config --global user.email "hasan@lighter.xyz"
160
165
  git config --global user.name "CircleCI Hasan"
161
166
  npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
162
167
  npm publish
163
168
 
169
+ publish_prerelease:
170
+ docker:
171
+ - image: cimg/node:22.4.1
172
+
173
+ steps:
174
+ - checkout
175
+ - run:
176
+ name: Find open PR for branch
177
+ command: |
178
+ PR_NUMBER=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" \
179
+ "https://api.github.com/repos/elliottech/zklighter-perps-ts/pulls?head=elliottech:${CIRCLE_BRANCH}&state=open" \
180
+ | jq -r '.[0].number // empty')
181
+ if [ -z "$PR_NUMBER" ]; then
182
+ echo "No open PR for branch ${CIRCLE_BRANCH}; skipping prerelease publish"
183
+ circleci-agent step halt
184
+ else
185
+ echo "Found PR #${PR_NUMBER}"
186
+ echo "export PR_NUMBER=${PR_NUMBER}" >> "$BASH_ENV"
187
+ fi
188
+ - run:
189
+ name: Generate prerelease version
190
+ command: |
191
+ CLEAN_BRANCH_NAME=$(echo "$CIRCLE_BRANCH" | sed 's/[^a-zA-Z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-\|-$//g')
192
+ CLEAN_ACTOR=$(echo "${CIRCLE_USERNAME:-circleci}" | sed 's/[^a-zA-Z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-\|-$//g')
193
+ COMMIT_SHA=$(echo "$CIRCLE_SHA1" | cut -c1-7)
194
+
195
+ # Semver-compatible version: 0.PR_NUMBER.0-ACTOR.COMMIT_SHA.BRANCH_NAME
196
+ # Always < 1.0.0 so it can never shadow a real release.
197
+ PRERELEASE_VERSION="0.${PR_NUMBER}.0-${CLEAN_ACTOR}.${COMMIT_SHA}.${CLEAN_BRANCH_NAME}"
198
+ echo "Prerelease version: $PRERELEASE_VERSION"
199
+
200
+ echo "export CLEAN_BRANCH_NAME=${CLEAN_BRANCH_NAME}" >> "$BASH_ENV"
201
+ echo "export PRERELEASE_VERSION=${PRERELEASE_VERSION}" >> "$BASH_ENV"
202
+ - run:
203
+ name: Remove binaries
204
+ command: |
205
+ rm -rf goctl-swagger-amd
206
+ rm -rf openapi-generator-cli.jar
207
+ - run:
208
+ name: Publish prerelease npm package
209
+ command: |
210
+ jq --arg v "$PRERELEASE_VERSION" '.version = $v' package.json > tmp.json && mv tmp.json package.json
211
+ npm set //registry.npmjs.org/:_authToken=$NPM_TOKEN
212
+ npm publish --tag "$CLEAN_BRANCH_NAME"
213
+ - run:
214
+ name: Comment on PR
215
+ command: |
216
+ COMMENT_BODY=$(jq -n --arg version "$PRERELEASE_VERSION" --arg tag "$CLEAN_BRANCH_NAME" \
217
+ '{body: ("## 🚀 Prerelease Published\n\n**Version:** `" + $version + "`\n**Tag:** `" + $tag + "`\n\n### Update package.json:\n```json\n\"zklighter-perps\": \"" + $version + "\"\n```")}')
218
+
219
+ EXISTING_COMMENT_ID=$(curl -s -H "Authorization: Bearer ${GITHUB_TOKEN}" \
220
+ "https://api.github.com/repos/elliottech/zklighter-perps-ts/issues/${PR_NUMBER}/comments?per_page=100" \
221
+ | jq -r '[.[] | select(.body | contains("🚀 Prerelease Published"))][0].id // empty')
222
+
223
+ if [ -n "$EXISTING_COMMENT_ID" ]; then
224
+ curl -s -X PATCH -H "Authorization: Bearer ${GITHUB_TOKEN}" \
225
+ -d "$COMMENT_BODY" \
226
+ "https://api.github.com/repos/elliottech/zklighter-perps-ts/issues/comments/${EXISTING_COMMENT_ID}" > /dev/null
227
+ else
228
+ curl -s -X POST -H "Authorization: Bearer ${GITHUB_TOKEN}" \
229
+ -d "$COMMENT_BODY" \
230
+ "https://api.github.com/repos/elliottech/zklighter-perps-ts/issues/${PR_NUMBER}/comments" > /dev/null
231
+ fi
232
+
164
233
  parameters:
165
234
  update_ts_sdk:
166
235
  default: false
@@ -205,4 +274,13 @@ workflows:
205
274
  only: main
206
275
  requires:
207
276
  - typecheck
277
+ # Publishes a PR prerelease (version 0.PR.0-actor.sha.branch, dist-tag =
278
+ # branch name) and posts/updates a PR comment with the version to use,
279
+ # mirroring the prerelease flow in zklighter-react-store.
280
+ - publish_prerelease:
281
+ filters:
282
+ branches:
283
+ ignore: main
284
+ requires:
285
+ - typecheck
208
286
 
package/README.md CHANGED
@@ -29,7 +29,13 @@ The `update_npm_package` workflow runs on `main`:
29
29
  [`tsconfig.json`](tsconfig.json)). Runs on every branch, including the
30
30
  timestamped branches opened by `update_ts_sdk`, so a regenerated SDK that
31
31
  would fail to compile in a consumer (e.g. `perps-fe`) is caught on its PR.
32
- - **`update_npm_package`** — publishes to npm (requires `typecheck` to pass).
32
+ - **`update_npm_package`** — publishes to npm (requires `typecheck` to pass;
33
+ `main` only).
34
+ - **`publish_prerelease`** — on non-`main` branches with an open PR, publishes
35
+ a prerelease version (`0.<PR>.0-<actor>.<sha>.<branch>`, npm dist-tag =
36
+ branch name) and posts/updates a PR comment with the exact version to drop
37
+ into a consumer's `package.json`, mirroring the prerelease flow in
38
+ `zklighter-react-store`.
33
39
 
34
40
  ## OpenAPI post-processing
35
41
 
@@ -0,0 +1,86 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ *
5
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
+ *
7
+ * The version of the OpenAPI document:
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ import * as runtime from '../runtime';
17
+ import type {
18
+ LivePointsTotal,
19
+ ResultCode,
20
+ } from '../models/index';
21
+ import {
22
+ LivePointsTotalFromJSON,
23
+ LivePointsTotalToJSON,
24
+ ResultCodeFromJSON,
25
+ ResultCodeToJSON,
26
+ } from '../models/index';
27
+
28
+ export interface LivePointsTotalRequest {
29
+ account_index: number;
30
+ authorization?: string;
31
+ auth?: string;
32
+ }
33
+
34
+ /**
35
+ *
36
+ */
37
+ export class LivepointsApi extends runtime.BaseAPI {
38
+
39
+ /**
40
+ * Get RH live points total for an account
41
+ * livePoints_total
42
+ */
43
+ async livePointsTotalRaw(requestParameters: LivePointsTotalRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<LivePointsTotal>> {
44
+ if (requestParameters['account_index'] == null) {
45
+ throw new runtime.RequiredError(
46
+ 'account_index',
47
+ 'Required parameter "account_index" was null or undefined when calling livePointsTotal().'
48
+ );
49
+ }
50
+
51
+ const queryParameters: any = {};
52
+
53
+ if (requestParameters['authorization'] != null) {
54
+ queryParameters['authorization'] = requestParameters['authorization'];
55
+ }
56
+
57
+ if (requestParameters['auth'] != null) {
58
+ queryParameters['auth'] = requestParameters['auth'];
59
+ }
60
+
61
+ if (requestParameters['account_index'] != null) {
62
+ queryParameters['account_index'] = requestParameters['account_index'];
63
+ }
64
+
65
+ const headerParameters: runtime.HTTPHeaders = {};
66
+
67
+ const response = await this.request({
68
+ path: `/api/v1/livePoints/total`,
69
+ method: 'GET',
70
+ headers: headerParameters,
71
+ query: queryParameters,
72
+ }, initOverrides);
73
+
74
+ return new runtime.JSONApiResponse(response, (jsonValue) => LivePointsTotalFromJSON(jsonValue));
75
+ }
76
+
77
+ /**
78
+ * Get RH live points total for an account
79
+ * livePoints_total
80
+ */
81
+ async livePointsTotal(requestParameters: LivePointsTotalRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<LivePointsTotal> {
82
+ const response = await this.livePointsTotalRaw(requestParameters, initOverrides);
83
+ return await response.value();
84
+ }
85
+
86
+ }
@@ -0,0 +1,78 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ *
5
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
+ *
7
+ * The version of the OpenAPI document:
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ import { mapValues } from '../runtime';
16
+ /**
17
+ *
18
+ * @export
19
+ * @interface LivePointsTotal
20
+ */
21
+ export interface LivePointsTotal {
22
+ /**
23
+ *
24
+ * @type {number}
25
+ * @memberof LivePointsTotal
26
+ */
27
+ code: number;
28
+ /**
29
+ *
30
+ * @type {string}
31
+ * @memberof LivePointsTotal
32
+ */
33
+ message?: string;
34
+ /**
35
+ *
36
+ * @type {number}
37
+ * @memberof LivePointsTotal
38
+ */
39
+ total_live_points: number;
40
+ }
41
+
42
+ /**
43
+ * Check if a given object implements the LivePointsTotal interface.
44
+ */
45
+ export function instanceOfLivePointsTotal(value: object): value is LivePointsTotal {
46
+ if (!('code' in value) || value['code'] === undefined) return false;
47
+ if (!('total_live_points' in value) || value['total_live_points'] === undefined) return false;
48
+ return true;
49
+ }
50
+
51
+ export function LivePointsTotalFromJSON(json: any): LivePointsTotal {
52
+ return LivePointsTotalFromJSONTyped(json, false);
53
+ }
54
+
55
+ export function LivePointsTotalFromJSONTyped(json: any, ignoreDiscriminator: boolean): LivePointsTotal {
56
+ if (json == null) {
57
+ return json;
58
+ }
59
+ return {
60
+
61
+ 'code': json['code'],
62
+ 'message': json['message'] == null ? undefined : json['message'],
63
+ 'total_live_points': json['total_live_points'],
64
+ };
65
+ }
66
+
67
+ export function LivePointsTotalToJSON(value?: LivePointsTotal | null): any {
68
+ if (value == null) {
69
+ return value;
70
+ }
71
+ return {
72
+
73
+ 'code': value['code'],
74
+ 'message': value['message'],
75
+ 'total_live_points': value['total_live_points'],
76
+ };
77
+ }
78
+
@@ -0,0 +1,69 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ *
5
+ * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
6
+ *
7
+ * The version of the OpenAPI document:
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+ import { mapValues } from '../runtime';
16
+ /**
17
+ *
18
+ * @export
19
+ * @interface ReqGetLivePointsTotal
20
+ */
21
+ export interface ReqGetLivePointsTotal {
22
+ /**
23
+ * made optional to support header auth clients
24
+ * @type {string}
25
+ * @memberof ReqGetLivePointsTotal
26
+ */
27
+ auth?: string;
28
+ /**
29
+ *
30
+ * @type {number}
31
+ * @memberof ReqGetLivePointsTotal
32
+ */
33
+ account_index: number;
34
+ }
35
+
36
+ /**
37
+ * Check if a given object implements the ReqGetLivePointsTotal interface.
38
+ */
39
+ export function instanceOfReqGetLivePointsTotal(value: object): value is ReqGetLivePointsTotal {
40
+ if (!('account_index' in value) || value['account_index'] === undefined) return false;
41
+ return true;
42
+ }
43
+
44
+ export function ReqGetLivePointsTotalFromJSON(json: any): ReqGetLivePointsTotal {
45
+ return ReqGetLivePointsTotalFromJSONTyped(json, false);
46
+ }
47
+
48
+ export function ReqGetLivePointsTotalFromJSONTyped(json: any, ignoreDiscriminator: boolean): ReqGetLivePointsTotal {
49
+ if (json == null) {
50
+ return json;
51
+ }
52
+ return {
53
+
54
+ 'auth': json['auth'] == null ? undefined : json['auth'],
55
+ 'account_index': json['account_index'],
56
+ };
57
+ }
58
+
59
+ export function ReqGetLivePointsTotalToJSON(value?: ReqGetLivePointsTotal | null): any {
60
+ if (value == null) {
61
+ return value;
62
+ }
63
+ return {
64
+
65
+ 'auth': value['auth'],
66
+ 'account_index': value['account_index'],
67
+ };
68
+ }
69
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zklighter-perps",
3
- "version": "1.0.285",
3
+ "version": "1.0.287",
4
4
  "description": "Lighter Perps SDK",
5
5
  "main": "index.ts",
6
6
  "directories": {