11import hre , { ethers } from "hardhat" ;
22import { read } from "./deploy" ;
33import multisigOwners from "../../multisig-owners.json" ;
4+ import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers" ;
45
56/**
67 * Changes the multisig owner of the `LiquidityBridgeContract` deployed on the current network to the safe wallet
@@ -12,6 +13,8 @@ import multisigOwners from "../../multisig-owners.json";
1213 *
1314 * @async
1415 * @param {string } newOwner - The address of the new multisig owner (Safe contract).
16+ * @param {string } network - The network where the script will run, by default will be the environment network.
17+ * @param {HardhatEthersSigner } signer - Optional signer for test.
1518 * @throws {Error } If the proxy contract is not deployed on the current network.
1619 * @throws {Error } If the provided `newOwner` address is not a valid multisig Safe contract.
1720 * @throws {Error } If the configuration of owners on the Safe does not match the expected configuration.
@@ -23,8 +26,12 @@ import multisigOwners from "../../multisig-owners.json";
2326 * await changeMultisigOwner(newMultisigAddress);
2427 */
2528
26- export const changeMultisigOwner = async ( newOwner : string ) => {
27- const network = hre . network . name ;
29+ export const changeMultisigOwner = async (
30+ newOwner : string ,
31+ network = "" ,
32+ signer ?: HardhatEthersSigner
33+ ) => {
34+ network = network === "" ? hre . network . name : network ;
2835 console . info ( `Changing multisig owner to: ${ newOwner } - ${ network } ` ) ;
2936
3037 const currentNetworkData =
@@ -49,7 +56,7 @@ export const changeMultisigOwner = async (newOwner: string) => {
4956 validateOwners ( safeOwners , owners ) ;
5057
5158 console . info ( "Starting ownership transfer process..." ) ;
52- await transferOwnership ( proxyAddress , newOwner ) ;
59+ await transferOwnership ( proxyAddress , newOwner , signer ) ;
5360 console . info ( "Ownership transfer process complete!" ) ;
5461} ;
5562
@@ -93,7 +100,8 @@ function validateOwners(safeOwners: string[], expectedOwners: string[]): void {
93100
94101async function transferOwnership (
95102 proxyAddress : string ,
96- newOwnerAddress : string
103+ newOwnerAddress : string ,
104+ signer ?: HardhatEthersSigner
97105) : Promise < void > {
98106 try {
99107 const contract = await ethers . getContractAt (
@@ -116,15 +124,18 @@ async function transferOwnership(
116124 console . info (
117125 `Transferring ownership of contract at ${ proxyAddress } to ${ newOwnerAddress } ...`
118126 ) ;
119- await contract . transferOwnership ( newOwnerAddress ) ;
127+ const connectedContract = signer ? contract . connect ( signer ) : contract ;
128+
129+ await connectedContract . transferOwnership ( newOwnerAddress ) ;
120130
121131 console . info (
122132 `Ownership of contract at ${ proxyAddress } successfully transferred to ${ newOwnerAddress } !`
123133 ) ;
124134
125135 await hre . upgrades . admin . transferProxyAdminOwnership (
126136 proxyAddress ,
127- newOwnerAddress
137+ newOwnerAddress ,
138+ signer
128139 ) ;
129140 } catch ( error ) {
130141 console . error (
0 commit comments