@@ -11,6 +11,7 @@ import {
1111 LiquidityBridgeContractV2 ,
1212} from "../typechain-types" ;
1313import { deployUpgradeLibraries } from "../scripts/deployment-utils/upgrade-proxy" ;
14+ import hre from "hardhat" ;
1415
1516type MultisigInfo = Record <
1617 string ,
@@ -50,6 +51,12 @@ describe("Should change LBC owner to the multisig.ts", function () {
5051 await helpers . impersonateAccount ( lbcOwner ) ;
5152 const impersonatedSigner = await ethers . getSigner ( lbcOwner ) ;
5253
54+ const desiredBalance = ethers . toQuantity ( ethers . parseEther ( "100" ) ) ;
55+ await ethers . provider . send ( "hardhat_setBalance" , [
56+ impersonatedSigner . address ,
57+ desiredBalance ,
58+ ] ) ;
59+
5360 await expect (
5461 changeMultisigOwner ( safeAddress , networkName , impersonatedSigner )
5562 ) . to . not . be . reverted ;
@@ -107,6 +114,82 @@ describe("Should change LBC owner to the multisig.ts", function () {
107114 ) ;
108115 await expect ( newLbc . version ( ) ) . to . eventually . be . equal ( "1.3.0" ) ;
109116 } ) ;
117+
118+ it ( "Should change the owner using Tenderly" , async ( ) => {
119+ await checkForkedNetwork ( ) ;
120+ const deploymentNetwork = hre . network . name ;
121+ const multisigAddress = multsigInfo [ deploymentNetwork ] . address ;
122+ if ( ! multisigAddress || multisigAddress === "" )
123+ throw new Error ( "Multisig address not found for current network" ) ;
124+
125+ // Get the current owner of LiquidityBridgeContract
126+ const deploymentData = read ( ) [ deploymentNetwork ] ;
127+ const proxyAddress = deploymentData . LiquidityBridgeContract . address ;
128+ if ( ! proxyAddress )
129+ throw new Error (
130+ `LiquidityBridgeContract address not found on network ${ deploymentNetwork } `
131+ ) ;
132+
133+ const contract = await ethers . getContractAt (
134+ "LiquidityBridgeContractV2" ,
135+ proxyAddress
136+ ) ;
137+ const currentOwner = await contract . owner ( ) ;
138+ console . info ( `Current owner: ${ currentOwner } ` ) ;
139+
140+ // Impersonate the current owner account
141+ await helpers . impersonateAccount ( currentOwner ) ;
142+ const impersonatedSigner = await ethers . getSigner ( currentOwner ) ;
143+
144+ // Set balance for the impersonated account
145+ const desiredBalance = ethers . toQuantity ( ethers . parseEther ( "100" ) ) ;
146+ await ethers . provider . send ( "hardhat_setBalance" , [
147+ impersonatedSigner . address ,
148+ desiredBalance ,
149+ ] ) ;
150+
151+ console . info ( `Impersonated account: ${ impersonatedSigner . address } ` ) ;
152+
153+ // Call changeMultisigOwner and ensure the Promise is fulfilled
154+ await expect (
155+ changeMultisigOwner (
156+ multisigAddress ,
157+ deploymentNetwork ,
158+ impersonatedSigner
159+ )
160+ ) . to . eventually . be . fulfilled ;
161+
162+ const newOwner = await contract . owner ( ) ;
163+ console . info ( `New owner: ${ newOwner } ` ) ;
164+
165+ // Verify ownership change
166+ expect ( newOwner . toLowerCase ( ) ) . to . equal ( multisigAddress . toLowerCase ( ) ) ;
167+
168+ // Verify old owner can no longer perform owner functions
169+ const adminAddress = await upgrades . erc1967 . getAdminAddress ( proxyAddress ) ;
170+
171+ // Get the ProxyAdmin contract instance
172+ const proxyAdminContract = await ethers . getContractAt (
173+ "LiquidityBridgeContractAdmin" ,
174+ adminAddress
175+ ) ;
176+
177+ // Attempt an upgrade with the former owner to ensure permissions were revoked
178+ const adminContract = proxyAdminContract . connect ( impersonatedSigner ) ;
179+ await expect (
180+ adminContract . upgrade ( proxyAddress , multisigAddress )
181+ ) . to . be . revertedWith ( "Ownable: caller is not the owner" ) ;
182+
183+ // Verify the ProxyAdmin owner was also updated
184+ const proxyAdminOwner = await proxyAdminContract . owner ( ) ;
185+ expect ( proxyAdminOwner . toLowerCase ( ) ) . to . equal (
186+ multisigAddress . toLowerCase ( )
187+ ) ;
188+
189+ console . info (
190+ `Ownership of LiquidityBridgeContract proxy changed to multisig in ${ deploymentNetwork } `
191+ ) ;
192+ } ) ;
110193} ) ;
111194
112195async function checkForkedNetwork ( ) {
0 commit comments