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

nktkas / hyperliquid / 19405103680

16 Nov 2025 11:46AM UTC coverage: 94.726% (-0.6%) from 95.329%
19405103680

push

github

nktkas
test(info): adapt command execution for Deno and Node.js environments

368 of 581 branches covered (63.34%)

Branch coverage included in aggregate %.

11667 of 12124 relevant lines covered (96.23%)

951.31 hits per line

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

88.52
/src/api/exchange/subAccountModify.ts
1
import * as v from "valibot";
353✔
2
import { Address, type DeepImmutable, parser, UnsignedInteger } from "../_base.ts";
353✔
3
import {
353✔
4
  type ExchangeRequestConfig,
5
  executeL1Action,
353✔
6
  type ExtractRequestAction,
7
  type ExtractRequestOptions,
8
  type MultiSignRequestConfig,
9
  Signature,
353✔
10
} from "./_base/mod.ts";
353✔
11

12
// -------------------- Schemas --------------------
13

14
/**
15
 * Modify a sub-account's.
16
 * @see null
17
 */
18
export const SubAccountModifyRequest = /* @__PURE__ */ (() => {
353✔
19
  return v.pipe(
598✔
20
    v.object({
598✔
21
      /** Action to perform. */
22
      action: v.pipe(
598✔
23
        v.object({
598✔
24
          /** Type of action. */
25
          type: v.pipe(
598✔
26
            v.literal("subAccountModify"),
598✔
27
            v.description("Type of action."),
598✔
28
          ),
29
          /** Sub-account address to modify. */
30
          subAccountUser: v.pipe(
598✔
31
            Address,
598✔
32
            v.description("Sub-account address to modify."),
598✔
33
          ),
34
          /** New sub-account name. */
35
          name: v.pipe(
598✔
36
            v.string(),
598✔
37
            v.minLength(1),
598✔
38
            v.description("New sub-account name."),
598✔
39
          ),
40
        }),
598✔
41
        v.description("Action to perform."),
598✔
42
      ),
43
      /** Unique request identifier (current timestamp in ms). */
44
      nonce: v.pipe(
598✔
45
        UnsignedInteger,
598✔
46
        v.description("Unique request identifier (current timestamp in ms)."),
598✔
47
      ),
48
      /** Cryptographic signature. */
49
      signature: v.pipe(
598✔
50
        Signature,
598✔
51
        v.description("Cryptographic signature."),
598✔
52
      ),
53
      /** Expiration time of the action. */
54
      expiresAfter: v.pipe(
598✔
55
        v.optional(UnsignedInteger),
598✔
56
        v.description("Expiration time of the action."),
598✔
57
      ),
58
    }),
598✔
59
    v.description("Modify a sub-account."),
598✔
60
  );
61
})();
353✔
62
export type SubAccountModifyRequest = v.InferOutput<typeof SubAccountModifyRequest>;
63

64
import { SuccessResponse } from "./_base/mod.ts";
353✔
65
export { SuccessResponse };
353✔
66

67
// -------------------- Function --------------------
68

69
/** Action parameters for the {@linkcode subAccountModify} function. */
70
export type SubAccountModifyParameters = ExtractRequestAction<v.InferInput<typeof SubAccountModifyRequest>>;
71
/** Request options for the {@linkcode subAccountModify} function. */
72
export type SubAccountModifyOptions = ExtractRequestOptions<v.InferInput<typeof SubAccountModifyRequest>>;
73

74
/**
75
 * Modify a sub-account's.
76
 * @param config - General configuration for Exchange API requests.
77
 * @param params - Parameters specific to the API request.
78
 * @param opts - Request execution options.
79
 * @returns Successful response without specific data.
80
 *
81
 * @throws {ApiRequestError} When the API returns an unsuccessful response.
82
 * @throws {TransportError} When the transport layer throws an error.
83
 *
84
 * @see null
85
 * @example
86
 * ```ts
87
 * import { HttpTransport } from "@nktkas/hyperliquid";
88
 * import { subAccountModify } from "@nktkas/hyperliquid/api/exchange";
89
 * import { privateKeyToAccount } from "npm:viem/accounts";
90
 *
91
 * const wallet = privateKeyToAccount("0x..."); // viem or ethers
92
 * const transport = new HttpTransport(); // or `WebSocketTransport`
93
 *
94
 * await subAccountModify(
95
 *   { transport, wallet },
96
 *   { subAccountUser: "0x...", name: "..."  },
97
 * );
98
 * ```
99
 */
100
export async function subAccountModify(
353✔
101
  config: ExchangeRequestConfig | MultiSignRequestConfig,
353✔
102
  params: DeepImmutable<SubAccountModifyParameters>,
353✔
103
  opts?: SubAccountModifyOptions,
353✔
104
): Promise<SuccessResponse> {
105
  const request = parser(SubAccountModifyRequest)({
356✔
106
    action: {
356✔
107
      type: "subAccountModify",
356✔
108
      ...params,
356✔
109
    },
356✔
110
    nonce: 0, // Placeholder; actual nonce generated in `executeL1Action`
356✔
111
    signature: { // Placeholder; actual signature generated in `executeL1Action`
356✔
112
      r: "0x0000000000000000000000000000000000000000000000000000000000000000",
356✔
113
      s: "0x0000000000000000000000000000000000000000000000000000000000000000",
356✔
114
      v: 27,
356✔
115
    },
356✔
116
    expiresAfter: typeof config.defaultExpiresAfter === "number"
×
117
      ? config.defaultExpiresAfter
×
118
      : await config.defaultExpiresAfter?.(),
×
119
  });
356✔
120
  return await executeL1Action(config, request, opts?.signal);
×
121
}
356✔
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