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-4648: Release ArDrive Flutter v2.14.0 #1375

Merged
merged 22 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4a1e344
feat(pin file bloc): adds a gql tag for public pinned files PE-4545
matibat Sep 15, 2023
e0785f1
feat(pin file bloc): sets ArFS-Pin tag for all pins, and Pinned-Data-…
matibat Sep 15, 2023
2d8de92
feat(pin file bloc): corrects imports PE-4545
matibat Sep 15, 2023
6980f20
feat(create drive form): adds a description of the selected drive pri…
matibat Sep 15, 2023
dac42f8
feat(deps): updates ardrive-io dep PE-4554
matibat Sep 18, 2023
357bc08
feat(drive detail page): updates the detach drive icon PE-4554
matibat Sep 18, 2023
791649d
feat(pin file bloc): tag public pinned files only PE-4545
matibat Sep 18, 2023
68a11d0
feat(create drive cubit): fixes bad casting PE-4597
matibat Sep 19, 2023
c90af04
test(create drive cubit): attempts to fix skipped test PE-4597
matibat Sep 19, 2023
b1033af
Revert "feat(create drive cubit): fixes bad casting PE-4597"
matibat Sep 19, 2023
dea7f44
Revert "test(create drive cubit): attempts to fix skipped test PE-4597"
matibat Sep 19, 2023
f6abb4e
Revert "Revert "feat(create drive cubit): fixes bad casting PE-4597""
matibat Sep 19, 2023
019b3f0
Revert "Revert "test(create drive cubit): attempts to fix skipped tes…
matibat Sep 19, 2023
7f07e6d
Merge pull request #1369 from ardriveapp/PE-4632
matibat Sep 20, 2023
8b338ee
feat(pin file bloc): awaits for the signature of the transaction PE-4645
matibat Sep 20, 2023
c2a4153
Merge pull request #1371 from ardriveapp/PE-4645
matibat Sep 20, 2023
6b6f441
feat(pubspec): bumps the version of ardrive-ui PE-4554
matibat Sep 20, 2023
c1236e4
Merge pull request #1368 from ardriveapp/PE-4554_detach_icon
matibat Sep 21, 2023
668cb18
Merge pull request #1366 from ardriveapp/PE-4597
matibat Sep 21, 2023
5918a44
Merge pull request #1365 from ardriveapp/PE-4545
matibat Sep 21, 2023
7c8b939
feat(before release preps): before-release version bump and android r…
matibat Sep 21, 2023
9b053df
Merge pull request #1374 from ardriveapp/PE-4648_before_release_preps
matibat Sep 21, 2023
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
3 changes: 3 additions & 0 deletions android/fastlane/metadata/android/en-US/changelogs/62.txt
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Android release notes ✅

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Adds an explanation for the privacy of drives on the Create Drive Modal
- Starts tagging public pins with new GQL Tags: ArFS-Pin and Pinned-Data-Tx
- Updates the icon for the Detach Drive option
33 changes: 23 additions & 10 deletions lib/blocs/drive_create/drive_create_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import 'package:ardrive/blocs/blocs.dart';
import 'package:ardrive/entities/entities.dart';
import 'package:ardrive/core/arfs/entities/arfs_entities.dart'
show DrivePrivacy;
import 'package:ardrive/entities/constants.dart' as constants;
import 'package:ardrive/entities/drive_entity.dart';
import 'package:ardrive/entities/folder_entity.dart';
import 'package:ardrive/models/models.dart';
import 'package:ardrive/services/services.dart';
import 'package:ardrive/turbo/services/upload_service.dart';
Expand All @@ -15,7 +19,9 @@ part 'drive_create_state.dart';
class DriveCreateCubit extends Cubit<DriveCreateState> {
final form = FormGroup({
'privacy': FormControl<String>(
value: DrivePrivacy.private, validators: [Validators.required]),
value: DrivePrivacy.private.name,
validators: [Validators.required],
),
});

final ArweaveService _arweave;
Expand All @@ -35,25 +41,32 @@ class DriveCreateCubit extends Cubit<DriveCreateState> {
_driveDao = driveDao,
_profileCubit = profileCubit,
_drivesCubit = drivesCubit,
super(DriveCreateInitial());
super(const DriveCreateInitial(privacy: DrivePrivacy.private));

void onPrivacyChanged() {
final privacy = form.control('privacy').value == DrivePrivacy.private.name
? DrivePrivacy.private
: DrivePrivacy.public;
emit(state.copyWith(privacy: privacy));
}

Future<void> submit(
String driveName,
) async {
final profile = _profileCubit.state as ProfileLoggedIn;
if (await _profileCubit.logoutIfWalletMismatch()) {
emit(DriveCreateWalletMismatch());
emit(DriveCreateWalletMismatch(privacy: state.privacy));
return;
}

final minimumWalletBalance = BigInt.from(10000000);
if (profile.walletBalance <= minimumWalletBalance &&
!_turboUploadService.useTurboUpload) {
emit(DriveCreateZeroBalance());
emit(DriveCreateZeroBalance(privacy: state.privacy));
return;
}

emit(DriveCreateInProgress());
emit(DriveCreateInProgress(privacy: state.privacy));

try {
final String drivePrivacy = form.control('privacy').value;
Expand All @@ -72,8 +85,8 @@ class DriveCreateCubit extends Cubit<DriveCreateState> {
name: driveName,
rootFolderId: createRes.rootFolderId,
privacy: drivePrivacy,
authMode: drivePrivacy == DrivePrivacy.private
? DriveAuthMode.password
authMode: drivePrivacy == constants.DrivePrivacy.private
? constants.DriveAuthMode.password
: null,
);

Expand Down Expand Up @@ -140,12 +153,12 @@ class DriveCreateCubit extends Cubit<DriveCreateState> {
addError(err);
}

emit(DriveCreateSuccess());
emit(DriveCreateSuccess(privacy: state.privacy));
}

@override
void onError(Object error, StackTrace stackTrace) {
emit(DriveCreateFailure());
emit(DriveCreateFailure(privacy: state.privacy));
super.onError(error, stackTrace);

logger.e('Failed to create drive', error, stackTrace);
Expand Down
64 changes: 57 additions & 7 deletions lib/blocs/drive_create/drive_create_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,68 @@ part of 'drive_create_cubit.dart';

@immutable
abstract class DriveCreateState extends Equatable {
final DrivePrivacy privacy;

const DriveCreateState({required this.privacy});

DriveCreateState copyWith({DrivePrivacy? privacy}) {
throw UnimplementedError();
}

@override
List<Object> get props => [];
List<Object> get props => [privacy];
}

class DriveCreateInitial extends DriveCreateState {}
class DriveCreateInitial extends DriveCreateState {
const DriveCreateInitial({required super.privacy});

class DriveCreateZeroBalance extends DriveCreateState {}
@override
DriveCreateInitial copyWith({DrivePrivacy? privacy}) {
return DriveCreateInitial(privacy: privacy ?? this.privacy);
}
}

class DriveCreateInProgress extends DriveCreateState {}
class DriveCreateZeroBalance extends DriveCreateState {
const DriveCreateZeroBalance({required super.privacy});

class DriveCreateSuccess extends DriveCreateState {}
@override
DriveCreateZeroBalance copyWith({DrivePrivacy? privacy}) {
return DriveCreateZeroBalance(privacy: privacy ?? this.privacy);
}
}

class DriveCreateInProgress extends DriveCreateState {
const DriveCreateInProgress({required super.privacy});

@override
DriveCreateInProgress copyWith({DrivePrivacy? privacy}) {
return DriveCreateInProgress(privacy: privacy ?? this.privacy);
}
}

class DriveCreateFailure extends DriveCreateState {}
class DriveCreateSuccess extends DriveCreateState {
const DriveCreateSuccess({required super.privacy});

class DriveCreateWalletMismatch extends DriveCreateState {}
@override
DriveCreateSuccess copyWith({DrivePrivacy? privacy}) {
return DriveCreateSuccess(privacy: privacy ?? this.privacy);
}
}

class DriveCreateFailure extends DriveCreateState {
const DriveCreateFailure({required super.privacy});

@override
DriveCreateFailure copyWith({DrivePrivacy? privacy}) {
return DriveCreateFailure(privacy: privacy ?? this.privacy);
}
}

class DriveCreateWalletMismatch extends DriveCreateState {
const DriveCreateWalletMismatch({required super.privacy});

@override
DriveCreateWalletMismatch copyWith({DrivePrivacy? privacy}) {
return DriveCreateWalletMismatch(privacy: privacy ?? this.privacy);
}
}
37 changes: 34 additions & 3 deletions lib/blocs/pin_file/pin_file_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'dart:async';
import 'package:ardrive/blocs/blocs.dart';
import 'package:ardrive/core/arfs/entities/arfs_entities.dart';
import 'package:ardrive/core/crypto/crypto.dart';
import 'package:ardrive/entities/file_entity.dart';
import 'package:ardrive/entities/entities.dart' show EntityTag, FileEntity;
import 'package:ardrive/entities/string_types.dart';
import 'package:ardrive/misc/misc.dart';
import 'package:ardrive/models/models.dart';
Expand Down Expand Up @@ -279,6 +279,7 @@ class PinFileBloc extends Bloc<PinFileEvent, PinFileState> {
) async {
final stateAsPinFileFieldsValid = state as PinFileFieldsValid;
final profileState = _profileCubit.state as ProfileLoggedIn;
final wallet = profileState.wallet;

emit(PinFileCreating(
id: stateAsPinFileFieldsValid.id,
Expand Down Expand Up @@ -311,13 +312,29 @@ class PinFileBloc extends Bloc<PinFileEvent, PinFileState> {
.folderById(driveId: _driveId, folderId: _parentFolderId)
.getSingle();

final isAPublicPin = fileKey == null;

if (_turboUploadService.useTurboUpload) {
final fileDataItem = await _arweave.prepareEntityDataItem(
newFileEntity,
profileState.wallet,
wallet,
key: fileKey,
skipSignature: true,
);

if (isAPublicPin) {
fileDataItem.addTag(
EntityTag.arFsPin,
'true',
);
fileDataItem.addTag(
EntityTag.pinnedDataTx,
newFileEntity.dataTxId!,
);
}

await fileDataItem.sign(wallet);

await _turboUploadService.postDataItem(
dataItem: fileDataItem,
wallet: profileState.wallet,
Expand All @@ -326,10 +343,24 @@ class PinFileBloc extends Bloc<PinFileEvent, PinFileState> {
} else {
final fileDataItem = await _arweave.prepareEntityTx(
newFileEntity,
profileState.wallet,
wallet,
fileKey,
skipSignature: true,
);

if (isAPublicPin) {
fileDataItem.addTag(
EntityTag.arFsPin,
'true',
);
fileDataItem.addTag(
EntityTag.pinnedDataTx,
newFileEntity.dataTxId!,
);
}

await fileDataItem.sign(wallet);

await _arweave.postTx(fileDataItem);
newFileEntity.txId = fileDataItem.id;
}
Expand Down
28 changes: 25 additions & 3 deletions lib/components/drive_create_form.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:ardrive/blocs/blocs.dart';
import 'package:ardrive/core/arfs/entities/arfs_entities.dart';
import 'package:ardrive/l11n/l11n.dart';
import 'package:ardrive/models/models.dart';
import 'package:ardrive/pages/congestion_warning_wrapper.dart';
Expand Down Expand Up @@ -73,6 +74,8 @@ class _DriveCreateFormState extends State<DriveCreateForm> {
],
);
} else {
final privacy = state.privacy;

return ArDriveStandardModal(
title: appLocalizationsOf(context).createDriveEmphasized,
content: SizedBox(
Expand Down Expand Up @@ -108,24 +111,43 @@ class _DriveCreateFormState extends State<DriveCreateForm> {
ReactiveDropdownField(
formControlName: 'privacy',
decoration: InputDecoration(
labelText: appLocalizationsOf(context).privacy),
labelText: appLocalizationsOf(context).privacy,
),
showErrors: (control) =>
control.dirty && control.invalid,
validationMessages:
kValidationMessages(appLocalizationsOf(context)),
items: [
DropdownMenuItem(
value: 'public',
value: DrivePrivacy.public.name,
child: Text(appLocalizationsOf(context).public),
),
DropdownMenuItem(
value: 'private',
value: DrivePrivacy.private.name,
child: Text(
appLocalizationsOf(context).private,
),
)
],
onChanged: (_) {
context.read<DriveCreateCubit>().onPrivacyChanged();
},
),
const SizedBox(height: 32),
Row(children: [
if (privacy == DrivePrivacy.private)
Flexible(
child: Text(
appLocalizationsOf(context)
.drivePrivacyDescriptionPrivate,
))
else
Flexible(
child: Text(
appLocalizationsOf(context)
.drivePrivacyDescriptionPublic,
))
]),
],
),
),
Expand Down
3 changes: 3 additions & 0 deletions lib/entities/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class EntityTag {
static const blockEnd = 'Block-End';
static const dataStart = 'Data-Start';
static const dataEnd = 'Data-End';

static const pinnedDataTx = 'Pinned-Data-Tx';
static const arFsPin = 'ArFS-Pin';
}

class ContentType {
Expand Down
8 changes: 8 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,14 @@
"@driveName": {
"description": "The name of certain drive"
},
"drivePrivacyDescriptionPrivate": "Private Drives offer state-of-the-art security, you control access.",
"@drivePrivacyDescriptionPrivate": {
"description": "Explains private drives."
},
"drivePrivacyDescriptionPublic": "Public Drives are discoverable, others can find and view the contents.",
"@drivePrivacyDescriptionPublic": {
"description": "Explains public drives."
},
"driveRoot": "Drive root",
"@driveRoot": {
"description": "The folder entity that is at the top of the folder hierarchy"
Expand Down
7 changes: 4 additions & 3 deletions lib/pages/drive_detail/drive_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,10 @@ class _DriveDetailPageState extends State<DriveDetailPage> {
);
},
content: _buildItem(
appLocalizationsOf(context)
.detachDrive,
ArDriveIcons.triangle()),
appLocalizationsOf(context)
.detachDrive,
ArDriveIcons.detach(),
),
),
],
child: HoverWidget(
Expand Down
5 changes: 4 additions & 1 deletion lib/services/arweave/arweave_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1068,11 +1068,14 @@ class ArweaveService {
Entity entity,
Wallet wallet, {
SecretKey? key,
bool skipSignature = false,
}) async {
final item = await entity.asDataItem(key);
item.setOwner(await wallet.getOwner());

await item.sign(wallet);
if (!skipSignature) {
await item.sign(wallet);
}

return item;
}
Expand Down
6 changes: 3 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "v1.9.1"
resolved-ref: c240bab3c61efec613832ce5636226aff2a18d63
ref: "v1.9.2"
resolved-ref: f8fb1bf502541e46caeb6e7e6270e2c488d7e126
url: "https://github.com/ar-io/ardrive_ui.git"
source: git
version: "1.9.1"
version: "1.9.2"
args:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Secure, permanent storage

publish_to: 'none'

version: 2.13.0
version: 2.14.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct version ✅


environment:
sdk: '>=2.18.5 <3.0.0'
Expand Down Expand Up @@ -39,7 +39,7 @@ dependencies:
ardrive_ui:
git:
url: https://github.com/ar-io/ardrive_ui.git
ref: v1.9.1
ref: v1.9.2
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bump ArDrive UI version ✅

artemis: ^7.0.0-beta.13
arweave:
git:
Expand Down
Loading