From 35a1546a1704af496a7195881518b5d52afb59db Mon Sep 17 00:00:00 2001 From: Loris Leiva Date: Mon, 29 Apr 2024 16:19:26 +0100 Subject: [PATCH] Fix missing args variable error in JS Experimental --- .changeset/mighty-swans-rest.md | 5 +++++ .../js-experimental/fragments/instructionFunction.ts | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changeset/mighty-swans-rest.md diff --git a/.changeset/mighty-swans-rest.md b/.changeset/mighty-swans-rest.md new file mode 100644 index 000000000..e3f3048b8 --- /dev/null +++ b/.changeset/mighty-swans-rest.md @@ -0,0 +1,5 @@ +--- +"@metaplex-foundation/kinobi": patch +--- + +Fix missing args variable error in JS Experimental diff --git a/src/renderers/js-experimental/fragments/instructionFunction.ts b/src/renderers/js-experimental/fragments/instructionFunction.ts index d2baa0357..902bc8726 100644 --- a/src/renderers/js-experimental/fragments/instructionFunction.ts +++ b/src/renderers/js-experimental/fragments/instructionFunction.ts @@ -1,4 +1,4 @@ -import { InstructionNode, ProgramNode } from '../../../nodes'; +import { InstructionNode, ProgramNode, isNode } from '../../../nodes'; import { camelCase, pascalCase } from '../../../shared'; import { ResolvedInstructionInput } from '../../../visitors'; import { TypeManifest } from '../TypeManifest'; @@ -66,7 +66,11 @@ export function getInstructionFunctionFragment( (instructionNode.extraArguments ?? []).filter( (field) => !field.defaultValue || field.defaultValueStrategy !== 'omitted' ).length > 0; - const hasAnyArgs = hasDataArgs || hasExtraArgs; + const hasRemainingAccountArgs = + (instructionNode.remainingAccounts ?? []).filter(({ value }) => + isNode(value, 'argumentValueNode') + ).length > 0; + const hasAnyArgs = hasDataArgs || hasExtraArgs || hasRemainingAccountArgs; const instructionDataName = nameApi.instructionDataType(instructionNode.name); const programAddressConstant = nameApi.programAddressConstant( programNode.name