Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,321 changes: 644 additions & 677 deletions Cargo.lock

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ sway-ir-macros = { path = "sway-ir/sway-ir-macros", version = "0.70.1" }
#

# Dependencies from the `fuel-abi-types` repository:
fuel-abi-types = "0.15"
fuel-abi-types = "0.16"

# Dependencies from the `fuel-core` repository:
#
Expand Down Expand Up @@ -259,3 +259,9 @@ vte = "0.13"
walkdir = "2.3"
whoami = "1.5"
wiremock = "0.6"

[patch.crates-io]
fuels = { git = "https://github.com/FuelLabs/fuels-rs", branch = "feat/bump-fuel-abi-types-0.16.0" }
fuels-core = { git = "https://github.com/FuelLabs/fuels-rs", branch = "feat/bump-fuel-abi-types-0.16.0" }
fuels-accounts = { git = "https://github.com/FuelLabs/fuels-rs", branch = "feat/bump-fuel-abi-types-0.16.0" }
fuels-code-gen = { git = "https://github.com/FuelLabs/fuels-rs", branch = "feat/bump-fuel-abi-types-0.16.0" }
6 changes: 6 additions & 0 deletions docs/book/src/reference/experimental_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,9 @@ fn conditionally_compiled() {
log("This is compiled only if both `some_feature` and `some_other_feature` are enabled.");
}
```

## Tracking Experimental Features

- `abi_type_aliases` — keeps the JSON ABI emitter from expanding type aliases into their target type when serializing a contract's ABI, allowing the published JSON to preserve the original alias names.

See the tracking issue for this feature [here](https://github.com/FuelLabs/sway/issues/7486).
4 changes: 4 additions & 0 deletions forc-pkg/src/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,10 @@ pub fn compile(
abi_with_callpaths: true,
type_ids_to_full_type_str: HashMap::<String, String>::new(),
unique_names: HashMap::new(),
metadata_declaration_cache: HashMap::new(),
concrete_declaration_cache: HashMap::new(),
type_cache_enabled: experimental.abi_type_aliases,
experimental,
},
engines,
if experimental.new_encoding {
Expand Down
14 changes: 11 additions & 3 deletions sway-core/src/abi_generation/abi_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub struct AbiStrContext {
pub abi_with_callpaths: bool,
pub abi_with_fully_specified_types: bool,
pub abi_root_type_without_generic_type_parameters: bool,
pub abi_type_aliases: bool,
}

impl TypeId {
Expand All @@ -26,7 +27,7 @@ impl TypeId {
let self_abi_str = type_engine
.get(*self)
.abi_str(handler, ctx, engines, true)?;
if self.is_generic_parameter(engines, resolved_type_id) {
if self.is_generic_parameter(engines, resolved_type_id, ctx.abi_type_aliases) {
Ok(format!("generic {self_abi_str}"))
} else {
match (
Expand All @@ -37,9 +38,10 @@ impl TypeId {
| (TypeInfo::Custom { .. }, TypeInfo::Enum { .. }) => type_engine
.get(resolved_type_id)
.abi_str(handler, ctx, engines, true),
(_, TypeInfo::Alias { ty, .. }) => ty
(_, TypeInfo::Alias { ty, .. }) if !ctx.abi_type_aliases => ty
.type_id
.get_abi_type_str(handler, ctx, engines, ty.type_id),
(_, TypeInfo::Alias { .. }) => Ok(self_abi_str),
(TypeInfo::Tuple(fields), TypeInfo::Tuple(resolved_fields)) => {
assert_eq!(fields.len(), resolved_fields.len());
let field_strs = resolved_fields
Expand Down Expand Up @@ -204,7 +206,13 @@ impl TypeInfo {
"__slice {}",
ty.abi_str(handler, ctx, engines, false)?
)),
Alias { ty, .. } => Ok(ty.abi_str(handler, ctx, engines, false)?),
Alias { name, ty } => {
if ctx.abi_type_aliases {
Ok(name.to_string())
} else {
ty.abi_str(handler, ctx, engines, false)
}
}
TraitType {
name,
implemented_in: _,
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/abi_generation/evm_abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn generate_abi_program(program: &TyProgram, engines: &Engines) -> EvmAbiRes
/// Gives back a string that represents the type, considering what it resolves to
fn get_type_str(type_id: &TypeId, engines: &Engines, resolved_type_id: TypeId) -> String {
let type_engine = engines.te();
if type_id.is_generic_parameter(engines, resolved_type_id) {
if type_id.is_generic_parameter(engines, resolved_type_id, false) {
format!("generic {}", abi_str(&type_engine.get(*type_id), engines))
} else {
match (
Expand Down
Loading
Loading