Skip to content

Conversation

@stwiname
Copy link
Collaborator

@stwiname stwiname commented Sep 9, 2025

Description

  • Use granular imports for codegen
  • Update solana specific dependencies
  • Expose decoder to sandbox
  • Dictionary improvements, fixes issue of being used when there is no filters

Fixes subquery/subql#2903

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist

  • I have tested locally
  • I have performed a self review of my changes
  • Updated any relevant documentation
  • Linked to any relevant issues
  • I have added tests relevant to my changes
  • Any dependent changes have been merged and published in downstream modules
  • My code is up to date with the base branch
  • I have updated relevant changelogs. We suggest using chan

@github-actions
Copy link
Contributor

github-actions bot commented Sep 9, 2025

Coverage report

Caution

Test run failed

St.
Category Percentage Covered / Total
🔴 Statements 51.25% 2147/4189
🟡 Branches 66.77% 223/334
🔴 Functions 49.76% 103/207
🔴 Lines 51.25% 2147/4189

Test suite run failed

Failed tests: 4/52. Failed suites: 1/8.
  ● test solana project.yaml › could get options in template from its deployment

    expect(received).toContain(expected) // indexOf

    Expected substring: "abi: Pool"
    Received string:    "dataSources:
      - kind: solana/Runtime
        mapping:
          file: ./dist/index.js
          handlers:
            - filter: {}
              handler: handlePoolCreated
              kind: solana/LogHandler
        startBlock: 12369621
      - kind: solana/Runtime
        mapping:
          file: ./dist/index.js
          handlers:
            - filter: {}
              handler: handleIncreaseLiquidity
              kind: solana/LogHandler
            - filter: {}
              handler: handleDecreaseLiquidity
              kind: solana/LogHandler
            - filter: {}
              handler: handleCollect
              kind: solana/LogHandler
            - filter: {}
              handler: handleTransfer
              kind: solana/LogHandler
        startBlock: 12369651
    network:
      chainId: '1'
    runner:
      node:
        name: '@subql/node-solana'
        version: '*'
      query:
        name: '@subql/query'
        version: '*'
    schema:
      file: ./schema.graphql
    specVersion: 1.0.0
    templates:
      - kind: solana/Runtime
        mapping:
          file: ./dist/index.js
          handlers:
            - filter: {}
              handler: handleInitialize
              kind: solana/LogHandler
            - filter: {}
              handler: handleSwap
              kind: solana/LogHandler
            - filter: {}
              handler: handleMint
              kind: solana/LogHandler
            - filter: {}
              handler: handleBurn
              kind: solana/LogHandler
            - filter: {}
              handler: handleFlash
              kind: solana/LogHandler
        name: Pool
    "

      41 |     const manifest = loadSolanaProjectManifest(path.join(projectsDir, 'project_1.0.0.yaml'));
      42 |     const deployment = manifest.toDeployment();
    > 43 |     expect(deployment).toContain('abi: Pool');
         |                        ^
      44 |   });
      45 | });
      46 |

      at Object.<anonymous> (packages/common-solana/src/project/project.spec.ts:43:24)

  ● project.yaml › can validate project.yaml

    Not implemented

      48 |   it('can validate project.yaml', () => {
      49 |     // TODO this should catch a specific error, the file doesn't currently exist
    > 50 |     throw new Error('Not implemented');
         |           ^
      51 |     expect(() => loadSolanaProjectManifest(path.join(projectsDir, 'project_falsy.yaml'))).toThrow();
      52 |     expect(() => loadSolanaProjectManifest(path.join(projectsDir, 'project_falsy_array.yaml'))).toThrow();
      53 |   });

      at Object.<anonymous> (packages/common-solana/src/project/project.spec.ts:50:11)

  ● project.yaml › can fail validation if version not supported

    Not implemented

      55 |   it('can fail validation if version not supported', () => {
      56 |     // TODO this should catch a specific error, the file doesn't currently exist
    > 57 |     throw new Error('Not implemented');
         |           ^
      58 |     expect(() => loadSolanaProjectManifest(path.join(projectsDir, 'project_invalid_version.yaml'))).toThrow('');
      59 |   });
      60 |

      at Object.<anonymous> (packages/common-solana/src/project/project.spec.ts:57:11)

  ● project.yaml › get v1.0.0 deployment mapping filter

    expect(received).toContain(expected) // indexOf

    Expected substring: "Transfer (address from, address to, uint256 tokenId)"
    Received string:    "dataSources:
      - kind: solana/Runtime
        mapping:
          file: ./dist/index.js
          handlers:
            - filter: {}
              handler: handlePoolCreated
              kind: solana/LogHandler
        startBlock: 12369621
      - kind: solana/Runtime
        mapping:
          file: ./dist/index.js
          handlers:
            - filter: {}
              handler: handleIncreaseLiquidity
              kind: solana/LogHandler
            - filter: {}
              handler: handleDecreaseLiquidity
              kind: solana/LogHandler
            - filter: {}
              handler: handleCollect
              kind: solana/LogHandler
            - filter: {}
              handler: handleTransfer
              kind: solana/LogHandler
        startBlock: 12369651
    network:
      chainId: '1'
    runner:
      node:
        name: '@subql/node-solana'
        version: '*'
      query:
        name: '@subql/query'
        version: '*'
    schema:
      file: ./schema.graphql
    specVersion: 1.0.0
    templates:
      - kind: solana/Runtime
        mapping:
          file: ./dist/index.js
          handlers:
            - filter: {}
              handler: handleInitialize
              kind: solana/LogHandler
            - filter: {}
              handler: handleSwap
              kind: solana/LogHandler
            - filter: {}
              handler: handleMint
              kind: solana/LogHandler
            - filter: {}
              handler: handleBurn
              kind: solana/LogHandler
            - filter: {}
              handler: handleFlash
              kind: solana/LogHandler
        name: Pool
    "

      70 |     const deploymentString = manifestVersioned.toDeployment();
      71 |     expect(filter).not.toBeNull();
    > 72 |     expect(deploymentString).toContain('Transfer (address from, address to, uint256 tokenId)');
         |                              ^
      73 |   });
      74 |
      75 |   it('can convert genesis hash in v1.0.0 to chainId in deployment', () => {

      at Object.<anonymous> (packages/common-solana/src/project/project.spec.ts:72:30)

Report generated by 🧪jest coverage report action from cb5c320

@stwiname stwiname requested a review from Copilot September 9, 2025 00:19
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Updates dependencies and improves functionality for the Solana SubQuery implementation by using granular imports for codegen, updating Solana-specific dependencies to newer versions, exposing decoder functionality to sandbox environments, and fixing dictionary improvement issues.

  • Use granular imports in codegen to improve build efficiency
  • Update Solana ecosystem dependencies (@solana/kit, @codama packages) to newer versions
  • Expose decoder interface to sandbox for instruction and log decoding
  • Fix dictionary condition handling to prevent usage when no filters are present

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/types/src/solana.ts Fix typo in property name and add Decoder interface with documentation
packages/types/src/global.ts Expose decoder globally for sandbox access
packages/types/package.json Update @solana/kit dependency version
packages/node/src/solana/decoder.ts Implement Decoder interface in SolanaDecoder class
packages/node/src/solana/api.solana.ts Update import path for Solana RPC
packages/node/src/indexer/indexer.manager.ts Inject decoder into sandbox environment
packages/node/src/indexer/dictionary/v2/solanaDictionaryV2.ts Fix dictionary condition sanitization logic
packages/node/src/app.module.ts Update SDK version tracking from ethers to @solana/kit
packages/node/package.json Update multiple dependency versions
packages/common-solana/src/codegen/codegen.ts Enable granular imports in codegen
packages/common-solana/package.json Update @codama dependency versions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

accountKey: Address;
/** List of indices used to load addresses of readonly accounts from a lookup table. */
readableIndexes: readonly number[];
readonlyIndexes: readonly number[];
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property name has been corrected from 'readableIndexes' to 'readonlyIndexes' to match the intended meaning of read-only access indexes.

Copilot uses AI. Check for mistakes.
safeApi: SolanaSafeApi,
): IndexerSandbox {
return this.sandboxService.getDsProcessor(ds, safeApi, this.apiService.api);
const sandbox = (this as any).sandboxService as SandboxService<
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'this as any' bypasses TypeScript's type checking. Consider updating the class property type or using a more type-safe approach to access the sandboxService.

Suggested change
const sandbox = (this as any).sandboxService as SandboxService<
const sandbox = this.sandboxService as SandboxService<

Copilot uses AI. Check for mistakes.
Comment on lines +12 to +17
const kitPath = require.resolve('@solana/kit');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version: ethersSdkVersion } = require('ethers/package.json');
const { version: solanaSdkVersion } = require(path.resolve(
kitPath,
'../../package.json',
));
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path resolution logic is fragile and depends on the internal structure of @solana/kit. Consider using a more reliable method to get the package version, such as requiring '@solana/kit/package.json' directly if available.

Copilot uses AI. Check for mistakes.
Comment on lines +12 to +17
const kitPath = require.resolve('@solana/kit');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { version: ethersSdkVersion } = require('ethers/package.json');
const { version: solanaSdkVersion } = require(path.resolve(
kitPath,
'../../package.json',
));
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path resolution logic is fragile and depends on the internal structure of @solana/kit. Consider using a more reliable method to get the package version, such as requiring '@solana/kit/package.json' directly if available.

Copilot uses AI. Check for mistakes.
@stwiname stwiname merged commit 6b71ade into main Sep 9, 2025
2 of 3 checks passed
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.

Solana starter project SolanaHandlerKind.Transaction not working

2 participants