77if TYPE_CHECKING :
88 from collections .abc import Iterator
99
10- from ape .api import ReceiptAPI
10+ from ape .api import AccountAPI , ReceiptAPI
1111 from ape .contracts import ContractInstance
1212
1313 from ape_safe .accounts import SafeAccount
14+ from ape_safe .client import SafeTxID
1415
1516
1617class SafeModuleManager (ManagerAccessMixin ):
@@ -27,9 +28,23 @@ def __contains__(self, module: Union[str, AddressType, "ContractInstance"]) -> b
2728 return self ._safe .contract .isModuleEnabled (module )
2829
2930 def enable (
30- self , module : Union [str , AddressType , "ContractInstance" ], ** txn_kwargs
31- ) -> "ReceiptAPI" :
32- return self ._safe .contract .enableModule (module , sender = self ._safe , ** txn_kwargs )
31+ self ,
32+ module : Union [str , AddressType , "ContractInstance" ],
33+ submitter : Union ["AccountAPI" , AddressType , str , None ] = None ,
34+ propose : bool = False ,
35+ ** txn_kwargs ,
36+ ) -> Union ["ReceiptAPI" , "SafeTxID" ]:
37+ if propose :
38+ txn = self ._safe .contract .enableModule .as_transaction (module , ** txn_kwargs )
39+ return self ._safe .propose (txn = txn , submitter = submitter )
40+
41+ else :
42+ return self ._safe .contract .enableModule (
43+ module ,
44+ sender = self ._safe ,
45+ submitter = submitter ,
46+ ** txn_kwargs ,
47+ )
3348
3449 def __iter__ (self ) -> "Iterator[ContractInstance]" :
3550 start_module = self .SENTINEL
@@ -56,14 +71,27 @@ def _get_previous_module(
5671 raise AssertionError (f"Module { module } not in Safe modules for { self ._safe } " )
5772
5873 def disable (
59- self , module : Union [str , AddressType , "ContractInstance" ], ** txn_kwargs
60- ) -> "ReceiptAPI" :
61- return self ._safe .contract .disableModule (
62- self ._get_previous_module (module ),
63- module ,
64- sender = self ._safe ,
65- ** txn_kwargs ,
66- )
74+ self ,
75+ module : Union [str , AddressType , "ContractInstance" ],
76+ submitter : Union ["AccountAPI" , AddressType , str , None ] = None ,
77+ propose : bool = False ,
78+ ** txn_kwargs ,
79+ ) -> Union ["ReceiptAPI" , "SafeTxID" ]:
80+ if propose :
81+ txn = self ._safe .contract .disableModule .as_transaction (
82+ self ._get_previous_module (module ),
83+ module ,
84+ ** txn_kwargs ,
85+ )
86+ return self ._safe .propose (txn = txn , submitter = submitter )
87+
88+ else :
89+ return self ._safe .contract .disableModule (
90+ self ._get_previous_module (module ),
91+ module ,
92+ sender = self ._safe ,
93+ ** txn_kwargs ,
94+ )
6795
6896 @property
6997 def guard (self ) -> Optional ["ContractInstance" ]:
@@ -81,6 +109,15 @@ def guard(self) -> Optional["ContractInstance"]:
81109 return self .chain_manager .contracts .instance_at (module_guard_address )
82110
83111 def set_guard (
84- self , guard : Union [str , AddressType , "ContractInstance" ], ** txn_kwargs
85- ) -> "ReceiptAPI" :
86- return self ._safe .contract .setModuleGuard (guard , sender = self ._safe , ** txn_kwargs )
112+ self ,
113+ guard : Union [str , AddressType , "ContractInstance" ],
114+ submitter : Union ["AccountAPI" , AddressType , str , None ] = None ,
115+ propose : bool = False ,
116+ ** txn_kwargs ,
117+ ) -> Union ["ReceiptAPI" , "SafeTxID" ]:
118+ if propose :
119+ txn = self ._safe .contract .setModuleGuard .as_transaction (guard , ** txn_kwargs )
120+ return self ._safe .propose (txn = txn , submitter = submitter )
121+
122+ else :
123+ return self ._safe .contract .setModuleGuard (guard , sender = self ._safe , ** txn_kwargs )
0 commit comments