mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-17 05:41:29 +02:00
feat: Add Tether Gold (XAUT0) token support to Solana wallet and add migration for existing wallets (#3136)
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 6.2 KiB |
@@ -99,6 +99,15 @@ class DefaultSPLTokens {
|
||||
iconPath: 'assets/images/avdo_icon.png',
|
||||
enabled: false,
|
||||
),
|
||||
SPLToken(
|
||||
name: "Tether Gold",
|
||||
symbol: "XAUT0",
|
||||
mintAddress: "AymATz4TCL9sWNEEV9Kvyz45CHVhDZ6kUgjTJPzLpU9P",
|
||||
decimal: 6,
|
||||
mint: 'xaut0',
|
||||
enabled: false,
|
||||
iconPath: "assets/images/xau_sol.png",
|
||||
),
|
||||
SPLToken(
|
||||
name: 'Abbott xStock',
|
||||
symbol: 'ABTx',
|
||||
|
||||
@@ -23,6 +23,7 @@ import 'package:cake_wallet/entities/sync_status_display_mode.dart';
|
||||
import 'package:cake_wallet/wownero/wownero.dart';
|
||||
import 'package:cw_core/pathForWallet.dart';
|
||||
import 'package:cw_core/root_dir.dart';
|
||||
import 'package:cw_core/spl_token.dart';
|
||||
import 'package:cw_core/utils/print_verbose.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
@@ -611,6 +612,9 @@ Future<void> defaultSettingsMigration(
|
||||
enabled: false,
|
||||
);
|
||||
break;
|
||||
case 63:
|
||||
await _addXaut0TokenToExistingSolanaWallets();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1489,3 +1493,39 @@ Future<void> _addXautTokenToExistingEthereumWallets() async {
|
||||
printV('Error in XAUT migration: $e');
|
||||
}
|
||||
}
|
||||
Future<void> _addXaut0TokenToExistingSolanaWallets() async {
|
||||
try {
|
||||
final xaut0Token = SPLToken(
|
||||
name: "Tether Gold",
|
||||
symbol: "XAUT0",
|
||||
mintAddress: "AymATz4TCL9sWNEEV9Kvyz45CHVhDZ6kUgjTJPzLpU9P",
|
||||
decimal: 6,
|
||||
mint: 'xaut0',
|
||||
enabled: false,
|
||||
iconPath: "assets/images/xau_sol.png",
|
||||
);
|
||||
|
||||
final allWallets = await WalletInfo.getAll();
|
||||
|
||||
final solanaWallets = allWallets.where((wallet) => wallet.type == WalletType.solana).toList();
|
||||
|
||||
for (final walletInfo in solanaWallets) {
|
||||
final sanitizedName = walletInfo.name.replaceAll(' ', '_');
|
||||
final boxName = '${sanitizedName}_${SPLToken.boxName}';
|
||||
|
||||
Box<SPLToken> tokenBox;
|
||||
if (CakeHive.isBoxOpen(boxName)) {
|
||||
tokenBox = CakeHive.box<SPLToken>(boxName);
|
||||
} else {
|
||||
tokenBox = await CakeHive.openBox<SPLToken>(boxName);
|
||||
}
|
||||
|
||||
final xaut0Address = xaut0Token.mintAddress;
|
||||
if (!tokenBox.containsKey(xaut0Address)) {
|
||||
await tokenBox.put(xaut0Address, xaut0Token);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
printV('Error in XAUT0 migration: $e');
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -324,7 +324,7 @@ Future<void> initializeAppConfigs({bool loadWallet = true}) async {
|
||||
payjoinSessionSource: payjoinSessionSource,
|
||||
anonpayInvoiceInfo: anonpayInvoiceInfo,
|
||||
havenSeedStore: havenSeedStore,
|
||||
initialMigrationVersion: 62,
|
||||
initialMigrationVersion: 63,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ class AssetDetailsModal extends StatelessWidget {
|
||||
child: Stack(
|
||||
children: [
|
||||
if (iconPath.isNotEmpty)
|
||||
Image.asset(iconPath, width: 75, height: 75)
|
||||
CakeImageWidget(imageUrl: iconPath, width: 75, height: 75)
|
||||
else
|
||||
Container(
|
||||
width: 75,
|
||||
|
||||
@@ -92,7 +92,7 @@ class AssetTile extends StatelessWidget {
|
||||
child: Stack(
|
||||
children: [
|
||||
if((iconPath).isNotEmpty)
|
||||
Image.asset(iconPath)
|
||||
CakeImageWidget(imageUrl: iconPath)
|
||||
else
|
||||
Container(
|
||||
width: 45,
|
||||
|
||||
Reference in New Issue
Block a user