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

[BUG] TypeError when transferring asset due to incorrect argument type conversion #205

Closed
AlexStroke opened this issue Jun 10, 2024 · 1 comment
Assignees

Comments

@AlexStroke
Copy link
Contributor

AlexStroke commented Jun 10, 2024

Description:
A TypeError occurs when attempting to transfer an asset in the test test_transfer_asset. The function transfer expects an argument of type AssetId, but a string is being passed instead.

Steps to Reproduce:

def test_transfer_asset(
    GIVEN_minted_asset,
    GIVEN_registered_account):
    with allure.step(
            f'WHEN client transfers an asset'):
        (client.submit_executable_only_success(
            [iroha.Instruction.
            transfer(
                5,
                GIVEN_minted_asset,
                GIVEN_registered_account)]))

Expected Behavior:
The transfer function should successfully convert the string argument to the appropriate AssetId type within the Rust implementation, avoiding the TypeError.

Actual Behavior:
telegram-cloud-photo-size-2-5411619597544708960-y

Code Reference:

...[pymethods]
impl PyAssetId {
    #[new]
    fn new(definition_id: PyAssetDefinitionId, account_id: PyAccountId) -> PyResult<Self> {
        Ok(Self(AssetId::new(definition_id.into(), account_id.into())))
    }

Developer's Comment:
"I think this API is not good. I should change it to take a string from Python and convert inside Rust to the right type."

@SamHSmith SamHSmith self-assigned this Jun 11, 2024
@SamHSmith
Copy link
Contributor

Fixed by this PR #211

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

No branches or pull requests

2 participants