Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/commands/contract/structs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface FieldType {
name: string
type: string
optional: boolean
extension: boolean
}

interface StructData {
Expand Down Expand Up @@ -51,6 +52,7 @@ export function getActionFieldFromAbi(abi: any): StructData[] {
name: 'value',
type: t,
optional: false,
extension: false,
}
}),
variant: true,
Expand All @@ -67,6 +69,7 @@ export function getActionFieldFromAbi(abi: any): StructData[] {
name: field.name,
type: parseType(field.type),
optional: field.type.endsWith('?') || field.type.endsWith('$'),
extension: field.type.endsWith('$'),
})
}

Expand Down Expand Up @@ -191,7 +194,14 @@ export function generateField(
)
}

if (field.optional) {
if (field.extension) {
optionsProps.push(
ts.factory.createPropertyAssignment(
ts.factory.createIdentifier('extension'),
ts.factory.createTrue()
)
)
} else if (field.optional) {
optionsProps.push(
ts.factory.createPropertyAssignment(
ts.factory.createIdentifier('optional'),
Expand Down
4 changes: 2 additions & 2 deletions test/data/contracts/mock-eosio.msig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export namespace Types {
declare proposal_name: Name
@Struct.field(permission_level)
declare level: permission_level
@Struct.field(Checksum256, {optional: true})
@Struct.field(Checksum256, {extension: true})
declare proposal_hash?: Checksum256
}
@Struct.type('cancel')
Expand Down Expand Up @@ -120,7 +120,7 @@ export namespace Types {
declare proposal_name: Name
@Struct.field(Bytes)
declare packed_transaction: Bytes
@Struct.field(TimePoint, {optional: true})
@Struct.field(TimePoint, {extension: true})
declare earliest_exec_time?: TimePoint
}
@Struct.type('transaction_header')
Expand Down
16 changes: 8 additions & 8 deletions test/data/contracts/mock-eosio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export namespace Types {
}
@Struct.type('blockchain_parameters_v1')
export class blockchain_parameters_v1 extends blockchain_parameters {
@Struct.field(UInt32, {optional: true})
@Struct.field(UInt32, {extension: true})
declare max_action_return_value_size?: UInt32
}
@Struct.type('buyram')
Expand Down Expand Up @@ -412,7 +412,7 @@ export namespace Types {
declare account: Name
@Struct.field(Name)
declare permission: Name
@Struct.field(Name, {optional: true})
@Struct.field(Name, {extension: true})
declare authorized_by?: Name
}
@Struct.type('delschedule')
Expand Down Expand Up @@ -549,7 +549,7 @@ export namespace Types {
declare type: Name
@Struct.field(Name)
declare requirement: Name
@Struct.field(Name, {optional: true})
@Struct.field(Name, {extension: true})
declare authorized_by?: Name
}
@Struct.type('logbuyram')
Expand Down Expand Up @@ -754,7 +754,7 @@ export namespace Types {
declare last_claim_time: TimePoint
@Struct.field(UInt16)
declare location: UInt16
@Struct.field(variant_block_signing_authority_v0, {optional: true})
@Struct.field(variant_block_signing_authority_v0, {extension: true})
declare producer_authority?: variant_block_signing_authority_v0
}
@Struct.type('producer_info2')
Expand Down Expand Up @@ -1004,7 +1004,7 @@ export namespace Types {
declare account: Name
@Struct.field(Bytes)
declare abi: Bytes
@Struct.field('string', {optional: true})
@Struct.field('string', {extension: true})
declare memo?: string
}
@Struct.type('setacctcpu')
Expand Down Expand Up @@ -1049,7 +1049,7 @@ export namespace Types {
declare vmversion: UInt8
@Struct.field(Bytes)
declare code: Bytes
@Struct.field('string', {optional: true})
@Struct.field('string', {extension: true})
declare memo?: string
}
@Struct.type('setinflation')
Expand Down Expand Up @@ -1130,7 +1130,7 @@ export namespace Types {
declare code: Name
@Struct.field(Name)
declare type: Name
@Struct.field(Name, {optional: true})
@Struct.field(Name, {extension: true})
declare authorized_by?: Name
}
@Struct.type('unregprod')
Expand Down Expand Up @@ -1168,7 +1168,7 @@ export namespace Types {
declare parent: Name
@Struct.field(authority)
declare auth: authority
@Struct.field(Name, {optional: true})
@Struct.field(Name, {extension: true})
declare authorized_by?: Name
}
@Struct.type('updaterex')
Expand Down