feat: Add memo support for swap (#3229)

* feat: Add memo support for swap

* fix: Error on swap page select receiver bottomsheet when picking receiveing currency that's not a wallet type

* feat: exclude providers that do not support memo when receive currency needs it, also show passed memo in confirmation and trade history sheets

* fix: overflow for destination tag on swap confirmation

* Update lib/view_model/exchange/exchange_view_model.dart [skip ci]

* Update lib/exchange/provider/trocador_exchange_provider.dart [skip ci]

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
David Adegoke
2026-05-20 20:09:34 +02:00
committed by GitHub
co-authored by Omar Hatem
parent d10f2f2a60
commit 1d652c76aa
56 changed files with 330 additions and 55 deletions
+13
View File
@@ -0,0 +1,13 @@
import 'package:cw_core/crypto_currency.dart';
enum MemoLabelType { destinationTag, memo }
const Map<CryptoCurrency, MemoLabelType> _currenciesRequiringMemo = {
CryptoCurrency.xrp: MemoLabelType.destinationTag,
CryptoCurrency.xlm: MemoLabelType.memo,
CryptoCurrency.ton: MemoLabelType.memo,
CryptoCurrency.eos: MemoLabelType.memo,
CryptoCurrency.hbar: MemoLabelType.memo,
};
MemoLabelType? memoLabelTypeFor(CryptoCurrency currency) => _currenciesRequiringMemo[currency];
+10 -1
View File
@@ -41,7 +41,7 @@ Future<void> initDb({String? pathOverride}) async {
}
}
await db?.close();
db = await openDatabase(dbFile.path, version: 6,
db = await openDatabase(dbFile.path, version: 7,
onUpgrade: (Database db, int oldVersion, int newVersion) async {
printV("migrating: $oldVersion, $newVersion");
if (oldVersion <= 1) {
@@ -96,6 +96,14 @@ CREATE TABLE IF NOT EXISTS BalanceCardStyleSettings (
if (oldVersion <= 5) {
await _createTradeTable(db);
}
if (oldVersion <= 6) {
await _addColumnIfNotExists(
db,
table: 'Trade',
column: 'toAddressExtraId',
definition: 'TEXT',
);
}
},
onCreate: (Database db, int version) async {
await db.execute(
@@ -234,6 +242,7 @@ CREATE TABLE IF NOT EXISTS Trade (
refundAddress TEXT,
walletId TEXT,
payoutAddress TEXT,
toAddressExtraId TEXT,
password TEXT,
providerId TEXT,
providerName TEXT,