Skip to content

Commit bc4048a

Browse files
committed
Add experimental ABI alias metadata support.
1 parent f060943 commit bc4048a

File tree

33 files changed

+2290
-773
lines changed

33 files changed

+2290
-773
lines changed

Cargo.lock

Lines changed: 667 additions & 702 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ sway-ir-macros = { path = "sway-ir/sway-ir-macros", version = "0.70.1" }
8080
#
8181

8282
# Dependencies from the `fuel-abi-types` repository:
83-
fuel-abi-types = "0.15"
83+
fuel-abi-types = "0.16"
8484

8585
# Dependencies from the `fuel-core` repository:
8686
#
@@ -95,9 +95,9 @@ fuel-core-types = { version = "0.47", default-features = false }
9595

9696
# Dependencies from the `fuels-rs` repository:
9797

98-
fuels = "0.76"
99-
fuels-core = "0.76"
100-
fuels-accounts = "0.76"
98+
fuels = { path = "../fuels-rs/packages/fuels", version = "0.76.0" }
99+
fuels-core = { path = "../fuels-rs/packages/fuels-core", version = "0.76.0" }
100+
fuels-accounts = { path = "../fuels-rs/packages/fuels-accounts", version = "0.76.0" }
101101

102102
# Dependencies from the `fuel-vm` repository:
103103
fuel-asm = "0.65"
@@ -259,3 +259,9 @@ vte = "0.13"
259259
walkdir = "2.3"
260260
whoami = "1.5"
261261
wiremock = "0.6"
262+
263+
[patch.crates-io]
264+
fuels = { git = "https://github.com/FuelLabs/fuels-rs", branch = "feat/alias-type" }
265+
fuels-core = { git = "https://github.com/FuelLabs/fuels-rs", branch = "feat/alias-type" }
266+
fuels-accounts = { git = "https://github.com/FuelLabs/fuels-rs", branch = "feat/alias-type" }
267+
fuels-code-gen = { git = "https://github.com/FuelLabs/fuels-rs", branch = "feat/alias-type" }

forc-pkg/src/pkg.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,6 +1811,9 @@ pub fn compile(
18111811
abi_with_callpaths: true,
18121812
type_ids_to_full_type_str: HashMap::<String, String>::new(),
18131813
unique_names: HashMap::new(),
1814+
metadata_declaration_cache: HashMap::new(),
1815+
concrete_declaration_cache: HashMap::new(),
1816+
experimental,
18141817
},
18151818
engines,
18161819
if experimental.new_encoding {

sway-core/src/abi_generation/abi_str.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub struct AbiStrContext {
1111
pub abi_with_callpaths: bool,
1212
pub abi_with_fully_specified_types: bool,
1313
pub abi_root_type_without_generic_type_parameters: bool,
14+
pub abi_type_aliases: bool,
1415
}
1516

1617
impl TypeId {
@@ -37,9 +38,10 @@ impl TypeId {
3738
| (TypeInfo::Custom { .. }, TypeInfo::Enum { .. }) => type_engine
3839
.get(resolved_type_id)
3940
.abi_str(handler, ctx, engines, true),
40-
(_, TypeInfo::Alias { ty, .. }) => ty
41+
(_, TypeInfo::Alias { ty, .. }) if !ctx.abi_type_aliases => ty
4142
.type_id
4243
.get_abi_type_str(handler, ctx, engines, ty.type_id),
44+
(_, TypeInfo::Alias { .. }) => Ok(self_abi_str),
4345
(TypeInfo::Tuple(fields), TypeInfo::Tuple(resolved_fields)) => {
4446
assert_eq!(fields.len(), resolved_fields.len());
4547
let field_strs = resolved_fields
@@ -204,7 +206,13 @@ impl TypeInfo {
204206
"__slice {}",
205207
ty.abi_str(handler, ctx, engines, false)?
206208
)),
207-
Alias { ty, .. } => Ok(ty.abi_str(handler, ctx, engines, false)?),
209+
Alias { name, ty } => {
210+
if ctx.abi_type_aliases {
211+
Ok(name.to_string())
212+
} else {
213+
ty.abi_str(handler, ctx, engines, false)
214+
}
215+
}
208216
TraitType {
209217
name,
210218
implemented_in: _,

0 commit comments

Comments
 (0)