Skip to content

Commit bba9306

Browse files
committed
feat: batch run examples
1 parent b29cfe3 commit bba9306

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+306
-90
lines changed

jot-examples/README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# 🧩 Jot Examples
22

3-
Runnable examples that demonstrate how to use the **Jot (Polkadot Java SDK)** to connect to a node, query on-chain data, and submit transactions.
4-
These examples are configured to run against the **Westend** test network and are intended to **succeed when run** using a funded test account.
3+
Runnable examples demonstrating how to use the Jot (Polkadot Java SDK) to connect to a node, query on-chain data, and submit transactions.
4+
5+
All examples are configured for the **Westend** test network and are designed to run successfully when using a **funded** test account.
6+
7+
> 💡 Note: For examples that submit extrinsics, **successfully** means the transaction is broadcast to the blockchain and a valid transaction hash is returned. Some calls may still fail at the protocol level (for example, attempting Staking.unbond on an account that is not currently staking).
58
69
---
710

@@ -29,11 +32,14 @@ From the `jot-examples` module:
2932
# Build everything
3033
mvn -q -DskipTests package
3134

32-
# Run any example (Replace <ExampleClass> with one below)
33-
mvn exec:java -Dexec.mainClass="<ExampleClass>"
35+
# Run a specific example (Replace class with one below)
36+
mvn exec:java -Dexec.mainClass="com.method5.jot.examples.query.QueryAccountAndBalanceExample"
37+
38+
# Run all examples not requiring funds
39+
mvn exec:java -Dexec.mainClass="com.method5.jot.util.RunAllReadOnly"
3440

35-
# For example:
36-
# mvn exec:java -Dexec.mainClass="com.method5.jot.examples.query.QueryAccountAndBalanceExample"
41+
# Run all examples
42+
mvn exec:java -Dexec.mainClass="com.method5.jot.util.RunAll"
3743
```
3844

3945
---

jot-examples/src/main/java/com/method5/jot/examples/extrinsic/BalancesTransferAllExample.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ public static void main(String[] args) throws Exception {
2121
}
2222
}
2323

24-
private static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
24+
public static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
2525
logger.info("Balances Transfer Example");
26+
logger.info("------------------------");
2627

2728
// Destination address
2829
AccountId destination = AccountId.fromSS58("13NHcoGFJsHJoCYVsJrrv2ygLtz2XJSR17KrnA9QTNYz3Zkz");

jot-examples/src/main/java/com/method5/jot/examples/extrinsic/BalancesTransferAllowDeathExample.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ public static void main(String[] args) throws Exception {
2323
}
2424
}
2525

26-
private static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
26+
public static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
2727
logger.info("Balances Transfer Allow Death Example");
28+
logger.info("------------------------");
2829

2930
// Destination address
3031
AccountId destination = AccountId.fromSS58("13NHcoGFJsHJoCYVsJrrv2ygLtz2XJSR17KrnA9QTNYz3Zkz");

jot-examples/src/main/java/com/method5/jot/examples/extrinsic/BalancesTransferKeepAliveExample.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ public static void main(String[] args) throws Exception {
2323
}
2424
}
2525

26-
private static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
26+
public static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
2727
logger.info("Balances Transfer Keep Alive Example");
28+
logger.info("------------------------");
2829

2930
// Destination address
3031
AccountId destination = AccountId.fromSS58("13NHcoGFJsHJoCYVsJrrv2ygLtz2XJSR17KrnA9QTNYz3Zkz");

jot-examples/src/main/java/com/method5/jot/examples/extrinsic/ConvictionVotingRemoveVoteExample.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ public static void main(String[] args) throws Exception {
2020
}
2121
}
2222

23-
private static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
23+
public static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
2424
logger.info("Conviction Voting Remove Vote Example");
25+
logger.info("------------------------");
2526

2627
// Referendum index
2728
int referendumIndex = 12345;

jot-examples/src/main/java/com/method5/jot/examples/extrinsic/ConvictionVotingVoteExample.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ public static void main(String[] args) throws Exception {
2424
}
2525
}
2626

27-
private static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
27+
public static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
2828
logger.info("Conviction Voting Vote Example");
29+
logger.info("------------------------");
2930

3031
// Referendum index
3132
int referendumIndex = 12345;

jot-examples/src/main/java/com/method5/jot/examples/extrinsic/MultisigApproveAsMultiExample.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ public static void main(String[] args) throws Exception {
2727
}
2828
}
2929

30-
private static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
30+
public static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
3131
logger.info("Multisig Approve As Multi Example");
32+
logger.info("------------------------");
3233

3334
// Multisig participants
3435
List<AccountId> signers = Arrays.asList(

jot-examples/src/main/java/com/method5/jot/examples/extrinsic/MultisigAsMultiExample.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ public static void main(String[] args) throws Exception {
2727
}
2828
}
2929

30-
private static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
30+
public static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
3131
logger.info("Multisig As Multi Example");
32+
logger.info("------------------------");
3233

3334
// Multisig participants
3435
List<AccountId> signers = Arrays.asList(

jot-examples/src/main/java/com/method5/jot/examples/extrinsic/OfflineSigningExample.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@ public static void main(String[] args) throws Exception {
2626
}
2727
}
2828

29-
private static void execute(OfflineApi api, SigningProvider signingProvider) throws Exception {
29+
public static void execute(OfflineApi api, SigningProvider signingProvider) throws Exception {
30+
logger.info("Offline Signing Example");
31+
logger.info("------------------------");
32+
3033
// Call to submit and retrieve results for
3134
Call call = api.tx().system().remark("test");
3235

3336
// Submit to RPC and wait for result
3437
String signedExtrinsic = call.signOffline(signingProvider, nonce);
3538

3639
// Result
37-
logger.info("Signed extrinsic: {}", signedExtrinsic);
40+
logger.info("Created signed extrinsic for System.remark(\"test\"): {}", signedExtrinsic);
3841
}
3942

4043
static

jot-examples/src/main/java/com/method5/jot/examples/extrinsic/ReceiveExtrinsicResultExample.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@ public static void main(String[] args) throws Exception {
2121
}
2222
}
2323

24-
private static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
24+
public static void execute(PolkadotWs api, SigningProvider signingProvider) throws Exception {
25+
logger.info("Retrieve Extrinsic Result Example");
26+
logger.info("------------------------");
27+
2528
// Call to submit and retrieve results for
2629
Call call = api.tx().system().remark("test");
2730

31+
logger.info("Submitting extrinsic..");
32+
2833
// Submit to RPC and wait for result
2934
ExtrinsicResult result = call.signAndWaitForResults(signingProvider);
3035

3136
// Result
37+
logger.info("Hash: {}", result.getHash());
38+
3239
logger.info("Successful: {}", result.isSuccess());
3340

3441
// Individual events related to extrinsic

0 commit comments

Comments
 (0)