-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
154 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...data/providers/wallet_secure_storage.dart → lib/src/data/providers/secure_storage.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:donationwallet/generated/rust/api/simple.dart'; | ||
import 'package:donationwallet/src/data/models/outputs_model.dart'; | ||
import 'package:donationwallet/src/data/models/sp_client_model.dart'; | ||
import 'package:donationwallet/src/data/models/sp_wallet_model.dart'; | ||
import 'package:donationwallet/src/data/repositories/wallet_repository.dart'; | ||
import 'package:donationwallet/src/domain/entities/wallet_entity.dart'; | ||
import 'package:donationwallet/src/utils/constants.dart'; | ||
|
||
class CreateWalletUseCase { | ||
final WalletRepository walletRepository; | ||
|
||
CreateWalletUseCase(this.walletRepository); | ||
|
||
Future<WalletEntity> call(String label, String network, int birthday) async { | ||
try { | ||
final wallet = await setup( | ||
label: defaultLabel, | ||
mnemonic: null, | ||
scanKey: null, | ||
spendKey: null, | ||
birthday: birthday, | ||
network: network, | ||
); | ||
|
||
// final spWallet = SpWallet(client: SpClient(label: wallet., scanSk: '', spendKey: null, mnemonic: '', spReceiver: null), outputs: Outputs(walletFingerprint: [], birthday: null, lastScan: null, outputs: {})); | ||
|
||
// return WalletEntity( | ||
// label: spWallet.client.label, | ||
// address: "", // we need to add it later | ||
// network: spWallet.client.spReceiver.network, | ||
// balance: BigInt.zero, // we compute that from all the outputs | ||
// birthday: spWallet.outputs.birthday, | ||
// lastScan: spWallet.outputs.lastScan, | ||
// ownedOutputs: spWallet.outputs.outputs, | ||
// ); | ||
|
||
final json = jsonDecode(wallet); | ||
final spWallet = SpWallet.fromJson(json); | ||
await walletRepository.saveWallet(label, spWallet); | ||
return await walletRepository.getWallet(label); | ||
} catch (e) { | ||
rethrow; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters