Skip to content

Commit

Permalink
Merge pull request #59 from MXCzkEVM/cloud_backup
Browse files Browse the repository at this point in the history
Cloud backup
  • Loading branch information
reasje authored Oct 8, 2024
2 parents 700fef8 + f0011c6 commit 3ef5eb6
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 9 deletions.
40 changes: 37 additions & 3 deletions android/app/google-services.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,52 @@
"package_name": "com.moonchain.mxc"
}
},
"oauth_client": [],
"oauth_client": [
{
"client_id": "810578982053-ef7chugg2fct7l6io3d7tis321hi1hnd.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.moonchain.mxc",
"certificate_hash": "5c3aaff06b031aa5f90f61c1e1d3b79fc0294af0"
}
},
{
"client_id": "810578982053-se1jg0k7sstre57ejkh1fg551spvji2o.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.moonchain.mxc",
"certificate_hash": "b3d8f034c8319b877f83a2a44ff9141325ded9c3"
}
},
{
"client_id": "810578982053-5mthh5ep4k1601komn39hu7c4biu4chb.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyCyny8vayQzMxTWnJcK7KIl7GKEwtloC8Q"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
"other_platform_oauth_client": [
{
"client_id": "810578982053-5mthh5ep4k1601komn39hu7c4biu4chb.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "810578982053-p196bn8p9ipg3709v4ftk2a28fcvi6ka.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "com.moonchain.mxc",
"app_store_id": "6736371768"
}
}
]
}
}
},
}
],
"configuration_version": "1"
}
6 changes: 6 additions & 0 deletions ios/Runner/GoogleService-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CLIENT_ID</key>
<string>810578982053-p196bn8p9ipg3709v4ftk2a28fcvi6ka.apps.googleusercontent.com</string>
<key>REVERSED_CLIENT_ID</key>
<string>com.googleusercontent.apps.810578982053-p196bn8p9ipg3709v4ftk2a28fcvi6ka</string>
<key>ANDROID_CLIENT_ID</key>
<string>810578982053-ef7chugg2fct7l6io3d7tis321hi1hnd.apps.googleusercontent.com</string>
<key>API_KEY</key>
<string>AIzaSyBY-VWbgxaPfGC0WnkSga4zWEFpSs0ybZU</string>
<key>GCM_SENDER_ID</key>
Expand Down
14 changes: 14 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@
<string>Would you allow Moonchain Wallet to use the Speech Recognition?</string>
<key>PermissionGroupNotification</key>
<string>Would you allow Moonchain Wallet to use the Notification?</string>
<!-- Google Sign-in Section -->
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
<string>com.googleusercontent.apps.810578982053-p196bn8p9ipg3709v4ftk2a28fcvi6ka</string>
</array>
</dict>
</array>
<!-- End of the Google Sign-in Section -->
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UIBackgroundModes</key>
Expand Down
2 changes: 2 additions & 0 deletions lib/core/src/firebase/firebase_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class DefaultFirebaseOptions {
messagingSenderId: '810578982053',
projectId: 'moonchain-app',
storageBucket: 'moonchain-app.appspot.com',
androidClientId: '810578982053-ef7chugg2fct7l6io3d7tis321hi1hnd.apps.googleusercontent.com',
iosClientId: '810578982053-p196bn8p9ipg3709v4ftk2a28fcvi6ka.apps.googleusercontent.com',
iosBundleId: 'com.moonchain.mxc',
);
}
13 changes: 8 additions & 5 deletions lib/features/common/packages/backup/google_drive_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class GoogleDriveUseCase extends ReactiveUseCase {
);

final Web3Repository _repository;
Map<String, String>? _googleAuthHeaders;

Future<bool> initGoogleDriveAccess() async {
final googleAuthHeaders = await singInToGoogleDrive();
Expand All @@ -16,7 +17,7 @@ class GoogleDriveUseCase extends ReactiveUseCase {
return false;
}

_repository.googleDriveRepository.initGoogleAuthHeaders(googleAuthHeaders);
_googleAuthHeaders = googleAuthHeaders;

return true;
}
Expand All @@ -25,16 +26,18 @@ class GoogleDriveUseCase extends ReactiveUseCase {
final googleAuthData = await GoogleSignIn(
scopes: [
'email',
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.file',
],
).signIn();

return await googleAuthData?.authHeaders;
final authHeaders = await googleAuthData?.authHeaders;

return authHeaders;
}

Future<void> uploadBackup(String mnemonic) async =>
_repository.googleDriveRepository.uploadBackup(mnemonic);
_repository.googleDriveRepository.uploadBackup(mnemonic, _googleAuthHeaders);

Future<String> readBackupFile() async =>
_repository.googleDriveRepository.readBackupFile();
_repository.googleDriveRepository.readBackupFile(_googleAuthHeaders);
}

0 comments on commit 3ef5eb6

Please sign in to comment.