Skip to content

Commit 0dd85c8

Browse files
committed
solana: add innerInstructionIndex to instruction
1 parent df25b72 commit 0dd85c8

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@subsquid/solana-normalization",
5+
"comment": "add innerInstructionIndex to instruction",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@subsquid/solana-normalization"
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@subsquid/solana-stream",
5+
"comment": "support instruction.innerInstructionIndex field",
6+
"type": "minor"
7+
}
8+
],
9+
"packageName": "@subsquid/solana-stream"
10+
}

solana/solana-normalization/src/data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ export interface AddressTableLookup {
4646

4747
export interface Instruction {
4848
transactionIndex: number
49+
innerInstructionIndex: number
4950
instructionAddress: number[]
5051
programId: Base58Bytes
5152
accounts: Base58Bytes[]

solana/solana-normalization/src/mapping.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ const PROGRAMS_MISSING_INVOKE_LOG = new Set([
138138

139139
class InstructionParser {
140140
private pos = 0
141+
private innerPos = -1
141142
private messages: Message[]
142143
private messagePos = 0
143144
private messagesTruncated = false
@@ -396,7 +397,14 @@ class InstructionParser {
396397
address[stackHeight - 1] = 0
397398
}
398399

400+
if (stackHeight === 1) {
401+
this.innerPos = -1
402+
} else {
403+
this.innerPos++
404+
}
405+
399406
let i: Instruction = {
407+
innerInstructionIndex: this.innerPos,
400408
transactionIndex: this.tx.transactionIndex,
401409
instructionAddress: address,
402410
programId: this.getAccount(src.programIdIndex),

solana/solana-stream/src/archive/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const getDataSchema = weakMemo((fields: FieldSelection) => {
6060
transactionIndex: NAT,
6161
instructionAddress: array(NAT),
6262
...project(fields.instruction, {
63+
instructionIndex: NAT,
6364
programId: B58,
6465
accounts: array(B58),
6566
data: B58,

0 commit comments

Comments
 (0)