Skip to content

Commit 5252473

Browse files
authored
Merge branch 'dev' into fix_decimals
2 parents 2d82108 + 6f9a5bb commit 5252473

File tree

58 files changed

+1732
-925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1732
-925
lines changed

assets/translations/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@
209209
"transactionDetailsTitle": "Transaction completed",
210210
"customSeedWarningText": "Custom seed phrases are generally less secure and easier to crack than a generated BIP39-compliant seed phrase. To confirm you understand and are aware of the risk, type \"I understand\" in the box below.",
211211
"customSeedIUnderstand": "i understand",
212-
"walletCreationBip39SeedError": "BIP39 seed phrase validation failed, try again or select 'Allow custom seed'",
212+
213+
"walletCreationBip39SeedError": "BIP39 seed phrase validation failed, try again or select 'Use custom seed phrase / private key (WIF)' to proceed",
213214
"walletCreationHdBip39SeedError": "Your input seed phrase is not BIP39 compliant, and can not be used in multi-address wallet mode. Please try again, or disable multi-address wallet mode and select 'Allow custom seed' to proceed.",
214215
"walletPageNoSuchAsset": "No assets match search criteria",
215216
"swap": "Swap",

assets/web_pages/fiat_widget.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<body>
2929
<iframe id="fiat-onramp-iframe" title="Fiat On-Ramp Widget"
3030
sandbox="allow-forms allow-scripts allow-same-origin allow-popups allow-top-navigation allow-top-navigation-by-user-action"
31-
src="">
31+
allow="payment; encrypted-media; microphone; camera; midi" src="">
3232
<!-- Placeholder fallback message -->
3333
<p>Your browser does not support iframes.</p>
3434
<p>Please use a modern browser to view this content.</p>
@@ -67,7 +67,7 @@
6767

6868
/**
6969
* Get URL parameter by name
70-
*
70+
*
7171
* @param {string} name - The name of the URL parameter to retrieve
7272
* @returns {string|null} - The value of the URL parameter or null if not found
7373
*/
@@ -76,10 +76,10 @@
7676
return params.get(name);
7777
}
7878

79-
/**
79+
/**
8080
* Handle messages from the iframe
81-
*
82-
* @param {MessageEvent} messageEvent
81+
*
82+
* @param {MessageEvent} messageEvent
8383
*/
8484
function _komodoOnMessageHandler(messageEvent) {
8585
let messageData;
@@ -96,18 +96,18 @@
9696
}
9797
}
9898

99-
/**
99+
/**
100100
* Post a message to the parent window
101-
*
102-
* @param {string|object} messageData
103-
*/
101+
*
102+
* @param {string|object} messageData
103+
*/
104104
function _komodoPostMessageToParent(messageData) {
105105
const messageString = (typeof messageData === 'object') ? JSON.stringify(messageData) : String(messageData);
106106

107107
// flutter_inappwebview
108108
console.log(messageString);
109109

110-
// universal_url opener
110+
// universal_url opener
111111
if (window.opener) {
112112
return window.opener.postMessage(messageString, "*");
113113
}
@@ -117,7 +117,7 @@
117117
}
118118

119119
// Windows WebView2 (desktop_webview_window)
120-
// https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/communicate-btwn-web-native
120+
// https://learn.microsoft.com/en-us/microsoft-edge/webview2/how-to/communicate-btwn-web-native
121121
if (window.chrome && window.chrome.webview) {
122122
return window.chrome.webview.postMessage(messageString);
123123
}

ios/Runner.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@
406406
"$(PROJECT_DIR)",
407407
);
408408
MACOSX_DEPLOYMENT_TARGET = 15.0;
409-
PRODUCT_BUNDLE_IDENTIFIER = com.komodoplatform.atomicdex;
409+
PRODUCT_BUNDLE_IDENTIFIER = com.komodo.wallet;
410410
PRODUCT_NAME = "$(TARGET_NAME)";
411411
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
412412
SWIFT_VERSION = 5.0;
@@ -549,7 +549,7 @@
549549
"$(PROJECT_DIR)",
550550
);
551551
MACOSX_DEPLOYMENT_TARGET = 15.0;
552-
PRODUCT_BUNDLE_IDENTIFIER = com.komodoplatform.atomicdex;
552+
PRODUCT_BUNDLE_IDENTIFIER = com.komodo.wallet;
553553
PRODUCT_NAME = "$(TARGET_NAME)";
554554
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
555555
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -584,7 +584,7 @@
584584
"$(PROJECT_DIR)",
585585
);
586586
MACOSX_DEPLOYMENT_TARGET = 15.0;
587-
PRODUCT_BUNDLE_IDENTIFIER = com.komodoplatform.atomicdex;
587+
PRODUCT_BUNDLE_IDENTIFIER = com.komodo.wallet;
588588
PRODUCT_NAME = "$(TARGET_NAME)";
589589
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
590590
SWIFT_VERSION = 5.0;

lib/app_config/app_config.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,9 @@ const List<String> appWalletOnlyAssetList = [
166166
/// Reduced to only KMD to minimize initial connections and resource usage.
167167
List<String> get enabledByDefaultCoins => [
168168
'KMD', // Komodo ecosystem coin
169+
'BTC-segwit' // Default Fiat Ramps coin
169170
];
170171

171-
List<String> get coinsWithFaucet => ['RICK', 'MORTY', 'DOC', 'MARTY'];
172-
173172
const String logsDbName = 'logs';
174173
const String appFolder = 'KomodoWallet';
175174

lib/bloc/app_bloc_root.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import 'package:web_dex/bloc/system_health/system_health_bloc.dart';
4848
import 'package:web_dex/bloc/taker_form/taker_bloc.dart';
4949
import 'package:web_dex/bloc/trading_status/trading_status_bloc.dart';
5050
import 'package:web_dex/bloc/trading_status/trading_status_service.dart';
51-
import 'package:web_dex/bloc/transaction_history/transaction_history_bloc.dart';
5251
import 'package:web_dex/bloc/transaction_history/transaction_history_repo.dart';
5352
import 'package:web_dex/bloc/version_info/version_info_bloc.dart';
5453
import 'package:web_dex/blocs/kmd_rewards_bloc.dart';
@@ -211,10 +210,6 @@ class AppBlocRoot extends StatelessWidget {
211210
sdk: komodoDefiSdk,
212211
),
213212
),
214-
BlocProvider<TransactionHistoryBloc>(
215-
create: (BuildContext ctx) =>
216-
TransactionHistoryBloc(sdk: komodoDefiSdk),
217-
),
218213
BlocProvider<SettingsBloc>(
219214
create: (context) =>
220215
SettingsBloc(storedPrefs, SettingsRepository()),

lib/bloc/assets_overview/bloc/asset_overview_bloc.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'package:web_dex/bloc/cex_market_data/profit_loss/profit_loss_repository.
1111
import 'package:web_dex/bloc/cex_market_data/sdk_auth_activation_extension.dart';
1212
import 'package:web_dex/bloc/coins_bloc/asset_coin_extension.dart';
1313
import 'package:web_dex/model/coin.dart';
14+
import 'package:web_dex/shared/constants.dart';
1415

1516
part 'asset_overview_event.dart';
1617
part 'asset_overview_state.dart';
@@ -100,7 +101,10 @@ class AssetOverviewBloc extends Bloc<AssetOverviewEvent, AssetOverviewState> {
100101
return;
101102
}
102103

103-
await _sdk.waitForEnabledCoinsToPassThreshold(supportedCoins);
104+
await _sdk.waitForEnabledCoinsToPassThreshold(
105+
supportedCoins,
106+
delay: kActivationPollingInterval,
107+
);
104108

105109
final activeCoins = await supportedCoins.removeInactiveCoins(_sdk);
106110
if (activeCoins.isEmpty) {

lib/bloc/bridge_form/bridge_validator.dart

Lines changed: 61 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ class BridgeValidator {
2828
required CoinsRepo coinsRepository,
2929
required DexRepository dexRepository,
3030
required KomodoDefiSdk sdk,
31-
}) : _bloc = bloc,
32-
_coinsRepo = coinsRepository,
33-
_dexRepo = dexRepository,
34-
_sdk = sdk,
35-
_add = bloc.add;
31+
}) : _bloc = bloc,
32+
_coinsRepo = coinsRepository,
33+
_dexRepo = dexRepository,
34+
_sdk = sdk,
35+
_add = bloc.add;
3636

3737
final BridgeBloc _bloc;
3838
final CoinsRepo _coinsRepo;
@@ -71,32 +71,32 @@ class BridgeValidator {
7171
}
7272

7373
DexFormError? _parsePreimageError(
74-
DataFromService<TradePreimage, BaseError> preimageData) {
74+
DataFromService<TradePreimage, BaseError> preimageData,
75+
) {
7576
final BaseError? error = preimageData.error;
7677

7778
if (error is TradePreimageNotSufficientBalanceError) {
7879
return _insufficientBalanceError(
79-
Rational.parse(error.required), error.coin);
80+
Rational.parse(error.required),
81+
error.coin,
82+
);
8083
} else if (error is TradePreimageNotSufficientBaseCoinBalanceError) {
8184
return _insufficientBalanceError(
82-
Rational.parse(error.required), error.coin);
83-
} else if (error is TradePreimageTransportError) {
84-
return DexFormError(
85-
error: LocaleKeys.notEnoughBalanceForGasError.tr(),
85+
Rational.parse(error.required),
86+
error.coin,
8687
);
88+
} else if (error is TradePreimageTransportError) {
89+
return DexFormError(error: LocaleKeys.notEnoughBalanceForGasError.tr());
8790
} else if (error is TradePreimageVolumeTooLowError) {
8891
return DexFormError(
89-
error: LocaleKeys.lowTradeVolumeError
90-
.tr(args: [formatAmt(double.parse(error.threshold)), error.coin]),
92+
error: LocaleKeys.lowTradeVolumeError.tr(
93+
args: [formatAmt(double.parse(error.threshold)), error.coin],
94+
),
9195
);
9296
} else if (error != null) {
93-
return DexFormError(
94-
error: error.message,
95-
);
97+
return DexFormError(error: error.message);
9698
} else if (preimageData.data == null) {
97-
return DexFormError(
98-
error: LocaleKeys.somethingWrong.tr(),
99-
);
99+
return DexFormError(error: LocaleKeys.somethingWrong.tr());
100100
}
101101

102102
return null;
@@ -128,10 +128,15 @@ class BridgeValidator {
128128
_state.sellAmount,
129129
);
130130
} catch (e, s) {
131-
log(e.toString(),
132-
trace: s, path: 'bridge_validator::_getPreimageData', isError: true);
131+
log(
132+
e.toString(),
133+
trace: s,
134+
path: 'bridge_validator::_getPreimageData',
135+
isError: true,
136+
);
133137
return DataFromService(
134-
error: TextError(error: 'Failed to request trade preimage'));
138+
error: TextError(error: 'Failed to request trade preimage'),
139+
);
135140
}
136141
}
137142

@@ -187,17 +192,17 @@ class BridgeValidator {
187192
if (availableBalance < maxOrderVolume && sellAmount > availableBalance) {
188193
final Rational minAmount = maxRational([
189194
_state.minSellAmount ?? Rational.zero,
190-
_state.bestOrder!.minVolume
195+
_state.bestOrder!.minVolume,
191196
])!;
192197

193198
if (availableBalance < minAmount) {
194-
_add(BridgeSetError(
195-
_insufficientBalanceError(minAmount, _state.sellCoin!.abbr),
196-
));
199+
_add(
200+
BridgeSetError(
201+
_insufficientBalanceError(minAmount, _state.sellCoin!.abbr),
202+
),
203+
);
197204
} else {
198-
_add(BridgeSetError(
199-
_setMaxError(availableBalance),
200-
));
205+
_add(BridgeSetError(_setMaxError(availableBalance)));
201206
}
202207

203208
return false;
@@ -218,9 +223,11 @@ class BridgeValidator {
218223
if (sellAmount < minAmount) {
219224
final Rational available = _state.maxSellAmount ?? Rational.zero;
220225
if (available < minAmount) {
221-
_add(BridgeSetError(
222-
_insufficientBalanceError(minAmount, _state.sellCoin!.abbr),
223-
));
226+
_add(
227+
BridgeSetError(
228+
_insufficientBalanceError(minAmount, _state.sellCoin!.abbr),
229+
),
230+
);
224231
} else {
225232
_add(BridgeSetError(_setMinError(minAmount)));
226233
}
@@ -233,22 +240,17 @@ class BridgeValidator {
233240

234241
Future<bool> _validateCoinAndParent(String abbr) async {
235242
final coin = _sdk.getSdkAsset(abbr);
236-
final enabledAssets = await _sdk.assets.getActivatedAssets();
237-
final isAssetEnabled = enabledAssets.contains(coin);
243+
final activatedAssetIds = await _coinsRepo.getActivatedAssetIds();
238244
final parentId = coin.id.parentId;
239-
final parent = _sdk.assets.available[parentId];
240245

241-
if (!isAssetEnabled) {
246+
if (!activatedAssetIds.contains(coin.id)) {
242247
_add(BridgeSetError(_coinNotActiveError(coin.id.id)));
243248
return false;
244249
}
245250

246-
if (parent != null) {
247-
final isParentEnabled = enabledAssets.contains(parent);
248-
if (!isParentEnabled) {
249-
_add(BridgeSetError(_coinNotActiveError(parent.id.id)));
250-
return false;
251-
}
251+
if (parentId != null && !activatedAssetIds.contains(parentId)) {
252+
_add(BridgeSetError(_coinNotActiveError(parentId.id)));
253+
return false;
252254
}
253255

254256
return true;
@@ -262,7 +264,8 @@ class BridgeValidator {
262264

263265
final selectedOrderAddress = selectedOrder.address;
264266
final asset = _sdk.getSdkAsset(selectedOrder.coin);
265-
final ownPubkeys = await _sdk.pubkeys.getPubkeys(asset);
267+
final cached = _sdk.pubkeys.lastKnown(asset.id);
268+
final ownPubkeys = cached ?? await _sdk.pubkeys.getPubkeys(asset);
266269
final ownAddresses = ownPubkeys.keys
267270
.where((pubkeyInfo) => pubkeyInfo.isActiveForSwap)
268271
.map((e) => e.address)
@@ -304,8 +307,9 @@ class BridgeValidator {
304307

305308
DexFormError _setOrderMaxError(Rational maxAmount) {
306309
return DexFormError(
307-
error: LocaleKeys.dexMaxOrderVolume
308-
.tr(args: [formatDexAmt(maxAmount), _state.sellCoin!.abbr]),
310+
error: LocaleKeys.dexMaxOrderVolume.tr(
311+
args: [formatDexAmt(maxAmount), _state.sellCoin!.abbr],
312+
),
309313
type: DexFormErrorType.largerMaxSellVolume,
310314
action: DexFormErrorAction(
311315
text: LocaleKeys.setMax.tr(),
@@ -318,8 +322,9 @@ class BridgeValidator {
318322

319323
DexFormError _insufficientBalanceError(Rational required, String abbr) {
320324
return DexFormError(
321-
error: LocaleKeys.dexBalanceNotSufficientError
322-
.tr(args: [abbr, formatDexAmt(required), abbr]),
325+
error: LocaleKeys.dexBalanceNotSufficientError.tr(
326+
args: [abbr, formatDexAmt(required), abbr],
327+
),
323328
);
324329
}
325330

@@ -341,20 +346,20 @@ class BridgeValidator {
341346
DexFormError _setMinError(Rational minAmount) {
342347
return DexFormError(
343348
type: DexFormErrorType.lessMinVolume,
344-
error: LocaleKeys.dexMinSellAmountError
345-
.tr(args: [formatDexAmt(minAmount), _state.sellCoin!.abbr]),
349+
error: LocaleKeys.dexMinSellAmountError.tr(
350+
args: [formatDexAmt(minAmount), _state.sellCoin!.abbr],
351+
),
346352
action: DexFormErrorAction(
347-
text: LocaleKeys.setMin.tr(),
348-
callback: () async {
349-
_add(BridgeSetSellAmount(minAmount));
350-
}),
353+
text: LocaleKeys.setMin.tr(),
354+
callback: () async {
355+
_add(BridgeSetSellAmount(minAmount));
356+
},
357+
),
351358
);
352359
}
353360

354361
DexFormError _tradingWithSelfError() {
355-
return DexFormError(
356-
error: LocaleKeys.dexTradingWithSelfError.tr(),
357-
);
362+
return DexFormError(error: LocaleKeys.dexTradingWithSelfError.tr());
358363
}
359364

360365
bool get _isSellCoinSelected => _state.sellCoin != null;

lib/bloc/cex_market_data/portfolio_growth/portfolio_growth_bloc.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import 'package:web_dex/bloc/coins_bloc/asset_coin_extension.dart';
1313
import 'package:web_dex/mm2/mm2_api/rpc/base.dart';
1414
import 'package:web_dex/model/coin.dart';
1515
import 'package:web_dex/model/text_error.dart';
16+
import 'package:web_dex/shared/constants.dart';
1617

1718
part 'portfolio_growth_event.dart';
1819
part 'portfolio_growth_state.dart';
@@ -160,7 +161,10 @@ class PortfolioGrowthBloc
160161
// In case most coins are activating on wallet startup, wait for at least
161162
// 50% of the coins to be enabled before attempting to load the uncached
162163
// chart.
163-
await _sdk.waitForEnabledCoinsToPassThreshold(filteredEventCoins);
164+
await _sdk.waitForEnabledCoinsToPassThreshold(
165+
filteredEventCoins,
166+
delay: kActivationPollingInterval,
167+
);
164168

165169
// Only remove inactivate/activating coins after an attempt to load the
166170
// cached chart, as the cached chart may contain inactive coins.

0 commit comments

Comments
 (0)