@@ -11,10 +11,11 @@ import {
1111 getConfigEnvironmentVariable ,
1212 getNetworkChainId ,
1313 sumedFees ,
14+ transferStatusInterval ,
1415 mapNetworkArgs ,
1516} from "./utils" ;
1617import { AdapterABI } from "./adapterABI" ;
17- import { DeployOptions , NetworkArguments } from "./types" ;
18+ import { DeployOptions , DeploymentInfo , NetworkArguments } from "./types" ;
1819
1920export class MultichainHardhatRuntimeEnvironmentField {
2021 private isInitiated : boolean = false ;
@@ -62,7 +63,10 @@ export class MultichainHardhatRuntimeEnvironmentField {
6263 contractName : string ,
6364 networkArgs : NetworkArguments < Abi > ,
6465 options ?: DeployOptions
65- ) : Promise < Transaction | void > {
66+ ) : Promise < {
67+ deploymentInfo : DeploymentInfo [ ] ;
68+ receipt : Transaction ;
69+ } | void > {
6670 const artifact = this . hre . artifacts . readArtifactSync ( contractName ) ;
6771
6872 return this . deployMultichainBytecode (
@@ -78,7 +82,10 @@ export class MultichainHardhatRuntimeEnvironmentField {
7882 contractAbi : Abi ,
7983 networkArgs : NetworkArguments < Abi > ,
8084 options ?: DeployOptions
81- ) : Promise < Transaction | void > {
85+ ) : Promise < {
86+ deploymentInfo : DeploymentInfo [ ] ;
87+ receipt : Transaction ;
88+ } | void > {
8289 if ( ! this . isInitiated ) await this . initConfig ( ) ;
8390 if ( ! this . web3 ) return ;
8491
@@ -118,8 +125,8 @@ export class MultichainHardhatRuntimeEnvironmentField {
118125 value : sumedFees ( fees ) ,
119126 } ;
120127 }
121-
122- return adapterContract . methods
128+ console . log ( "Sending transaction..." ) ;
129+ const receipt = await adapterContract . methods
123130 . deploy (
124131 contractBytecode ,
125132 this . gasLimit ,
@@ -131,5 +138,62 @@ export class MultichainHardhatRuntimeEnvironmentField {
131138 fees
132139 )
133140 . send ( payableTxOptions ) ;
141+ const networkNames = Object . keys ( networkArgs ) ;
142+ const { transactionHash } = receipt ;
143+ console . log (
144+ `Multichain deployment initiated, transaction hash: ${ transactionHash }
145+
146+ ` +
147+ "\n" +
148+ "Destinaton networks:" +
149+ networkNames . join ( "\r\n" )
150+ ) ;
151+
152+ const [ deployer ] = await this . web3 . eth . getAccounts ( ) ;
153+
154+ const destinationDomainChainIDs = deployDomainIDs . map ( ( deployDomainID ) => {
155+ const deployDomain : Domain = this . domains . find (
156+ ( domain ) => BigInt ( domain . id ) === deployDomainID
157+ ) ! ;
158+ return deployDomain . chainId ;
159+ } ) ;
160+
161+ const deploymentInfo : DeploymentInfo [ ] = await Promise . all (
162+ destinationDomainChainIDs . map ( async ( domainChainID , index ) => {
163+ const network = networkNames [ index ] ;
164+
165+ const contractAddress = await adapterContract . methods
166+ . computeContractAddressForChain (
167+ deployer ,
168+ salt ,
169+ isUniquePerChain ,
170+ domainChainID
171+ )
172+ . call ( ) ;
173+ console . log (
174+ `Contract deploying on ${ network . toUpperCase ( ) } : ${ contractAddress } `
175+ ) ;
176+
177+ const explorerUrl = await transferStatusInterval (
178+ this . hre . config . multichain . environment ,
179+ transactionHash ,
180+ domainChainID
181+ ) ;
182+
183+ console . log ( `Bridge transfer executed. More details: ${ explorerUrl } ` ) ;
184+
185+ return {
186+ network,
187+ contractAddress,
188+ explorerUrl,
189+ transactionHash,
190+ } ;
191+ } )
192+ ) ;
193+
194+ return {
195+ receipt,
196+ deploymentInfo,
197+ } ;
134198 }
135199}
0 commit comments