Skip to content

Detect binary extensions in types, and mark those fields as optional #4

@aaroncox

Description

@aaroncox

If we detect a binary extension in the ABI, we need to mark those fields as optional.

{
    "name": "unlinkauth",
    "base": "",
    "fields": [
        {
            "name": "account",
            "type": "name"
        },
        {
            "name": "code",
            "type": "name"
        },
        {
            "name": "type",
            "type": "name"
        },
        {
            "name": "authorized_by",
            "type": "name$"
        }
    ]
}

The authorized_by field at the bottom has a $ at the end of its type, indicating its a binary extension, and these fields from my understanding are always optional. Currently our code generation isn't accounting for this, and is outputting:

@Struct.type('unlinkauth')
export class Unlinkauth extends Struct {
    @Struct.field(Name)
    account!: Name
    @Struct.field(Name)
    code!: Name
    @Struct.field(Name)
    type!: Name
    @Struct.field(Name)
    authorized_by!: Name
}

and

export interface Unlinkauth {
    account: NameType
    code: NameType
    type: NameType
    authorized_by: NameType
}

The authorized_by fields in both of these should be marked as optional.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions