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

refactor(send_raw_transaction): revert back to tx_hex #2494

Draft
wants to merge 4 commits into
base: sia-demo
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app_build/build_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@
},
"coins": {
"update_commit_on_build": true,
"bundled_coins_repo_commit": "55abfdedbd640958cad8ef3c339bd51d54838e8e",
"bundled_coins_repo_commit": "ddcdbca7f4cb71026f0901a9fb738d65ae825638",
"coins_repo_api_url": "https://api.github.com/repos/KomodoPlatform/coins",
"coins_repo_content_url": "https://raw.githubusercontent.com/KomodoPlatform/coins",
"coins_repo_branch": "master",
"runtime_updates_enabled": true,
"mapped_files": {},
"mapped_files": {
"assets/config/coins_config.json": "utils/coins_config_unfiltered.json",
"assets/config/coins.json": "coins"
},
"mapped_folders": {
"assets/coin_icons/png/": "icons"
}
Expand Down
Binary file modified assets/coin_icons/png/tsia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 0 additions & 9 deletions lib/bloc/withdraw_form/withdraw_form_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -294,19 +294,10 @@ class WithdrawFormBloc extends Bloc<WithdrawFormEvent, WithdrawFormState> {
return;
}

if (state.withdrawDetails.txHex == null &&
state.withdrawDetails.txJson == null) {
emitter(state.copyWith(
isSending: false,
sendError: TextError(error: 'Missing txHex and txJson')
));
}

final response = await _coinsRepo.sendRawTransaction(
SendRawTransactionRequest(
coin: state.withdrawDetails.coin,
txHex: state.withdrawDetails.txHex,
txJson: state.withdrawDetails.txJson,
),
);

Expand Down
6 changes: 1 addition & 5 deletions lib/blocs/kmd_rewards_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,9 @@ class KmdRewardsBloc implements BlocBase {
);
}

if (withdrawDetails.txHex == null && withdrawDetails.txJson == null) {
return BlocResponse(error: TextError(error: 'Missing txHex and txJson'));
}

final tx = await coinsBloc.sendRawTransaction(SendRawTransactionRequest(
coin: 'KMD',
txHex: withdrawDetails.txHex!,
txHex: withdrawDetails.txHex,
));
if (tx.error != null) {
final BaseError error =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,13 @@ import 'package:web_dex/mm2/mm2_api/rpc/base.dart';
class SendRawTransactionRequest implements BaseRequest {
SendRawTransactionRequest({
required this.coin,
this.txHex,
this.txJson,
}) {
assert(txHex != null || txJson != null,
'Either txHex or txJson must have a value.');
}
required this.txHex,
});

factory SendRawTransactionRequest.fromJson(Map<String, dynamic> json) {
return SendRawTransactionRequest(
coin: json['coin'],
txHex: json['tx_hex'],
txJson: json['tx_json'],
);
}

Expand All @@ -23,7 +18,6 @@ class SendRawTransactionRequest implements BaseRequest {

String coin;
String? txHex;
Map<String, dynamic>? txJson;

@override
late String userpass;
Expand All @@ -33,8 +27,7 @@ class SendRawTransactionRequest implements BaseRequest {
return <String, dynamic>{
'method': method,
'coin': coin,
if (txHex != null) 'tx_hex': txHex,
if (txJson != null) 'tx_json': txJson,
'tx_hex': txHex,
'userpass': userpass,
};
}
Expand Down
9 changes: 2 additions & 7 deletions lib/model/withdraw_details/withdraw_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import 'package:web_dex/model/withdraw_details/fee_details.dart';

class WithdrawDetails {
WithdrawDetails({
this.txHex,
this.txJson,
required this.txHex,
required this.txHash,
required this.from,
required this.to,
Expand All @@ -25,7 +24,6 @@ class WithdrawDetails {

return WithdrawDetails(
txHex: json['tx_hex'],
txJson: json['tx_json'],
txHash: json['tx_hash'],
from: List.from(json['from']),
to: List.from(json['to']),
Expand All @@ -43,7 +41,6 @@ class WithdrawDetails {

static WithdrawDetails empty() => WithdrawDetails(
txHex: '',
txJson: null,
txHash: '',
from: [],
to: [],
Expand All @@ -58,8 +55,7 @@ class WithdrawDetails {
internalId: '',
);

final String? txHex;
final Map<String, dynamic>? txJson;
final String txHex;
final String txHash;
final List<String> from;
final List<String> to;
Expand Down Expand Up @@ -87,7 +83,6 @@ class WithdrawDetails {
static WithdrawDetails fromTrezorJson(Map<String, dynamic> json) {
return WithdrawDetails(
txHex: json['tx_hex'],
txJson: json['tx_json'],
txHash: json['tx_hash'],
totalAmount: json['total_amount'].toString(),
coin: json['coin'],
Expand Down
Loading