@@ -247,36 +247,14 @@ export const deploySharedContracts = async (
247247
248248 const coinIssuerAddress = await deployer . deploy ( CoinIssuerArtifact , [
249249 feeAssetAddress . toString ( ) ,
250- 1n * 10n ** 18n , // @todo #8084
251- governanceAddress . toString ( ) ,
250+ 1_000_000n * 10n ** 18n , // @todo #8084
251+ l1Client . account . address ,
252252 ] ) ;
253253 logger . verbose ( `Deployed CoinIssuer at ${ coinIssuerAddress } ` ) ;
254254
255- const feeAsset = getContract ( {
256- address : feeAssetAddress . toString ( ) ,
257- abi : FeeAssetArtifact . contractAbi ,
258- client : l1Client ,
259- } ) ;
260-
261255 logger . verbose ( `Waiting for deployments to complete` ) ;
262256 await deployer . waitForDeployments ( ) ;
263257
264- if ( args . acceleratedTestDeployments || ! ( await feeAsset . read . minters ( [ coinIssuerAddress . toString ( ) ] ) ) ) {
265- const { txHash } = await deployer . sendTransaction (
266- {
267- to : feeAssetAddress . toString ( ) ,
268- data : encodeFunctionData ( {
269- abi : FeeAssetArtifact . contractAbi ,
270- functionName : 'addMinter' ,
271- args : [ coinIssuerAddress . toString ( ) ] ,
272- } ) ,
273- } ,
274- { gasLimit : 100_000n } ,
275- ) ;
276- logger . verbose ( `Added coin issuer ${ coinIssuerAddress } as minter on fee asset in ${ txHash } ` ) ;
277- txHashes . push ( txHash ) ;
278- }
279-
280258 // Registry ownership will be transferred to governance later, after rollup is added
281259
282260 let feeAssetHandlerAddress : EthAddress | undefined = undefined ;
@@ -500,7 +478,12 @@ export const deployRollup = async (
500478 > ,
501479 addresses : Pick <
502480 L1ContractAddresses ,
503- 'feeJuiceAddress' | 'registryAddress' | 'rewardDistributorAddress' | 'stakingAssetAddress' | 'gseAddress'
481+ | 'feeJuiceAddress'
482+ | 'registryAddress'
483+ | 'rewardDistributorAddress'
484+ | 'stakingAssetAddress'
485+ | 'gseAddress'
486+ | 'governanceAddress'
504487 > ,
505488 logger : Logger ,
506489) => {
@@ -678,6 +661,24 @@ export const deployRollup = async (
678661 ) ;
679662 }
680663
664+ // If the owner is not the Governance contract, transfer ownership to the Governance contract
665+ logger . verbose ( addresses . governanceAddress . toString ( ) ) ;
666+ if ( getAddress ( await rollupContract . getOwner ( ) ) !== getAddress ( addresses . governanceAddress . toString ( ) ) ) {
667+ // TODO(md): add send transaction to the deployer such that we do not need to manage tx hashes here
668+ const { txHash : transferOwnershipTxHash } = await deployer . sendTransaction ( {
669+ to : rollupContract . address ,
670+ data : encodeFunctionData ( {
671+ abi : RegistryArtifact . contractAbi ,
672+ functionName : 'transferOwnership' ,
673+ args : [ getAddress ( addresses . governanceAddress . toString ( ) ) ] ,
674+ } ) ,
675+ } ) ;
676+ logger . verbose (
677+ `Transferring the ownership of the rollup contract at ${ rollupContract . address } to the Governance ${ addresses . governanceAddress } in tx ${ transferOwnershipTxHash } ` ,
678+ ) ;
679+ txHashes . push ( transferOwnershipTxHash ) ;
680+ }
681+
681682 await deployer . waitForDeployments ( ) ;
682683 await Promise . all ( txHashes . map ( txHash => extendedClient . waitForTransactionReceipt ( { hash : txHash } ) ) ) ;
683684 logger . verbose ( `Rollup deployed` ) ;
@@ -690,6 +691,8 @@ export const handoverToGovernance = async (
690691 deployer : L1Deployer ,
691692 registryAddress : EthAddress ,
692693 gseAddress : EthAddress ,
694+ coinIssuerAddress : EthAddress ,
695+ feeAssetAddress : EthAddress ,
693696 governanceAddress : EthAddress ,
694697 logger : Logger ,
695698 acceleratedTestDeployments : boolean | undefined ,
@@ -707,6 +710,18 @@ export const handoverToGovernance = async (
707710 client : extendedClient ,
708711 } ) ;
709712
713+ const coinIssuerContract = getContract ( {
714+ address : getAddress ( coinIssuerAddress . toString ( ) ) ,
715+ abi : CoinIssuerArtifact . contractAbi ,
716+ client : extendedClient ,
717+ } ) ;
718+
719+ const feeAsset = getContract ( {
720+ address : getAddress ( feeAssetAddress . toString ( ) ) ,
721+ abi : FeeAssetArtifact . contractAbi ,
722+ client : extendedClient ,
723+ } ) ;
724+
710725 const txHashes : Hex [ ] = [ ] ;
711726
712727 // If the owner is not the Governance contract, transfer ownership to the Governance contract
@@ -746,6 +761,54 @@ export const handoverToGovernance = async (
746761 txHashes . push ( transferOwnershipTxHash ) ;
747762 }
748763
764+ if ( acceleratedTestDeployments || ( await feeAsset . read . owner ( ) ) !== coinIssuerAddress . toString ( ) ) {
765+ const { txHash } = await deployer . sendTransaction (
766+ {
767+ to : feeAssetAddress . toString ( ) ,
768+ data : encodeFunctionData ( {
769+ abi : FeeAssetArtifact . contractAbi ,
770+ functionName : 'transferOwnership' ,
771+ args : [ coinIssuerAddress . toString ( ) ] ,
772+ } ) ,
773+ } ,
774+ { gasLimit : 500_000n } ,
775+ ) ;
776+ logger . verbose ( `Transfer ownership of fee asset to coin issuer ${ coinIssuerAddress } in ${ txHash } ` ) ;
777+ txHashes . push ( txHash ) ;
778+
779+ const { txHash : acceptTokenOwnershipTxHash } = await deployer . sendTransaction (
780+ {
781+ to : coinIssuerAddress . toString ( ) ,
782+ data : encodeFunctionData ( {
783+ abi : CoinIssuerArtifact . contractAbi ,
784+ functionName : 'acceptTokenOwnership' ,
785+ } ) ,
786+ } ,
787+ { gasLimit : 500_000n } ,
788+ ) ;
789+ logger . verbose ( `Accept ownership of fee asset in ${ acceptTokenOwnershipTxHash } ` ) ;
790+ txHashes . push ( acceptTokenOwnershipTxHash ) ;
791+ }
792+
793+ // If the owner is not the Governance contract, transfer ownership to the Governance contract
794+ if (
795+ acceleratedTestDeployments ||
796+ ( await coinIssuerContract . read . owner ( ) ) !== getAddress ( governanceAddress . toString ( ) )
797+ ) {
798+ const { txHash : transferOwnershipTxHash } = await deployer . sendTransaction ( {
799+ to : coinIssuerContract . address ,
800+ data : encodeFunctionData ( {
801+ abi : CoinIssuerArtifact . contractAbi ,
802+ functionName : 'transferOwnership' ,
803+ args : [ getAddress ( governanceAddress . toString ( ) ) ] ,
804+ } ) ,
805+ } ) ;
806+ logger . verbose (
807+ `Transferring the ownership of the coin issuer contract at ${ coinIssuerAddress } to the Governance ${ governanceAddress } in tx ${ transferOwnershipTxHash } ` ,
808+ ) ;
809+ txHashes . push ( transferOwnershipTxHash ) ;
810+ }
811+
749812 // Wait for all actions to be mined
750813 await deployer . waitForDeployments ( ) ;
751814 await Promise . all ( txHashes . map ( txHash => extendedClient . waitForTransactionReceipt ( { hash : txHash } ) ) ) ;
@@ -964,6 +1027,7 @@ export const deployL1Contracts = async (
9641027 governanceAddress,
9651028 rewardDistributorAddress,
9661029 zkPassportVerifierAddress,
1030+ coinIssuerAddress,
9671031 } = await deploySharedContracts ( l1Client , deployer , args , logger ) ;
9681032 const { rollup, slashFactoryAddress } = await deployRollup (
9691033 l1Client ,
@@ -975,6 +1039,7 @@ export const deployL1Contracts = async (
9751039 gseAddress,
9761040 rewardDistributorAddress,
9771041 stakingAssetAddress,
1042+ governanceAddress,
9781043 } ,
9791044 logger ,
9801045 ) ;
@@ -988,6 +1053,8 @@ export const deployL1Contracts = async (
9881053 deployer ,
9891054 registryAddress ,
9901055 gseAddress ,
1056+ coinIssuerAddress ,
1057+ feeAssetAddress ,
9911058 governanceAddress ,
9921059 logger ,
9931060 args . acceleratedTestDeployments ,
@@ -1032,6 +1099,7 @@ export const deployL1Contracts = async (
10321099 feeAssetHandlerAddress,
10331100 stakingAssetHandlerAddress,
10341101 zkPassportVerifierAddress,
1102+ coinIssuerAddress,
10351103 } ,
10361104 } ;
10371105} ;
0 commit comments