Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AbiDecode for arrays using const_generics #7008

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

xunilrj
Copy link
Contributor

@xunilrj xunilrj commented Mar 10, 2025

Description

This is part of #6860.

This completes abi encoding for arrays. Allowing arrays of any size as inputs and outputs in predicates/scripts/contracts.
This PR also allows arrays to be initialized with "const generics" such as:

#[cfg(experimental_const_generics = true)]
impl<T, const N: u64> AbiDecode for [T; N]
where
    T: AbiDecode,
{
    fn abi_decode(ref mut buffer: BufferReader) -> [T; N] {
        let first: T = buffer.decode::<T>();
        let mut array = [first; N];  // <-------------------- This can used now
        ...
        array
    }
}

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@xunilrj xunilrj force-pushed the xunilrj/abi-decode-for-arrays branch from 218afe8 to 0a62db8 Compare March 10, 2025 14:21
Copy link

codspeed-hq bot commented Mar 10, 2025

CodSpeed Performance Report

Merging #7008 will not alter performance

Comparing xunilrj/abi-decode-for-arrays (08bf291) with master (13621ae)

Summary

✅ 22 untouched benchmarks

@xunilrj xunilrj self-assigned this Mar 10, 2025
@xunilrj xunilrj marked this pull request as ready for review March 10, 2025 18:57
@xunilrj xunilrj requested review from a team as code owners March 10, 2025 18:57
@xunilrj xunilrj mentioned this pull request Feb 13, 2025
12 tasks
Copy link
Contributor

@zees-dev zees-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very useful functionality; LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants