• 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

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

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

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

10
/** Modify a sub-account's. */
11
export const SubAccountModifyRequest = /* @__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("subAccountModify"),
605✔
20
            v.description("Type of action."),
605✔
21
          ),
22
          /** Sub-account address to modify. */
23
          subAccountUser: v.pipe(
605✔
24
            Address,
605✔
25
            v.description("Sub-account address to modify."),
605✔
26
          ),
27
          /** New sub-account name. */
28
          name: v.pipe(
605✔
29
            v.string(),
605✔
30
            v.minLength(1),
605✔
31
            v.description("New sub-account name."),
605✔
32
          ),
33
        }),
605✔
34
        v.description("Action to perform."),
605✔
35
      ),
36
      /** Unique request identifier (current timestamp in ms). */
37
      nonce: v.pipe(
605✔
38
        UnsignedInteger,
605✔
39
        v.description("Unique request identifier (current timestamp in ms)."),
605✔
40
      ),
41
      /** Cryptographic signature. */
42
      signature: v.pipe(
605✔
43
        Signature,
605✔
44
        v.description("Cryptographic signature."),
605✔
45
      ),
46
      /** Expiration time of the action. */
47
      expiresAfter: v.pipe(
605✔
48
        v.optional(UnsignedInteger),
605✔
49
        v.description("Expiration time of the action."),
605✔
50
      ),
51
    }),
605✔
52
    v.description("Modify a sub-account."),
605✔
53
  );
54
})();
357✔
55
export type SubAccountModifyRequest = v.InferOutput<typeof SubAccountModifyRequest>;
56

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

66
// ============================================================
67
// Execution Logic
68
// ============================================================
69

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

80
/** Action parameters for the {@linkcode subAccountModify} function. */
81
export type SubAccountModifyParameters = ExtractRequestAction<v.InferInput<typeof SubAccountModifyRequest>>;
82

83
/** Request options for the {@linkcode subAccountModify} function. */
84
export type SubAccountModifyOptions = ExtractRequestOptions<v.InferInput<typeof SubAccountModifyRequest>>;
85

86
/** Successful variant of {@linkcode SubAccountModifyResponse} without errors. */
87
export type SubAccountModifySuccessResponse = ExcludeErrorResponse<SubAccountModifyResponse>;
88

89
/**
90
 * Modify a sub-account's.
91
 * @param config - General configuration for Exchange API requests.
92
 * @param params - Parameters specific to the API request.
93
 * @param opts - Request execution options.
94
 * @returns Successful response without specific data.
95
 *
96
 * @throws {ApiRequestError} When the API returns an unsuccessful response.
97
 * @throws {TransportError} When the transport layer throws an error.
98
 *
99
 * @example
100
 * ```ts
101
 * import { HttpTransport } from "@nktkas/hyperliquid";
102
 * import { subAccountModify } from "@nktkas/hyperliquid/api/exchange";
103
 * import { privateKeyToAccount } from "viem/accounts";
104
 *
105
 * const wallet = privateKeyToAccount("0x..."); // viem or ethers
106
 * const transport = new HttpTransport(); // or `WebSocketTransport`
107
 *
108
 * await subAccountModify(
109
 *   { transport, wallet },
110
 *   { subAccountUser: "0x...", name: "..."  },
111
 * );
112
 * ```
113
 */
114
export async function subAccountModify(
357✔
115
  config: ExchangeRequestConfig | MultiSignRequestConfig,
357✔
116
  params: DeepImmutable<SubAccountModifyParameters>,
357✔
117
  opts?: SubAccountModifyOptions,
357✔
118
): Promise<SubAccountModifySuccessResponse> {
119
  const request = parser(SubAccountModifyRequest)({
360✔
120
    action: {
360✔
121
      type: "subAccountModify",
360✔
122
      ...params,
360✔
123
    },
360✔
124
    nonce: 0, // Placeholder; actual nonce generated in `executeL1Action`
360✔
125
    signature: { // Placeholder; actual signature generated in `executeL1Action`
360✔
126
      r: "0x0000000000000000000000000000000000000000000000000000000000000000",
360✔
127
      s: "0x0000000000000000000000000000000000000000000000000000000000000000",
360✔
128
      v: 27,
360✔
129
    },
360✔
130
    expiresAfter: typeof config.defaultExpiresAfter === "number"
×
131
      ? config.defaultExpiresAfter
×
132
      : await config.defaultExpiresAfter?.(),
×
133
  });
360✔
134
  return await executeL1Action(config, request, opts?.signal);
×
135
}
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