Skip to content

Commit

Permalink
fix: inject contract_dependency::CONTRACT_ID as b256 (FuelLabs#3412)
Browse files Browse the repository at this point in the history
  • Loading branch information
kayagokalp authored Nov 29, 2022
1 parent 22db07e commit a7a1942
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion forc-pkg/src/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2123,7 +2123,7 @@ pub fn dependency_namespace(

// Construct namespace with contract id
let contract_dep_constant_name = "CONTRACT_ID";
let contract_id_value = format!("\"{dep_contract_id}\"");
let contract_id_value = format!("0x{dep_contract_id}");
let contract_id_constant = ConfigTimeConstant {
r#type: "b256".to_string(),
value: contract_id_value,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[[package]]
name = 'contract_a'
source = 'member'
dependencies = ['std']
contract-dependencies = [
'contract_b',
'contract_c',
Expand All @@ -14,3 +15,12 @@ contract-dependencies = ['contract_c']
[[package]]
name = 'contract_c'
source = 'path+from-root-C28B6153CE3E3FEB'

[[package]]
name = 'core'
source = 'path+from-root-C28B6153CE3E3FEB'

[[package]]
name = 'std'
source = 'path+from-root-C28B6153CE3E3FEB'
dependencies = ['core']
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ implicit-std = false
license = "Apache-2.0"
name = "contract_a"

[dependencies]
std = { path = "../../../../../../../../sway-lib-std/" }

[contract-dependencies]
contract_b = { path = "../contract_b" }
contract_c = { path = "../contract_c" }
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ use contract_b::CONTRACT_ID as CONTRACT_B_ID;
use contract_c::CONTRACT_ID as CONTRACT_C_ID;

abi MyContract {
fn test_function();
fn test_function();
}

impl MyContract for Contract {
fn test_function() {
let CONTRACT_B_ID = CONTRACT_B_ID;
let CONTRACT_C_ID = CONTRACT_C_ID;
}
}

impl MyContract for Contract {
fn test_function() {
let CONTRACT_B = CONTRACT_B_ID;
let CONTRACT_C = CONTRACT_C_ID;
let contract_b_id = ContractId::from(CONTRACT_B);
let contract_c_id = ContractId::from(CONTRACT_C);
}
}

0 comments on commit a7a1942

Please sign in to comment.