@0xmonaco/core 1.0.33 → 1.0.34

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.
@@ -33,13 +33,36 @@
33
33
  * console.log(`Rewards remaining: ${result.rewardsBalance}`);
34
34
  * ```
35
35
  */
36
- import type { GetRewardsBalanceResponse, PitpassAPI, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse } from "@0xmonaco/types";
36
+ import type { GetRewardsBalanceResponse, PitpassAPI, TraderCodeAvailabilityResponse, TraderCodeInfoResponse, TraderCodeResponse, TransferRewardsParams, TransferRewardsResponse } from "@0xmonaco/types";
37
37
  import { BaseAPI } from "../base";
38
38
  export declare class PitpassAPIImpl extends BaseAPI implements PitpassAPI {
39
39
  /**
40
- * Return the authenticated caller's TraderCode (their normalized wallet address).
40
+ * Return the authenticated caller's TraderCode.
41
+ *
42
+ * The response carries both the permanent wallet-derived `code` and the
43
+ * custom-handle fields (`customCode`, `isCustom`, `display`).
41
44
  */
42
45
  getMyTraderCode(): Promise<TraderCodeResponse>;
46
+ /**
47
+ * Claim or edit the caller's custom (vanity) TraderCode handle.
48
+ *
49
+ * The handle is validated client-side (letter-first `[A-Za-z0-9_]`, length
50
+ * 5–20) and sent exactly as entered — casing is preserved. The server is the
51
+ * authoritative gate (409 taken, 422 invalid, 429 rate-limited, 403 disabled).
52
+ */
53
+ setTraderCode(code: string): Promise<TraderCodeResponse>;
54
+ /**
55
+ * Clear the caller's custom TraderCode handle, reverting to the wallet-derived
56
+ * default. The freed handle enters a cooldown before it can be reclaimed.
57
+ */
58
+ clearTraderCode(): Promise<TraderCodeResponse>;
59
+ /**
60
+ * Public advisory check of whether a custom TraderCode handle is available.
61
+ *
62
+ * As-you-type UX helper only; the authoritative gate is the atomic claim in
63
+ * {@link setTraderCode}. Returns `available` and, when unavailable, a `reason`.
64
+ */
65
+ checkTraderCodeAvailability(code: string): Promise<TraderCodeAvailabilityResponse>;
43
66
  /**
44
67
  * Public lookup of a TraderCode by wallet address.
45
68
  * Accepts the bare address or the `Monaco - <address>` display form.
@@ -33,15 +33,57 @@
33
33
  * console.log(`Rewards remaining: ${result.rewardsBalance}`);
34
34
  * ```
35
35
  */
36
- import { TransferRewardsParamsSchema, validate } from "@0xmonaco/types";
36
+ import { SetTraderCodeParamsSchema, TransferRewardsParamsSchema, validate } from "@0xmonaco/types";
37
37
  import { BaseAPI } from "../base";
38
38
  export class PitpassAPIImpl extends BaseAPI {
39
39
  /**
40
- * Return the authenticated caller's TraderCode (their normalized wallet address).
40
+ * Return the authenticated caller's TraderCode.
41
+ *
42
+ * The response carries both the permanent wallet-derived `code` and the
43
+ * custom-handle fields (`customCode`, `isCustom`, `display`).
41
44
  */
42
45
  async getMyTraderCode() {
43
46
  return await this.makeAuthenticatedRequest("/api/v1/pitpass/codes/me", { method: "GET" });
44
47
  }
48
+ /**
49
+ * Claim or edit the caller's custom (vanity) TraderCode handle.
50
+ *
51
+ * The handle is validated client-side (letter-first `[A-Za-z0-9_]`, length
52
+ * 5–20) and sent exactly as entered — casing is preserved. The server is the
53
+ * authoritative gate (409 taken, 422 invalid, 429 rate-limited, 403 disabled).
54
+ */
55
+ async setTraderCode(code) {
56
+ const validated = validate(SetTraderCodeParamsSchema, { code });
57
+ return await this.makeAuthenticatedRequest("/api/v1/pitpass/codes/me/custom", {
58
+ method: "PUT",
59
+ body: JSON.stringify({ code: validated.code }),
60
+ });
61
+ }
62
+ /**
63
+ * Clear the caller's custom TraderCode handle, reverting to the wallet-derived
64
+ * default. The freed handle enters a cooldown before it can be reclaimed.
65
+ */
66
+ async clearTraderCode() {
67
+ return await this.makeAuthenticatedRequest("/api/v1/pitpass/codes/me/custom", { method: "DELETE" });
68
+ }
69
+ /**
70
+ * Public advisory check of whether a custom TraderCode handle is available.
71
+ *
72
+ * As-you-type UX helper only; the authoritative gate is the atomic claim in
73
+ * {@link setTraderCode}. Returns `available` and, when unavailable, a `reason`.
74
+ */
75
+ async checkTraderCodeAvailability(code) {
76
+ // Trim to mirror the claim path (setTraderCode validates a trimmed handle),
77
+ // so the advisory check and the eventual claim agree on padded input.
78
+ const query = new URLSearchParams({ code: code.trim() }).toString();
79
+ const raw = await this.makePublicRequest(`/api/v1/pitpass/codes/available?${query}`, {
80
+ method: "GET",
81
+ });
82
+ // The API always serializes `reason`, sending "" (proto3 string default)
83
+ // when the handle is available; surface that as an omitted `reason` so
84
+ // callers can rely on the documented ergonomic shape.
85
+ return { available: raw.available, reason: raw.reason ? raw.reason : undefined };
86
+ }
45
87
  /**
46
88
  * Public lookup of a TraderCode by wallet address.
47
89
  * Accepts the bare address or the `Monaco - <address>` display form.
@@ -34,6 +34,9 @@ export declare const COVERED: {
34
34
  get_my_trader_code: string;
35
35
  get_rewards_balance: string;
36
36
  get_trader_code_info: string;
37
+ set_trader_code: string;
38
+ clear_trader_code: string;
39
+ check_trader_code_availability: string;
37
40
  get_open_interest: string;
38
41
  get_order_by_id: string;
39
42
  get_orderbook_snapshot: string;
package/dist/coverage.js CHANGED
@@ -34,6 +34,9 @@ export const COVERED = {
34
34
  get_my_trader_code: "pitpass.getMyTraderCode",
35
35
  get_rewards_balance: "pitpass.getRewardsBalance",
36
36
  get_trader_code_info: "pitpass.getTraderCodeInfo",
37
+ set_trader_code: "pitpass.setTraderCode",
38
+ clear_trader_code: "pitpass.clearTraderCode",
39
+ check_trader_code_availability: "pitpass.checkTraderCodeAvailability",
37
40
  get_open_interest: "getOpenInterest",
38
41
  get_order_by_id: "getOrder",
39
42
  get_orderbook_snapshot: "getOrderbook",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0xmonaco/core",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,8 +23,8 @@
23
23
  "viem": "^2.45.2"
24
24
  },
25
25
  "dependencies": {
26
- "@0xmonaco/contracts": "1.0.33",
27
- "@0xmonaco/types": "1.0.33",
26
+ "@0xmonaco/contracts": "1.0.34",
27
+ "@0xmonaco/types": "1.0.34",
28
28
  "@noble/curves": "^1.9.1",
29
29
  "@noble/hashes": "^1.8.0",
30
30
  "http-status-codes": "^2.3.0"