-
Notifications
You must be signed in to change notification settings - Fork 250
Add multi-address support to "Faucet" button #2533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
08fdbdf
Add multi-address support to "Faucet" button
TazzyMeister e82db99
isMobile not displaying Faucet button
TazzyMeister de2e433
Merge branch 'dev' into add/multi-address-faucet
TazzyMeister 85825e8
Update coin_addresses.dart
TazzyMeister 3a80929
Merge branch 'dev' into add/multi-address-faucet
TazzyMeister b36440f
Merge branch 'dev' into add/multi-address-faucet
CharlVS c26a51c
Merge branch 'dev' into add/multi-address-faucet
TazzyMeister cb2a740
Merge remote-tracking branch 'origin/dev' into add/multi-address-faucet
TazzyMeister 54a8721
Update faucet_button.dart
TazzyMeister f9add4b
Merge remote-tracking branch 'origin/dev' into add/multi-address-faucet
TazzyMeister 4910636
Merge branch 'dev' into add/multi-address-faucet
TazzyMeister a808178
Created Bloc for Faucet Button
TazzyMeister 3ed8386
Fixed multiple Dialogs
TazzyMeister 3b4a2f6
Merge branch 'dev' into add/multi-address-faucet
TazzyMeister 33fd5bf
Updated manner of keeping Active Address
TazzyMeister 6507714
Merge branch 'dev' into add/multi-address-faucet
TazzyMeister 5d6cd43
UI adjustments
TazzyMeister 71deb6d
Merge branch 'dev' into add/multi-address-faucet
TazzyMeister 6429215
Feedback adjustments
TazzyMeister 7d75a26
Merge branch 'add/multi-address-faucet' of https://github.com/TazzyMe…
TazzyMeister e3c965f
Update faucet_button_state.dart
TazzyMeister 74a03a2
Refactored all names
TazzyMeister 0558253
fix: merge errors
takenagain 485b420
Merge branch 'dev' into add/multi-address-faucet
TazzyMeister a5f775b
Merge remote-tracking branch 'upstream/dev' into add/multi-address-fa…
TazzyMeister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,48 @@ | ||
| import 'package:flutter_bloc/flutter_bloc.dart'; | ||
| import 'package:komodo_defi_sdk/komodo_defi_sdk.dart'; | ||
| import 'package:web_dex/3p_api/faucet/faucet.dart' as api; | ||
| import 'package:web_dex/3p_api/faucet/faucet_response.dart'; | ||
| import 'package:web_dex/bloc/faucet_button/faucet_button_event.dart'; | ||
| import 'package:web_dex/bloc/faucet_button/faucet_button_state.dart'; | ||
| import 'package:logging/logging.dart'; | ||
|
|
||
| class FaucetBloc extends Bloc<FaucetEvent, FaucetState> implements StateStreamable<FaucetState> { | ||
| final KomodoDefiSdk kdfSdk; | ||
| final _log = Logger('FaucetBloc'); | ||
|
|
||
| FaucetBloc({required this.kdfSdk}) : super(FaucetInitial()) { | ||
| on<FaucetRequested>(_onFaucetRequest); | ||
| } | ||
|
|
||
| Future<void> _onFaucetRequest( | ||
| FaucetRequested event, | ||
| Emitter<FaucetState> emit, | ||
| ) async { | ||
| if (state is FaucetRequestInProgress) { | ||
| final currentLoading = state as FaucetRequestInProgress; | ||
| if (currentLoading.address == event.address) { | ||
| return; | ||
| } | ||
| } | ||
|
|
||
| emit(FaucetRequestInProgress(address: event.address)); | ||
|
|
||
| try { | ||
| final response = await api.callFaucet(event.coinAbbr, event.address); | ||
|
|
||
| if (response.status == FaucetStatus.success) { | ||
| emit(FaucetRequestSuccess(FaucetResponse( | ||
| status: response.status, | ||
| address: event.address, | ||
| message: response.message, | ||
| coin: event.coinAbbr, | ||
| ))); | ||
| } else { | ||
| emit(FaucetRequestError("Faucet request failed: ${response.message}")); | ||
| } | ||
| } catch (error, stackTrace) { | ||
| _log.shout('Faucet request failed', error, stackTrace); | ||
| emit(FaucetRequestError("Network error: ${error.toString()}")); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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,21 @@ | ||
| import 'package:equatable/equatable.dart'; | ||
|
|
||
| abstract class FaucetEvent extends Equatable { | ||
| const FaucetEvent(); | ||
|
|
||
| @override | ||
| List<Object> get props => []; | ||
| } | ||
|
|
||
| class FaucetRequested extends FaucetEvent { | ||
| final String coinAbbr; | ||
| final String address; | ||
|
|
||
| const FaucetRequested({ | ||
| required this.coinAbbr, | ||
| required this.address, | ||
| }); | ||
|
|
||
| @override | ||
| List<Object> get props => [coinAbbr, address]; | ||
| } |
|
takenagain marked this conversation as resolved.
|
This file contains hidden or 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,40 @@ | ||
| import 'package:equatable/equatable.dart'; | ||
| import 'package:web_dex/3p_api/faucet/faucet_response.dart'; | ||
|
|
||
| abstract class FaucetState extends Equatable { | ||
| const FaucetState(); | ||
|
|
||
| @override | ||
| List<Object?> get props => []; | ||
| } | ||
|
|
||
| class FaucetInitial extends FaucetState { | ||
| const FaucetInitial(); | ||
| } | ||
|
|
||
| class FaucetRequestInProgress extends FaucetState { | ||
| final String address; | ||
|
|
||
| const FaucetRequestInProgress({required this.address}); | ||
|
|
||
| @override | ||
| List<Object?> get props => [address]; | ||
| } | ||
|
|
||
| class FaucetRequestSuccess extends FaucetState { | ||
| final FaucetResponse response; | ||
|
|
||
| const FaucetRequestSuccess(this.response); | ||
|
|
||
| @override | ||
| List<Object?> get props => [response]; | ||
| } | ||
|
|
||
| class FaucetRequestError extends FaucetState { | ||
| final String message; | ||
|
|
||
| const FaucetRequestError(this.message); | ||
|
|
||
| @override | ||
| List<Object?> get props => [message]; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.