From a0432b3415fcea69a2f2b4e06b665bd5b16045c4 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:34:59 -0300 Subject: [PATCH 1/2] hotfix - proceed upload despite the contract read error - proceed with sync if licenses were not synced --- lib/core/upload/bundle_signer.dart | 6 ++++- lib/core/upload/cost_calculator.dart | 8 ++++++- lib/core/upload/transaction_signer.dart | 6 ++++- .../domain/repositories/sync_repository.dart | 24 +++++++++++-------- .../lib/src/cost_calculator.dart | 11 +++++++-- pubspec.yaml | 2 +- 6 files changed, 41 insertions(+), 16 deletions(-) diff --git a/lib/core/upload/bundle_signer.dart b/lib/core/upload/bundle_signer.dart index ab82c4b099..20ef26c9e6 100644 --- a/lib/core/upload/bundle_signer.dart +++ b/lib/core/upload/bundle_signer.dart @@ -59,7 +59,11 @@ class ArweaveBundleTransactionSigner implements BundleTransactionSigner { logger.i('Adding tip...'); - await pstService.addCommunityTipToTx(bundleTx); + try { + await pstService.addCommunityTipToTx(bundleTx); + } catch (e) { + logger.e('Error adding community tip to transaction. Proceeding.', e); + } logger.i('Tip added'); diff --git a/lib/core/upload/cost_calculator.dart b/lib/core/upload/cost_calculator.dart index 0304280d6b..f2fa323d93 100644 --- a/lib/core/upload/cost_calculator.dart +++ b/lib/core/upload/cost_calculator.dart @@ -1,6 +1,7 @@ import 'package:ardrive/services/arweave/arweave.dart'; import 'package:ardrive/turbo/turbo.dart'; import 'package:ardrive/utils/logger.dart'; +import 'package:ardrive_utils/ardrive_utils.dart'; import 'package:arweave/utils.dart'; import 'package:equatable/equatable.dart'; import 'package:pst/pst.dart'; @@ -64,7 +65,12 @@ class UploadCostEstimateCalculatorForAR extends ArDriveUploadCostCalculator { }) async { final costInAR = await _arweaveService.getPrice(byteSize: totalSize); - final pstFee = await _pstService.getPSTFee(costInAR); + Winston pstFee = Winston(BigInt.zero); + try { + pstFee = await _pstService.getPSTFee(costInAR); + } catch (e) { + logger.e('Error adding community tip to transaction. Proceeding.', e); + } final totalCostAR = costInAR + pstFee.value; diff --git a/lib/core/upload/transaction_signer.dart b/lib/core/upload/transaction_signer.dart index 8862583570..038a45c9db 100644 --- a/lib/core/upload/transaction_signer.dart +++ b/lib/core/upload/transaction_signer.dart @@ -65,7 +65,11 @@ class ArweaveTransactionSigner implements TransactionSigner { ..addApplicationTags(version: version) ..addUTags(); - await pstService.addCommunityTipToTx(dataTx); + try { + await pstService.addCommunityTipToTx(dataTx); + } catch (e) { + logger.e('Error adding community tip to transaction. Proceeding.', e); + } // Don't include the file's Content-Type tag if it is meant to be private. if (!isPrivate) { diff --git a/lib/sync/domain/repositories/sync_repository.dart b/lib/sync/domain/repositories/sync_repository.dart index f456551053..c836dcf332 100644 --- a/lib/sync/domain/repositories/sync_repository.dart +++ b/lib/sync/domain/repositories/sync_repository.dart @@ -239,16 +239,20 @@ class _SyncRepository implements SyncRepository { logger.i('Syncing licenses...'); - final licenseTxIds = {}; - final revisionsToSyncLicense = (await _driveDao - .allFileRevisionsWithLicenseReferencedButNotSynced() - .get()) - ..retainWhere((rev) => licenseTxIds.add(rev.licenseTxId!)); - logger.d('Found ${revisionsToSyncLicense.length} licenses to sync'); - - await _updateLicenses( - revisionsToSyncLicense: revisionsToSyncLicense, - ); + try { + final licenseTxIds = {}; + final revisionsToSyncLicense = (await _driveDao + .allFileRevisionsWithLicenseReferencedButNotSynced() + .get()) + ..retainWhere((rev) => licenseTxIds.add(rev.licenseTxId!)); + logger.d('Found ${revisionsToSyncLicense.length} licenses to sync'); + + await _updateLicenses( + revisionsToSyncLicense: revisionsToSyncLicense, + ); + } catch (e) { + logger.e('Error syncing licenses. Proceeding.', e); + } logger.i('Licenses synced'); diff --git a/packages/ardrive_uploader/lib/src/cost_calculator.dart b/packages/ardrive_uploader/lib/src/cost_calculator.dart index 4c1e9499b2..348ea8f779 100644 --- a/packages/ardrive_uploader/lib/src/cost_calculator.dart +++ b/packages/ardrive_uploader/lib/src/cost_calculator.dart @@ -1,10 +1,10 @@ +import 'package:ardrive_uploader/src/utils/logger.dart'; import 'package:ardrive_utils/ardrive_utils.dart'; import 'package:arweave/arweave.dart'; import 'package:arweave/utils.dart'; // ignore: depend_on_referenced_packages import 'package:equatable/equatable.dart'; import 'package:pst/pst.dart'; -import 'package:ardrive_uploader/src/utils/logger.dart'; abstract class ArDriveUploadCostCalculator { Future calculateCost({required int totalSize}); @@ -67,7 +67,14 @@ class UploadCostEstimateCalculatorForAR extends ArDriveUploadCostCalculator { .get('/price/$totalSize') .then((res) => BigInt.parse(res.body)); - final pstFee = await _pstService.getPSTFee(costInAR); + late final Winston pstFee; + + try { + pstFee = await _pstService.getPSTFee(costInAR); + } catch (e) { + logger.e('Error adding community tip to transaction. Proceeding.', e); + pstFee = Winston(BigInt.zero); + } final totalCostAR = costInAR + pstFee.value; diff --git a/pubspec.yaml b/pubspec.yaml index ea2db77505..afa3a78745 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: Secure, permanent storage publish_to: 'none' -version: 2.55.1 +version: 2.55.2 environment: sdk: '>=3.2.0 <4.0.0' From 806d2eb2cd83829576416f3662226a0f4213770c Mon Sep 17 00:00:00 2001 From: Thiago Carvalho <32248947+thiagocarvalhodev@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:46:53 -0300 Subject: [PATCH 2/2] Update test.yml --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8a18bdc8bf..a2539e34b4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -3,7 +3,7 @@ on: jobs: test-and-lint: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: # Checkout - uses: actions/checkout@v3 @@ -34,4 +34,4 @@ jobs: run: flutter analyze - name: Test app - run: scr test \ No newline at end of file + run: scr test