@@ -28,6 +28,7 @@ use std::{
28
28
str:: FromStr ,
29
29
sync:: { atomic:: AtomicBool , Arc } ,
30
30
} ;
31
+ use sway_core:: namespace:: Root ;
31
32
pub use sway_core:: Programs ;
32
33
use sway_core:: {
33
34
abi_generation:: {
@@ -50,7 +51,7 @@ use sway_core::{set_bytecode_configurables_offset, PrintAsm, PrintIr};
50
51
use sway_error:: { error:: CompileError , handler:: Handler , warning:: CompileWarning } ;
51
52
use sway_features:: ExperimentalFeatures ;
52
53
use sway_types:: constants:: { CORE , STD } ;
53
- use sway_types:: { Ident , Span , Spanned } ;
54
+ use sway_types:: { Ident , ProgramId , Span , Spanned } ;
54
55
use sway_utils:: { constants, time_expr, PerformanceData , PerformanceMetric } ;
55
56
use tracing:: { debug, info} ;
56
57
@@ -1581,13 +1582,15 @@ pub fn sway_build_config(
1581
1582
///
1582
1583
/// `contract_id_value` should only be Some when producing the `dependency_namespace` for a contract with tests enabled.
1583
1584
/// This allows us to provide a contract's `CONTRACT_ID` constant to its own unit tests.
1585
+ #[ allow( clippy:: too_many_arguments) ]
1584
1586
pub fn dependency_namespace (
1585
1587
lib_namespace_map : & HashMap < NodeIx , namespace:: Root > ,
1586
1588
compiled_contract_deps : & CompiledContractDeps ,
1587
1589
graph : & Graph ,
1588
1590
node : NodeIx ,
1589
1591
engines : & Engines ,
1590
1592
contract_id_value : Option < ContractIdConst > ,
1593
+ program_id : ProgramId ,
1591
1594
experimental : ExperimentalFeatures ,
1592
1595
) -> Result < namespace:: Root , vec1:: Vec1 < CompileError > > {
1593
1596
// TODO: Clean this up when config-time constants v1 are removed.
@@ -1597,11 +1600,12 @@ pub fn dependency_namespace(
1597
1600
namespace:: namespace_with_contract_id (
1598
1601
engines,
1599
1602
name. clone ( ) ,
1603
+ program_id,
1600
1604
contract_id_value,
1601
1605
experimental,
1602
1606
) ?
1603
1607
} else {
1604
- namespace :: namespace_without_contract_id ( name. clone ( ) )
1608
+ Root :: new ( name. clone ( ) , None , program_id , false )
1605
1609
} ;
1606
1610
1607
1611
// Add direct dependencies.
@@ -1629,6 +1633,7 @@ pub fn dependency_namespace(
1629
1633
namespace:: namespace_with_contract_id (
1630
1634
engines,
1631
1635
name. clone ( ) ,
1636
+ program_id,
1632
1637
contract_id_value,
1633
1638
experimental,
1634
1639
) ?
@@ -2444,6 +2449,10 @@ pub fn build(
2444
2449
..profile. clone ( )
2445
2450
} ;
2446
2451
2452
+ let program_id = engines
2453
+ . se ( )
2454
+ . get_or_create_program_id_from_manifest_path ( & manifest. entry_path ( ) ) ;
2455
+
2447
2456
// `ContractIdConst` is a None here since we do not yet have a
2448
2457
// contract ID value at this point.
2449
2458
let dep_namespace = match dependency_namespace (
@@ -2453,6 +2462,7 @@ pub fn build(
2453
2462
node,
2454
2463
& engines,
2455
2464
None ,
2465
+ program_id,
2456
2466
experimental,
2457
2467
) {
2458
2468
Ok ( o) => o,
@@ -2510,6 +2520,10 @@ pub fn build(
2510
2520
profile. clone ( )
2511
2521
} ;
2512
2522
2523
+ let program_id = engines
2524
+ . se ( )
2525
+ . get_or_create_program_id_from_manifest_path ( & manifest. entry_path ( ) ) ;
2526
+
2513
2527
// Note that the contract ID value here is only Some if tests are enabled.
2514
2528
let dep_namespace = match dependency_namespace (
2515
2529
& lib_namespace_map,
@@ -2518,6 +2532,7 @@ pub fn build(
2518
2532
node,
2519
2533
& engines,
2520
2534
contract_id_value. clone ( ) ,
2535
+ program_id,
2521
2536
experimental,
2522
2537
) {
2523
2538
Ok ( o) => o,
@@ -2617,13 +2632,18 @@ pub fn check(
2617
2632
let contract_id_value =
2618
2633
( idx == plan. compilation_order . len ( ) - 1 ) . then ( || DUMMY_CONTRACT_ID . to_string ( ) ) ;
2619
2634
2635
+ let program_id = engines
2636
+ . se ( )
2637
+ . get_or_create_program_id_from_manifest_path ( & manifest. entry_path ( ) ) ;
2638
+
2620
2639
let dep_namespace = dependency_namespace (
2621
2640
& lib_namespace_map,
2622
2641
& compiled_contract_deps,
2623
2642
& plan. graph ,
2624
2643
node,
2625
2644
engines,
2626
2645
contract_id_value,
2646
+ program_id,
2627
2647
experimental,
2628
2648
)
2629
2649
. expect ( "failed to create dependency namespace" ) ;
0 commit comments