@@ -178,38 +178,45 @@ export default class Blockchain {
178
178
return web3 . currentProvider ;
179
179
}
180
180
181
- addArtifactFile ( _params , cb ) {
181
+ async addArtifactFile ( _params , cb ) {
182
182
if ( ! this . blockchainConfig . enabled ) {
183
183
cb ( ) ;
184
184
}
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
- } ;
204
185
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
+ } ) ;
211
216
} ) ;
212
- } ) ;
217
+ } catch ( e ) {
218
+ cb ( e ) ;
219
+ }
213
220
}
214
221
215
222
registerConsoleCommands ( ) {
0 commit comments