Skip to content

Commit

Permalink
allow to request all balances of transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcgroul committed Jul 17, 2024
1 parent 36ebb4c commit 8c77f4b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@subsquid/solana-stream",
"comment": "allow to request all balances of transaction",
"type": "minor"
}
],
"packageName": "@subsquid/solana-stream"
}
1 change: 1 addition & 0 deletions solana/solana-stream/src/data/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface InstructionRequestWhere {

export interface InstructionRequestRelations {
transaction?: boolean
transactionBalances?: boolean
transactionTokenBalances?: boolean
transactionInstructions?: boolean
logs?: boolean
Expand Down
8 changes: 8 additions & 0 deletions solana/solana-stream/src/rpc/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ class BlockFilter {
return groupBy(this.block.instructions, i => i.transactionIndex)
}

@def
private balancesByTx(): Map<number, Balance[]> {
return groupBy(this.block.balances, b => b.transactionIndex)
}

@def
private tokenBalancesByTx(): Map<number, TokenBalance[]> {
return groupBy(this.block.tokenBalances, b => b.transactionIndex)
Expand Down Expand Up @@ -220,6 +225,9 @@ class BlockFilter {
if (rel.transaction) {
this.include.transactions.add(this.getTransaction(ins.transactionIndex))
}
if (rel.transactionBalances) {
include(this.include.balances, this.balancesByTx().get(ins.transactionIndex))
}
if (rel.transactionTokenBalances) {
include(this.include.tokenBalances, this.tokenBalancesByTx().get(ins.transactionIndex))
}
Expand Down

0 comments on commit 8c77f4b

Please sign in to comment.