Skip to content

Commit

Permalink
Merge pull request #1854 from ardriveapp/dev
Browse files Browse the repository at this point in the history
PE-6731: Release ArDrive v2.54.2
  • Loading branch information
thiagocarvalhodev authored Sep 13, 2024
2 parents 8bc6fdd + 5d0962f commit 9cf925d
Show file tree
Hide file tree
Showing 14 changed files with 20,900 additions and 222 deletions.
25 changes: 19 additions & 6 deletions lib/arns/domain/arns_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:convert';
import 'package:ardrive/arns/data/arns_dao.dart';
import 'package:ardrive/authentication/ardrive_auth.dart';
import 'package:ardrive/core/arfs/repository/file_repository.dart';
import 'package:ardrive/entities/profile_types.dart';
import 'package:ardrive/models/models.dart';
import 'package:ardrive/services/arweave/arweave_service.dart';
import 'package:ardrive/turbo/services/upload_service.dart';
Expand Down Expand Up @@ -96,12 +97,24 @@ class _ARNSRepository implements ARNSRepository {
required String processId,
bool uploadNewRevision = true,
}) async {
await _sdk.setUndername(
jwtString: _auth.getJWTAsString(),
domain: undername.domain,
txId: undername.record.transactionId,
undername: undername.name,
);
if (_auth.currentUser.profileType == ProfileType.arConnect) {
logger.d('Setting undername with ArConnect');

final id = await _sdk.setUndernameWithArConnect(
txId: undername.record.transactionId,
domain: undername.domain,
undername: undername.name,
);

logger.d('Undername set with ArConnect: $id');
} else {
await _sdk.setUndername(
jwtString: _auth.getJWTAsString(),
domain: undername.domain,
txId: undername.record.transactionId,
undername: undername.name,
);
}

_cachedUndernames[undername.domain]![undername.name] = undername;

Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void main() async {
await _initializeServices();

await _startApp();
}, (error, stackTrace) {
}, (error, stackTrace) async {
logger.e('Error caught.', error, stackTrace);
});
}
Expand Down
15 changes: 13 additions & 2 deletions lib/models/database/database.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ part 'database.g.dart';
'../tables/licenses.drift',
'../tables/network_transactions.drift',
'../tables/profiles.drift',
'../tables/snapshot_entries.drift',
'../tables/arns_records.drift',
'../tables/ant_records.drift',
},
Expand All @@ -31,7 +30,7 @@ class Database extends _$Database {
Database([QueryExecutor? e]) : super(e ?? openConnection());

@override
int get schemaVersion => 21;
int get schemaVersion => 22;
@override
MigrationStrategy get migration => MigrationStrategy(
onCreate: (Migrator m) {
Expand Down Expand Up @@ -131,6 +130,18 @@ class Database extends _$Database {
await m.createTable(arnsRecords);
await m.createTable(antRecords);
}

if (from < 22) {
logger.d('Migrating schema from v21 to v22');

logger.d('Dropping snapshot_entries table');

await customStatement('''
DROP TABLE IF EXISTS snapshot_entries;
''');

logger.d('snapshot_entries table dropped');
}
} catch (e, stacktrace) {
logger.e(
'CRITICAL! Failed to migrate database from $from to $to',
Expand Down
13 changes: 0 additions & 13 deletions lib/models/tables/snapshot_entries.drift

This file was deleted.

6 changes: 6 additions & 0 deletions packages/ario_sdk/lib/src/ario_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ abstract class ArioSDK {
required String domain,
String undername = '@',
});

Future<dynamic> setUndernameWithArConnect({
required String txId,
required String domain,
String undername = '@',
});
}
27 changes: 24 additions & 3 deletions packages/ario_sdk/lib/src/implementations/ario_sdk_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ class ArioSDKWeb implements ArioSDK {
domain: domain,
);

return _setARNSImpl(jwtString, arnsUndername);
return _setARNSImpl(
jwtString,
arnsUndername,
false,
);
}

@override
Expand All @@ -79,17 +83,34 @@ class ArioSDKWeb implements ArioSDK {

return _cachedUndernames[record.domain]!.toList();
}

@override
Future setUndernameWithArConnect(
{required String txId,
required String domain,
String undername = '@'}) async {
final arnsUndername = ARNSUndername(
record: ARNSRecord(transactionId: txId, ttlSeconds: 3600),
name: undername,
domain: domain,
);

return _setARNSImpl('', arnsUndername, true);
}
}

@JS('setARNS')
external Object _setARNS(String jwtString, txId, domain, String undername);
external Object _setARNS(
String jwtString, txId, domain, String undername, bool useArConnect);

Future<dynamic> _setARNSImpl(String jwtString, ARNSUndername undername) async {
Future<dynamic> _setARNSImpl(
String jwtString, ARNSUndername undername, bool useArConnect) async {
final promise = _setARNS(
jwtString,
undername.record.transactionId,
undername.domain,
undername.name,
useArConnect,
);

final stringified = await promiseToFuture(promise);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,11 @@ class ArioSDKWeb implements ArioSDK {
// TODO: implement setUndername
throw UnimplementedError();
}

@override
Future setUndernameWithArConnect(
{required String txId, required String domain, String undername = '@'}) {
// TODO: implement setUndernameWithArConnect
throw UnimplementedError();
}
}
Loading

0 comments on commit 9cf925d

Please sign in to comment.