|
|
@@ -1,5 +1,6 @@
|
|
|
import {
|
|
|
bytesTypeNode,
|
|
|
+ bytesValueNode,
|
|
|
camelCase,
|
|
|
DiscriminatorNode,
|
|
|
fieldDiscriminatorNode,
|
|
|
@@ -16,7 +17,11 @@ import { instructionAccountNodesFromAnchorV00 } from './InstructionAccountNode';
|
|
|
import { instructionArgumentNodeFromAnchorV00 } from './InstructionArgumentNode';
|
|
|
import { typeNodeFromAnchorV00 } from './typeNodes';
|
|
|
|
|
|
-export function instructionNodeFromAnchorV00(idl: IdlV00Instruction, origin?: 'anchor' | 'shank'): InstructionNode {
|
|
|
+export function instructionNodeFromAnchorV00(
|
|
|
+ idl: IdlV00Instruction,
|
|
|
+ ixIndex: number,
|
|
|
+ origin?: 'anchor' | 'shank',
|
|
|
+): InstructionNode {
|
|
|
const idlName = idl.name ?? '';
|
|
|
const name = camelCase(idlName);
|
|
|
let dataArguments = (idl.args ?? []).map(instructionArgumentNodeFromAnchorV00);
|
|
|
@@ -41,6 +46,15 @@ export function instructionNodeFromAnchorV00(idl: IdlV00Instruction, origin?: 'a
|
|
|
});
|
|
|
dataArguments = [discriminatorField, ...dataArguments];
|
|
|
discriminators = [fieldDiscriminatorNode('discriminator')];
|
|
|
+ } else if (origin === 'shank') {
|
|
|
+ const discriminatorField = instructionArgumentNode({
|
|
|
+ defaultValue: bytesValueNode('base16', ixIndex.toString(16)),
|
|
|
+ defaultValueStrategy: 'omitted',
|
|
|
+ name: 'discriminator',
|
|
|
+ type: fixedSizeTypeNode(bytesTypeNode(), 1),
|
|
|
+ });
|
|
|
+ dataArguments = [discriminatorField, ...dataArguments];
|
|
|
+ discriminators = [fieldDiscriminatorNode('discriminator')];
|
|
|
}
|
|
|
|
|
|
return instructionNode({
|