Skip to content

Rust renderer generates duplicate struct fields when flattening composite account groups with same-named accounts #969

@Rhovian

Description

@Rhovian

The Rust renderer flattens composite account groups into a single struct without handling duplicate account names, resulting in compilation errors.

{
  "name": "withdraw",
  "accounts": [
    {
      "name": "withdrawFromAvailable",
      "accounts": [
        { "name": "vaultState", ... },
        { "name": "eventAuthority", ... },
        { "name": "program", ... }
      ]
    },
    {
      "name": "withdrawFromReserveAccounts",
      "accounts": [
        { "name": "vaultState", ... }
      ]
    },
    { "name": "eventAuthority", ... },
    { "name": "program", ... }
  ]
}

generates:

pub struct Withdraw {
    pub vault_state: Pubkey,        // from withdrawFromAvailable
    pub event_authority: Pubkey,    // from withdrawFromAvailable
    pub program: Pubkey,            // from withdrawFromAvailable
    pub vault_state: Pubkey,        // DUPLICATE - from withdrawFromReserveAccounts
    pub event_authority: Pubkey,    // DUPLICATE - top level
    pub program: Pubkey,            // DUPLICATE - top level
}

sample IDL from kamino that exhibits this issue:

https://github.com/Kamino-Finance/klend-sdk/blob/master/src/idl/kvault.json

Not seeing any visitor that would help here, but maybe im missing something? expected behaviour would just be field dedup

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