From e7808d7bf15c0a557d8887bf631efab0bcf98ded Mon Sep 17 00:00:00 2001 From: jdaev Date: Fri, 1 Oct 2021 15:27:09 -0400 Subject: [PATCH 1/5] fix: filter for drive entity owner --- lib/blocs/sync/sync_cubit.dart | 4 ++-- lib/services/arweave/arweave_service.dart | 24 +++++++++++++++++++++-- pubspec.yaml | 2 +- web/index.html | 2 +- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/lib/blocs/sync/sync_cubit.dart b/lib/blocs/sync/sync_cubit.dart index 34bcb3d7d3..90cfe95036 100644 --- a/lib/blocs/sync/sync_cubit.dart +++ b/lib/blocs/sync/sync_cubit.dart @@ -68,7 +68,6 @@ class SyncCubit extends Cubit { emit(SyncInProgress()); // Only sync in drives owned by the user if they're logged in. if (profile is ProfileLoggedIn) { - //Check if profile is ArConnect to skip sync while tab is hidden final isArConnect = await _profileCubit.isCurrentProfileArConnect(); @@ -115,7 +114,7 @@ class SyncCubit extends Cubit { Future _syncDrive(String driveId) async { final drive = await _driveDao.driveById(driveId: driveId).getSingle(); - + final owner = await _arweave.getOwnerForDriveEntityWithId(driveId); SecretKey driveKey; if (drive.isPrivate) { final profile = _profileCubit.state; @@ -138,6 +137,7 @@ class SyncCubit extends Cubit { lastBlockHeight: max(drive.lastBlockHeight - 5, drive.lastBlockHeight), after: drive.syncCursor, driveKey: driveKey, + owner: owner, ); // Create entries for all the new revisions of file and folders in this drive. diff --git a/lib/services/arweave/arweave_service.dart b/lib/services/arweave/arweave_service.dart index 4064beec7d..195518c115 100644 --- a/lib/services/arweave/arweave_service.dart +++ b/lib/services/arweave/arweave_service.dart @@ -43,8 +43,13 @@ class ArweaveService { } /// Gets the entity history for a particular drive starting from the specified block height. - Future getNewEntitiesForDrive(String driveId, - {String after, int lastBlockHeight, SecretKey driveKey}) async { + Future getNewEntitiesForDrive( + String driveId, { + String after, + int lastBlockHeight, + SecretKey driveKey, + String owner, + }) async { final driveEntityHistoryQuery = await _gql.execute( DriveEntityHistoryQuery( variables: DriveEntityHistoryArguments( @@ -107,6 +112,8 @@ class ArweaveService { // Sort the entities in each block by ascending commit time. for (final block in blockHistory) { block.entities.sort((e1, e2) => e1.createdAt.compareTo(e2.createdAt)); + //Remove entities with spoofed owners + block.entities.removeWhere((e) => e.ownerAddress != owner); } return DriveEntityHistory( @@ -235,6 +242,19 @@ class ArweaveService { } } + /// Gets the owner of the drive sorted by blockheight. + /// Returns `null` if no valid drive is found or the provided `driveKey` is incorrect. + Future getOwnerForDriveEntityWithId(String driveId) async { + final firstOwnerQuery = await _gql.execute(FirstDriveEntityWithIdOwnerQuery( + variables: FirstDriveEntityWithIdOwnerArguments(driveId: driveId))); + + if (firstOwnerQuery.data.transactions.edges.isEmpty) { + return null; + } + + return firstOwnerQuery.data.transactions.edges.first.node.owner.address; + } + /// Gets any created private drive belonging to [profileId], as long as its unlockable with [password] when used with the [getSignatureFn] Future getAnyPrivateDriveEntity( String profileId, diff --git a/pubspec.yaml b/pubspec.yaml index 02d1d9d4f8..29ef28b734 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -14,7 +14,7 @@ publish_to: 'none' # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.1.4 +version: 1.1.5 environment: diff --git a/web/index.html b/web/index.html index 1f60916fb8..cc70629249 100644 --- a/web/index.html +++ b/web/index.html @@ -35,7 +35,7 @@ - + From 3176d94fd3c18d23e6e9f08ce9b74269d7648164 Mon Sep 17 00:00:00 2001 From: jdaev Date: Tue, 5 Oct 2021 16:39:31 -0400 Subject: [PATCH 2/5] task: correct dependency versions --- pubspec.lock | 26 +++++++++++++------------- pubspec.yaml | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index cea3adbb56..8b4b06939f 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -58,7 +58,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.1" bloc: dependency: transitive description: @@ -156,7 +156,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" checked_yaml: dependency: transitive description: @@ -268,7 +268,7 @@ packages: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.0" + version: "6.1.2" file_selector: dependency: "direct main" description: @@ -648,7 +648,7 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.5" path_provider_linux: dependency: transitive description: @@ -718,7 +718,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.1" + version: "4.2.3" provider: dependency: transitive description: @@ -835,7 +835,7 @@ packages: name: sqlite3 url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.2.0" sqlparser: dependency: transitive description: @@ -891,21 +891,21 @@ packages: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.16.8" + version: "1.17.10" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.2" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.3.19" + version: "0.4.0" timeago: dependency: "direct main" description: @@ -933,7 +933,7 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.10" + version: "6.0.12" url_launcher_linux: dependency: transitive description: @@ -989,7 +989,7 @@ packages: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "6.2.0" + version: "7.1.1" watcher: dependency: transitive description: @@ -1040,5 +1040,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.13.0 <3.0.0" - flutter: ">=2.2.0" + dart: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 6595ddc47c..559aecc225 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -78,4 +78,4 @@ flutter: - assets/config/ - assets/fonts/ - assets/images/brand/ - - assets/images/profile/ + - assets/images/profile/ \ No newline at end of file From df6f7e03110113d132ed4d52ea56a493121985d4 Mon Sep 17 00:00:00 2001 From: jdaev Date: Tue, 5 Oct 2021 16:57:11 -0400 Subject: [PATCH 3/5] task: fix formatting --- lib/blocs/sync/sync_cubit.dart | 2 +- lib/services/arweave/arweave_service.dart | 2 +- pubspec.lock | 26 +++++++++++------------ pubspec.yaml | 3 +-- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/lib/blocs/sync/sync_cubit.dart b/lib/blocs/sync/sync_cubit.dart index 26503b621a..b45f11ad66 100644 --- a/lib/blocs/sync/sync_cubit.dart +++ b/lib/blocs/sync/sync_cubit.dart @@ -573,4 +573,4 @@ class SyncCubit extends Cubit { _syncSub?.cancel(); return super.close(); } -} \ No newline at end of file +} diff --git a/lib/services/arweave/arweave_service.dart b/lib/services/arweave/arweave_service.dart index 87fc031762..ea673414e0 100644 --- a/lib/services/arweave/arweave_service.dart +++ b/lib/services/arweave/arweave_service.dart @@ -473,4 +473,4 @@ class UploadTransactions { Transaction dataTx; UploadTransactions(this.entityTx, this.dataTx); -} \ No newline at end of file +} diff --git a/pubspec.lock b/pubspec.lock index 8b4b06939f..cea3adbb56 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -58,7 +58,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.8.1" + version: "2.6.1" bloc: dependency: transitive description: @@ -156,7 +156,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.3.1" + version: "1.2.0" checked_yaml: dependency: transitive description: @@ -268,7 +268,7 @@ packages: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.2" + version: "6.1.0" file_selector: dependency: "direct main" description: @@ -648,7 +648,7 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.4" path_provider_linux: dependency: transitive description: @@ -718,7 +718,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.3" + version: "4.2.1" provider: dependency: transitive description: @@ -835,7 +835,7 @@ packages: name: sqlite3 url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.1.2" sqlparser: dependency: transitive description: @@ -891,21 +891,21 @@ packages: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.17.10" + version: "1.16.8" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.2" + version: "0.3.0" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.4.0" + version: "0.3.19" timeago: dependency: "direct main" description: @@ -933,7 +933,7 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.12" + version: "6.0.10" url_launcher_linux: dependency: transitive description: @@ -989,7 +989,7 @@ packages: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "7.1.1" + version: "6.2.0" watcher: dependency: transitive description: @@ -1040,5 +1040,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.14.0 <3.0.0" - flutter: ">=2.5.0" \ No newline at end of file + dart: ">=2.13.0 <3.0.0" + flutter: ">=2.2.0" diff --git a/pubspec.yaml b/pubspec.yaml index 559aecc225..3dd96af373 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,7 +54,6 @@ dependencies: package_info_plus: ^1.0.3 js: ^0.6.3 collection: ^1.15.0-nullsafety.4 - dev_dependencies: flutter_test: @@ -78,4 +77,4 @@ flutter: - assets/config/ - assets/fonts/ - assets/images/brand/ - - assets/images/profile/ \ No newline at end of file + - assets/images/profile/ From ada39d6142dd0ba00fbe26a29ab30280a5c546fa Mon Sep 17 00:00:00 2001 From: jdaev Date: Tue, 5 Oct 2021 17:01:33 -0400 Subject: [PATCH 4/5] task: correct pubspec.lock --- pubspec.lock | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index cea3adbb56..d52638d085 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -58,7 +58,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.6.1" + version: "2.8.1" bloc: dependency: transitive description: @@ -156,7 +156,7 @@ packages: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.1" checked_yaml: dependency: transitive description: @@ -268,7 +268,7 @@ packages: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.0" + version: "6.1.2" file_selector: dependency: "direct main" description: @@ -648,7 +648,7 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.4" + version: "2.0.5" path_provider_linux: dependency: transitive description: @@ -718,7 +718,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.2.1" + version: "4.2.3" provider: dependency: transitive description: @@ -835,7 +835,7 @@ packages: name: sqlite3 url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "1.2.0" sqlparser: dependency: transitive description: @@ -891,21 +891,21 @@ packages: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.16.8" + version: "1.17.10" test_api: dependency: transitive description: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "0.4.2" test_core: dependency: transitive description: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.3.19" + version: "0.4.0" timeago: dependency: "direct main" description: @@ -933,7 +933,7 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.10" + version: "6.0.12" url_launcher_linux: dependency: transitive description: @@ -989,7 +989,7 @@ packages: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "6.2.0" + version: "7.1.1" watcher: dependency: transitive description: @@ -1040,5 +1040,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.13.0 <3.0.0" - flutter: ">=2.2.0" + dart: ">=2.14.0 <3.0.0" + flutter: ">=2.5.0" From ce09cc4ce5f7783c1f5e28432be5c6f7bf86734c Mon Sep 17 00:00:00 2001 From: jdaev Date: Tue, 5 Oct 2021 17:05:36 -0400 Subject: [PATCH 5/5] task: correct whitespace --- lib/services/arweave/arweave_service.dart | 3 +++ pubspec.yaml | 1 + 2 files changed, 4 insertions(+) diff --git a/lib/services/arweave/arweave_service.dart b/lib/services/arweave/arweave_service.dart index ea673414e0..4aa8d4dab0 100644 --- a/lib/services/arweave/arweave_service.dart +++ b/lib/services/arweave/arweave_service.dart @@ -376,6 +376,7 @@ class ArweaveService { /// Creates and signs a [Transaction] representing the provided entity. /// /// Optionally provide a [SecretKey] to encrypt the entity data. + Future prepareEntityTx( Entity entity, Wallet wallet, [ @@ -406,6 +407,7 @@ class ArweaveService { /// Creates and signs a [DataItem] representing the provided entity. /// /// Optionally provide a [SecretKey] to encrypt the entity data. + Future prepareEntityDataItem( Entity entity, Wallet wallet, [ @@ -420,6 +422,7 @@ class ArweaveService { } /// Creates and signs a [Transaction] representing the provided [DataBundle]. + Future prepareDataBundleTx( DataBundle bundle, Wallet wallet) async { final bundleTx = await client.transactions.prepare( diff --git a/pubspec.yaml b/pubspec.yaml index 3dd96af373..6595ddc47c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,6 +54,7 @@ dependencies: package_info_plus: ^1.0.3 js: ^0.6.3 collection: ^1.15.0-nullsafety.4 + dev_dependencies: flutter_test: