Skip to content

feat[docs]: add docs for @raw_return decorator#4699

Merged
charles-cooper merged 7 commits intovyperlang:masterfrom
charles-cooper:docs/raw_return
Jun 17, 2025
Merged

feat[docs]: add docs for @raw_return decorator#4699
charles-cooper merged 7 commits intovyperlang:masterfrom
charles-cooper:docs/raw_return

Conversation

@charles-cooper
Copy link
Copy Markdown
Member

What I did

How I did it

How to verify it

Commit message

Commit message for the final, squashed PR. (Optional, but reviewers will appreciate it! Please see our commit message style guide for what we would ideally like to see in a commit message.)

Description for the changelog

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@charles-cooper charles-cooper marked this pull request as ready for review June 16, 2025 10:14
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.94%. Comparing base (94750db) to head (596a5c1).
⚠️ Report is 31 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4699   +/-   ##
=======================================
  Coverage   92.94%   92.94%           
=======================================
  Files         131      131           
  Lines       19037    19037           
  Branches     3309     3309           
=======================================
  Hits        17694    17694           
  Misses        905      905           
  Partials      438      438           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

``@view`` Function does not alter contract state
``@payable`` Function is able to receive Ether
``@nonreentrant`` Function cannot be called back into during an external call
``@raw_return`` Function returns raw bytes without ABI-encoding (external functions only)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
``@raw_return`` Function returns raw bytes without ABI-encoding (external functions only)
``@raw_return`` Function returns raw bytes without ABI-encoding (``@external`` functions only)

* It can only be used on ``@external`` functions
* The function must have a ``Bytes[N]`` return type
* It cannot be used on ``@deploy`` (constructor) functions
* It cannot be used on internal functions
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* It cannot be used on internal functions
* It cannot be used on ``@internal`` functions

@raw_return
def forward_call(target: address) -> Bytes[1024]:
# Returns the raw bytes from the external call without ABI-encoding
return raw_call(target, msg.data, max_outsize=1024, is_delegate_call=True)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

to make the example more generic, let's add @payable and also msg.value to raw_call


* It can only be used on ``@external`` functions
* The function must have a ``Bytes[N]`` return type
* It cannot be used on ``@deploy`` (constructor) functions
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* It cannot be used on ``@deploy`` (constructor) functions
* It cannot be used on ``@deploy`` (constructor) functions (you can however use it in the `__default__()` function)

@cyberthirst
Copy link
Copy Markdown
Collaborator

maybe let's add a note that calling such function via interface is impossible and that raw_call has to be used

@cyberthirst
Copy link
Copy Markdown
Collaborator

also maybe mention the potential pitfall of having multiple return statements one of which doesn't expect the data to not be abi encoded

@charles-cooper charles-cooper merged commit 1c86f70 into vyperlang:master Jun 17, 2025
161 checks passed
@charles-cooper charles-cooper deleted the docs/raw_return branch June 17, 2025 11:51
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.

3 participants