Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add stackHeight field in CompiledInstruction #272

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fenghaojiang
Copy link

fix: add stackHeight field in CompiledInstruction

The original CompiledInstruction struct is missing the field stackHeight. Because in this sdk CompiledInstruction is used to parse inner instruction while the inner instruction raw response is like:

{
                    "programIdIndex": 22,
                    "accounts": [10],
                    "data": "18y7nEsq5",
                    "stackHeight": 2
}
type CompiledInstruction struct {
	// Index into the message.accountKeys array indicating the program account that executes this instruction.
	// NOTE: it is actually a uint8, but using a uint16 because uint8 is treated as a byte everywhere,
	// and that can be an issue.
	ProgramIDIndex uint16 `json:"programIdIndex"`

	// List of ordered indices into the message.accountKeys array indicating which accounts to pass to the program.
	// NOTE: it is actually a []uint8, but using a uint16 because []uint8 is treated as a []byte everywhere,
	// and that can be an issue.
	Accounts []uint16 `json:"accounts"`

	// The program input data encoded in a base-58 string.
	Data Base58 `json:"data"`

	StackHeight uint16 `json:"stackHeight"`
}

Without this field, parse inner instruction would miss part of the stack height data.

rpc/types.go

type InnerInstruction struct {
	// TODO: <number> == int64 ???
	// Index of the transaction instruction from which the inner instruction(s) originated
	Index uint16 `json:"index"`

	// Ordered list of inner program instructions that were invoked during a single transaction instruction.
	Instructions []solana.CompiledInstruction `json:"instructions"`
}

@sebkaluzny
Copy link
Contributor

I already did the same, but it looks like it went missing after merge:
#227

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants