@@ -209,3 +209,54 @@ task("task:removeDeployerFromSafeOwnersAndUpdateThreshold").setAction(
209209 await safeKitDeployer . executeTransaction ( batch ) ;
210210 } ,
211211) ;
212+
213+ // Just update the threshold, use this task instead of previous one if you want deployer to stay as an owner
214+ // Example usage:
215+ // npx hardhat task:updateSafeThreshold
216+ task ( "task:updateSafeThreshold" ) . setAction ( async function (
217+ _ ,
218+ { getNamedAccounts, ethers, network } ,
219+ ) {
220+ // Get the deployer
221+ const { deployer } = await getNamedAccounts ( ) ;
222+
223+ // Get the Safe proxy and address
224+ const { safeProxy, safeProxyAddress } = await getSafeProxyAddress ( ethers ) ;
225+
226+ // Make sure the deployer is an owner of the SafeL2Proxy contract
227+ const safeOwners = await safeProxy . getOwners ( ) ;
228+ if ( ! safeOwners . includes ( deployer ) ) {
229+ throw new Error (
230+ `Deployer should be an owner of the SafeL2Proxy contract.
231+ Current owners: ${ safeOwners . join ( ", " ) } , expected: ${ deployer } ` ,
232+ ) ;
233+ }
234+
235+ // Make sure the threshold is 1
236+ const threshold = await safeProxy . getThreshold ( ) ;
237+ if ( threshold !== BigInt ( 1 ) ) {
238+ throw new Error ( `Threshold should be 1. Current threshold: ${ threshold } ` ) ;
239+ }
240+
241+ // Get the SafeKit deployer
242+ const safeKitDeployer = await getSafeKitDeployer (
243+ deployer ,
244+ safeProxyAddress ,
245+ network ,
246+ ethers ,
247+ ) ;
248+
249+ // Get the new threshold
250+ const newThreshold = Number ( getRequiredEnvVar ( "SAFE_NEW_THRESHOLD" ) ) ;
251+
252+ // Generate the transaction to update the threshold
253+ const changeThresholdTx =
254+ await safeKitDeployer . createChangeThresholdTx ( newThreshold ) ;
255+
256+ // Create, sign and execute the transaction using the deployer (the Safe's current only owner)
257+ const batch = await safeKitDeployer . createTransaction ( {
258+ transactions : [ changeThresholdTx . data ] ,
259+ } ) ;
260+ await safeKitDeployer . signTransaction ( batch ) ;
261+ await safeKitDeployer . executeTransaction ( batch ) ;
262+ } ) ;
0 commit comments