Skip to content

feat(soroban): support bytesN as function parameters and return values#1908

Open
aryanbaranwal001 wants to merge 6 commits into
hyperledger-solang:mainfrom
aryanbaranwal001:feat/soroban-bytes-n-codec
Open

feat(soroban): support bytesN as function parameters and return values#1908
aryanbaranwal001 wants to merge 6 commits into
hyperledger-solang:mainfrom
aryanbaranwal001:feat/soroban-bytes-n-codec

Conversation

@aryanbaranwal001
Copy link
Copy Markdown

Description

Adds support for bytesN (bytes1bytes32) solidity function parameters or return types for the Soroban target. The following now compiles to valid WASM and round trips through the host.

contract BytesNCodec {
    function echo_bytes5(bytes5 x) public pure returns (bytes5) {
        return x;
    }
}

Key Changes

  • codegen/encoding/soroban_encoding.rs: added Type::Bytes(n) arms to soroban_decode_arg and soroban_encode_arg. All 1 ≤ n ≤ 32 route through BytesObject via bytes_copy_to_linear_memory (decode) and bytes_new_from_linear_memory (encode), matching soroban-sdk's BytesN<N> wire format.

Tests

  • Added 3 tests in tests/soroban_testcases/bytes_n_codec.rs covering narrow, non-natural, and wide LLVM integer widths.

… and codec

Signed-off-by: Aryan Baranwal <aryanbaranwal131214@gmail.com>
Signed-off-by: Aryan Baranwal <aryanbaranwal131214@gmail.com>
…alues

Signed-off-by: Aryan Baranwal <aryanbaranwal131214@gmail.com>
Signed-off-by: Aryan Baranwal <aryanbaranwal131214@gmail.com>
Signed-off-by: Aryan Baranwal <aryanbaranwal131214@gmail.com>
…, bytes32

Signed-off-by: Aryan Baranwal <aryanbaranwal131214@gmail.com>
@aryanbaranwal001
Copy link
Copy Markdown
Author

This PR is continuation of the work in #1904 and depends on it.

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.

1 participant