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

Inconsistent result from function for a struct with an array of enums #6739

Open
petertonysmith94 opened this issue Nov 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@petertonysmith94
Copy link

Summary

Experiencing an issue with the encoded response of the following contract function. We have replicated this issue in both the TS-SDK and RS-SDK.

From the function, we return the following struct:

// 0x000000000000000100000000000000010000000000000001
StructWithEnumArray {
    a: [EnumWithNative::Pending, EnumWithNative::Pending, EnumWithNative::Pending],
}

However, the result from the function call is the following:

// 0x000000000000000100000000000000000000000000000001
StructWithEnumArray {
    a: [EnumWithNative::Pending, EnumWithNative::Checked, EnumWithNative::Pending],
}

The return data receipt for the function call is the follow:

// raw receipt
{
  id: '0xa52541ced4559cf68e923e81ffc900d6855994bfabad4dd9f24c4dfea8e4f183',
  pc: '44544',
  is: '11712',
  ptr: '67107840',
  digest: '0x639809bc6d63798b4571d10a078c77219a7191b65eb30d8b08415d8631c1dbd9',
  len: '24',
  receiptType: 'RETURN_DATA',
  data: '0x000000000000000100000000000000000000000000000001',
}

Expected

The contract method should return:

StructWithEnumArray { a: [Pending, Pending, Pending] }

Actual

The contract method actually returns:

StructWithEnumArray { a: [Pending, Checked, Pending] }

Additional notes

When we remove the input arguments for this function, we receive the correct expected result.

fn return_struct_with_enum_array() -> StructWithEnumArray {
    const EXPECTED_ENUM = EnumWithNative::Pending;
    const EXPECTED: StructWithEnumArray = StructWithEnumArray {
        a: [EXPECTED_ENUM, EXPECTED_ENUM, EXPECTED_ENUM],
    };

    EXPECTED
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant