From c9b3c8a92d87b614d057a12fa265995276916297 Mon Sep 17 00:00:00 2001 From: dev2 Date: Thu, 19 Dec 2024 13:51:00 +0100 Subject: [PATCH 1/4] refactor: simplify TronTransaction raw transaction handling and remove unused import --- lib/src/crypto/tron/entities/tron_transaction.dart | 3 +-- lib/src/domain/entities/generic_transaction.dart | 2 -- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/src/crypto/tron/entities/tron_transaction.dart b/lib/src/crypto/tron/entities/tron_transaction.dart index 8d1f0ae07..cc0eb25af 100644 --- a/lib/src/crypto/tron/entities/tron_transaction.dart +++ b/lib/src/crypto/tron/entities/tron_transaction.dart @@ -140,8 +140,7 @@ base class TronTransaction extends EVMTransaction { ); final rawData = raw_data_hex.hexToBytes; - final tron.Transaction_raw rawTx = - tron.Transaction_raw.fromBuffer(rawData); + final Transaction_raw rawTx = Transaction_raw.fromBuffer(rawData); final contract = rawTx.contract.first; final contractType = contract.type; diff --git a/lib/src/domain/entities/generic_transaction.dart b/lib/src/domain/entities/generic_transaction.dart index 5775ed77d..818eeb6f1 100644 --- a/lib/src/domain/entities/generic_transaction.dart +++ b/lib/src/domain/entities/generic_transaction.dart @@ -7,8 +7,6 @@ import 'package:walletkit_dart/src/common/http_repository.dart'; import 'package:walletkit_dart/src/crypto/utxo/entities/payments/p2h.dart'; import 'package:walletkit_dart/src/crypto/utxo/utils/pubkey_to_address.dart'; import 'package:walletkit_dart/walletkit_dart.dart'; -import 'package:walletkit_dart/src/crypto/tron/repositories/rpc/core/Tron.pb.dart' - as tron; part '../../crypto/evm/entities/transactions/evm_transaction.dart'; part '../../crypto/utxo/entities/transactions/utxo_transaction.dart'; From 54e18d319cb8821300067ea2416508e296d0fcb1 Mon Sep 17 00:00:00 2001 From: dev2 Date: Thu, 19 Dec 2024 13:55:24 +0100 Subject: [PATCH 2/4] Adjust Generate Docs Jobs to only run on main --- .github/workflows/dart.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 0f7f1ca18..fe197b5aa 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -54,6 +54,7 @@ jobs: generate-docs: runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' permissions: contents: write # Required for pushing to gh-pages pages: write # Required for deploying to Pages From aaae4c43498fece976c371189b00dd584c9ddc8b Mon Sep 17 00:00:00 2001 From: dev2 Date: Thu, 19 Dec 2024 14:30:12 +0100 Subject: [PATCH 3/4] Better Error Handling for Failed Simulations --- lib/src/crypto/utxo/utxo_analyzer.dart | 6 ++++++ test/no_ci/input_simulation_test.dart | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/src/crypto/utxo/utxo_analyzer.dart b/lib/src/crypto/utxo/utxo_analyzer.dart index d6a14f95f..83192ac55 100644 --- a/lib/src/crypto/utxo/utxo_analyzer.dart +++ b/lib/src/crypto/utxo/utxo_analyzer.dart @@ -257,6 +257,12 @@ Future fetchUTXOTransactions({ min: minEndpoints, ); + print( + "Selected ${endpoints.map( + (e) => "$e", + )}", + ); + final isolateManager = IsolateManager(); /// diff --git a/test/no_ci/input_simulation_test.dart b/test/no_ci/input_simulation_test.dart index 8dbcea3a8..8bab8227e 100644 --- a/test/no_ci/input_simulation_test.dart +++ b/test/no_ci/input_simulation_test.dart @@ -203,7 +203,7 @@ Future<(UTXOTransaction, String?)> fetchUTXOTXByHash( Iterable nodes, Iterable addressTypes, ) async { - final (result, _, _) = await fetchFromRandomElectrumXNode( + final (result, _, e) = await fetchFromRandomElectrumXNode( (client) async { return ( await client.getTransactionForSimulation( @@ -221,6 +221,8 @@ Future<(UTXOTransaction, String?)> fetchUTXOTXByHash( timeout: Duration(seconds: 10), ); + expect(e, isNull); + expect(result, isNotNull, reason: "Result is null for $hash"); return result!; From d983fa7dcfa6471e0ed08b1fdb0481ae0694b7ac Mon Sep 17 00:00:00 2001 From: dev2 Date: Thu, 19 Dec 2024 14:37:51 +0100 Subject: [PATCH 4/4] refactor: improve output handling in ElectrumXClient and enhance error messaging in signInputs --- .../crypto/utxo/repositories/electrum_json_rpc_client.dart | 4 ++-- lib/src/crypto/utxo/utils/send.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/crypto/utxo/repositories/electrum_json_rpc_client.dart b/lib/src/crypto/utxo/repositories/electrum_json_rpc_client.dart index 6e52746b8..890a7ec0f 100644 --- a/lib/src/crypto/utxo/repositories/electrum_json_rpc_client.dart +++ b/lib/src/crypto/utxo/repositories/electrum_json_rpc_client.dart @@ -153,14 +153,14 @@ class ElectrumXClient { return ElectrumOutput.fromJson(_outputs[index]); } }) - ]; + ].nonNulls; return UTXOTransaction.create( json: mainTxJson, addressTypes: addressTypes, type: type, nodes: nodes, - spentOutputs: outputs.whereType(), + spentOutputs: outputs, ); } diff --git a/lib/src/crypto/utxo/utils/send.dart b/lib/src/crypto/utxo/utils/send.dart index f61d9ab8f..26183bbcd 100644 --- a/lib/src/crypto/utxo/utils/send.dart +++ b/lib/src/crypto/utxo/utils/send.dart @@ -291,7 +291,7 @@ List signInputs({ walletPath: walletPath, ); } else - throw SendFailure("Can't sign input without node"); + throw SendFailure("Can't sign input without node: $output $input"); } if (tx is BTCRawTransaction && output.scriptPubKey.isSegwit) {