From 2a538ae160a6b84baba473f42031ad8620ce8120 Mon Sep 17 00:00:00 2001
From: skynetcap <100323448+skynetcap@users.noreply.github.com>
Date: Sun, 1 Sep 2024 12:25:16 -0700
Subject: [PATCH 01/65] Update version and restructure Maven GPG plugin
configuration
Bump project version from 1.17.6 to 1.17.7. Move the Maven GPG plugin configuration into a new 'deploy' profile to streamline the build process and separate concerns effectively.
---
pom.xml | 46 +++++++++++++++++++++++++++-------------------
1 file changed, 27 insertions(+), 19 deletions(-)
diff --git a/pom.xml b/pom.xml
index 66d2d5d2..7ff142ec 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.mmorrell
solanaj
jar
- 1.17.6
+ 1.17.7
${project.groupId}:${project.artifactId}
Java client for Solana RPC
https://github.com/skynetcap/solanaj
@@ -174,24 +174,6 @@
-
- org.apache.maven.plugins
- maven-gpg-plugin
- 3.2.4
-
-
- sign-artifacts
- verify
-
- sign
-
-
- c:/Users/Michael/.gnupg/
- 0x27FAE7D2
-
-
-
-
org.apache.maven.plugins
maven-compiler-plugin
@@ -199,4 +181,30 @@
+
+
+ deploy
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+ c:/Users/Michael/.gnupg/
+ 0x27FAE7D2
+
+
+
+
+
+
+
+
From 3dbbddf944fdfac0c4df02e9357e5be4756857b1 Mon Sep 17 00:00:00 2001
From: skynetcap <100323448+skynetcap@users.noreply.github.com>
Date: Mon, 2 Sep 2024 00:58:27 -0700
Subject: [PATCH 02/65] Add getAccountInfo tests and some documentation, to
test Cursor AI.
---
.../java/org/p2p/solanaj/core/Account.java | 10 +++
.../org/p2p/solanaj/core/MainnetTest.java | 79 +++++++++++++++----
2 files changed, 72 insertions(+), 17 deletions(-)
diff --git a/src/main/java/org/p2p/solanaj/core/Account.java b/src/main/java/org/p2p/solanaj/core/Account.java
index cc41eb67..7cb3b0c1 100644
--- a/src/main/java/org/p2p/solanaj/core/Account.java
+++ b/src/main/java/org/p2p/solanaj/core/Account.java
@@ -24,6 +24,14 @@ private Account(TweetNaclFast.Signature.KeyPair keyPair) {
this.keyPair = keyPair;
}
+ /**
+ * Deprecated method for creating an Account object from mnemonic using the legacy deviation path.
+ *
+ * @param words seed words
+ * @param passphrase seed passphrase
+ * @return Account object generated from the mnemonic
+ * @deprecated This method uses a deprecated deviation path. Use the new method fromBip44Mnemonic instead.
+ */
@Deprecated
public static Account fromMnemonic(List words, String passphrase) {
byte[] seed = MnemonicCode.toSeed(words, passphrase);
@@ -116,4 +124,6 @@ private static byte[] convertJsonStringToByteArray(String characters) {
return buffer.array();
}
+
+
}
\ No newline at end of file
diff --git a/src/test/java/org/p2p/solanaj/core/MainnetTest.java b/src/test/java/org/p2p/solanaj/core/MainnetTest.java
index f8bdc97f..b1ed9392 100644
--- a/src/test/java/org/p2p/solanaj/core/MainnetTest.java
+++ b/src/test/java/org/p2p/solanaj/core/MainnetTest.java
@@ -61,6 +61,51 @@ public void getAccountInfoBase58() throws RpcException {
assertTrue(balance > 0);
}
+ @Test
+ public void getAccountInfoWithConfirmedCommitment() throws RpcException {
+ // Get account Info with confirmed commitment
+ final AccountInfo accountInfo = client.getApi().getAccountInfo(PublicKey.valueOf("So11111111111111111111111111111111111111112"), Map.of("commitment", Commitment.CONFIRMED));
+ final double balance = (double) accountInfo.getValue().getLamports() / LAMPORTS_PER_SOL;
+
+ // Account data list
+ final List accountData = accountInfo.getValue().getData();
+
+ // Verify "base64" string in accountData
+ assertTrue(accountData.stream().anyMatch(s -> s.equalsIgnoreCase("base64")));
+ assertTrue(balance > 0);
+ }
+
+ @Test
+ public void getAccountInfoWithFinalizedCommitment() throws RpcException {
+ // Get account Info with finalized commitment
+ final AccountInfo accountInfo = client.getApi().getAccountInfo(PublicKey.valueOf("So11111111111111111111111111111111111111112"), Map.of("commitment", Commitment.FINALIZED));
+ final double balance = (double) accountInfo.getValue().getLamports() / LAMPORTS_PER_SOL;
+
+ // Account data list
+ final List accountData = accountInfo.getValue().getData();
+
+ // Verify "base64" string in accountData
+ assertTrue(accountData.stream().anyMatch(s -> s.equalsIgnoreCase("base64")));
+ assertTrue(balance > 0);
+ }
+
+ @Test
+ public void getAccountInfoWithEncodingJsonParsed() throws RpcException {
+ // Get account Info with encoding jsonParsed
+ final AccountInfo accountInfo = client.getApi().getAccountInfo(PublicKey.valueOf("So11111111111111111111111111111111111111112"), Map.of("encoding", "jsonParsed"));
+ final double balance = (double) accountInfo.getValue().getLamports() / LAMPORTS_PER_SOL;
+
+ // Account data list
+ final List accountData = accountInfo.getValue().getData();
+
+ // Verify "jsonParsed" string in accountData
+ assertTrue(accountData.stream().anyMatch(s -> s.equalsIgnoreCase("jsonParsed")));
+ assertTrue(balance > 0);
+ }
+
+
+
+
@Test
public void getAccountInfoRootCommitment() {
try {
@@ -68,7 +113,7 @@ public void getAccountInfoRootCommitment() {
final AccountInfo accountInfo = client.getApi().getAccountInfo(PublicKey.valueOf(
"So11111111111111111111111111111111111111112"), Map.of("commitment", Commitment.ROOT));
final double balance = (double) accountInfo.getValue().getLamports() / LAMPORTS_PER_SOL;
-
+ LOGGER.info("balance = " + balance);
// Verify any balance
assertTrue(balance > 0);
} catch (RpcException e) {
@@ -139,12 +184,12 @@ public void getBlockCommitmentTest() {
long block = 5;
try {
- final BlockCommitment blockCommitment = client.getApi().getBlockCommitment(block);
+ final BlockCommitment blockCommitment = client.getApi().getBlockCommitment(block);
- LOGGER.info(String.format("block = %d, totalStake = %d", block, blockCommitment.getTotalStake()));
+ LOGGER.info(String.format("block = %d, totalStake = %d", block, blockCommitment.getTotalStake()));
- assertNotNull(blockCommitment);
- assertTrue(blockCommitment.getTotalStake() > 0);
+ assertNotNull(blockCommitment);
+ assertTrue(blockCommitment.getTotalStake() > 0);
} catch (RpcException e) {
e.printStackTrace();
}
@@ -153,9 +198,9 @@ public void getBlockCommitmentTest() {
@Test
public void getBlockHeightTest() {
try {
- long blockHeight = client.getApi().getBlockHeight();
- LOGGER.info(String.format("Block height = %d", blockHeight));
- assertTrue(blockHeight > 0);
+ long blockHeight = client.getApi().getBlockHeight();
+ LOGGER.info(String.format("Block height = %d", blockHeight));
+ assertTrue(blockHeight > 0);
} catch (RpcException e) {
e.printStackTrace();
}
@@ -193,17 +238,17 @@ public void getVersionTest() throws RpcException {
@Test
public void getClusterNodesTest() {
try {
- final List clusterNodes = client.getApi().getClusterNodes();
+ final List clusterNodes = client.getApi().getClusterNodes();
- // Make sure we got some nodes
- assertNotNull(clusterNodes);
- assertTrue(clusterNodes.size() > 0);
+ // Make sure we got some nodes
+ assertNotNull(clusterNodes);
+ assertTrue(clusterNodes.size() > 0);
- // Output the nodes
- LOGGER.info("Cluster Nodes:");
- clusterNodes.forEach(clusterNode -> {
- LOGGER.info(clusterNode.toString());
- });
+ // Output the nodes
+ LOGGER.info("Cluster Nodes:");
+ clusterNodes.forEach(clusterNode -> {
+ LOGGER.info(clusterNode.toString());
+ });
} catch (RpcException e) {
e.printStackTrace();
}
From 12af101d11b2b4a05d1b0f63b4f5ab466f11443b Mon Sep 17 00:00:00 2001
From: skynetcap <100323448+skynetcap@users.noreply.github.com>
Date: Mon, 2 Sep 2024 01:07:42 -0700
Subject: [PATCH 03/65] Add getAccountInfo tests and some documentation, to
test Cursor AI.
---
.../java/org/p2p/solanaj/core/TransactionInstruction.java | 4 ++++
src/test/java/org/p2p/solanaj/core/MainnetTest.java | 1 +
2 files changed, 5 insertions(+)
diff --git a/src/main/java/org/p2p/solanaj/core/TransactionInstruction.java b/src/main/java/org/p2p/solanaj/core/TransactionInstruction.java
index 06cf9343..217def8c 100644
--- a/src/main/java/org/p2p/solanaj/core/TransactionInstruction.java
+++ b/src/main/java/org/p2p/solanaj/core/TransactionInstruction.java
@@ -2,11 +2,15 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
+import lombok.ToString;
+import lombok.EqualsAndHashCode;
import java.util.List;
@Getter
@AllArgsConstructor
+@ToString
+@EqualsAndHashCode
public class TransactionInstruction {
private PublicKey programId;
diff --git a/src/test/java/org/p2p/solanaj/core/MainnetTest.java b/src/test/java/org/p2p/solanaj/core/MainnetTest.java
index b1ed9392..c8fd9106 100644
--- a/src/test/java/org/p2p/solanaj/core/MainnetTest.java
+++ b/src/test/java/org/p2p/solanaj/core/MainnetTest.java
@@ -90,6 +90,7 @@ public void getAccountInfoWithFinalizedCommitment() throws RpcException {
}
@Test
+ @Ignore
public void getAccountInfoWithEncodingJsonParsed() throws RpcException {
// Get account Info with encoding jsonParsed
final AccountInfo accountInfo = client.getApi().getAccountInfo(PublicKey.valueOf("So11111111111111111111111111111111111111112"), Map.of("encoding", "jsonParsed"));
From c7aa76d0a79ea73b79a36344c107622801362cb5 Mon Sep 17 00:00:00 2001
From: skynetcap <100323448+skynetcap@users.noreply.github.com>
Date: Mon, 2 Sep 2024 01:20:04 -0700
Subject: [PATCH 04/65] Revert "Add getAccountInfo tests and some
documentation, to test Cursor AI."
This reverts commit 12af101d11b2b4a05d1b0f63b4f5ab466f11443b.
---
.../java/org/p2p/solanaj/core/TransactionInstruction.java | 4 ----
src/test/java/org/p2p/solanaj/core/MainnetTest.java | 1 -
2 files changed, 5 deletions(-)
diff --git a/src/main/java/org/p2p/solanaj/core/TransactionInstruction.java b/src/main/java/org/p2p/solanaj/core/TransactionInstruction.java
index 217def8c..06cf9343 100644
--- a/src/main/java/org/p2p/solanaj/core/TransactionInstruction.java
+++ b/src/main/java/org/p2p/solanaj/core/TransactionInstruction.java
@@ -2,15 +2,11 @@
import lombok.AllArgsConstructor;
import lombok.Getter;
-import lombok.ToString;
-import lombok.EqualsAndHashCode;
import java.util.List;
@Getter
@AllArgsConstructor
-@ToString
-@EqualsAndHashCode
public class TransactionInstruction {
private PublicKey programId;
diff --git a/src/test/java/org/p2p/solanaj/core/MainnetTest.java b/src/test/java/org/p2p/solanaj/core/MainnetTest.java
index c8fd9106..b1ed9392 100644
--- a/src/test/java/org/p2p/solanaj/core/MainnetTest.java
+++ b/src/test/java/org/p2p/solanaj/core/MainnetTest.java
@@ -90,7 +90,6 @@ public void getAccountInfoWithFinalizedCommitment() throws RpcException {
}
@Test
- @Ignore
public void getAccountInfoWithEncodingJsonParsed() throws RpcException {
// Get account Info with encoding jsonParsed
final AccountInfo accountInfo = client.getApi().getAccountInfo(PublicKey.valueOf("So11111111111111111111111111111111111111112"), Map.of("encoding", "jsonParsed"));
From e90e76c97e98bbd4081a29883e1165b3de461ea3 Mon Sep 17 00:00:00 2001
From: skynetcap <100323448+skynetcap@users.noreply.github.com>
Date: Mon, 2 Sep 2024 01:20:17 -0700
Subject: [PATCH 05/65] Revert "Add getAccountInfo tests and some
documentation, to test Cursor AI."
This reverts commit 3dbbddf944fdfac0c4df02e9357e5be4756857b1.
---
.../java/org/p2p/solanaj/core/Account.java | 10 ---
.../org/p2p/solanaj/core/MainnetTest.java | 79 ++++---------------
2 files changed, 17 insertions(+), 72 deletions(-)
diff --git a/src/main/java/org/p2p/solanaj/core/Account.java b/src/main/java/org/p2p/solanaj/core/Account.java
index 7cb3b0c1..cc41eb67 100644
--- a/src/main/java/org/p2p/solanaj/core/Account.java
+++ b/src/main/java/org/p2p/solanaj/core/Account.java
@@ -24,14 +24,6 @@ private Account(TweetNaclFast.Signature.KeyPair keyPair) {
this.keyPair = keyPair;
}
- /**
- * Deprecated method for creating an Account object from mnemonic using the legacy deviation path.
- *
- * @param words seed words
- * @param passphrase seed passphrase
- * @return Account object generated from the mnemonic
- * @deprecated This method uses a deprecated deviation path. Use the new method fromBip44Mnemonic instead.
- */
@Deprecated
public static Account fromMnemonic(List words, String passphrase) {
byte[] seed = MnemonicCode.toSeed(words, passphrase);
@@ -124,6 +116,4 @@ private static byte[] convertJsonStringToByteArray(String characters) {
return buffer.array();
}
-
-
}
\ No newline at end of file
diff --git a/src/test/java/org/p2p/solanaj/core/MainnetTest.java b/src/test/java/org/p2p/solanaj/core/MainnetTest.java
index b1ed9392..f8bdc97f 100644
--- a/src/test/java/org/p2p/solanaj/core/MainnetTest.java
+++ b/src/test/java/org/p2p/solanaj/core/MainnetTest.java
@@ -61,51 +61,6 @@ public void getAccountInfoBase58() throws RpcException {
assertTrue(balance > 0);
}
- @Test
- public void getAccountInfoWithConfirmedCommitment() throws RpcException {
- // Get account Info with confirmed commitment
- final AccountInfo accountInfo = client.getApi().getAccountInfo(PublicKey.valueOf("So11111111111111111111111111111111111111112"), Map.of("commitment", Commitment.CONFIRMED));
- final double balance = (double) accountInfo.getValue().getLamports() / LAMPORTS_PER_SOL;
-
- // Account data list
- final List accountData = accountInfo.getValue().getData();
-
- // Verify "base64" string in accountData
- assertTrue(accountData.stream().anyMatch(s -> s.equalsIgnoreCase("base64")));
- assertTrue(balance > 0);
- }
-
- @Test
- public void getAccountInfoWithFinalizedCommitment() throws RpcException {
- // Get account Info with finalized commitment
- final AccountInfo accountInfo = client.getApi().getAccountInfo(PublicKey.valueOf("So11111111111111111111111111111111111111112"), Map.of("commitment", Commitment.FINALIZED));
- final double balance = (double) accountInfo.getValue().getLamports() / LAMPORTS_PER_SOL;
-
- // Account data list
- final List accountData = accountInfo.getValue().getData();
-
- // Verify "base64" string in accountData
- assertTrue(accountData.stream().anyMatch(s -> s.equalsIgnoreCase("base64")));
- assertTrue(balance > 0);
- }
-
- @Test
- public void getAccountInfoWithEncodingJsonParsed() throws RpcException {
- // Get account Info with encoding jsonParsed
- final AccountInfo accountInfo = client.getApi().getAccountInfo(PublicKey.valueOf("So11111111111111111111111111111111111111112"), Map.of("encoding", "jsonParsed"));
- final double balance = (double) accountInfo.getValue().getLamports() / LAMPORTS_PER_SOL;
-
- // Account data list
- final List accountData = accountInfo.getValue().getData();
-
- // Verify "jsonParsed" string in accountData
- assertTrue(accountData.stream().anyMatch(s -> s.equalsIgnoreCase("jsonParsed")));
- assertTrue(balance > 0);
- }
-
-
-
-
@Test
public void getAccountInfoRootCommitment() {
try {
@@ -113,7 +68,7 @@ public void getAccountInfoRootCommitment() {
final AccountInfo accountInfo = client.getApi().getAccountInfo(PublicKey.valueOf(
"So11111111111111111111111111111111111111112"), Map.of("commitment", Commitment.ROOT));
final double balance = (double) accountInfo.getValue().getLamports() / LAMPORTS_PER_SOL;
- LOGGER.info("balance = " + balance);
+
// Verify any balance
assertTrue(balance > 0);
} catch (RpcException e) {
@@ -184,12 +139,12 @@ public void getBlockCommitmentTest() {
long block = 5;
try {
- final BlockCommitment blockCommitment = client.getApi().getBlockCommitment(block);
+ final BlockCommitment blockCommitment = client.getApi().getBlockCommitment(block);
- LOGGER.info(String.format("block = %d, totalStake = %d", block, blockCommitment.getTotalStake()));
+ LOGGER.info(String.format("block = %d, totalStake = %d", block, blockCommitment.getTotalStake()));
- assertNotNull(blockCommitment);
- assertTrue(blockCommitment.getTotalStake() > 0);
+ assertNotNull(blockCommitment);
+ assertTrue(blockCommitment.getTotalStake() > 0);
} catch (RpcException e) {
e.printStackTrace();
}
@@ -198,9 +153,9 @@ public void getBlockCommitmentTest() {
@Test
public void getBlockHeightTest() {
try {
- long blockHeight = client.getApi().getBlockHeight();
- LOGGER.info(String.format("Block height = %d", blockHeight));
- assertTrue(blockHeight > 0);
+ long blockHeight = client.getApi().getBlockHeight();
+ LOGGER.info(String.format("Block height = %d", blockHeight));
+ assertTrue(blockHeight > 0);
} catch (RpcException e) {
e.printStackTrace();
}
@@ -238,17 +193,17 @@ public void getVersionTest() throws RpcException {
@Test
public void getClusterNodesTest() {
try {
- final List clusterNodes = client.getApi().getClusterNodes();
+ final List clusterNodes = client.getApi().getClusterNodes();
- // Make sure we got some nodes
- assertNotNull(clusterNodes);
- assertTrue(clusterNodes.size() > 0);
+ // Make sure we got some nodes
+ assertNotNull(clusterNodes);
+ assertTrue(clusterNodes.size() > 0);
- // Output the nodes
- LOGGER.info("Cluster Nodes:");
- clusterNodes.forEach(clusterNode -> {
- LOGGER.info(clusterNode.toString());
- });
+ // Output the nodes
+ LOGGER.info("Cluster Nodes:");
+ clusterNodes.forEach(clusterNode -> {
+ LOGGER.info(clusterNode.toString());
+ });
} catch (RpcException e) {
e.printStackTrace();
}
From 280316c21c3cc43061baa72a3f3096276057c00f Mon Sep 17 00:00:00 2001
From: skynetcap <100323448+skynetcap@users.noreply.github.com>
Date: Wed, 4 Sep 2024 16:28:29 -0700
Subject: [PATCH 06/65] Add stake minimum delegation and prioritization fees
methods
Added new methods to retrieve the network's stake minimum delegation and recent prioritization fees. Refactored existing code to improve checks for null values and added relevant tests to cover the new functionalities.
---
src/main/java/org/p2p/solanaj/rpc/RpcApi.java | 157 ++++++++++++++----
.../rpc/types/RecentPrioritizationFees.java | 21 +++
.../org/p2p/solanaj/core/MainnetTest.java | 21 ++-
3 files changed, 163 insertions(+), 36 deletions(-)
create mode 100644 src/main/java/org/p2p/solanaj/rpc/types/RecentPrioritizationFees.java
diff --git a/src/main/java/org/p2p/solanaj/rpc/RpcApi.java b/src/main/java/org/p2p/solanaj/rpc/RpcApi.java
index 37f0b3d2..4c515605 100644
--- a/src/main/java/org/p2p/solanaj/rpc/RpcApi.java
+++ b/src/main/java/org/p2p/solanaj/rpc/RpcApi.java
@@ -25,6 +25,7 @@
import org.p2p.solanaj.rpc.types.config.VoteAccountConfig;
import org.p2p.solanaj.ws.SubscriptionWebSocketClient;
import org.p2p.solanaj.ws.listeners.NotificationEventListener;
+import org.p2p.solanaj.rpc.types.RecentPrioritizationFees;
public class RpcApi {
private RpcClient client;
@@ -40,7 +41,7 @@ public String getLatestBlockhash() throws RpcException {
public String getLatestBlockhash(Commitment commitment) throws RpcException {
List