|
| 1 | +import 'dart:async'; |
1 | 2 | import 'dart:io'; |
2 | 3 |
|
3 | 4 | import 'package:isar/isar.dart'; |
@@ -128,6 +129,7 @@ class TezosWallet extends Bip39Wallet<Tezos> { |
128 | 129 | // customFee: customFee?.raw.toInt(), |
129 | 130 | // customGasLimit: customGasLimit, |
130 | 131 | // reveal: false, |
| 132 | + customGasLimit: 10600, |
131 | 133 | ); |
132 | 134 |
|
133 | 135 | // if (reveal) { |
@@ -286,8 +288,38 @@ class TezosWallet extends Bip39Wallet<Tezos> { |
286 | 288 | @override |
287 | 289 | Future<TxData> confirmSend({required TxData txData}) async { |
288 | 290 | _hackedCheckTorNodePrefs(); |
| 291 | + |
| 292 | + final completer = Completer<void>(); |
| 293 | + final sub = mainDB.isar.transactions |
| 294 | + .where() |
| 295 | + .walletIdEqualTo(walletId) |
| 296 | + .watch(fireImmediately: true) |
| 297 | + .listen((event) { |
| 298 | + if (!completer.isCompleted && |
| 299 | + event |
| 300 | + .where((e) => e.txid == txData.tezosOperationsList!.result.id) |
| 301 | + .isNotEmpty) { |
| 302 | + completer.complete(); |
| 303 | + } |
| 304 | + }); |
| 305 | + |
289 | 306 | await txData.tezosOperationsList!.inject(); |
290 | | - await txData.tezosOperationsList!.monitor(); |
| 307 | + |
| 308 | + final completerFuture = completer.future.timeout( |
| 309 | + const Duration(minutes: 2), |
| 310 | + onTimeout: () { |
| 311 | + throw Exception("Tezos confirm send timeout"); |
| 312 | + }, |
| 313 | + ); |
| 314 | + |
| 315 | + while (!completer.isCompleted) { |
| 316 | + await updateTransactions(); |
| 317 | + await Future<void>.delayed(const Duration(seconds: 3)); |
| 318 | + } |
| 319 | + |
| 320 | + await completerFuture; |
| 321 | + |
| 322 | + unawaited(sub.cancel()); |
291 | 323 | return txData.copyWith(txid: txData.tezosOperationsList!.result.id); |
292 | 324 | } |
293 | 325 |
|
|
0 commit comments