From 74fa47565a0673b356fddf73799638568496574b Mon Sep 17 00:00:00 2001 From: Francois Date: Mon, 26 May 2025 22:23:49 +0200 Subject: [PATCH 1/2] feat(withdrawal): add ibc source channel support Modified version of 9bd8215e2b04c69b9f0a48d6da86315309b7fde5 --- .../app_build/build_config.json | 2 +- .../withdrawal/withdrawal_rpc_namespace.dart | 1 + .../example/lib/screens/withdrawal_page.dart | 17 +++++++++++------ .../lib/src/withdrawal/withdrawal_types.dart | 4 ++++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/komodo_defi_framework/app_build/build_config.json b/packages/komodo_defi_framework/app_build/build_config.json index a2875df2..43be5c90 100644 --- a/packages/komodo_defi_framework/app_build/build_config.json +++ b/packages/komodo_defi_framework/app_build/build_config.json @@ -63,7 +63,7 @@ "coins": { "fetch_at_build_enabled": true, "update_commit_on_build": true, - "bundled_coins_repo_commit": "cbbfe2dc83a8c5f037bcbef21737acd86b85b543", + "bundled_coins_repo_commit": "c4713dd3b5a68351136b850de6e6db99e57a2b8d", "coins_repo_api_url": "https://api.github.com/repos/KomodoPlatform/coins", "coins_repo_content_url": "https://komodoplatform.github.io/coins", "coins_repo_branch": "master", diff --git a/packages/komodo_defi_rpc_methods/lib/src/rpc_methods/withdrawal/withdrawal_rpc_namespace.dart b/packages/komodo_defi_rpc_methods/lib/src/rpc_methods/withdrawal/withdrawal_rpc_namespace.dart index 29141e5c..efa43aca 100644 --- a/packages/komodo_defi_rpc_methods/lib/src/rpc_methods/withdrawal/withdrawal_rpc_namespace.dart +++ b/packages/komodo_defi_rpc_methods/lib/src/rpc_methods/withdrawal/withdrawal_rpc_namespace.dart @@ -18,6 +18,7 @@ class WithdrawMethodsNamespace extends BaseRpcMethodNamespace { from: params.from, memo: params.memo, max: params.isMax ?? false, + ibcSourceChannel: params.ibcSourceChannel, ), ); } diff --git a/packages/komodo_defi_sdk/example/lib/screens/withdrawal_page.dart b/packages/komodo_defi_sdk/example/lib/screens/withdrawal_page.dart index 2f170dbd..3d9b558e 100644 --- a/packages/komodo_defi_sdk/example/lib/screens/withdrawal_page.dart +++ b/packages/komodo_defi_sdk/example/lib/screens/withdrawal_page.dart @@ -113,6 +113,7 @@ class _WithdrawalScreenState extends State { memo: _memoController.text.isEmpty ? null : _memoController.text, isMax: _isMaxAmount, ibcTransfer: _isIbcTransfer ? true : null, + ibcSourceChannel: _isIbcTransfer ? _ibcChannelController.text : null, ); final preview = await _sdk.withdrawals.previewWithdrawal(params); @@ -324,13 +325,17 @@ class _WithdrawalScreenState extends State { controller: _ibcChannelController, decoration: const InputDecoration( labelText: 'IBC Channel', - hintText: 'Enter IBC channel ID', + hintText: 'Enter IBC channel ID (e.g. channel-141)', ), - validator: - (value) => - value?.isEmpty == true - ? 'Please enter IBC channel' - : null, + validator: (value) { + if (value?.isEmpty == true) { + return 'Please enter IBC channel'; + } + if (!RegExp(r'^channel-\d+$').hasMatch(value!)) { + return 'Channel must be in format "channel-" followed by a number'; + } + return null; + }, ), ], ], diff --git a/packages/komodo_defi_types/lib/src/withdrawal/withdrawal_types.dart b/packages/komodo_defi_types/lib/src/withdrawal/withdrawal_types.dart index 0689d763..5ee915cd 100644 --- a/packages/komodo_defi_types/lib/src/withdrawal/withdrawal_types.dart +++ b/packages/komodo_defi_types/lib/src/withdrawal/withdrawal_types.dart @@ -153,6 +153,7 @@ class WithdrawParameters extends Equatable { this.from, this.memo, this.ibcTransfer, + this.ibcSourceChannel, this.isMax, }) : assert( amount != null || (isMax ?? false), @@ -166,6 +167,7 @@ class WithdrawParameters extends Equatable { final WithdrawalSource? from; final String? memo; final bool? ibcTransfer; + final String? ibcSourceChannel; final bool? isMax; JsonMap toJson() => { @@ -177,6 +179,7 @@ class WithdrawParameters extends Equatable { if (from != null) 'from': from!.toRpcParams(), if (memo != null) 'memo': memo, if (ibcTransfer != null) 'ibc_transfer': ibcTransfer, + if (ibcSourceChannel != null) 'ibc_source_channel': ibcSourceChannel, }; @override @@ -188,6 +191,7 @@ class WithdrawParameters extends Equatable { from, memo, ibcTransfer, + ibcSourceChannel, isMax, ]; } From 67fd1d981a411104e227363fd3c5af4d159ec672 Mon Sep 17 00:00:00 2001 From: Francois Date: Mon, 26 May 2025 23:29:56 +0200 Subject: [PATCH 2/2] fix(fee-info): change toJson type from Tendermint to CosmosGas --- .../lib/src/rpc_methods/withdrawal/withdraw_request.dart | 1 + .../komodo_defi_types/lib/src/transactions/fee_info.dart | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/komodo_defi_rpc_methods/lib/src/rpc_methods/withdrawal/withdraw_request.dart b/packages/komodo_defi_rpc_methods/lib/src/rpc_methods/withdrawal/withdraw_request.dart index e731c9e7..89f026bb 100644 --- a/packages/komodo_defi_rpc_methods/lib/src/rpc_methods/withdrawal/withdraw_request.dart +++ b/packages/komodo_defi_rpc_methods/lib/src/rpc_methods/withdrawal/withdraw_request.dart @@ -39,6 +39,7 @@ class WithdrawRequest final WithdrawalSource? from; final String? memo; final bool max; + // TODO: update to `int?` when the KDF changes in v2.5.0-beta final String? ibcSourceChannel; @override diff --git a/packages/komodo_defi_types/lib/src/transactions/fee_info.dart b/packages/komodo_defi_types/lib/src/transactions/fee_info.dart index 4188d9d9..01dc842c 100644 --- a/packages/komodo_defi_types/lib/src/transactions/fee_info.dart +++ b/packages/komodo_defi_types/lib/src/transactions/fee_info.dart @@ -235,10 +235,13 @@ sealed class FeeInfo with _$FeeInfo { 'gas_price': gasPrice.toDouble(), 'gas_limit': gasLimit, }, + // TODO: update to Tendermint for KDF v2.5.0-beta FeeInfoTendermint(:final coin, :final amount, :final gasLimit) => { - 'type': 'Tendermint', + 'type': 'CosmosGas', 'coin': coin, - 'amount': amount.toString(), + 'gas_price': gasLimit > 0 + ? (amount / Decimal.fromInt(gasLimit)).toDouble() + : 0.0, 'gas_limit': gasLimit, }, };