Skip to main content

GitHub Repository

Dependencies

  • java.net.http
  • software.sava.json.iterator
  • software.sava.core
  • software.sava.rpc

Features With Examples

Instructions

Defined Types

Generate Source

Build Configuration

GitHub Access Token: Generate a classic token with the read:packages scope to access dependencies hosted on GitHub Package Repository.
.gradle/gradle.properties
savaGithubPackagesUsername=GITHUB_USERNAME
savaGithubPackagesPassword=GITHUB_TOKEN

Compile & Run

Generated code will be placed under the basePackageName in the sourceDirectory. Onchain IDL’s configured in the programs JSON file will be fetched in a single request. Other remote IDL’s for programs will be fetched concurrently in numThreads with a baseDelayMillis between requests.

Program Configuration

[
  {
    "name": "Jupiter Swap",
    "program": "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4",
    "package": "jupiter.swap"
  }
]
  • name (required)
    • Human-readable program name. Also used to derive defaults for other fields.
  • package (optional)
    • Java package suffix for this specific program. If omitted, it defaults to the lower-case form of name.
    • Final Java package for generated code: <basePackageName>.<package>.anchor
    • Example: with --basePackageName=software.sava.anchor.gen and "package": "pyth.receiver", classes go under software.sava.anchor.gen.pyth.receiver.anchor.
  • program (required unless idlURL or idlFile is provided)
    • Base58-encoded Solana program address. Used to compute the onchain IDL address and to fetch the IDL when not using idlURL or idlFile.
  • idlURL (optional)
    • HTTP(S) URL to fetch the program’s IDL JSON. When provided, the generator fetches the IDL from this URL instead of the chain or file.
  • idlFile (optional)
    • Path to a local IDL JSON file on disk. When provided (and idlURL is absent), the generator reads the IDL from this file.
  • exportPackages (boolean, optional)
    • Whether to export this program’s packages in the generated module-info.java. Overrides the global --exportPackages for this entry only. If omitted, the global value applies.

Compile

./compile.sh

Run

./genSrc.sh --help
./genSrc.sh \
 --tabLength=2 \
 --sourceDirectory="src/main/java" \
 --moduleName="org.your.module" \
 --basePackageName="org.your.package.anchor.gen" \
 --programs="./main_net_programs.json" \
 --rpc="https://rpc.com" \
 --baseDelayMillis=200 \
 --numThreads=5
I