Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PE-6948: proceed upload despite the contract read error #1894

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/core/upload/bundle_signer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
8 changes: 7 additions & 1 deletion lib/core/upload/cost_calculator.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 5 additions & 1 deletion lib/core/upload/transaction_signer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
24 changes: 14 additions & 10 deletions lib/sync/domain/repositories/sync_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,20 @@ class _SyncRepository implements SyncRepository {

logger.i('Syncing licenses...');

final licenseTxIds = <String>{};
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 = <String>{};
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);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sync the licenses shouldn't break the sync.

}

logger.i('Licenses synced');

Expand Down
11 changes: 9 additions & 2 deletions packages/ardrive_uploader/lib/src/cost_calculator.dart
Original file line number Diff line number Diff line change
@@ -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<UploadCostEstimate> calculateCost({required int totalSize});
Expand Down Expand Up @@ -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;

Expand Down
Loading