@@ -66,26 +66,26 @@ class ENS {
6666 async . map (
6767 this . config . namesystemConfig . dappConnection || this . config . contractsConfig . dappConnection ,
6868 ( conn , next ) => {
69- if ( conn === '$EMBARK' ) {
70- return this . events . request ( 'proxy:endpoint:get' , next ) ;
71- }
72- next ( null , conn ) ;
73- } , ( err , connections ) => {
74- if ( err ) {
75- return done ( err ) ;
76- }
77- done ( null , {
78- env : this . env ,
79- registration : this . config . namesystemConfig . register ,
80- registryAbi : this . ensConfig . ENSRegistry . abiDefinition ,
81- registryAddress : this . ensConfig . ENSRegistry . deployedAddress ,
82- registrarAbi : this . ensConfig . FIFSRegistrar . abiDefinition ,
83- registrarAddress : this . ensConfig . FIFSRegistrar . deployedAddress ,
84- resolverAbi : this . ensConfig . Resolver . abiDefinition ,
85- resolverAddress : this . ensConfig . Resolver . deployedAddress ,
86- dappConnection : connections
69+ if ( conn === '$EMBARK' ) {
70+ return this . events . request ( 'proxy:endpoint:get' , next ) ;
71+ }
72+ next ( null , conn ) ;
73+ } , ( err , connections ) => {
74+ if ( err ) {
75+ return done ( err ) ;
76+ }
77+ done ( null , {
78+ env : this . env ,
79+ registration : this . config . namesystemConfig . register ,
80+ registryAbi : this . ensConfig . ENSRegistry . abiDefinition ,
81+ registryAddress : this . ensConfig . ENSRegistry . deployedAddress ,
82+ registrarAbi : this . ensConfig . FIFSRegistrar . abiDefinition ,
83+ registrarAddress : this . ensConfig . FIFSRegistrar . deployedAddress ,
84+ resolverAbi : this . ensConfig . Resolver . abiDefinition ,
85+ resolverAddress : this . ensConfig . Resolver . deployedAddress ,
86+ dappConnection : connections
87+ } ) ;
8788 } ) ;
88- } ) ;
8989 }
9090
9191 async init ( cb = ( ) => { } ) {
@@ -110,6 +110,7 @@ class ENS {
110110 return ;
111111 }
112112 this . actionsRegistered = true ;
113+ this . embark . registerActionForEvent ( "contracts:build:before" , this . beforeContractBuild . bind ( this ) ) ;
113114 this . embark . registerActionForEvent ( "deployment:deployContracts:beforeAll" , this . configureContractsAndRegister . bind ( this ) ) ;
114115 this . embark . registerActionForEvent ( 'deployment:contract:beforeDeploy' , this . modifyENSArguments . bind ( this ) ) ;
115116 this . embark . registerActionForEvent ( "deployment:deployContracts:afterAll" , this . associateContractAddresses . bind ( this ) ) ;
@@ -271,6 +272,17 @@ class ENS {
271272 } ) ;
272273 }
273274
275+ async beforeContractBuild ( _options , cb ) {
276+ if ( this . configured ) {
277+ return cb ( ) ;
278+ }
279+ // Add contracts to contract manager so that they can be resolved as dependencies
280+ this . ensConfig . ENSRegistry = await this . events . request2 ( 'contracts:add' , this . ensConfig . ENSRegistry ) ;
281+ this . ensConfig . Resolver = await this . events . request2 ( 'contracts:add' , this . ensConfig . Resolver ) ;
282+ this . ensConfig . FIFSRegistrar = await this . events . request2 ( 'contracts:add' , this . ensConfig . FIFSRegistrar ) ;
283+ cb ( ) ;
284+ }
285+
274286 async configureContractsAndRegister ( _options , cb ) {
275287 const NO_REGISTRATION = 'NO_REGISTRATION' ;
276288 const self = this ;
@@ -292,8 +304,8 @@ class ENS {
292304 const registration = this . config . namesystemConfig . register ;
293305 const doRegister = registration && registration . rootDomain ;
294306
295- this . ensConfig . ENSRegistry = await this . events . request2 ( 'contracts:add' , this . ensConfig . ENSRegistry ) ;
296307 await this . events . request2 ( 'deployment:contract:deploy' , this . ensConfig . ENSRegistry ) ;
308+ // Add Resolver to contract manager again but this time with correct arguments (Registry address)
297309 this . ensConfig . Resolver . args = [ this . ensConfig . ENSRegistry . deployedAddress ] ;
298310 this . ensConfig . Resolver = await this . events . request2 ( 'contracts:add' , this . ensConfig . Resolver ) ;
299311 await this . events . request2 ( 'deployment:contract:deploy' , this . ensConfig . Resolver ) ;
0 commit comments