Skip to content

Commit

Permalink
Add support for isOptional instruction account attribute (#106)
Browse files Browse the repository at this point in the history
* Add support for isOptional instruction account attribute

* Fix lint

---------

Co-authored-by: febo <[email protected]>
  • Loading branch information
lorisleiva and febo authored Feb 17, 2023
1 parent ba4e7f4 commit 202d823
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/render-instruction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ ${typeMapperImports.join('\n')}`.trim()
// Make collection items easy to identify and avoid name clashes
ac.name = deriveCollectionAccountsName(ac.name, acc.name)
const knownPubkey = resolveKnownPubkey(ac.name)
const optional = ac.optional ?? false
const optional = ac.optional ?? ac.isOptional ?? false
if (knownPubkey == null) {
processedAccountsKey.push({ ...ac, optional })
} else {
Expand All @@ -134,7 +134,7 @@ ${typeMapperImports.join('\n')}`.trim()
}
} else {
const knownPubkey = resolveKnownPubkey(acc.name)
const optional = acc.optional ?? false
const optional = acc.optional ?? acc.isOptional ?? false
if (knownPubkey == null) {
processedAccountsKey.push({ ...acc, optional })
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export type IdlInstructionAccount = {
isSigner: boolean
desc?: string
optional?: boolean
isOptional?: boolean
}

export type IdlType =
Expand Down Expand Up @@ -449,7 +450,7 @@ export const BIGNUM = [
'i256',
'i512',
] as const
export type Bignum = typeof BIGNUM[number]
export type Bignum = (typeof BIGNUM)[number]
export function isNumberLikeType(ty: IdlType): ty is NumbersTypeMapKey {
return (
typeof ty === 'string' && numbersTypeMap[ty as NumbersTypeMapKey] != null
Expand Down

0 comments on commit 202d823

Please sign in to comment.