-
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.
Remove the user property from the ConnectedUser class (#75)
* feat: add scalability changes fo updarte group * chore: add fromUser constructor for ConnectedUser --------- Co-authored-by: Gbogboade Ayomide <[email protected]> Co-authored-by: Madhur Gupta <[email protected]>
- Loading branch information
1 parent
9b1ad8c
commit e65148b
Showing
16 changed files
with
168 additions
and
88 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,40 @@ | ||
import 'package:push_restapi_dart/push_restapi_dart.dart'; | ||
|
||
Future<ConnectedUser?> getConnectedUserV2({ | ||
Future<ConnectedUser> getConnectedUserV2({ | ||
required Wallet wallet, | ||
String? privateKey, | ||
}) async { | ||
return getConnectedUserV2Core(wallet: wallet, privateKey: privateKey); | ||
} | ||
|
||
Future<ConnectedUser> getConnectedUserV2Core({ | ||
required Wallet wallet, | ||
String? privateKey, | ||
}) async { | ||
final user = await getUser(address: getAccountAddress(wallet)); | ||
|
||
if (user == null) { | ||
return null; | ||
} | ||
if (user != null && user.encryptedPrivateKey != null) { | ||
if (privateKey != null) { | ||
return ConnectedUser.fromUser(user: user, privateKey: privateKey); | ||
} else { | ||
final decryptedPrivateKey = await getDecryptedPrivateKey( | ||
address: wallet.address!, | ||
wallet: wallet, | ||
user: user, | ||
); | ||
|
||
if (privateKey != null) { | ||
return ConnectedUser(user: user, privateKey: privateKey); | ||
return ConnectedUser.fromUser( | ||
user: user, privateKey: decryptedPrivateKey); | ||
} | ||
} else { | ||
final newUser = | ||
await createUser(signer: wallet.signer!, progressHook: (hook) {}); | ||
final decryptedPrivateKey = await getDecryptedPrivateKey( | ||
address: wallet.address!, | ||
wallet: wallet, | ||
user: user, | ||
user: newUser, | ||
); | ||
|
||
return ConnectedUser(user: user, privateKey: decryptedPrivateKey); | ||
return ConnectedUser.fromUser( | ||
user: newUser, privateKey: decryptedPrivateKey); | ||
} | ||
} |
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
Oops, something went wrong.