Skip to content
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

Implement stake unstake UI flow #552

Closed
wants to merge 35 commits into from

Conversation

gabaldon
Copy link
Contributor

@gabaldon gabaldon commented May 30, 2024

This PR cannot be merge until the explorer and witnet.dart witnet/witnet.dart#38 is updated. Also, all todos: // TODO(#542) must be resolved before merging the PR.

integration_test/e2e_update_theme_test.dart Outdated Show resolved Hide resolved
integration_test/test_utils.dart Show resolved Hide resolved
lib/bloc/explorer/explorer_bloc.dart Show resolved Hide resolved
lib/bloc/explorer/explorer_bloc.dart Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add this file to .gitignore

@@ -44,24 +51,34 @@ Future<bool> _sendTransaction(Transaction transaction) async {
}
}

class VTTCreateBloc extends Bloc<VTTCreateEvent, VTTCreateState> {
/// Create new [VTTCreateBloc].
class TransactionBloc extends Bloc<TransactionEvent, TransactionState> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the changes introduced in this PR, we are adding staking business logic in addition to VTT's. Could we move this class to a file in lib/bloc/transactions/TransactionBlock.dart or similar?

Comment on lines +410 to +415
int valueOwedNanoWit = 0;
int valueChangeNanoWit = 0;
WalletType walletType = wallet.walletType;
// Reset tx value paid
valuePaidNanoWit = 0;
valueOwedNanoWit = getTransactionOutputValue(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int valueOwedNanoWit = 0;
int valueChangeNanoWit = 0;
WalletType walletType = wallet.walletType;
// Reset tx value paid
valuePaidNanoWit = 0;
valueOwedNanoWit = getTransactionOutputValue(
int valueChangeNanoWit = 0;
WalletType walletType = wallet.walletType;
// Reset tx value paid
valuePaidNanoWit = 0;
int valueOwedNanoWit = getTransactionOutputValue(

Comment on lines +344 to +359
switch (txType) {
case layout.TransactionType.Vtt:
outputs.add(ValueTransferOutput.fromJson({
'pkh': address,
'value': outputValue,
'time_lock': 0,
}));
case layout.TransactionType.Stake:
change = ValueTransferOutput.fromJson({
'pkh': address,
'value': outputValue,
'time_lock': 0,
});
case layout.TransactionType.Unstake:
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
switch (txType) {
case layout.TransactionType.Vtt:
outputs.add(ValueTransferOutput.fromJson({
'pkh': address,
'value': outputValue,
'time_lock': 0,
}));
case layout.TransactionType.Stake:
change = ValueTransferOutput.fromJson({
'pkh': address,
'value': outputValue,
'time_lock': 0,
});
case layout.TransactionType.Unstake:
return;
}
final outputData = {
'pkh': address,
'value': outputValue,
'time_lock': 0,
};
switch (txType) {
case layout.TransactionType.Vtt:
outputs.add(ValueTransferOutput.fromJson(outputData));
case layout.TransactionType.Stake:
change = ValueTransferOutput.fromJson(outputData);
case layout.TransactionType.Unstake:
return;
}

@@ -163,7 +163,9 @@ class ApiExplorer {

/// Send a Generic Transaction
Future<dynamic> sendTransaction(Transaction transaction) async {
print('...........Sending transaction..........');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print('...........Sending transaction..........');

Comment on lines +213 to +214
// TODO(#542): use StakeInfo instead of BlockInfo
// TODO(#542): use StakeDetails instead of BlockDetails
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use only one comment?

return stakeEntry;
}

// TODO(#542): use UnstakeInfo instead of BlockInfo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use only one comment?

@@ -1,6 +1,6 @@
part of 'vtt_create_bloc.dart';

enum VTTCreateStatus {
enum TransactionStatus {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. This shouldn't be in a value_transfer folder

@gabaldon gabaldon changed the base branch from main to 2.0 July 31, 2024 09:19
@gabaldon
Copy link
Contributor Author

merged in branch 2.0

@gabaldon gabaldon closed this Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants