@@ -24,51 +24,62 @@ public static void main(String[] args) throws Exception {
2424 Wallet wallet = Wallet .fromMnemonic (Config .MNEMONIC_PHRASE );
2525
2626 try (PolkadotWs api = new PolkadotWs (Config .WSS_SERVER , 10000 )) {
27- ManualQueryExample .execute (api );
28- QueryAccountAndBalanceExample .execute (api );
29- QueryBlockExample .execute (api );
30- QueryBlockHashExample .execute (api );
31- QueryBlockHeaderExample .execute (api );
32- QueryBlockEventsExample .execute (api );
33- QueryFeeInfoExample .execute (api , wallet .getSigner ());
34- QueryFinalizedHeadExample .execute (api );
35- QueryMetadataExample .execute (api );
36- QueryNonceExample .execute (api );
37- QueryRuntimeVersionExample .execute (api );
38- QuerySystemDetailsExample .execute (api );
39- SubscribeAllHeadsExample .execute (api );
40- SubscribeBestHeadsExample .execute (api );
41- SubscribeFinalizedHeadsExample .execute (api );
42- SubscribeLatestHeadsExample .execute (api );
43- SubscribeRuntimeVersionExample .execute (api );
44- ReceiveExtrinsicResultExample .execute (api , wallet .getSigner ());
45- // BalancesTransferAllExample.execute(api, wallet.getSigner());
46- BalancesTransferAllowDeathExample .execute (api , wallet .getSigner ());
47- BalancesTransferKeepAliveExample .execute (api , wallet .getSigner ());
48- ConvictionVotingVoteExample .execute (api , wallet .getSigner ());
49- ConvictionVotingRemoveVoteExample .execute (api , wallet .getSigner ());
50- MultisigAsMultiExample .execute (api , wallet .getSigner ());
51- MultisigApproveAsMultiExample .execute (api , wallet .getSigner ());
52- StakingBondExample .execute (api , wallet .getSigner ());
53- StakingChillExample .execute (api , wallet .getSigner ());
54- StakingNominateExample .execute (api , wallet .getSigner ());
55- StakingPayoutStakersExample .execute (api , wallet .getSigner ());
56- StakingRebondExample .execute (api , wallet .getSigner ());
57- StakingUnbondExample .execute (api , wallet .getSigner ());
58- SystemRemarkExample .execute (api , wallet .getSigner ());
59- UtilityBatchExample .execute (api , wallet .getSigner ());
60- UtilityBatchAllExample .execute (api , wallet .getSigner ());
61- UtilityForceBatchExample .execute (api , wallet .getSigner ());
62- ParsingMetadataExample .execute (api );
27+ runSafely ("ManualQueryExample" , () -> ManualQueryExample .execute (api ));
28+ runSafely ("QueryAccountAndBalanceExample" , () -> QueryAccountAndBalanceExample .execute (api ));
29+ runSafely ("QueryBlockExample" , () -> QueryBlockExample .execute (api ));
30+ runSafely ("QueryBlockHashExample" , () -> QueryBlockHashExample .execute (api ));
31+ runSafely ("QueryBlockHeaderExample" , () -> QueryBlockHeaderExample .execute (api ));
32+ runSafely ("QueryBlockEventsExample" , () -> QueryBlockEventsExample .execute (api ));
33+ runSafely ("QueryFeeInfoExample" , () -> QueryFeeInfoExample .execute (api , wallet .getSigner ()));
34+ runSafely ("QueryFinalizedHeadExample" , () -> QueryFinalizedHeadExample .execute (api ));
35+ runSafely ("QueryMetadataExample" , () -> QueryMetadataExample .execute (api ));
36+ runSafely ("QueryNonceExample" , () -> QueryNonceExample .execute (api ));
37+ runSafely ("QueryRuntimeVersionExample" , () -> QueryRuntimeVersionExample .execute (api ));
38+ runSafely ("QuerySystemDetailsExample" , () -> QuerySystemDetailsExample .execute (api ));
39+ runSafely ("SubscribeAllHeadsExample" , () -> SubscribeAllHeadsExample .execute (api ));
40+ runSafely ("SubscribeBestHeadsExample" , () -> SubscribeBestHeadsExample .execute (api ));
41+ runSafely ("SubscribeFinalizedHeadsExample" , () -> SubscribeFinalizedHeadsExample .execute (api ));
42+ runSafely ("SubscribeLatestHeadsExample" , () -> SubscribeLatestHeadsExample .execute (api ));
43+ runSafely ("SubscribeRuntimeVersionExample" , () -> SubscribeRuntimeVersionExample .execute (api ));
44+ runSafely ("ReceiveExtrinsicResultExample" , () -> ReceiveExtrinsicResultExample .execute (api , wallet .getSigner ()));
45+ runSafely ("BalancesTransferAllowDeathExample" , () -> BalancesTransferAllowDeathExample .execute (api , wallet .getSigner ()));
46+ runSafely ("BalancesTransferKeepAliveExample" , () -> BalancesTransferKeepAliveExample .execute (api , wallet .getSigner ()));
47+ runSafely ("ConvictionVotingVoteExample" , () -> ConvictionVotingVoteExample .execute (api , wallet .getSigner ()));
48+ runSafely ("ConvictionVotingRemoveVoteExample" , () -> ConvictionVotingRemoveVoteExample .execute (api , wallet .getSigner ()));
49+ runSafely ("MultisigAsMultiExample" , () -> MultisigAsMultiExample .execute (api , wallet .getSigner ()));
50+ runSafely ("MultisigApproveAsMultiExample" , () -> MultisigApproveAsMultiExample .execute (api , wallet .getSigner ()));
51+ runSafely ("StakingBondExample" , () -> StakingBondExample .execute (api , wallet .getSigner ()));
52+ runSafely ("StakingChillExample" , () -> StakingChillExample .execute (api , wallet .getSigner ()));
53+ runSafely ("StakingNominateExample" , () -> StakingNominateExample .execute (api , wallet .getSigner ()));
54+ runSafely ("StakingPayoutStakersExample" , () -> StakingPayoutStakersExample .execute (api , wallet .getSigner ()));
55+ runSafely ("StakingRebondExample" , () -> StakingRebondExample .execute (api , wallet .getSigner ()));
56+ runSafely ("StakingUnbondExample" , () -> StakingUnbondExample .execute (api , wallet .getSigner ()));
57+ runSafely ("SystemRemarkExample" , () -> SystemRemarkExample .execute (api , wallet .getSigner ()));
58+ runSafely ("UtilityBatchExample" , () -> UtilityBatchExample .execute (api , wallet .getSigner ()));
59+ runSafely ("UtilityBatchAllExample" , () -> UtilityBatchAllExample .execute (api , wallet .getSigner ()));
60+ runSafely ("UtilityForceBatchExample" , () -> UtilityForceBatchExample .execute (api , wallet .getSigner ()));
61+ runSafely ("ParsingMetadataExample" , () -> ParsingMetadataExample .execute (api ));
6362 }
6463
65- Ed25519WalletExample . execute ( );
66- ScaleEncodingExample . execute ( );
67- AddressConversionExample . execute ( );
68- GenericWalletExample . execute ( );
64+ runSafely ( " Ed25519WalletExample" , Ed25519WalletExample :: execute );
65+ runSafely ( " ScaleEncodingExample" , ScaleEncodingExample :: execute );
66+ runSafely ( " AddressConversionExample" , AddressConversionExample :: execute );
67+ runSafely ( " GenericWalletExample" , GenericWalletExample :: execute );
6968
7069 try (OfflineApi api = new OfflineApi ()) {
71- OfflineSigningExample .execute (api , wallet .getSigner ());
70+ runSafely ("OfflineSigningExample" , () -> OfflineSigningExample .execute (api , wallet .getSigner ()));
71+ }
72+
73+ logger .info ("All examples finished." );
74+ }
75+
76+ private static void runSafely (String name , ThrowingRunnable task ) {
77+ try {
78+ logger .info ("→ Running {}" , name );
79+ task .run ();
80+ logger .info ("✓ Completed {}" , name );
81+ } catch (Exception e ) {
82+ logger .error ("✗ Failed {}: {}" , name , e .getMessage (), e );
7283 }
7384 }
74- }
85+ }
0 commit comments