• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nktkas / hyperliquid / 19514753888

19 Nov 2025 08:02PM UTC coverage: 94.811% (+0.1%) from 94.685%
19514753888

push

github

nktkas
ci: remove environment for test job

364 of 583 branches covered (62.44%)

Branch coverage included in aggregate %.

12208 of 12677 relevant lines covered (96.3%)

964.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/src/api/exchange/setDisplayName.ts
1
import * as v from "valibot";
357✔
2

3
// ============================================================
4
// API Schemas
5
// ============================================================
6

7
import { UnsignedInteger } from "../_base.ts";
357✔
8
import { ErrorResponse, Signature, SuccessResponse } from "./_base/mod.ts";
357✔
9

10
/** Set the display name in the leaderboard. */
11
export const SetDisplayNameRequest = /* @__PURE__ */ (() => {
357✔
12
  return v.pipe(
605✔
13
    v.object({
605✔
14
      /** Action to perform. */
15
      action: v.pipe(
605✔
16
        v.object({
605✔
17
          /** Type of action. */
18
          type: v.pipe(
605✔
19
            v.literal("setDisplayName"),
605✔
20
            v.description("Type of action."),
605✔
21
          ),
22
          /**
23
           * Display name.
24
           *
25
           * Set to an empty string to remove the display name.
26
           */
27
          displayName: v.pipe(
605✔
28
            v.string(),
605✔
29
            v.description(
605✔
30
              "Display name." +
605✔
31
                "\n\nSet to an empty string to remove the display name.",
605✔
32
            ),
33
          ),
34
        }),
605✔
35
        v.description("Action to perform."),
605✔
36
      ),
37
      /** Unique request identifier (current timestamp in ms). */
38
      nonce: v.pipe(
605✔
39
        UnsignedInteger,
605✔
40
        v.description("Unique request identifier (current timestamp in ms)."),
605✔
41
      ),
42
      /** Cryptographic signature. */
43
      signature: v.pipe(
605✔
44
        Signature,
605✔
45
        v.description("Cryptographic signature."),
605✔
46
      ),
47
      /** Expiration time of the action. */
48
      expiresAfter: v.pipe(
605✔
49
        v.optional(UnsignedInteger),
605✔
50
        v.description("Expiration time of the action."),
605✔
51
      ),
52
    }),
605✔
53
    v.description("Set the display name in the leaderboard."),
605✔
54
  );
55
})();
357✔
56
export type SetDisplayNameRequest = v.InferOutput<typeof SetDisplayNameRequest>;
57

58
/** Successful response without specific data or error response. */
59
export const SetDisplayNameResponse = /* @__PURE__ */ (() => {
357✔
60
  return v.pipe(
605✔
61
    v.union([SuccessResponse, ErrorResponse]),
2,420✔
62
    v.description("Successful response without specific data or error response."),
605✔
63
  );
64
})();
357✔
65
export type SetDisplayNameResponse = v.InferOutput<typeof SetDisplayNameResponse>;
66

67
// ============================================================
68
// Execution Logic
69
// ============================================================
70

71
import { type DeepImmutable, parser } from "../_base.ts";
357✔
72
import {
357✔
73
  type ExchangeRequestConfig,
74
  type ExcludeErrorResponse,
75
  executeL1Action,
357✔
76
  type ExtractRequestAction,
77
  type ExtractRequestOptions,
78
  type MultiSignRequestConfig,
79
} from "./_base/mod.ts";
357✔
80

81
/** Action parameters for the {@linkcode setDisplayName} function. */
82
export type SetDisplayNameParameters = ExtractRequestAction<v.InferInput<typeof SetDisplayNameRequest>>;
83

84
/** Request options for the {@linkcode setDisplayName} function. */
85
export type SetDisplayNameOptions = ExtractRequestOptions<v.InferInput<typeof SetDisplayNameRequest>>;
86

87
/** Successful variant of {@linkcode SetDisplayNameResponse} without errors. */
88
export type SetDisplayNameSuccessResponse = ExcludeErrorResponse<SetDisplayNameResponse>;
89

90
/**
91
 * Set the display name in the leaderboard.
92
 * @param config - General configuration for Exchange API requests.
93
 * @param params - Parameters specific to the API request.
94
 * @param opts - Request execution options.
95
 * @returns Successful response without specific data.
96
 *
97
 * @throws {ApiRequestError} When the API returns an unsuccessful response.
98
 * @throws {TransportError} When the transport layer throws an error.
99
 *
100
 * @example
101
 * ```ts
102
 * import { HttpTransport } from "@nktkas/hyperliquid";
103
 * import { setDisplayName } from "@nktkas/hyperliquid/api/exchange";
104
 * import { privateKeyToAccount } from "viem/accounts";
105
 *
106
 * const wallet = privateKeyToAccount("0x..."); // viem or ethers
107
 * const transport = new HttpTransport(); // or `WebSocketTransport`
108
 *
109
 * await setDisplayName(
110
 *   { transport, wallet },
111
 *   { displayName: "..." },
112
 * );
113
 * ```
114
 */
115
export async function setDisplayName(
357✔
116
  config: ExchangeRequestConfig | MultiSignRequestConfig,
357✔
117
  params: DeepImmutable<SetDisplayNameParameters>,
357✔
118
  opts?: SetDisplayNameOptions,
357✔
119
): Promise<SetDisplayNameSuccessResponse> {
120
  const request = parser(SetDisplayNameRequest)({
360✔
121
    action: {
360✔
122
      type: "setDisplayName",
360✔
123
      ...params,
360✔
124
    },
360✔
125
    nonce: 0, // Placeholder; actual nonce generated in `executeL1Action`
360✔
126
    signature: { // Placeholder; actual signature generated in `executeL1Action`
360✔
127
      r: "0x0000000000000000000000000000000000000000000000000000000000000000",
360✔
128
      s: "0x0000000000000000000000000000000000000000000000000000000000000000",
360✔
129
      v: 27,
360✔
130
    },
360✔
131
    expiresAfter: typeof config.defaultExpiresAfter === "number"
×
132
      ? config.defaultExpiresAfter
×
133
      : await config.defaultExpiresAfter?.(),
×
134
  });
360✔
135
  return await executeL1Action(config, request, opts?.signal);
×
136
}
360✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc