Skip to content

Commit

Permalink
Start adding better Javadocs for module / package overview
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-james committed Sep 30, 2024
1 parent dee979d commit 52c4569
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 32 deletions.
19 changes: 13 additions & 6 deletions overview.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<html>
<head>
<title>Solana4j Library Overview</title>
<title>solana4j Library Overview</title>
</head>
<body>
<h1>Solana4j Library Overview</h1>
<p>This library provides APIs for interacting with the Solana blockchain, focusing on token operations.</p>
<h1>solana4j Library Overview</h1>
<p>This library provides APIs for reading and writing messages to the Solana blockchain with both the Legacy
and V0 Solana Message encodings. This library supports interacting with a subset of the core Solana Programs, including
the SystemProgram, TokenProgram and AssociatedTokenProgram. The library can be easily extended to support more
Programs.
</p>
<h2>Features</h2>
<ul>
<li>Token account management</li>
<li>Minting and transferring tokens</li>
<li>Multisig account operations</li>
<li>Creating Token, Mint, MultiSig and Nonce Accounts.</li>
<li>Sol and Token Transfers.</li>
<li>Mint Operations.</li>
<li>Nonce Account Operations.</li>
<li>Creating, Extending and Retrieving AddressLookupTables.</li>
<li>Compute Budget Operations.</li>
</ul>
</body>
</html>
4 changes: 4 additions & 0 deletions src/main/java/com/lmax/solana4j/encoding/SolanaEncoding.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public final class SolanaEncoding
*/
public static final int MAX_MESSAGE_SIZE = 1280 - 40 - 8;

private SolanaEncoding()
{
}

/**
* Creates a new message builder for the given buffer.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.util.List;
import java.util.stream.Collectors;

class SolanaLegacyInstructionView extends SolanaInstructionView implements MessageVisitor.LegacyInstructionView
final class SolanaLegacyInstructionView extends SolanaInstructionView implements MessageVisitor.LegacyInstructionView
{
private final MessageVisitor.LegacyAccountsView accountsView;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.List;
import java.util.stream.Collectors;

class SolanaLegacyMessageView extends SolanaMessageView implements LegacyMessageView
final class SolanaLegacyMessageView extends SolanaMessageView implements LegacyMessageView
{
private final MessageVisitor.LegacyAccountsView accountsView;
private final List<MessageVisitor.InstructionView> instructions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import static java.util.Objects.requireNonNull;
import static net.i2p.crypto.eddsa.spec.EdDSANamedCurveTable.ED_25519_CURVE_SPEC;

class SolanaProgramDerivedAddress implements ProgramDerivedAddress
final class SolanaProgramDerivedAddress implements ProgramDerivedAddress
{
public static final byte[] PROGRAM_DERIVED_ADDRESS_BYTES = "ProgramDerivedAddress".getBytes(StandardCharsets.UTF_8);
private static final int BUMP_LENGTH = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.List;
import java.util.stream.Collectors;

class SolanaV0InstructionView extends SolanaInstructionView implements MessageVisitor.V0InstructionView
final class SolanaV0InstructionView extends SolanaInstructionView implements MessageVisitor.V0InstructionView
{
private final MessageVisitor.V0AccountsView accountsView;

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/lmax/solana4j/package-info.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/**
* Solana
* This is the base package representing the entrypoint to the library. Functionality includes
* building a Solana Message, reading a signed or unsigned Solana Message, as well as exposing methods
* to create useful domain objects, such as an AddressLookupTable, Blockhash, Slot and a PublicKey.
*/
package com.lmax.solana4j;
33 changes: 16 additions & 17 deletions src/main/java/com/lmax/solana4j/programs/TokenProgramBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

/**
* Program for managing token operations on the Solana blockchain.
*
*/
public abstract class TokenProgramBase
{
Expand Down Expand Up @@ -99,9 +98,9 @@ public TransactionInstruction initializeMint(
/**
* Mints new tokens to a list of destinations.
*
* @param mint the public key of the mint
* @param authority the public key of the authority
* @param destination the destination to mint to
* @param mint the public key of the mint
* @param authority the public key of the authority
* @param destination the destination to mint to
* @return {@code TransactionInstruction} of the created instruction
*/
public TransactionInstruction mintTo(
Expand Down Expand Up @@ -179,7 +178,7 @@ public static class TokenProgramBaseFactory
* Factory method for creating a new instance of {@code TokenProgramBaseFactory}.
*
* @param tokenProgramId the program id of the token program
* @param tb the transaction builder
* @param tb the transaction builder
*/
protected TokenProgramBaseFactory(final PublicKey tokenProgramId, final TransactionBuilder tb)
{
Expand Down Expand Up @@ -351,8 +350,8 @@ protected static TransactionInstruction initializeMint(
.data(67, bb ->
{
bb.order(ByteOrder.LITTLE_ENDIAN)
.put((byte) INITIALIZE_MINT_INSTRUCTION)
.put(decimals);
.put((byte) INITIALIZE_MINT_INSTRUCTION)
.put(decimals);
mintAuthority.write(bb);
bb.put((byte) (
freezeAuthority.isPresent()
Expand Down Expand Up @@ -392,8 +391,8 @@ static TransactionInstruction mintTo(
.account(destination.getDestination(), false, true)
.account(authority, true, false)
.data(1 + 8, bb -> bb.order(ByteOrder.LITTLE_ENDIAN)
.put((byte) MINT_TO_INSTRUCTION)
.putLong(destination.getAmount()))
.put((byte) MINT_TO_INSTRUCTION)
.putLong(destination.getAmount()))
);
}

Expand Down Expand Up @@ -421,8 +420,8 @@ static TransactionInstruction transfer(
ib
.program(programId)
.data(1 + 8, bb -> bb.order(ByteOrder.LITTLE_ENDIAN)
.put((byte) TRANSFER_INSTRUCTION)
.putLong(amount))
.put((byte) TRANSFER_INSTRUCTION)
.putLong(amount))
.account(source, false, true)
.account(destination, false, true)
.account(owner, signers.isEmpty(), false);
Expand Down Expand Up @@ -451,8 +450,8 @@ static TransactionInstruction initializeMultisig(
ib
.program(programId)
.data(1 + 1, bb -> bb.order(ByteOrder.LITTLE_ENDIAN)
.put((byte) INITIALIZE_MULTISIG_INSTRUCTION)
.put((byte) requiredSignatures))
.put((byte) INITIALIZE_MULTISIG_INSTRUCTION)
.put((byte) requiredSignatures))
.account(multisigPublicKey, false, true)
.account(RENT, false, false);
signers.forEach(signer -> ib
Expand Down Expand Up @@ -488,10 +487,10 @@ static TransactionInstruction setAuthority(
ib
.program(programId)
.data(1 + 1 + 1 + PublicKey.PUBLIC_KEY_LENGTH, bb -> bb.order(ByteOrder.LITTLE_ENDIAN)
.put((byte) SET_AUTHORITY_INSTRUCTION)
.put(authorityType.value)
.put((byte) 1)
.put(newAuthorityBuffer.flip())
.put((byte) SET_AUTHORITY_INSTRUCTION)
.put(authorityType.value)
.put((byte) 1)
.put(newAuthorityBuffer.flip())
)
.account(tokenAccount, false, true)
.account(oldAuthority, signers.isEmpty(), false);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* This module provides core functionality for interacting with the Solana blockchain,
* focusing on token operations such as minting, transferring, and managing token accounts.
* This module provides functionality for reading and writing messages on the Solana blockchain.
* <p>
* The module is part of the solana4j library and exports key packages for token management
* and transaction building.
* The Solana Legacy and V0 encoding schemes are both supported. The library has support for interacting
* with core programs such as the SystemProgram, TokenProgram and AssociatedTokenProgram. Support for
* more programs can be easily extended.
* </p>
*/
module com.lmax.solana4j {
Expand Down

0 comments on commit 52c4569

Please sign in to comment.