Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Fixed
- Parsing transactions where innerTransactions is null (#23)

## [6.1.1] - 2025-09-10
### Added
Expand Down
31 changes: 28 additions & 3 deletions packages/node/src/solana/api.solana.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import {

// Add api key to work
const HTTP_ENDPOINT =
process.env.HTTP_ENDPOINT ?? 'https://solana.api.onfinality.io/public';
process.env.HTTP_ENDPOINT ??
'https://api.mainnet-beta.solana.com' ??
'https://solana.api.onfinality.io/public';

const IDL_swap: IdlV01 = require('../../test/swapFpHZwjELNnjvThjajtiVmkz3yPQEHjLtka2fwHW.idl.json');

Expand All @@ -37,8 +39,11 @@ describe('Api.solana', () => {
block = await solanaApi.fetchBlock(325_922_873);
}, 20_000);

function getTxBySig(sig: string): SolanaTransaction {
const tx = block.block.transactions.find((tx) =>
function getTxBySig(
sig: string,
specificBlock?: IBlock<SolanaBlock>,
): SolanaTransaction {
const tx = (specificBlock ?? block).block.transactions.find((tx) =>
tx.transaction.signatures.find((s) => s === sig),
);
if (!tx) {
Expand Down Expand Up @@ -261,6 +266,26 @@ describe('Api.solana', () => {
expect(txWError!.meta!.logs).toBeDefined();
expect(txWError!.meta!.logs!.length).toBeGreaterThan(0);
});

it('can parse a block with a transaction that has "null" innerTransactions', async () => {
// The problem transaction: https://solscan.io/tx/3mSAfK9hm4wgMw5kzKpVz73viBftapNLwECN9rmG5Q6qWPyARognZsyoosB4XjYf5nFRtcEmrKGVgLGLRN7tnmWN?cluster=devnet
const solanaApi = await SolanaApi.create(
'https://api.devnet.solana.com',
eventEmitter,
decoder,
);

const block = await solanaApi.fetchBlock(405433240);

expect(block).toBeDefined();

expect(
getTxBySig(
'3mSAfK9hm4wgMw5kzKpVz73viBftapNLwECN9rmG5Q6qWPyARognZsyoosB4XjYf5nFRtcEmrKGVgLGLRN7tnmWN',
block,
),
).toBeDefined();
});
});

// Tests that data types can be stringified, this is important to test because of circular references
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/solana/api.solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class SolanaApi {
return 'mainnet';
case 'EKLxEB4xoEDq9AAn5HhFiP5WqdhNVc4An2HvJyzHzx7u': // Not tested
return 'testnet;';
case 'GH7ome3EiwEr7tu9JuTh2dpYWBJK3z69Xm1ZE3MEE6JC':
case 'EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG':
return 'devnet';
default:
return 'unknown';
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/solana/block.solana.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export function transformBlock(
meta: tx.meta
? {
...tx.meta,
innerInstructions: tx.meta.innerInstructions.map(
innerInstructions: (tx.meta.innerInstructions ?? []).map(
(innerInstruction) => ({
...innerInstruction,
instructions: innerInstruction.instructions.map(
Expand Down
Loading