@nktkas/hyperliquid 0.22.0 → 0.22.2
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.
- package/README.md +84 -27
- package/esm/mod.d.ts +1 -1
- package/esm/mod.d.ts.map +1 -1
- package/esm/src/clients/exchange.d.ts +136 -166
- package/esm/src/clients/exchange.d.ts.map +1 -1
- package/esm/src/clients/exchange.js +122 -147
- package/esm/src/clients/multiSign.d.ts +129 -282
- package/esm/src/clients/multiSign.d.ts.map +1 -1
- package/esm/src/clients/multiSign.js +125 -246
- package/esm/src/signing/_ethers.d.ts +33 -0
- package/esm/src/signing/_ethers.d.ts.map +1 -0
- package/esm/src/signing/_ethers.js +12 -0
- package/esm/src/signing/_private_key.d.ts +22 -0
- package/esm/src/signing/_private_key.d.ts.map +1 -0
- package/esm/src/signing/_private_key.js +124 -0
- package/esm/src/signing/_sorter.d.ts +154 -0
- package/esm/src/signing/_sorter.d.ts.map +1 -0
- package/esm/src/{signing.js → signing/_sorter.js} +1 -401
- package/esm/src/signing/_viem.d.ts +23 -0
- package/esm/src/signing/_viem.d.ts.map +1 -0
- package/esm/src/signing/_viem.js +6 -0
- package/esm/src/signing/_window.d.ts +23 -0
- package/esm/src/signing/_window.d.ts.map +1 -0
- package/esm/src/signing/_window.js +29 -0
- package/esm/src/signing/mod.d.ts +251 -0
- package/esm/src/signing/mod.d.ts.map +1 -0
- package/esm/src/signing/mod.js +352 -0
- package/esm/src/types/exchange/requests.d.ts +1 -1
- package/esm/src/types/exchange/requests.d.ts.map +1 -1
- package/package.json +6 -5
- package/script/mod.d.ts +1 -1
- package/script/mod.d.ts.map +1 -1
- package/script/src/clients/exchange.d.ts +136 -166
- package/script/src/clients/exchange.d.ts.map +1 -1
- package/script/src/clients/exchange.js +206 -231
- package/script/src/clients/multiSign.d.ts +129 -282
- package/script/src/clients/multiSign.d.ts.map +1 -1
- package/script/src/clients/multiSign.js +170 -291
- package/script/src/signing/_ethers.d.ts +33 -0
- package/script/src/signing/_ethers.d.ts.map +1 -0
- package/script/src/signing/_ethers.js +26 -0
- package/script/src/signing/_private_key.d.ts +22 -0
- package/script/src/signing/_private_key.d.ts.map +1 -0
- package/script/src/signing/_private_key.js +138 -0
- package/script/src/signing/_sorter.d.ts +154 -0
- package/script/src/signing/_sorter.d.ts.map +1 -0
- package/script/src/{signing.js → signing/_sorter.js} +2 -410
- package/script/src/signing/_viem.d.ts +23 -0
- package/script/src/signing/_viem.d.ts.map +1 -0
- package/script/src/signing/_viem.js +19 -0
- package/script/src/signing/_window.d.ts +23 -0
- package/script/src/signing/_window.d.ts.map +1 -0
- package/script/src/signing/_window.js +43 -0
- package/script/src/signing/mod.d.ts +251 -0
- package/script/src/signing/mod.d.ts.map +1 -0
- package/script/src/signing/mod.js +387 -0
- package/script/src/types/exchange/requests.d.ts +1 -1
- package/script/src/types/exchange/requests.d.ts.map +1 -1
- package/esm/src/signing.d.ts +0 -463
- package/esm/src/signing.d.ts.map +0 -1
- package/script/src/signing.d.ts +0 -463
- package/script/src/signing.d.ts.map +0 -1
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { keccak_256 } from "@noble/hashes/sha3";
|
|
2
|
+
import { getPublicKey } from "@noble/secp256k1";
|
|
3
|
+
import { encodeHex } from "../../deps/jsr.io/@std/encoding/1.0.10/hex.js";
|
|
4
|
+
import { actionSorter, isAbstractEthersSigner, isAbstractEthersV5Signer, isAbstractViemWalletClient, isAbstractWindowEthereum, isValidPrivateKey, signL1Action, signUserSignedAction, userSignedActionEip712Types, } from "../signing/mod.js";
|
|
2
5
|
import { ExchangeClient, } from "./exchange.js";
|
|
3
6
|
/**
|
|
4
7
|
* Multi-signature exchange client for interacting with the Hyperliquid API.
|
|
@@ -15,14 +18,11 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
15
18
|
* @example
|
|
16
19
|
* ```ts
|
|
17
20
|
* import * as hl from "@nktkas/hyperliquid";
|
|
18
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
19
21
|
*
|
|
20
22
|
* const multiSignAddress = "0x...";
|
|
21
23
|
* const signers = [
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* privateKeyToAccount("0x..."),
|
|
25
|
-
* ];
|
|
24
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
25
|
+
* ] as const;
|
|
26
26
|
*
|
|
27
27
|
* const transport = new hl.HttpTransport();
|
|
28
28
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
@@ -53,17 +53,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
53
53
|
* @example
|
|
54
54
|
* ```ts
|
|
55
55
|
* import * as hl from "@nktkas/hyperliquid";
|
|
56
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
57
56
|
*
|
|
58
57
|
* const multiSignAddress = "0x...";
|
|
59
58
|
* const signers = [
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* // ...
|
|
63
|
-
* privateKeyToAccount("0x..."),
|
|
64
|
-
* ];
|
|
59
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
60
|
+
* ] as const;
|
|
65
61
|
*
|
|
66
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
62
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
67
63
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
68
64
|
*
|
|
69
65
|
* const data = await multiSignClient.approveAgent({ agentAddress: "0x...", agentName: "agentName" });
|
|
@@ -86,6 +82,8 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
86
82
|
const sortedAction = actionSorter[action.type](action);
|
|
87
83
|
const outerSigner = await this._getWalletAddress(this.signers[0]);
|
|
88
84
|
const signatures = await this._multiSignUserSignedAction(sortedAction, outerSigner);
|
|
85
|
+
if (sortedAction.agentName === "")
|
|
86
|
+
sortedAction.agentName = null;
|
|
89
87
|
// Send a multi-sig action
|
|
90
88
|
return super.multiSig({
|
|
91
89
|
signatures,
|
|
@@ -107,17 +105,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
107
105
|
* @example
|
|
108
106
|
* ```ts
|
|
109
107
|
* import * as hl from "@nktkas/hyperliquid";
|
|
110
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
111
108
|
*
|
|
112
109
|
* const multiSignAddress = "0x...";
|
|
113
110
|
* const signers = [
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* // ...
|
|
117
|
-
* privateKeyToAccount("0x..."),
|
|
118
|
-
* ];
|
|
111
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
112
|
+
* ] as const;
|
|
119
113
|
*
|
|
120
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
114
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
121
115
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
122
116
|
*
|
|
123
117
|
* const data = await multiSignClient.approveBuilderFee({ maxFeeRate: "0.01%", builder: "0x..." });
|
|
@@ -160,17 +154,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
160
154
|
* @example
|
|
161
155
|
* ```ts
|
|
162
156
|
* import * as hl from "@nktkas/hyperliquid";
|
|
163
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
164
157
|
*
|
|
165
158
|
* const multiSignAddress = "0x...";
|
|
166
159
|
* const signers = [
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* // ...
|
|
170
|
-
* privateKeyToAccount("0x..."),
|
|
171
|
-
* ];
|
|
160
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
161
|
+
* ] as const;
|
|
172
162
|
*
|
|
173
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
163
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
174
164
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
175
165
|
*
|
|
176
166
|
* const data = await multiSignClient.batchModify({
|
|
@@ -235,17 +225,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
235
225
|
* @example
|
|
236
226
|
* ```ts
|
|
237
227
|
* import * as hl from "@nktkas/hyperliquid";
|
|
238
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
239
228
|
*
|
|
240
229
|
* const multiSignAddress = "0x...";
|
|
241
230
|
* const signers = [
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
* // ...
|
|
245
|
-
* privateKeyToAccount("0x..."),
|
|
246
|
-
* ];
|
|
231
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
232
|
+
* ] as const;
|
|
247
233
|
*
|
|
248
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
234
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
249
235
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
250
236
|
*
|
|
251
237
|
* const data = await multiSignClient.cancel({
|
|
@@ -298,17 +284,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
298
284
|
* @example
|
|
299
285
|
* ```ts
|
|
300
286
|
* import * as hl from "@nktkas/hyperliquid";
|
|
301
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
302
287
|
*
|
|
303
288
|
* const multiSignAddress = "0x...";
|
|
304
289
|
* const signers = [
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
* // ...
|
|
308
|
-
* privateKeyToAccount("0x..."),
|
|
309
|
-
* ];
|
|
290
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
291
|
+
* ] as const;
|
|
310
292
|
*
|
|
311
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
293
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
312
294
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
313
295
|
*
|
|
314
296
|
* const data = await multiSignClient.cancelByCloid({
|
|
@@ -360,17 +342,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
360
342
|
* @example
|
|
361
343
|
* ```ts
|
|
362
344
|
* import * as hl from "@nktkas/hyperliquid";
|
|
363
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
364
345
|
*
|
|
365
346
|
* const multiSignAddress = "0x...";
|
|
366
347
|
* const signers = [
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
* // ...
|
|
370
|
-
* privateKeyToAccount("0x..."),
|
|
371
|
-
* ];
|
|
348
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
349
|
+
* ] as const;
|
|
372
350
|
*
|
|
373
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
351
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
374
352
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
375
353
|
*
|
|
376
354
|
* const data = await multiSignClient.cDeposit({ wei: 1 * 1e8 });
|
|
@@ -413,17 +391,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
413
391
|
* @example
|
|
414
392
|
* ```ts
|
|
415
393
|
* import * as hl from "@nktkas/hyperliquid";
|
|
416
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
417
394
|
*
|
|
418
395
|
* const multiSignAddress = "0x...";
|
|
419
396
|
* const signers = [
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
* // ...
|
|
423
|
-
* privateKeyToAccount("0x..."),
|
|
424
|
-
* ];
|
|
397
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
398
|
+
* ] as const;
|
|
425
399
|
*
|
|
426
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
400
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
427
401
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
428
402
|
*
|
|
429
403
|
* const data = await multiSignClient.claimRewards();
|
|
@@ -460,17 +434,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
460
434
|
* @example
|
|
461
435
|
* ```ts
|
|
462
436
|
* import * as hl from "@nktkas/hyperliquid";
|
|
463
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
464
437
|
*
|
|
465
438
|
* const multiSignAddress = "0x...";
|
|
466
439
|
* const signers = [
|
|
467
|
-
*
|
|
468
|
-
*
|
|
469
|
-
* // ...
|
|
470
|
-
* privateKeyToAccount("0x..."),
|
|
471
|
-
* ];
|
|
440
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
441
|
+
* ] as const;
|
|
472
442
|
*
|
|
473
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
443
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
474
444
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
475
445
|
*
|
|
476
446
|
* const data = await multiSignClient.convertToMultiSigUser({ // convert to normal user
|
|
@@ -481,7 +451,7 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
481
451
|
*/
|
|
482
452
|
async convertToMultiSigUser(...[args, signal]) {
|
|
483
453
|
// Destructure the parameters
|
|
484
|
-
const
|
|
454
|
+
const actionArgs = args;
|
|
485
455
|
// Construct an action
|
|
486
456
|
const nonce = await this.nonceManager();
|
|
487
457
|
const action = {
|
|
@@ -516,17 +486,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
516
486
|
* @example
|
|
517
487
|
* ```ts
|
|
518
488
|
* import * as hl from "@nktkas/hyperliquid";
|
|
519
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
520
489
|
*
|
|
521
490
|
* const multiSignAddress = "0x...";
|
|
522
491
|
* const signers = [
|
|
523
|
-
*
|
|
524
|
-
*
|
|
525
|
-
* // ...
|
|
526
|
-
* privateKeyToAccount("0x..."),
|
|
527
|
-
* ];
|
|
492
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
493
|
+
* ] as const;
|
|
528
494
|
*
|
|
529
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
495
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
530
496
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
531
497
|
*
|
|
532
498
|
* const data = await multiSignClient.createSubAccount({ name: "subAccountName" });
|
|
@@ -566,17 +532,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
566
532
|
* @example
|
|
567
533
|
* ```ts
|
|
568
534
|
* import * as hl from "@nktkas/hyperliquid";
|
|
569
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
570
535
|
*
|
|
571
536
|
* const multiSignAddress = "0x...";
|
|
572
537
|
* const signers = [
|
|
573
|
-
*
|
|
574
|
-
*
|
|
575
|
-
* // ...
|
|
576
|
-
* privateKeyToAccount("0x..."),
|
|
577
|
-
* ];
|
|
538
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
539
|
+
* ] as const;
|
|
578
540
|
*
|
|
579
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
541
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
580
542
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
581
543
|
*
|
|
582
544
|
* const data = await multiSignClient.createVault({
|
|
@@ -671,17 +633,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
671
633
|
* @example
|
|
672
634
|
* ```ts
|
|
673
635
|
* import * as hl from "@nktkas/hyperliquid";
|
|
674
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
675
636
|
*
|
|
676
637
|
* const multiSignAddress = "0x...";
|
|
677
638
|
* const signers = [
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
* // ...
|
|
681
|
-
* privateKeyToAccount("0x..."),
|
|
682
|
-
* ];
|
|
639
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
640
|
+
* ] as const;
|
|
683
641
|
*
|
|
684
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
642
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
685
643
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
686
644
|
*
|
|
687
645
|
* const data = await multiSignClient.cWithdraw({ wei: 1 * 1e8 });
|
|
@@ -724,17 +682,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
724
682
|
* @example
|
|
725
683
|
* ```ts
|
|
726
684
|
* import * as hl from "@nktkas/hyperliquid";
|
|
727
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
728
685
|
*
|
|
729
686
|
* const multiSignAddress = "0x...";
|
|
730
687
|
* const signers = [
|
|
731
|
-
*
|
|
732
|
-
*
|
|
733
|
-
* // ...
|
|
734
|
-
* privateKeyToAccount("0x..."),
|
|
735
|
-
* ];
|
|
688
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
689
|
+
* ] as const;
|
|
736
690
|
*
|
|
737
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
691
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
738
692
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
739
693
|
*
|
|
740
694
|
* const data = await multiSignClient.evmUserModify({ usingBigBlocks: true });
|
|
@@ -774,17 +728,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
774
728
|
* @example
|
|
775
729
|
* ```ts
|
|
776
730
|
* import * as hl from "@nktkas/hyperliquid";
|
|
777
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
778
731
|
*
|
|
779
732
|
* const multiSignAddress = "0x...";
|
|
780
733
|
* const signers = [
|
|
781
|
-
*
|
|
782
|
-
*
|
|
783
|
-
* // ...
|
|
784
|
-
* privateKeyToAccount("0x..."),
|
|
785
|
-
* ];
|
|
734
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
735
|
+
* ] as const;
|
|
786
736
|
*
|
|
787
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
737
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
788
738
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
789
739
|
*
|
|
790
740
|
* const data = await multiSignClient.modify({
|
|
@@ -853,17 +803,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
853
803
|
* @example
|
|
854
804
|
* ```ts
|
|
855
805
|
* import * as hl from "@nktkas/hyperliquid";
|
|
856
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
857
806
|
*
|
|
858
807
|
* const multiSignAddress = "0x...";
|
|
859
808
|
* const signers = [
|
|
860
|
-
*
|
|
861
|
-
*
|
|
862
|
-
* // ...
|
|
863
|
-
* privateKeyToAccount("0x..."),
|
|
864
|
-
* ];
|
|
809
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
810
|
+
* ] as const;
|
|
865
811
|
*
|
|
866
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
812
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
867
813
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
868
814
|
*
|
|
869
815
|
* const data = await multiSignClient.order({
|
|
@@ -950,17 +896,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
950
896
|
* @example
|
|
951
897
|
* ```ts
|
|
952
898
|
* import * as hl from "@nktkas/hyperliquid";
|
|
953
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
954
899
|
*
|
|
955
900
|
* const multiSignAddress = "0x...";
|
|
956
901
|
* const signers = [
|
|
957
|
-
*
|
|
958
|
-
*
|
|
959
|
-
* // ...
|
|
960
|
-
* privateKeyToAccount("0x..."),
|
|
961
|
-
* ];
|
|
902
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
903
|
+
* ] as const;
|
|
962
904
|
*
|
|
963
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
905
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
964
906
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
965
907
|
*
|
|
966
908
|
* const data = await multiSignClient.perpDexClassTransfer({
|
|
@@ -1008,17 +950,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1008
950
|
* @example
|
|
1009
951
|
* ```ts
|
|
1010
952
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1011
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1012
953
|
*
|
|
1013
954
|
* const multiSignAddress = "0x...";
|
|
1014
955
|
* const signers = [
|
|
1015
|
-
*
|
|
1016
|
-
*
|
|
1017
|
-
* // ...
|
|
1018
|
-
* privateKeyToAccount("0x..."),
|
|
1019
|
-
* ];
|
|
956
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
957
|
+
* ] as const;
|
|
1020
958
|
*
|
|
1021
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
959
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1022
960
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1023
961
|
*
|
|
1024
962
|
* const data = await multiSignClient.registerReferrer({ code: "TEST" });
|
|
@@ -1058,17 +996,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1058
996
|
* @example
|
|
1059
997
|
* ```ts
|
|
1060
998
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1061
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1062
999
|
*
|
|
1063
1000
|
* const multiSignAddress = "0x...";
|
|
1064
1001
|
* const signers = [
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
1067
|
-
* // ...
|
|
1068
|
-
* privateKeyToAccount("0x..."),
|
|
1069
|
-
* ];
|
|
1002
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1003
|
+
* ] as const;
|
|
1070
1004
|
*
|
|
1071
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1005
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1072
1006
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1073
1007
|
*
|
|
1074
1008
|
* const data = await multiSignClient.reserveRequestWeight({ weight: 10 });
|
|
@@ -1143,17 +1077,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1143
1077
|
* @example
|
|
1144
1078
|
* ```ts
|
|
1145
1079
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1146
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1147
1080
|
*
|
|
1148
1081
|
* const multiSignAddress = "0x...";
|
|
1149
1082
|
* const signers = [
|
|
1150
|
-
*
|
|
1151
|
-
*
|
|
1152
|
-
* // ...
|
|
1153
|
-
* privateKeyToAccount("0x..."),
|
|
1154
|
-
* ];
|
|
1083
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1084
|
+
* ] as const;
|
|
1155
1085
|
*
|
|
1156
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1086
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1157
1087
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1158
1088
|
*
|
|
1159
1089
|
* const data = await multiSignClient.setDisplayName({ displayName: "My Name" });
|
|
@@ -1193,17 +1123,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1193
1123
|
* @example
|
|
1194
1124
|
* ```ts
|
|
1195
1125
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1196
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1197
1126
|
*
|
|
1198
1127
|
* const multiSignAddress = "0x...";
|
|
1199
1128
|
* const signers = [
|
|
1200
|
-
*
|
|
1201
|
-
*
|
|
1202
|
-
* // ...
|
|
1203
|
-
* privateKeyToAccount("0x..."),
|
|
1204
|
-
* ];
|
|
1129
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1130
|
+
* ] as const;
|
|
1205
1131
|
*
|
|
1206
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1132
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1207
1133
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1208
1134
|
*
|
|
1209
1135
|
* const data = await multiSignClient.setReferrer({ code: "TEST" });
|
|
@@ -1267,17 +1193,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1267
1193
|
* @example
|
|
1268
1194
|
* ```ts
|
|
1269
1195
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1270
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1271
1196
|
*
|
|
1272
1197
|
* const multiSignAddress = "0x...";
|
|
1273
1198
|
* const signers = [
|
|
1274
|
-
*
|
|
1275
|
-
*
|
|
1276
|
-
* // ...
|
|
1277
|
-
* privateKeyToAccount("0x..."),
|
|
1278
|
-
* ];
|
|
1199
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1200
|
+
* ] as const;
|
|
1279
1201
|
*
|
|
1280
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1202
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1281
1203
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1282
1204
|
*
|
|
1283
1205
|
* const data = await multiSignClient.spotSend({
|
|
@@ -1324,17 +1246,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1324
1246
|
* @example
|
|
1325
1247
|
* ```ts
|
|
1326
1248
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1327
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1328
1249
|
*
|
|
1329
1250
|
* const multiSignAddress = "0x...";
|
|
1330
1251
|
* const signers = [
|
|
1331
|
-
*
|
|
1332
|
-
*
|
|
1333
|
-
* // ...
|
|
1334
|
-
* privateKeyToAccount("0x..."),
|
|
1335
|
-
* ];
|
|
1252
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1253
|
+
* ] as const;
|
|
1336
1254
|
*
|
|
1337
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1255
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1338
1256
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1339
1257
|
*
|
|
1340
1258
|
* const data = await multiSignClient.spotUser({ toggleSpotDusting: { optOut: false } });
|
|
@@ -1374,17 +1292,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1374
1292
|
* @example
|
|
1375
1293
|
* ```ts
|
|
1376
1294
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1377
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1378
1295
|
*
|
|
1379
1296
|
* const multiSignAddress = "0x...";
|
|
1380
1297
|
* const signers = [
|
|
1381
|
-
*
|
|
1382
|
-
*
|
|
1383
|
-
* // ...
|
|
1384
|
-
* privateKeyToAccount("0x..."),
|
|
1385
|
-
* ];
|
|
1298
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1299
|
+
* ] as const;
|
|
1386
1300
|
*
|
|
1387
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1301
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1388
1302
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1389
1303
|
*
|
|
1390
1304
|
* const data = await multiSignClient.subAccountSpotTransfer({
|
|
@@ -1429,17 +1343,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1429
1343
|
* @example
|
|
1430
1344
|
* ```ts
|
|
1431
1345
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1432
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1433
1346
|
*
|
|
1434
1347
|
* const multiSignAddress = "0x...";
|
|
1435
1348
|
* const signers = [
|
|
1436
|
-
*
|
|
1437
|
-
*
|
|
1438
|
-
* // ...
|
|
1439
|
-
* privateKeyToAccount("0x..."),
|
|
1440
|
-
* ];
|
|
1349
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1350
|
+
* ] as const;
|
|
1441
1351
|
*
|
|
1442
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1352
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1443
1353
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1444
1354
|
*
|
|
1445
1355
|
* const data = await multiSignClient.subAccountTransfer({
|
|
@@ -1483,17 +1393,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1483
1393
|
* @example
|
|
1484
1394
|
* ```ts
|
|
1485
1395
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1486
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1487
1396
|
*
|
|
1488
1397
|
* const multiSignAddress = "0x...";
|
|
1489
1398
|
* const signers = [
|
|
1490
|
-
*
|
|
1491
|
-
*
|
|
1492
|
-
* // ...
|
|
1493
|
-
* privateKeyToAccount("0x..."),
|
|
1494
|
-
* ];
|
|
1399
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1400
|
+
* ] as const;
|
|
1495
1401
|
*
|
|
1496
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1402
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1497
1403
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1498
1404
|
*
|
|
1499
1405
|
* const data = await multiSignClient.tokenDelegate({
|
|
@@ -1540,17 +1446,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1540
1446
|
* @example
|
|
1541
1447
|
* ```ts
|
|
1542
1448
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1543
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1544
1449
|
*
|
|
1545
1450
|
* const multiSignAddress = "0x...";
|
|
1546
1451
|
* const signers = [
|
|
1547
|
-
*
|
|
1548
|
-
*
|
|
1549
|
-
* // ...
|
|
1550
|
-
* privateKeyToAccount("0x..."),
|
|
1551
|
-
* ];
|
|
1452
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1453
|
+
* ] as const;
|
|
1552
1454
|
*
|
|
1553
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1455
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1554
1456
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1555
1457
|
*
|
|
1556
1458
|
* const data = await multiSignClient.twapCancel({
|
|
@@ -1601,17 +1503,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1601
1503
|
* @example
|
|
1602
1504
|
* ```ts
|
|
1603
1505
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1604
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1605
1506
|
*
|
|
1606
1507
|
* const multiSignAddress = "0x...";
|
|
1607
1508
|
* const signers = [
|
|
1608
|
-
*
|
|
1609
|
-
*
|
|
1610
|
-
* // ...
|
|
1611
|
-
* privateKeyToAccount("0x..."),
|
|
1612
|
-
* ];
|
|
1509
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1510
|
+
* ] as const;
|
|
1613
1511
|
*
|
|
1614
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1512
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1615
1513
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1616
1514
|
*
|
|
1617
1515
|
* const data = await multiSignClient.twapOrder({
|
|
@@ -1668,17 +1566,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1668
1566
|
* @example
|
|
1669
1567
|
* ```ts
|
|
1670
1568
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1671
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1672
1569
|
*
|
|
1673
1570
|
* const multiSignAddress = "0x...";
|
|
1674
1571
|
* const signers = [
|
|
1675
|
-
*
|
|
1676
|
-
*
|
|
1677
|
-
* // ...
|
|
1678
|
-
* privateKeyToAccount("0x..."),
|
|
1679
|
-
* ];
|
|
1572
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1573
|
+
* ] as const;
|
|
1680
1574
|
*
|
|
1681
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1575
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1682
1576
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1683
1577
|
*
|
|
1684
1578
|
* const data = await multiSignClient.updateIsolatedMargin({
|
|
@@ -1730,17 +1624,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1730
1624
|
* @example
|
|
1731
1625
|
* ```ts
|
|
1732
1626
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1733
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1734
1627
|
*
|
|
1735
1628
|
* const multiSignAddress = "0x...";
|
|
1736
1629
|
* const signers = [
|
|
1737
|
-
*
|
|
1738
|
-
*
|
|
1739
|
-
* // ...
|
|
1740
|
-
* privateKeyToAccount("0x..."),
|
|
1741
|
-
* ];
|
|
1630
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1631
|
+
* ] as const;
|
|
1742
1632
|
*
|
|
1743
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1633
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1744
1634
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1745
1635
|
*
|
|
1746
1636
|
* const data = await multiSignClient.updateLeverage({
|
|
@@ -1792,17 +1682,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1792
1682
|
* @example
|
|
1793
1683
|
* ```ts
|
|
1794
1684
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1795
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1796
1685
|
*
|
|
1797
1686
|
* const multiSignAddress = "0x...";
|
|
1798
1687
|
* const signers = [
|
|
1799
|
-
*
|
|
1800
|
-
*
|
|
1801
|
-
* // ...
|
|
1802
|
-
* privateKeyToAccount("0x..."),
|
|
1803
|
-
* ];
|
|
1688
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1689
|
+
* ] as const;
|
|
1804
1690
|
*
|
|
1805
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1691
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1806
1692
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1807
1693
|
*
|
|
1808
1694
|
* const data = await multiSignClient.usdClassTransfer({ amount: "1", toPerp: true });
|
|
@@ -1845,17 +1731,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1845
1731
|
* @example
|
|
1846
1732
|
* ```ts
|
|
1847
1733
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1848
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1849
1734
|
*
|
|
1850
1735
|
* const multiSignAddress = "0x...";
|
|
1851
1736
|
* const signers = [
|
|
1852
|
-
*
|
|
1853
|
-
*
|
|
1854
|
-
* // ...
|
|
1855
|
-
* privateKeyToAccount("0x..."),
|
|
1856
|
-
* ];
|
|
1737
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1738
|
+
* ] as const;
|
|
1857
1739
|
*
|
|
1858
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1740
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1859
1741
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1860
1742
|
*
|
|
1861
1743
|
* const data = await multiSignClient.usdSend({ destination: "0x...", amount: "1" });
|
|
@@ -1898,17 +1780,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1898
1780
|
* @example
|
|
1899
1781
|
* ```ts
|
|
1900
1782
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1901
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1902
1783
|
*
|
|
1903
1784
|
* const multiSignAddress = "0x...";
|
|
1904
1785
|
* const signers = [
|
|
1905
|
-
*
|
|
1906
|
-
*
|
|
1907
|
-
* // ...
|
|
1908
|
-
* privateKeyToAccount("0x..."),
|
|
1909
|
-
* ];
|
|
1786
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1787
|
+
* ] as const;
|
|
1910
1788
|
*
|
|
1911
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1789
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1912
1790
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1913
1791
|
*
|
|
1914
1792
|
* const data = await multiSignClient.vaultDistribute({ vaultAddress: "0x...", usd: 10 * 1e6 });
|
|
@@ -1948,17 +1826,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
1948
1826
|
* @example
|
|
1949
1827
|
* ```ts
|
|
1950
1828
|
* import * as hl from "@nktkas/hyperliquid";
|
|
1951
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
1952
1829
|
*
|
|
1953
1830
|
* const multiSignAddress = "0x...";
|
|
1954
1831
|
* const signers = [
|
|
1955
|
-
*
|
|
1956
|
-
*
|
|
1957
|
-
* // ...
|
|
1958
|
-
* privateKeyToAccount("0x..."),
|
|
1959
|
-
* ];
|
|
1832
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1833
|
+
* ] as const;
|
|
1960
1834
|
*
|
|
1961
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1835
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
1962
1836
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
1963
1837
|
*
|
|
1964
1838
|
* const data = await multiSignClient.vaultModify({
|
|
@@ -2002,17 +1876,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
2002
1876
|
* @example
|
|
2003
1877
|
* ```ts
|
|
2004
1878
|
* import * as hl from "@nktkas/hyperliquid";
|
|
2005
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
2006
1879
|
*
|
|
2007
1880
|
* const multiSignAddress = "0x...";
|
|
2008
1881
|
* const signers = [
|
|
2009
|
-
*
|
|
2010
|
-
*
|
|
2011
|
-
* // ...
|
|
2012
|
-
* privateKeyToAccount("0x..."),
|
|
2013
|
-
* ];
|
|
1882
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1883
|
+
* ] as const;
|
|
2014
1884
|
*
|
|
2015
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1885
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
2016
1886
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
2017
1887
|
*
|
|
2018
1888
|
* const data = await multiSignClient.vaultTransfer({
|
|
@@ -2057,17 +1927,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
2057
1927
|
* @example
|
|
2058
1928
|
* ```ts
|
|
2059
1929
|
* import * as hl from "@nktkas/hyperliquid";
|
|
2060
|
-
* import { privateKeyToAccount } from "viem/accounts";
|
|
2061
1930
|
*
|
|
2062
1931
|
* const multiSignAddress = "0x...";
|
|
2063
1932
|
* const signers = [
|
|
2064
|
-
*
|
|
2065
|
-
*
|
|
2066
|
-
* // ...
|
|
2067
|
-
* privateKeyToAccount("0x..."),
|
|
2068
|
-
* ];
|
|
1933
|
+
* "0x...", // Private key; or any other wallet libraries
|
|
1934
|
+
* ] as const;
|
|
2069
1935
|
*
|
|
2070
|
-
* const transport = new hl.HttpTransport(); // or WebSocketTransport
|
|
1936
|
+
* const transport = new hl.HttpTransport(); // or `WebSocketTransport`
|
|
2071
1937
|
* const multiSignClient = new hl.MultiSignClient({ transport, multiSignAddress, signers });
|
|
2072
1938
|
*
|
|
2073
1939
|
* const data = await multiSignClient.withdraw3({ destination: "0x...", amount: "1" });
|
|
@@ -2102,7 +1968,10 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
2102
1968
|
}
|
|
2103
1969
|
/** Extracts the wallet address from different wallet types. */
|
|
2104
1970
|
async _getWalletAddress(wallet) {
|
|
2105
|
-
if (
|
|
1971
|
+
if (isValidPrivateKey(wallet)) {
|
|
1972
|
+
return privateKeyToAddress(wallet);
|
|
1973
|
+
}
|
|
1974
|
+
else if (isAbstractViemWalletClient(wallet)) {
|
|
2106
1975
|
return wallet.address;
|
|
2107
1976
|
}
|
|
2108
1977
|
else if (isAbstractEthersSigner(wallet) || isAbstractEthersV5Signer(wallet)) {
|
|
@@ -2154,3 +2023,13 @@ export class MultiSignClient extends ExchangeClient {
|
|
|
2154
2023
|
}));
|
|
2155
2024
|
}
|
|
2156
2025
|
}
|
|
2026
|
+
/** Converts a private key to an Ethereum address. */
|
|
2027
|
+
function privateKeyToAddress(privateKey) {
|
|
2028
|
+
const cleanKey = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
|
|
2029
|
+
const publicKey = getPublicKey(cleanKey, false);
|
|
2030
|
+
const publicKeyWithoutPrefix = publicKey.slice(1);
|
|
2031
|
+
const hash = keccak_256(publicKeyWithoutPrefix);
|
|
2032
|
+
const addressBytes = hash.slice(-20);
|
|
2033
|
+
const address = encodeHex(addressBytes);
|
|
2034
|
+
return `0x${address}`;
|
|
2035
|
+
}
|