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

feat: support returning Vec<> types from contracts #848

Merged
merged 32 commits into from
Mar 13, 2023

Conversation

iqdecay
Copy link
Contributor

@iqdecay iqdecay commented Feb 16, 2023

This PR closes #746 by allowing the user to return a vector containing any type
from a smart contract.
It relies on one main change:

  • The script that uses the CALL opcode on the contract now needs the output
    type of the contract call to work properly. Indeed, to know how many bytes
    the vector takes in VM memory and return all these bytes, you need to know
    the encoding width of the inner type of the vector.

@iqdecay iqdecay requested a review from digorithm as a code owner February 16, 2023 18:48
@iqdecay iqdecay self-assigned this Feb 16, 2023
@iqdecay iqdecay requested review from mohammadfawaz and a team February 16, 2023 18:52
@iqdecay iqdecay mentioned this pull request Feb 23, 2023
packages/fuels-core/src/abi_decoder.rs Outdated Show resolved Hide resolved
packages/fuels-core/src/abi_decoder.rs Outdated Show resolved Hide resolved
packages/fuels-core/src/abi_decoder.rs Outdated Show resolved Hide resolved
packages/fuels-programs/src/call_utils.rs Outdated Show resolved Hide resolved
packages/fuels-programs/src/call_utils.rs Outdated Show resolved Hide resolved
packages/fuels-programs/src/contract.rs Outdated Show resolved Hide resolved
packages/fuels/tests/types.rs Outdated Show resolved Hide resolved
packages/fuels/tests/types.rs Outdated Show resolved Hide resolved
packages/fuels/tests/types.rs Outdated Show resolved Hide resolved
@segfault-magnet
Copy link
Contributor

Review done alongside @hal3e

Is returning Vectors from scripts planned as well @digorithm @iqdecay ?

@iqdecay
Copy link
Contributor Author

iqdecay commented Mar 2, 2023

Is returning Vectors from scripts planned as well @digorithm @iqdecay ?

Tracking in #866

Copy link
Contributor

@hal3e hal3e left a comment

Choose a reason for hiding this comment

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

Reviewed alongside @segfault-magnet

packages/fuels-core/src/abi_decoder.rs Outdated Show resolved Hide resolved
packages/fuels-programs/src/contract.rs Outdated Show resolved Hide resolved
packages/fuels-types/src/param_types.rs Outdated Show resolved Hide resolved
packages/fuels-core/src/abi_decoder.rs Show resolved Hide resolved
packages/fuels-programs/src/call_utils.rs Outdated Show resolved Hide resolved
@iqdecay iqdecay enabled auto-merge (squash) March 10, 2023 19:37
@iqdecay iqdecay requested review from a team, hal3e and segfault-magnet and removed request for hal3e March 10, 2023 21:13
Copy link
Contributor

@segfault-magnet segfault-magnet left a comment

Choose a reason for hiding this comment

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

Reviewed with @hal3e

packages/fuels-types/src/param_types.rs Outdated Show resolved Hide resolved
Co-authored-by: Ahmed Sagdati <37515857+segfault-magnet@users.noreply.github.com>
@iqdecay iqdecay requested a review from segfault-magnet March 13, 2023 12:54
Copy link
Contributor

@segfault-magnet segfault-magnet left a comment

Choose a reason for hiding this comment

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

🎉

@iqdecay iqdecay merged commit 5dde0bd into master Mar 13, 2023
@iqdecay iqdecay deleted the iqdecay/feat-contract-vec-return branch March 13, 2023 14:18
mohammadfawaz pushed a commit to FuelLabs/sway that referenced this pull request Apr 12, 2023
- This PR enables returning heap types from scripts.
- In FuelLabs/fuels-rs#848, support was added
for
returning vectors from smart contracts in the SDK, this safeguard can
now be
  removed so the same can happen with scripts.
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.

Transform Vec return from a contract into a raw_slice return from the calling scripts
6 participants