Skip to content

Commit

Permalink
solana: add innerInstructionIndex to instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcgroul committed Oct 30, 2024
1 parent df25b72 commit 0dd85c8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@subsquid/solana-normalization",
"comment": "add innerInstructionIndex to instruction",
"type": "minor"
}
],
"packageName": "@subsquid/solana-normalization"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@subsquid/solana-stream",
"comment": "support instruction.innerInstructionIndex field",
"type": "minor"
}
],
"packageName": "@subsquid/solana-stream"
}
1 change: 1 addition & 0 deletions solana/solana-normalization/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export interface AddressTableLookup {

export interface Instruction {
transactionIndex: number
innerInstructionIndex: number
instructionAddress: number[]
programId: Base58Bytes
accounts: Base58Bytes[]
Expand Down
8 changes: 8 additions & 0 deletions solana/solana-normalization/src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ const PROGRAMS_MISSING_INVOKE_LOG = new Set([

class InstructionParser {
private pos = 0
private innerPos = -1
private messages: Message[]
private messagePos = 0
private messagesTruncated = false
Expand Down Expand Up @@ -396,7 +397,14 @@ class InstructionParser {
address[stackHeight - 1] = 0
}

if (stackHeight === 1) {
this.innerPos = -1
} else {
this.innerPos++
}

let i: Instruction = {
innerInstructionIndex: this.innerPos,
transactionIndex: this.tx.transactionIndex,
instructionAddress: address,
programId: this.getAccount(src.programIdIndex),
Expand Down
1 change: 1 addition & 0 deletions solana/solana-stream/src/archive/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const getDataSchema = weakMemo((fields: FieldSelection) => {
transactionIndex: NAT,
instructionAddress: array(NAT),
...project(fields.instruction, {
instructionIndex: NAT,
programId: B58,
accounts: array(B58),
data: B58,
Expand Down

0 comments on commit 0dd85c8

Please sign in to comment.