@@ -246,36 +246,14 @@ export const deploySharedContracts = async (
246246
247247 const coinIssuerAddress = await deployer . deploy ( CoinIssuerArtifact , [
248248 feeAssetAddress . toString ( ) ,
249- 1n * 10n ** 18n , // @todo #8084
250- governanceAddress . toString ( ) ,
249+ 1_000_000n * 10n ** 18n , // @todo #8084
250+ l1Client . account . address ,
251251 ] ) ;
252252 logger . verbose ( `Deployed CoinIssuer at ${ coinIssuerAddress } ` ) ;
253253
254- const feeAsset = getContract ( {
255- address : feeAssetAddress . toString ( ) ,
256- abi : FeeAssetArtifact . contractAbi ,
257- client : l1Client ,
258- } ) ;
259-
260254 logger . verbose ( `Waiting for deployments to complete` ) ;
261255 await deployer . waitForDeployments ( ) ;
262256
263- if ( args . acceleratedTestDeployments || ! ( await feeAsset . read . minters ( [ coinIssuerAddress . toString ( ) ] ) ) ) {
264- const { txHash } = await deployer . sendTransaction (
265- {
266- to : feeAssetAddress . toString ( ) ,
267- data : encodeFunctionData ( {
268- abi : FeeAssetArtifact . contractAbi ,
269- functionName : 'addMinter' ,
270- args : [ coinIssuerAddress . toString ( ) ] ,
271- } ) ,
272- } ,
273- { gasLimit : 100_000n } ,
274- ) ;
275- logger . verbose ( `Added coin issuer ${ coinIssuerAddress } as minter on fee asset in ${ txHash } ` ) ;
276- txHashes . push ( txHash ) ;
277- }
278-
279257 // Registry ownership will be transferred to governance later, after rollup is added
280258
281259 let feeAssetHandlerAddress : EthAddress | undefined = undefined ;
@@ -499,7 +477,12 @@ export const deployRollup = async (
499477 > ,
500478 addresses : Pick <
501479 L1ContractAddresses ,
502- 'feeJuiceAddress' | 'registryAddress' | 'rewardDistributorAddress' | 'stakingAssetAddress' | 'gseAddress'
480+ | 'feeJuiceAddress'
481+ | 'registryAddress'
482+ | 'rewardDistributorAddress'
483+ | 'stakingAssetAddress'
484+ | 'gseAddress'
485+ | 'governanceAddress'
503486 > ,
504487 logger : Logger ,
505488) => {
@@ -677,6 +660,24 @@ export const deployRollup = async (
677660 ) ;
678661 }
679662
663+ // If the owner is not the Governance contract, transfer ownership to the Governance contract
664+ logger . verbose ( addresses . governanceAddress . toString ( ) ) ;
665+ if ( getAddress ( await rollupContract . getOwner ( ) ) !== getAddress ( addresses . governanceAddress . toString ( ) ) ) {
666+ // TODO(md): add send transaction to the deployer such that we do not need to manage tx hashes here
667+ const { txHash : transferOwnershipTxHash } = await deployer . sendTransaction ( {
668+ to : rollupContract . address ,
669+ data : encodeFunctionData ( {
670+ abi : RegistryArtifact . contractAbi ,
671+ functionName : 'transferOwnership' ,
672+ args : [ getAddress ( addresses . governanceAddress . toString ( ) ) ] ,
673+ } ) ,
674+ } ) ;
675+ logger . verbose (
676+ `Transferring the ownership of the rollup contract at ${ rollupContract . address } to the Governance ${ addresses . governanceAddress } in tx ${ transferOwnershipTxHash } ` ,
677+ ) ;
678+ txHashes . push ( transferOwnershipTxHash ) ;
679+ }
680+
680681 await deployer . waitForDeployments ( ) ;
681682 await Promise . all ( txHashes . map ( txHash => extendedClient . waitForTransactionReceipt ( { hash : txHash } ) ) ) ;
682683 logger . verbose ( `Rollup deployed` ) ;
@@ -689,6 +690,8 @@ export const handoverToGovernance = async (
689690 deployer : L1Deployer ,
690691 registryAddress : EthAddress ,
691692 gseAddress : EthAddress ,
693+ coinIssuerAddress : EthAddress ,
694+ feeAssetAddress : EthAddress ,
692695 governanceAddress : EthAddress ,
693696 logger : Logger ,
694697 acceleratedTestDeployments : boolean | undefined ,
@@ -706,6 +709,18 @@ export const handoverToGovernance = async (
706709 client : extendedClient ,
707710 } ) ;
708711
712+ const coinIssuerContract = getContract ( {
713+ address : getAddress ( coinIssuerAddress . toString ( ) ) ,
714+ abi : CoinIssuerArtifact . contractAbi ,
715+ client : extendedClient ,
716+ } ) ;
717+
718+ const feeAsset = getContract ( {
719+ address : getAddress ( feeAssetAddress . toString ( ) ) ,
720+ abi : FeeAssetArtifact . contractAbi ,
721+ client : extendedClient ,
722+ } ) ;
723+
709724 const txHashes : Hex [ ] = [ ] ;
710725
711726 // If the owner is not the Governance contract, transfer ownership to the Governance contract
@@ -745,6 +760,54 @@ export const handoverToGovernance = async (
745760 txHashes . push ( transferOwnershipTxHash ) ;
746761 }
747762
763+ if ( acceleratedTestDeployments || ( await feeAsset . read . owner ( ) ) !== coinIssuerAddress . toString ( ) ) {
764+ const { txHash } = await deployer . sendTransaction (
765+ {
766+ to : feeAssetAddress . toString ( ) ,
767+ data : encodeFunctionData ( {
768+ abi : FeeAssetArtifact . contractAbi ,
769+ functionName : 'transferOwnership' ,
770+ args : [ coinIssuerAddress . toString ( ) ] ,
771+ } ) ,
772+ } ,
773+ { gasLimit : 500_000n } ,
774+ ) ;
775+ logger . verbose ( `Transfer ownership of fee asset to coin issuer ${ coinIssuerAddress } in ${ txHash } ` ) ;
776+ txHashes . push ( txHash ) ;
777+
778+ const { txHash : acceptTokenOwnershipTxHash } = await deployer . sendTransaction (
779+ {
780+ to : coinIssuerAddress . toString ( ) ,
781+ data : encodeFunctionData ( {
782+ abi : CoinIssuerArtifact . contractAbi ,
783+ functionName : 'acceptTokenOwnership' ,
784+ } ) ,
785+ } ,
786+ { gasLimit : 500_000n } ,
787+ ) ;
788+ logger . verbose ( `Accept ownership of fee asset in ${ acceptTokenOwnershipTxHash } ` ) ;
789+ txHashes . push ( acceptTokenOwnershipTxHash ) ;
790+ }
791+
792+ // If the owner is not the Governance contract, transfer ownership to the Governance contract
793+ if (
794+ acceleratedTestDeployments ||
795+ ( await coinIssuerContract . read . owner ( ) ) !== getAddress ( governanceAddress . toString ( ) )
796+ ) {
797+ const { txHash : transferOwnershipTxHash } = await deployer . sendTransaction ( {
798+ to : coinIssuerContract . address ,
799+ data : encodeFunctionData ( {
800+ abi : CoinIssuerArtifact . contractAbi ,
801+ functionName : 'transferOwnership' ,
802+ args : [ getAddress ( governanceAddress . toString ( ) ) ] ,
803+ } ) ,
804+ } ) ;
805+ logger . verbose (
806+ `Transferring the ownership of the coin issuer contract at ${ coinIssuerAddress } to the Governance ${ governanceAddress } in tx ${ transferOwnershipTxHash } ` ,
807+ ) ;
808+ txHashes . push ( transferOwnershipTxHash ) ;
809+ }
810+
748811 // Wait for all actions to be mined
749812 await deployer . waitForDeployments ( ) ;
750813 await Promise . all ( txHashes . map ( txHash => extendedClient . waitForTransactionReceipt ( { hash : txHash } ) ) ) ;
@@ -961,6 +1024,7 @@ export const deployL1Contracts = async (
9611024 governanceAddress,
9621025 rewardDistributorAddress,
9631026 zkPassportVerifierAddress,
1027+ coinIssuerAddress,
9641028 } = await deploySharedContracts ( l1Client , deployer , args , logger ) ;
9651029 const { rollup, slashFactoryAddress } = await deployRollup (
9661030 l1Client ,
@@ -972,6 +1036,7 @@ export const deployL1Contracts = async (
9721036 gseAddress,
9731037 rewardDistributorAddress,
9741038 stakingAssetAddress,
1039+ governanceAddress,
9751040 } ,
9761041 logger ,
9771042 ) ;
@@ -985,6 +1050,8 @@ export const deployL1Contracts = async (
9851050 deployer ,
9861051 registryAddress ,
9871052 gseAddress ,
1053+ coinIssuerAddress ,
1054+ feeAssetAddress ,
9881055 governanceAddress ,
9891056 logger ,
9901057 args . acceleratedTestDeployments ,
@@ -1029,6 +1096,7 @@ export const deployL1Contracts = async (
10291096 feeAssetHandlerAddress,
10301097 stakingAssetHandlerAddress,
10311098 zkPassportVerifierAddress,
1099+ coinIssuerAddress,
10321100 } ,
10331101 } ;
10341102} ;
0 commit comments