49: Add wallet transaction submission operations
This commit is contained in:
@@ -11,10 +11,11 @@ import java.io.IOException;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Solana wallet capable of identifying itself and signing transactions.
|
* A Solana wallet capable of identifying itself, signing transactions and
|
||||||
|
* submitting them to the Solana blockchain.
|
||||||
*
|
*
|
||||||
* <p>Signing a transaction does not submit it to the Solana blockchain.
|
* <p>Signing and submission can be performed separately or as one complete
|
||||||
* Submission must be performed separately through {@code SolanaBlockChain}.</p>
|
* operation.</p>
|
||||||
*/
|
*/
|
||||||
public interface SolanaWallet {
|
public interface SolanaWallet {
|
||||||
/**
|
/**
|
||||||
@@ -106,4 +107,35 @@ public interface SolanaWallet {
|
|||||||
SolanaSignedTransaction signTransaction(
|
SolanaSignedTransaction signTransaction(
|
||||||
@NotNull SolanaUnsignedTransaction transaction
|
@NotNull SolanaUnsignedTransaction transaction
|
||||||
) throws IOException, InterruptedException;
|
) throws IOException, InterruptedException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submits a signed Solana transaction to the Solana blockchain.
|
||||||
|
*
|
||||||
|
* @param transaction the signed transaction to submit
|
||||||
|
* @return the transaction signature returned by Solana RPC
|
||||||
|
* @throws IllegalArgumentException if the transaction is missing or blank
|
||||||
|
* @throws IOException if the transaction cannot be sent
|
||||||
|
* @throws InterruptedException if the calling thread is interrupted
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
ΩSolanaTransactionSignatureΩ sendTransaction(
|
||||||
|
@NotNull SolanaSignedTransaction transaction
|
||||||
|
) throws IOException, InterruptedException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Signs and submits an unsigned Solana transaction.
|
||||||
|
*
|
||||||
|
* @param transaction the unsigned transaction to sign and submit
|
||||||
|
* @return the transaction signature returned by Solana RPC
|
||||||
|
* @throws IllegalArgumentException if the transaction is missing or blank
|
||||||
|
* @throws IOException if the transaction cannot be signed or sent
|
||||||
|
* @throws InterruptedException if the signing process or calling thread
|
||||||
|
* is interrupted
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
default ΩSolanaTransactionSignatureΩ signAndSendTransaction(
|
||||||
|
@NotNull SolanaUnsignedTransaction transaction
|
||||||
|
) throws IOException, InterruptedException {
|
||||||
|
return sendTransaction(signTransaction(transaction));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,6 +171,13 @@ public class SolanaWalletImpl implements SolanaWallet {
|
|||||||
return sst;
|
return sst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull ΩSolanaTransactionSignatureΩ sendTransaction(
|
||||||
|
@NotNull SolanaSignedTransaction transaction
|
||||||
|
) throws IOException, InterruptedException {
|
||||||
|
return solanaBlockChain.sendTransaction(transaction);
|
||||||
|
}
|
||||||
|
|
||||||
private record SignerResponse(
|
private record SignerResponse(
|
||||||
String signer,
|
String signer,
|
||||||
ΩBase64StringΩ signedTransaction
|
ΩBase64StringΩ signedTransaction
|
||||||
|
|||||||
Reference in New Issue
Block a user