Skip to content

feat(ethexe): add an attribute #[sails_rs::return(...)] to specify name of returned values from function #860

@StackOverflowExcept1on

Description

@StackOverflowExcept1on

Problem to Solve

#[sails_rs::service(events = Events)]
impl SomeService {
    #[sails_rs::return(r1)]
    pub async fn do_this(&mut self, p1: u32, p2: sails_rs::String) -> u32 {
        self.emit_eth_event(Events::DoThisEvent(p1 * 2, p2 + "hey from sails!")).unwrap();
        p1 * 2
    }
    #[sails_rs::return(r1)]
    pub fn this(&self, p1: bool) -> bool {
        !p1
    }
}

We can then use this name when generating callbacks:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28;

interface IEthAppWithEventsCallbacks {
    function replyOn_svc1DoThis(bytes32 messageId, uint32 r1) external;

    function replyOn_svc1This(bytes32 messageId, bool r1) external;

    function errorReply(bytes32 messageId, bytes4 replyCode) external;
}

This should also work for tuples. The user can add multiple #[sails_rs::return(r1)] on each line, similar to Solidity's docstrings: https://github.com/StackOverflowExcept1on/frost-secp256k1-evm/blob/40ad4da33913be370ba304be3918dee64430ad09/src/FROST.sol#L68-L69

Possible Solution

N/A

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions