Skip to content

fix(swaps): accept single import payloads#3491

Draft
CharlVS wants to merge 1 commit into
devfrom
fix/swap-import
Draft

fix(swaps): accept single import payloads#3491
CharlVS wants to merge 1 commit into
devfrom
fix/swap-import

Conversation

@CharlVS

@CharlVS CharlVS commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Normalize swap import JSON before sending the import_swaps RPC.
  • Accept array payloads, single raw swap objects, {"swap": {...}}, {"swaps": [...]}, and {"result": {"swaps": [...]}}.
  • Show friendly validation messages for invalid JSON, empty lists, unsupported wrappers, or non-object swap entries.

Root cause

Single-swap export can produce a my_swap_status response shaped as {"swap": {...}}, while the import screen previously cast pasted JSON directly to List, causing a raw Dart type error before the RPC call.

Validation

  • dart format lib/views/settings/widgets/general_settings/import_swaps.dart
  • git diff --check -- lib/views/settings/widgets/general_settings/import_swaps.dart
  • flutter analyze --no-pub lib/views/settings/widgets/general_settings/import_swaps.dart

Full repository flutter analyze was attempted earlier and is still blocked by existing generated/build and SDK analysis issues unrelated to this change.

@github-actions

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 8fc00ba):

https://walletrc--pull-3491-merge-hpfs2zm4.web.app

(expires Fri, 19 Jun 2026 19:06:39 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: f66a4ff03faa546f12f0ae5a841bd9eff2714dcc

if (decoded.containsKey('result')) {
final dynamic result = decoded['result'];
if (result is Map) {
final dynamic swaps = result['swaps'];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

isn't this called "swap" and not "swaps"?
in my output from https://komodoplatform.com/en/docs/komodo-defi-framework/api/v20/swaps_and_orders/recreate_swap_data/ it was called "swap"... it was just one swap though, but i assume that it's a list of "swap"s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants