Skip to content

Commit

Permalink
Merge pull request #1820 from ardriveapp/PE-6472-implement-ario-sdk-i…
Browse files Browse the repository at this point in the history
…ntegration-gar

PE-6472: implement ario sdk integration gar
  • Loading branch information
thiagocarvalhodev authored Sep 6, 2024
2 parents b826be3 + 44261cc commit ada7a42
Show file tree
Hide file tree
Showing 185 changed files with 120,821 additions and 1,426 deletions.
2 changes: 1 addition & 1 deletion .fvmrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"flutter": "3.19.6",
"flavors": {}
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ app.*.map.json

# FVM Version Cache
.fvm/

# Ignore node_modules and package-lock.json in ario_sdk/web
packages/ario_sdk/web/node_modules/
packages/ario_sdk/web/package-lock.json
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
"drift"
],
"cSpell.words": [
"Arweave",
"bento",
"Hkdf",
"hmac",
"sublist",
"Widgetbook"
],
"dart.flutterSdkPath": ".fvm/versions/3.19.6"
}
}
3 changes: 2 additions & 1 deletion Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ end

lane :build_autogenerated_code do
sh_on_root(command: "flutter gen-l10n")
sh_on_root(command: "flutter pub run build_runner build --delete-conflicting-outputs")
sh_on_root(command: "flutter pub global activate script_runner")
sh_on_root(command: "scr setup")
end

lane :update_pr_and_jira do |options|
Expand Down
8 changes: 8 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ analyzer:
- 'lib/services/arweave/graphql/**'
- '**.g.dart'
- 'build/**'
- 'node_modules/**'
- 'macos/**'
- 'ios/**'
- 'android/**'
- 'web/**'
- 'scripts/**'
- 'docs/**'
- 'drift_schemas/**'
language:
strict-casts: false
strict-inference: false
Expand Down
4 changes: 4 additions & 0 deletions assets/config/dev.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"defaultArweaveGatewayUrl": "https://arweave.net",
"defaultArweaveGatewayForDataRequest": {
"label": "Arweave.net",
"url": "https://arweave.net"
},
"useTurboUpload": true,
"useTurboPayment": true,
"defaultTurboUploadUrl": "https://upload.ardrive.dev",
Expand Down
4 changes: 4 additions & 0 deletions assets/config/prod.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"defaultArweaveGatewayUrl": "https://arweave.net",
"defaultArweaveGatewayForDataRequest": {
"label": "Arweave.net",
"url": "https://arweave.net"
},
"useTurboUpload": true,
"useTurboPayment": true,
"defaultTurboUploadUrl": "https://upload.ardrive.io",
Expand Down
4 changes: 4 additions & 0 deletions assets/config/staging.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"defaultArweaveGatewayUrl": "https://arweave.net",
"defaultArweaveGatewayForDataRequest": {
"label": "Arweave.net",
"url": "https://arweave.net"
},
"useTurboUpload": true,
"useTurboPayment": true,
"defaultTurboUploadUrl": "https://upload.ardrive.io",
Expand Down
107 changes: 59 additions & 48 deletions lib/app_shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:ardrive/components/side_bar.dart';
import 'package:ardrive/drive_explorer/multi_thumbnail_creation/multi_thumbnail_creation_warn_modal.dart';
import 'package:ardrive/misc/misc.dart';
import 'package:ardrive/pages/drive_detail/components/hover_widget.dart';
import 'package:ardrive/services/config/config_service.dart';
import 'package:ardrive/shared/blocs/banner/app_banner_bloc.dart';
import 'package:ardrive/sync/domain/cubit/sync_cubit.dart';
import 'package:ardrive/sync/domain/sync_progress.dart';
Expand Down Expand Up @@ -111,64 +112,74 @@ class AppShellState extends State<AppShell> {
child: Material(
borderRadius: BorderRadius.circular(8),
child: ProgressDialog(
useNewArDriveUI: true,
progressBar: ProgressBar(
percentage: context
.read<SyncCubit>()
.syncProgressController
.stream,
),
percentageDetails:
_syncStreamBuilder(
builderWithData: (syncProgress) =>
Text(
appLocalizationsOf(context)
.syncProgressPercentage(
(syncProgress.progress * 100)
.roundToDouble()
.toString(),
),
style:
typography.paragraphNormal(
fontWeight: ArFontWeight.bold,
),
useNewArDriveUI: true,
progressBar: ProgressBar(
percentage: context
.read<SyncCubit>()
.syncProgressController
.stream,
),
percentageDetails: _syncStreamBuilder(
builderWithData: (syncProgress) =>
Text(
appLocalizationsOf(context)
.syncProgressPercentage(
(syncProgress.progress * 100)
.roundToDouble()
.toString(),
),
style: typography.paragraphNormal(
fontWeight: ArFontWeight.bold,
),
),
progressDescription:
_syncStreamBuilder(
builderWithData: (syncProgress) =>
Text(
syncProgress.drivesCount == 0
? ''
: syncProgress.drivesCount >
1
? appLocalizationsOf(
context)
.driveSyncedOfDrivesCount(
syncProgress
.drivesSynced,
syncProgress
.drivesCount)
: appLocalizationsOf(
context)
.syncingOnlyOneDrive,
style:
typography.paragraphNormal(
fontWeight: ArFontWeight.bold,
),
),
progressDescription:
_syncStreamBuilder(
builderWithData: (syncProgress) =>
Text(
syncProgress.drivesCount == 0
? ''
: syncProgress.drivesCount > 1
? appLocalizationsOf(
context)
.driveSyncedOfDrivesCount(
syncProgress
.drivesSynced,
syncProgress
.drivesCount)
: appLocalizationsOf(
context)
.syncingOnlyOneDrive,
style: typography.paragraphNormal(
fontWeight: ArFontWeight.bold,
),
),
title: isCurrentProfileArConnect
? appLocalizationsOf(context)
.syncingPleaseRemainOnThisTab
: appLocalizationsOf(context)
.syncingPleaseWait),
),
title: isCurrentProfileArConnect
? appLocalizationsOf(context)
.syncingPleaseRemainOnThisTab
: appLocalizationsOf(context)
.syncingPleaseWait,
),
),
);
},
);
},
),
if (context.read<ConfigService>().flavor !=
Flavor.production)
Positioned(
bottom: 0,
right: 20,
child: Text(
'Using gateway: ${context.read<ConfigService>().config.defaultArweaveGatewayUrl}',
style: ArDriveTypographyNew.of(context)
.paragraphLarge(
fontWeight: ArFontWeight.semiBold,
),
),
),
],
)
: scaffold,
Expand Down
55 changes: 55 additions & 0 deletions lib/arns/data/arns_dao.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import 'package:ardrive/models/database/database.dart';
import 'package:drift/drift.dart';
import 'package:uuid/uuid.dart';

part 'arns_dao.g.dart';

@DriftAccessor(include: {'./queries/arns_queries.drift'})
class ARNSDao extends DatabaseAccessor<Database> with _$ARNSDaoMixin {
ARNSDao(super.attachedDatabase);

Future<void> saveARNSRecord({
required String domain,
required String transactionId,
String? undername,
bool isActive = true,
int ttl = 3600,
required String fileId,
}) async {
// Create a companion object with the values to insert
final arnsRecord = ArnsRecordsCompanion(
domain: Value(domain),
transactionId: Value(transactionId),
name: Value(undername ?? '@'), // Nullable value
isActive: Value(isActive),
ttl: Value(ttl),
id: Value(const Uuid().v4()),
fileId: Value(fileId),
);

// Insert the new record into the table
await into(arnsRecords).insertOnConflictUpdate(arnsRecord);
}

Future<void> saveAntRecords(List<AntRecord> records) async {
await batch((batch) {
batch.insertAllOnConflictUpdate(antRecords, records);
});
}

Future<void> saveARNSRecords(List<ArnsRecord> records) async {
await batch((batch) {
batch.insertAllOnConflictUpdate(arnsRecords, records);
});
}

Future<void> updateARNSRecordActiveStatus({
required String id,
required bool isActive,
}) async {
final record = await getARNSRecordById(id: id).getSingle();

await into(arnsRecords)
.insertOnConflictUpdate(record.copyWith(isActive: Value(isActive)));
}
}
33 changes: 33 additions & 0 deletions lib/arns/data/queries/arns_queries.drift
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import '../../../models/tables/arns_records.drift';
import '../../../models/tables/ant_records.drift';

getARNSRecordByName as ARNSRecordQueryResult:
SELECT * FROM arns_records
WHERE domain = :domain AND name = :name;

getActiveARNSRecordsForFileId as ARNSRecordQueryResult:
SELECT * FROM arns_records
WHERE file_id = :fileId
AND is_active = TRUE;

getARNSRecordByDomain as ARNSRecordQueryResult:
SELECT * FROM arns_records WHERE domain = :domain;

getAllARNSRecords as ARNSRecordQueryResult:
SELECT * FROM arns_records;

getAllANTRecords as ANTRecordQueryResult:
SELECT * FROM ant_records;

getANTRecordByDomain as ANTRecordQueryResult:
SELECT * FROM ant_records WHERE domain = :domain;

getARNSRecordById as ANTRecordQueryResult:
SELECT * FROM arns_records WHERE id = :id;

getARNSRecordByNameAndFileId
as ARNSRecordQueryResult:
SELECT * FROM arns_records
WHERE domain = :domain
AND name = :name
AND file_id = :fileId;
Loading

0 comments on commit ada7a42

Please sign in to comment.