|
| 1 | +import json |
1 | 2 | import logging |
2 | 3 | import secrets |
3 | 4 |
|
|
27 | 28 | sign_usd_class_transfer_action, |
28 | 29 | sign_usd_transfer_action, |
29 | 30 | sign_withdraw_from_bridge_action, |
| 31 | + sign_convert_to_multi_sig_user_action, |
| 32 | + sign_convert_to_multi_sig_signer_action, |
30 | 33 | ) |
31 | 34 | from hyperliquid.utils.types import Any, BuilderInfo, Cloid, List, Meta, Optional, SpotMeta, Tuple |
32 | 35 |
|
@@ -549,3 +552,58 @@ def approve_builder_fee(self, builder: str, max_fee_rate: str) -> Any: |
549 | 552 | action = {"maxFeeRate": max_fee_rate, "builder": builder, "nonce": timestamp, "type": "approveBuilderFee"} |
550 | 553 | signature = sign_approve_builder_fee(self.wallet, action, self.base_url == MAINNET_API_URL) |
551 | 554 | return self._post_action(action, signature, timestamp) |
| 555 | + |
| 556 | + def convert_to_multi_sig_user(self, authorized_users: List[str], threshold: int) -> Any: |
| 557 | + timestamp = get_timestamp_ms() |
| 558 | + authorized_users = sorted(authorized_users) |
| 559 | + signers = { |
| 560 | + "authorizedUsers": authorized_users, |
| 561 | + "threshold": threshold, |
| 562 | + } |
| 563 | + action = { |
| 564 | + "type": "convertToMultiSigUser", |
| 565 | + "signers": json.dumps(signers), |
| 566 | + "nonce": timestamp, |
| 567 | + } |
| 568 | + signature = sign_convert_to_multi_sig_user_action(self.wallet, action, self.base_url == MAINNET_API_URL) |
| 569 | + return self._post_action( |
| 570 | + action, |
| 571 | + signature, |
| 572 | + timestamp, |
| 573 | + ) |
| 574 | + |
| 575 | + def convert_to_multi_sig_signer(self, signer: str, multi_sig_user: str) -> Any: |
| 576 | + timestamp = get_timestamp_ms() |
| 577 | + action = { |
| 578 | + "type": "convertToMultiSigUser", |
| 579 | + "signer": signer, |
| 580 | + "multi_sig_user": multi_sig_user, |
| 581 | + "nonce": timestamp, |
| 582 | + } |
| 583 | + signature = sign_convert_to_multi_sig_signer_action(self.wallet, action, self.base_url == MAINNET_API_URL) |
| 584 | + return self._post_action( |
| 585 | + action, |
| 586 | + signature, |
| 587 | + timestamp, |
| 588 | + ) |
| 589 | + |
| 590 | + def multi_sig(self, multi_sig_user, inner_action, signatures, nonce, vault_address=None): |
| 591 | + multi_sig_action = { |
| 592 | + "type": "multiSig", |
| 593 | + "user": multi_sig_user.lower(), |
| 594 | + "signatures": signatures, |
| 595 | + "inner": inner_action, |
| 596 | + } |
| 597 | + signature = sign_l1_action( |
| 598 | + self.wallet, |
| 599 | + multi_sig_action, |
| 600 | + vault_address, |
| 601 | + nonce, |
| 602 | + self.base_url == MAINNET_API_URL, |
| 603 | + ) |
| 604 | + |
| 605 | + return self._post_action( |
| 606 | + multi_sig_action, |
| 607 | + signature, |
| 608 | + nonce, |
| 609 | + ) |
0 commit comments