@@ -178,38 +178,45 @@ export default class Blockchain {
178178 return web3 . currentProvider ;
179179 }
180180
181- addArtifactFile ( _params , cb ) {
181+ async addArtifactFile ( _params , cb ) {
182182 if ( ! this . blockchainConfig . enabled ) {
183183 cb ( ) ;
184184 }
185- this . events . request ( "config:contractsConfig" , ( _err , contractsConfig ) => {
186- async . map ( contractsConfig . dappConnection , ( conn , mapCb ) => {
187- if ( conn === '$EMBARK' ) {
188- // Connect to Embark's endpoint (proxy)
189- return this . events . request ( "proxy:endpoint:get" , mapCb ) ;
190- }
191- mapCb ( null , conn ) ;
192- } , ( err , results ) => {
193- if ( err ) {
194- this . logger . error ( __ ( 'Error getting dapp connection' ) ) ;
195- return cb ( err ) ;
196- }
197- const config = {
198- provider : contractsConfig . library || 'web3' ,
199- dappConnection : results ,
200- dappAutoEnable : contractsConfig . dappAutoEnable ,
201- warnIfMetamask : this . blockchainConfig . isDev ,
202- blockchainClient : this . blockchainConfig . client
203- } ;
204185
205- this . events . request ( "pipeline:register" , {
206- path : [ this . embarkConfig . generationDir , 'config' ] ,
207- file : 'blockchain.json' ,
208- format : 'json' ,
209- content : config
210- } , cb ) ;
186+ try {
187+ const networkId = await this . events . request2 ( 'blockchain:networkId' ) ;
188+ this . events . request ( "config:contractsConfig" , ( _err , contractsConfig ) => {
189+ async . map ( contractsConfig . dappConnection , ( conn , mapCb ) => {
190+ if ( conn === '$EMBARK' ) {
191+ // Connect to Embark's endpoint (proxy)
192+ return this . events . request ( "proxy:endpoint:get" , mapCb ) ;
193+ }
194+ mapCb ( null , conn ) ;
195+ } , ( err , results ) => {
196+ if ( err ) {
197+ this . logger . error ( __ ( 'Error getting dapp connection' ) ) ;
198+ return cb ( err ) ;
199+ }
200+ const config = {
201+ provider : contractsConfig . library || 'web3' ,
202+ dappConnection : results ,
203+ dappAutoEnable : contractsConfig . dappAutoEnable ,
204+ warnIfMetamask : this . blockchainConfig . isDev ,
205+ blockchainClient : this . blockchainConfig . client ,
206+ networkId
207+ } ;
208+
209+ this . events . request ( "pipeline:register" , {
210+ path : [ this . embarkConfig . generationDir , 'config' ] ,
211+ file : 'blockchain.json' ,
212+ format : 'json' ,
213+ content : config
214+ } , cb ) ;
215+ } ) ;
211216 } ) ;
212- } ) ;
217+ } catch ( e ) {
218+ cb ( e ) ;
219+ }
213220 }
214221
215222 registerConsoleCommands ( ) {
0 commit comments