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