Skip to content

Commit

Permalink
chore: ⬆️ Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
redDwarf03 committed Dec 13, 2024
1 parent d36ba78 commit e7ffa4f
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 227 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
flutter 3.24.4-stable
flutter 3.24.5-stable
84 changes: 19 additions & 65 deletions lib/src/util/transaction_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ mixin TransactionMixin {
) {
return ArchethicTransactionSender(
apiService: apiService,
phoenixHttpEndpoint: '${apiService.endpoint}/socket/websocket',
websocketEndpoint:
'${apiService.endpoint.replaceAll('https:', 'wss:').replaceAll('http:', 'wss:')}/socket/websocket',
);
}

Expand All @@ -40,72 +37,29 @@ mixin TransactionMixin {
break;
}
var next = false;
String websocketEndpoint;
switch (apiService.endpoint) {
case 'https://mainnet.archethic.net':
case 'https://testnet.archethic.net':
websocketEndpoint =
"${apiService.endpoint.replaceAll('https:', 'wss:').replaceAll('http:', 'wss:')}/socket/websocket";
break;
default:
websocketEndpoint =
"${apiService.endpoint.replaceAll('https:', 'wss:').replaceAll('http:', 'ws:')}/socket/websocket";
break;
}

final transactionRepository = ArchethicTransactionSender(
apiService: apiService,
phoenixHttpEndpoint: '${apiService.endpoint}/socket/websocket',
websocketEndpoint: websocketEndpoint,
);
await transactionRepository.send(
transaction: transaction,
onConfirmation: (confirmation) async {
if (confirmation.isEnoughConfirmed) {
if (kDebugMode) {
sl.get<LogManager>().log(
'nbConfirmations: ${confirmation.nbConfirmations}, transactionAddress: ${confirmation.transactionAddress}, maxConfirmations: ${confirmation.maxConfirmations}',
level: LogLevel.debug,
name: 'TransactionDexMixin - sendTransactions',
);
}
transactionRepository.close();
next = true;
}
},
onError: (error) async {
transactionRepository.close();
error.maybeMap(
connectivity: (_) {
errorDetail = 'No connection';
},
consensusNotReached: (_) {
errorDetail = 'Consensus not reached';
},
timeout: (_) {
errorDetail = 'Timeout';
},
invalidConfirmation: (_) {
errorDetail = 'Invalid Confirmation';
},
insufficientFunds: (_) {
errorDetail = 'Insufficient funds';
},
other: (error) {
errorDetail = error.messageLabel;
if (error.data != null) {
final data = error.data! as Map<String, dynamic>;
if (data['data'] != null && data['data']['message'] != null) {
errorDetail = data['data']['message'];
}
try {
await transactionRepository.send(
transaction: transaction,
onConfirmation: (confirmation) async {
if (confirmation.isEnoughConfirmed) {
if (kDebugMode) {
sl.get<LogManager>().log(
'nbConfirmations: ${confirmation.nbConfirmations}, transactionAddress: ${confirmation.transactionAddress}, maxConfirmations: ${confirmation.maxConfirmations}',
level: LogLevel.debug,
name: 'TransactionDexMixin - sendTransactions',
);
}
},
orElse: () {
errorDetail = 'An error is occured';
},
);
},
);
transactionRepository.close();
next = true;
}
},
);
} catch (transactionError) {
errorDetail = transactionError.toString();
}

while (next == false && errorDetail.isEmpty) {
await Future.delayed(const Duration(seconds: 1));
Expand Down
Loading

0 comments on commit e7ffa4f

Please sign in to comment.