chore(spl): remove prints, log what's important, remove unnecessary docs
What changed, and why it matters
This commit is a routine cleanup of Solana token wallet code. It removes debug print statements, trims verbose logging, and deletes lengthy documentation comments. There are no functional changes to how the wallet handles money, keys, or network calls, and no security bug is introduced or fixed.
No security action required. Treat as normal maintenance; review only if you want to confirm no accidental logic changes were made during the cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is a pure refactor across three Dart files in the Solana/SPL token implementation. It strips print() debug output from solana_token_api.dart, replaces some Logging.instance.i() calls with silent operation in solana_token_wallet.dart, and removes extensive dartdoc comments throughout. No logic, control flow, cryptographic handling, RPC parameters, or balance calculations were altered. The commit title and message explicitly frame this as a chore: ‘remove prints, log what’s important, remove unnecessary docs’.
Changed components
lib/services/solana/solana_token_api.dartlib/wallets/wallet/impl/solana_wallet.dartlib/wallets/wallet/impl/sub_wallets/solana_token_wallet.dartInspect captured patch +17 / −344
diff --git a/lib/services/solana/solana_token_api.dart b/lib/services/solana/solana_token_api.dart
index ac1bdab..336562c 100644
--- a/lib/services/solana/solana_token_api.dart
+++ b/lib/services/solana/solana_token_api.dart
@@ -21,9 +21,7 @@ class SolanaTokenApiException implements Exception {
String toString() => 'SolanaTokenApiException: $message';
}
-/// Response wrapper for Solana token API calls.
-///
-/// Follows the pattern that the result is either value or exception
+/// Result wrapper for Solana token API calls.
class SolanaTokenApiResponse<T> {
final T? value;
final Exception? exception;
@@ -127,8 +125,6 @@ class SolanaTokenAPI {
RpcClient? _rpcClient;
- /// Initialize with a configured RPC client.
- /// This should be called with the same RPC client from SolanaWallet.
void initializeRpcClient(RpcClient rpcClient) {
_rpcClient = rpcClient;
}
@@ -141,9 +137,6 @@ class SolanaTokenAPI {
}
}
- /// Get token accounts owned by a wallet address for a specific mint.
- ///
- /// Returns a list of token account addresses owned by the wallet.
Future<SolanaTokenApiResponse<List<String>>> getTokenAccountsByOwner(
String ownerAddress, {
String? mint,
@@ -155,14 +148,12 @@ class SolanaTokenAPI {
final result = await _rpcClient!.getTokenAccountsByOwner(
ownerAddress,
- // Create the appropriate filter: by mint if specified, or else all SPL tokens.
mint != null
? TokenAccountsFilter.byMint(mint)
: TokenAccountsFilter.byProgramId(splTokenProgramId),
encoding: Encoding.jsonParsed,
);
- // Extract token account addresses from the RPC response.
final accountAddresses = result.value
.map((account) => account.pubkey)
.toList();
@@ -178,170 +169,73 @@ class SolanaTokenAPI {
}
}
- /// Get the balance of a specific token account.
- ///
- /// Parameters:
- /// - tokenAccountAddress: The token account address to query.
- ///
- /// Returns the balance as a BigInt (in smallest units).
Future<SolanaTokenApiResponse<BigInt>> getTokenAccountBalance(
String tokenAccountAddress,
) async {
try {
_checkClient();
- // Query the token account with jsonParsed encoding to get token amount.
final response = await _rpcClient!.getAccountInfo(
tokenAccountAddress,
encoding: Encoding.jsonParsed,
);
if (response.value == null) {
- // Token account doesn't exist.
return SolanaTokenApiResponse<BigInt>(value: BigInt.zero);
}
final accountData = response.value!;
- // Extract token amount from parsed data.
try {
- // Debug: Print the structure of accountData.
- print(
- '[SOLANA_TOKEN_API] accountData type: ${accountData.runtimeType}',
- );
- print(
- '[SOLANA_TOKEN_API] accountData.data type: ${accountData.data.runtimeType}',
- );
- print('[SOLANA_TOKEN_API] accountData.data: ${accountData.data}');
-
- // The solana package returns a ParsedAccountData which is a sealed class/union type.
- // For SPL Token accounts, it contains SplTokenProgramAccountData.
-
final parsedData = accountData.data;
if (parsedData is ParsedAccountData) {
- print('[SOLANA_TOKEN_API] ParsedAccountData detected');
-
try {
final extractedBalance = parsedData.when(
splToken: (spl) {
- print('[SOLANA_TOKEN_API] Handling splToken variant');
- print('[SOLANA_TOKEN_API] spl type: ${spl.runtimeType}');
-
return spl.when(
account: (info, type, accountType) {
- print('[SOLANA_TOKEN_API] Handling account variant');
- print('[SOLANA_TOKEN_API] info type: ${info.runtimeType}');
- print(
- '[SOLANA_TOKEN_API] info.tokenAmount: ${info.tokenAmount}',
- );
-
try {
final tokenAmount = info.tokenAmount;
- print(
- '[SOLANA_TOKEN_API] tokenAmount.amount: ${tokenAmount.amount}',
- );
- print(
- '[SOLANA_TOKEN_API] tokenAmount.decimals: ${tokenAmount.decimals}',
- );
-
- final balanceBigInt = BigInt.parse(tokenAmount.amount);
- print(
- '[SOLANA_TOKEN_API] Successfully extracted balance: $balanceBigInt',
- );
- return balanceBigInt;
+ return BigInt.parse(tokenAmount.amount);
} catch (e) {
- print('[SOLANA_TOKEN_API] Error extracting balance: $e');
return null;
}
},
- mint: (info, type, accountType) {
- print(
- '[SOLANA_TOKEN_API] Got mint variant (not expected for token account balance)',
- );
- return null;
- },
- unknown: (type) {
- print('[SOLANA_TOKEN_API] Got unknown account variant');
- return null;
- },
- );
- },
- stake: (_) {
- print(
- '[SOLANA_TOKEN_API] Got stake account type (not expected)',
+ mint: (info, type, accountType) => null,
+ unknown: (type) => null,
);
- return null;
},
+ stake: (_) => null,
token2022: (token2022Data) {
- print(
- '[SOLANA_TOKEN_API] Handling token2022 account type',
- );
- print('[SOLANA_TOKEN_API] token2022Data type: ${token2022Data.runtimeType}');
-
return token2022Data.when(
account: (info, type, accountType) {
- print('[SOLANA_TOKEN_API] Handling token2022 account variant');
- print('[SOLANA_TOKEN_API] info type: ${info.runtimeType}');
- print(
- '[SOLANA_TOKEN_API] info.tokenAmount: ${info.tokenAmount}',
- );
-
try {
final tokenAmount = info.tokenAmount;
- print(
- '[SOLANA_TOKEN_API] tokenAmount.amount: ${tokenAmount.amount}',
- );
- print(
- '[SOLANA_TOKEN_API] tokenAmount.decimals: ${tokenAmount.decimals}',
- );
-
- final balanceBigInt = BigInt.parse(tokenAmount.amount);
- print(
- '[SOLANA_TOKEN_API] Successfully extracted token2022 balance: $balanceBigInt',
- );
- return balanceBigInt;
+ return BigInt.parse(tokenAmount.amount);
} catch (e) {
- print('[SOLANA_TOKEN_API] Error extracting token2022 balance: $e');
return null;
}
},
- mint: (info, type, accountType) {
- print(
- '[SOLANA_TOKEN_API] Got token2022 mint variant (not expected for token account balance)',
- );
- return null;
- },
- unknown: (type) {
- print('[SOLANA_TOKEN_API] Got unknown token2022 account variant');
- return null;
- },
+ mint: (info, type, accountType) => null,
+ unknown: (type) => null,
);
},
- unsupported: (_) {
- print('[SOLANA_TOKEN_API] Got unsupported account type');
- return null;
- },
+ unsupported: (_) => null,
);
if (extractedBalance != null && extractedBalance is BigInt) {
- print('[SOLANA_TOKEN_API] Extracted balance: $extractedBalance');
return SolanaTokenApiResponse<BigInt>(
value: extractedBalance as BigInt,
);
}
} catch (e) {
- print('[SOLANA_TOKEN_API] Error using when() method: $e');
- print('[SOLANA_TOKEN_API] Stack trace: ${StackTrace.current}');
+ // Ignore parsing errors.
}
}
- // If we can't extract from the Dart object, return zero.
- print('[SOLANA_TOKEN_API] Returning zero balance');
return SolanaTokenApiResponse<BigInt>(value: BigInt.zero);
} catch (e) {
- // If parsing fails, return zero balance.
- print('[SOLANA_TOKEN_API] Exception during parsing: $e');
return SolanaTokenApiResponse<BigInt>(value: BigInt.zero);
}
} on Exception catch (e) {
@@ -354,23 +248,11 @@ class SolanaTokenAPI {
}
}
- /// Get the total supply of a token.
- ///
- /// Parameters:
- /// - mint: The token mint address.
- ///
- /// Returns the total supply as a BigInt.
- ///
- /// NOTE: Currently returns placeholder data for UI placeholders.
- ///
- /// TODO: Implement full RPC call when API is ready.
+ // TODO: Implement full RPC call when API is ready.
Future<SolanaTokenApiResponse<BigInt>> getTokenSupply(String mint) async {
try {
_checkClient();
-
// TODO: Get the mint account info when RPC APIs are stable.
- //
- // For now return placeholder mock data.
return SolanaTokenApiResponse<BigInt>(
value: BigInt.parse('1000000000000000000'),
);
@@ -384,16 +266,7 @@ class SolanaTokenAPI {
}
}
- /// Get token account information with balance and metadata.
- ///
- /// Parameters:
- /// - tokenAccountAddress: The token account address.
- ///
- /// Returns detailed token account information.
- ///
- /// Currently returns placeholder data for UI placeholders.
- ///
- /// TODO: Implement full RPC call when API is ready.
+ // TODO: Implement full RPC call when API is ready.
Future<SolanaTokenApiResponse<TokenAccountInfo>> getTokenAccountInfo(
String tokenAccountAddress,
) async {
@@ -423,13 +296,6 @@ class SolanaTokenAPI {
}
}
- /// Find the Associated Token Account (ATA) for a wallet and mint.
- ///
- /// Parameters:
- /// - ownerAddress: The wallet address.
- /// - mint: The token mint address.
- ///
- /// Returns the derived ATA address.
String findAssociatedTokenAddress(String ownerAddress, String mint) {
// Return a placeholder.
//
@@ -437,9 +303,6 @@ class SolanaTokenAPI {
return '';
}
- /// Check if a wallet owns a token (has a token account for the given mint).
- ///
- /// Returns true if the wallet has a token account for this mint, false otherwise.
Future<SolanaTokenApiResponse<bool>> ownsToken(
String ownerAddress,
String mint,
@@ -468,16 +331,6 @@ class SolanaTokenAPI {
}
}
- /// Fetch SPL token metadata from Solana metadata program.
- ///
- /// The Solana Token Metadata program (metaqbxxUerdq28cj1RbAqWwTRiWLs6nshmbbuP3xqb)
- /// stores token metadata at a PDA derived from the mint address.
- ///
- /// Returns: Map with name, symbol, decimals, and optional logo URI
- /// Returns null if metadata cannot be found (user can enter custom details),
- ///
- /// Note: Full PDA derivation is not yet implemented in the solana package.
- /// Currently returns null to allow users to manually enter token details.
Future<SolanaTokenApiResponse<Map<String, dynamic>?>>
fetchTokenMetadataByMint(
String mintAddress,
diff --git a/lib/wallets/wallet/impl/solana_wallet.dart b/lib/wallets/wallet/impl/solana_wallet.dart
index 4e0882a..01969e1 100644
--- a/lib/wallets/wallet/impl/solana_wallet.dart
+++ b/lib/wallets/wallet/impl/solana_wallet.dart
@@ -37,18 +37,12 @@ class SolanaWallet extends Bip39Wallet<Solana> {
NodeModel? _solNode;
- RpcClient? _rpcClient; // The Solana RpcClient.
+ RpcClient? _rpcClient;
- /// Get the RPC client for this wallet.
- ///
- /// This is used by services like SolanaTokenAPI that need to make RPC calls.
RpcClient? getRpcClient() {
return _rpcClient;
}
- /// Get the keypair for this wallet.
- ///
- /// Used internally and by token wallets for signing transactions.
Future<Ed25519HDKeyPair> getKeyPair() async {
return _getKeyPair();
}
@@ -648,11 +642,9 @@ class SolanaWallet extends Bip39Wallet<Solana> {
@override
Future<bool> updateUTXOs() async {
- // No UTXOs in Solana
return false;
}
- /// Update the list of custom Solana token mint addresses for this wallet.
Future<void> updateSolanaTokens(Set<String> mintAddresses) async {
await info.updateSolanaCustomTokenMintAddresses(
newMintAddresses: mintAddresses,
@@ -667,7 +659,6 @@ class SolanaWallet extends Bip39Wallet<Solana> {
);
}
- /// Make sure the Solana RpcClient uses Tor if it's enabled.
void checkClient() {
final node = getCurrentNode();
diff --git a/lib/wallets/wallet/impl/sub_wallets/solana_token_wallet.dart b/lib/wallets/wallet/impl/sub_wallets/solana_token_wallet.dart
index d7dfcd9..6c9d913 100644
--- a/lib/wallets/wallet/impl/sub_wallets/solana_token_wallet.dart
+++ b/lib/wallets/wallet/impl/sub_wallets/solana_token_wallet.dart
@@ -27,21 +27,13 @@ import '../../../models/tx_data.dart';
import '../../wallet.dart';
import '../solana_wallet.dart';
-/// Solana Token Wallet for SPL token transfers.
-///
-/// Implements send functionality for Solana SPL tokens (like USDC, USDT, etc.)
-/// by delegating RPC calls and key management to the parent SolanaWallet.
class SolanaTokenWallet extends Wallet {
@override
int get isarTransactionVersion => 2;
- /// Create a new Solana Token Wallet.
- ///
- /// Requires a parent SolanaWallet to provide RPC client and key management.
SolanaTokenWallet(this.parentSolanaWallet, this.splToken)
: super(parentSolanaWallet.cryptoCurrency);
- /// Parent Solana wallet (provides RPC client and keypair access).
final SolanaWallet parentSolanaWallet;
final SplToken splToken;
@@ -51,19 +43,12 @@ class SolanaTokenWallet extends Wallet {
String get tokenSymbol => splToken.symbol;
int get tokenDecimals => splToken.decimals;
- /// Override walletId to delegate to parent wallet
@override
String get walletId => parentSolanaWallet.walletId;
- /// Override mainDB to delegate to parent wallet
- /// (SolanaTokenWallet shares the same database as its parent)
@override
MainDB get mainDB => parentSolanaWallet.mainDB;
- // =========================================================================
- // Abstract method implementations
- // =========================================================================
-
@override
FilterOperation? get changeAddressFilterOperation => null;
@@ -86,7 +71,6 @@ class SolanaTokenWallet extends Wallet {
@override
Future<TxData> prepareSend({required TxData txData}) async {
try {
- // Input validation.
if (txData.recipients == null || txData.recipients!.isEmpty) {
throw ArgumentError("At least one recipient is required");
}
@@ -106,14 +90,12 @@ class SolanaTokenWallet extends Wallet {
throw ArgumentError("Recipient address cannot be empty");
}
- // Validate recipient is a valid base58 address.
try {
Ed25519HDPublicKey.fromBase58(recipientAddress);
} catch (e) {
throw ArgumentError("Invalid recipient address: $recipientAddress");
}
- // Get wallet state.
final rpcClient = parentSolanaWallet.getRpcClient();
if (rpcClient == null) {
throw Exception("RPC client not initialized");
@@ -122,7 +104,6 @@ class SolanaTokenWallet extends Wallet {
final keyPair = await parentSolanaWallet.getKeyPair();
final walletAddress = keyPair.address;
- // Get sender's token acct.
final senderTokenAccount = await _findTokenAccount(
ownerAddress: walletAddress,
mint: tokenMint,
@@ -136,7 +117,6 @@ class SolanaTokenWallet extends Wallet {
);
}
- // Validate sender token account exists and has proper data.
try {
final accountInfo = await rpcClient.getAccountInfo(
senderTokenAccount,
@@ -151,10 +131,8 @@ class SolanaTokenWallet extends Wallet {
throw Exception("Failed to validate sender token account: $e");
}
- // Get latest block hash (used internally by RPC client).
await rpcClient.getLatestBlockhash();
- // Get recipient's token account (or derive ATA if it doesn't exist).
final recipientTokenAccount = await _findOrDeriveRecipientTokenAccount(
recipientAddress: recipientAddress,
mint: tokenMint,
@@ -194,7 +172,7 @@ class SolanaTokenWallet extends Wallet {
} catch (e) {
if (e.toString().contains("does not exist") ||
e.toString().contains("not owned by")) {
- rethrow; // Re-throw our validation errors.
+ rethrow;
}
throw Exception(
"Failed to validate recipient token account: $e. "
@@ -202,7 +180,6 @@ class SolanaTokenWallet extends Wallet {
);
}
- // Build SPL token tx instruction.
final senderTokenAccountKey = Ed25519HDPublicKey.fromBase58(
senderTokenAccount,
);
@@ -211,7 +188,6 @@ class SolanaTokenWallet extends Wallet {
);
final mintPubkey = Ed25519HDPublicKey.fromBase58(tokenMint);
- // Query the actual token program owner (important for Token-2022 variants).
String tokenProgramId;
try {
final mintInfo = await rpcClient.getAccountInfo(
@@ -238,8 +214,6 @@ class SolanaTokenWallet extends Wallet {
);
}
- // Build the transfer instruction (will be rebuilt in confirmSend with updated blockhash).
- // Determine which token program type to use based on the queried owner.
final TokenProgramType tokenProgram =
tokenProgramId != 'TokenkegQfeZyiNwAJsyFbPVwwQQfg5bgUiqhStM5QA'
&& tokenProgramId.startsWith('Token')
@@ -257,7 +231,6 @@ class SolanaTokenWallet extends Wallet {
tokenProgram: tokenProgram,
);
- // Estimate fee.
final feeEstimate =
await _getEstimatedTokenTransferFee(
senderTokenAccountKey: senderTokenAccountKey,
@@ -268,11 +241,10 @@ class SolanaTokenWallet extends Wallet {
) ??
5000;
- // Return prepared TxData.
return txData.copyWith(
fee: Amount(
rawValue: BigInt.from(feeEstimate),
- fractionDigits: 9, // Solana uses 9 decimal places for lamports.
+ fractionDigits: 9,
),
solanaRecipientTokenAccount: recipientTokenAccount,
);
@@ -330,12 +302,7 @@ class SolanaTokenWallet extends Wallet {
);
}
- // Log the token account for debugging.
- Logging.instance.i(
- "$runtimeType confirmSend - using recipient token account: $recipientTokenAccount",
- );
-
- // 5. Build SPL token tx instruction.
+ // Build SPL token tx instruction.
final senderTokenAccountKey = Ed25519HDPublicKey.fromBase58(
senderTokenAccount,
);
@@ -388,10 +355,6 @@ class SolanaTokenWallet extends Wallet {
tokenProgram: tokenProgram,
);
- Logging.instance.i(
- "$runtimeType confirmSend: Built TransferChecked instruction for token program $tokenProgramId",
- );
-
// Create message.
final message = Message(instructions: [instruction]);
@@ -678,26 +641,14 @@ class SolanaTokenWallet extends Wallet {
@override
Future<void> updateBalance() async {
try {
- Logging.instance.i(
- "$runtimeType updateBalance: Starting balance update for tokenMint=$tokenMint",
- );
-
final rpcClient = parentSolanaWallet.getRpcClient();
if (rpcClient == null) {
- Logging.instance.w(
- "$runtimeType updateBalance: RPC client not initialized",
- );
return;
}
final keyPair = await parentSolanaWallet.getKeyPair();
final walletAddress = keyPair.address;
- Logging.instance.i(
- "$runtimeType updateBalance: Wallet address = $walletAddress",
- );
-
- // Get sender's token account.
final senderTokenAccount = await _findTokenAccount(
ownerAddress: walletAddress,
mint: tokenMint,
@@ -705,17 +656,9 @@ class SolanaTokenWallet extends Wallet {
);
if (senderTokenAccount == null) {
- Logging.instance.w(
- "$runtimeType updateBalance: No token account found for mint $tokenMint",
- );
return;
}
- Logging.instance.i(
- "$runtimeType updateBalance: Found token account = $senderTokenAccount",
- );
-
- // Fetch the token balance.
final tokenApi = SolanaTokenAPI();
tokenApi.initializeRpcClient(rpcClient);
@@ -731,26 +674,12 @@ class SolanaTokenWallet extends Wallet {
}
if (balanceResponse.value != null) {
- // Log the updated balance.
- Logging.instance.i(
- "$runtimeType updateBalance: New balance = ${balanceResponse.value} (${balanceResponse.value! / BigInt.from(10).pow(tokenDecimals)} ${tokenSymbol})",
- );
-
- // Persist balance to WalletSolanaTokenInfo in Isar database.
- Logging.instance.i(
- "$runtimeType updateBalance: Looking up WalletSolanaTokenInfo for walletId=$walletId, tokenMint=$tokenMint",
- );
-
final info = await mainDB.isar.walletSolanaTokenInfo
.where()
.walletIdTokenAddressEqualTo(walletId, tokenMint)
.findFirst();
if (info != null) {
- Logging.instance.i(
- "$runtimeType updateBalance: Found WalletSolanaTokenInfo with ID=${info.id}, updating cached balance",
- );
-
final balanceAmount = Amount(
rawValue: balanceResponse.value!,
fractionDigits: tokenDecimals,
@@ -794,11 +723,6 @@ class SolanaTokenWallet extends Wallet {
@override
Future<void> refresh() async {
- Logging.instance.i(
- "$runtimeType refresh: Starting refresh for tokenMint=$tokenMint",
- );
- // Refresh both the parent wallet and token balance.
- // This ensures the cached token balance in the database is updated.
await parentSolanaWallet.refresh();
await updateBalance();
await updateTransactions();
@@ -806,36 +730,22 @@ class SolanaTokenWallet extends Wallet {
@override
Future<Amount> estimateFeeFor(Amount amount, BigInt feeRate) async {
- // Delegate to parent SolanaWallet for fee estimation.
- // For token transfers, the fee is the same as a regular SOL transfer.
return parentSolanaWallet.estimateFeeFor(amount, feeRate);
}
@override
Future<FeeObject> get fees async {
- // Delegate to parent SolanaWallet for fee information.
- // For token transfers, the fees are the same as regular SOL transfers.
return parentSolanaWallet.fees;
}
@override
Future<bool> pingCheck() async {
- // Delegate to parent SolanaWallet for RPC health check.
return parentSolanaWallet.pingCheck();
}
@override
- Future<void> checkSaveInitialReceivingAddress() async {
- // Token accounts are derived, not managed separately.
- }
+ Future<void> checkSaveInitialReceivingAddress() async {}
- // =========================================================================
- // Helper methods
- // =========================================================================
-
- /// Find a token account for the given owner and mint.
- ///
- /// Returns the token account address if found, otherwise null.
Future<String?> _findTokenAccount({
required String ownerAddress,
required String mint,
@@ -868,12 +778,6 @@ class SolanaTokenWallet extends Wallet {
}
}
- /// Find or derive the recipient's token account for a given mint.
- ///
- /// This method first attempts to find an existing token account owned by the recipient.
- /// If not found, it attempts to derive the ATA (Associated Token Account) address.
- ///
- /// Returns the token account address if found or derived, otherwise null.
Future<String?> _findOrDeriveRecipientTokenAccount({
required String recipientAddress,
required String mint,
@@ -926,28 +830,15 @@ class SolanaTokenWallet extends Wallet {
}
}
- /// Derive the Associated Token Account (ATA) address for a given owner and mint.
- ///
- /// The ATA is computed using:
- /// PDA = findProgramAddress(
- /// seeds = [b"account", owner_pubkey, token_program_id, mint_pubkey],
- /// program_id = AssociatedTokenProgram
- /// )
- ///
- /// Returns the derived ATA address as a base58 string, or null if derivation fails.
Future<String?> _deriveAtaAddress({
required String ownerAddress,
required String mint,
required RpcClient rpcClient,
}) async {
try {
- // Parse public keys from base58.
final ownerPubkey = Ed25519HDPublicKey.fromBase58(ownerAddress);
final mintPubkey = Ed25519HDPublicKey.fromBase58(mint);
- // Detect which token program owns the mint by querying its owner directly.
- // This is important because Token-2022 variants have different program IDs
- // on different networks.
final tokenApi = SolanaTokenAPI();
tokenApi.initializeRpcClient(rpcClient);
@@ -959,36 +850,21 @@ class SolanaTokenWallet extends Wallet {
);
if (mintInfo.value != null) {
tokenProgramId = mintInfo.value!.owner;
- Logging.instance.i(
- "$runtimeType _deriveAtaAddress: Detected token program owner=$tokenProgramId "
- "for mint=$mint",
- );
} else {
- // Fallback to SPL Token if we can't query.
tokenProgramId = 'TokenkegQfeZyiNwAJsyFbPVwwQQfg5bgUiqhStM5QA';
- Logging.instance.w(
- "$runtimeType _deriveAtaAddress: Could not query mint, using default SPL Token program",
- );
}
} catch (e) {
- // Fallback to SPL Token on error.
tokenProgramId = 'TokenkegQfeZyiNwAJsyFbPVwwQQfg5bgUiqhStM5QA';
- Logging.instance.w(
- "$runtimeType _deriveAtaAddress: Error querying mint owner: $e, using SPL Token",
- );
}
final tokenProgramPubkey = Ed25519HDPublicKey.fromBase58(tokenProgramId);
- // Associated Token Program ID (same for both SPL and Token-2022).
const associatedTokenProgramId =
'ATokenGPvbdGVqstVQmcLsNZAqeEjlCoquUSjfJ5c';
final associatedTokenProgramPubkey = Ed25519HDPublicKey.fromBase58(
associatedTokenProgramId,
);
- // Build seeds for ATA PDA derivation.
- // Seeds: ["account", owner, tokenProgram, mint]
final seeds = [
'account'.codeUnits,
ownerPubkey.toBase58().codeUnits,
@@ -996,10 +872,6 @@ class SolanaTokenWallet extends Wallet {
mintPubkey.toBase58().codeUnits,
];
- Logging.instance.i(
- "$runtimeType _deriveAtaAddress: Building seeds for ATA derivation",
- );
-
final ataAddress = await Ed25519HDPublicKey.findProgramAddress(
seeds: seeds,
programId: associatedTokenProgramPubkey,
@@ -1007,37 +879,6 @@ class SolanaTokenWallet extends Wallet {
final ataBase58 = ataAddress.toBase58();
- Logging.instance.i(
- "$runtimeType _deriveAtaAddress: Successfully derived ATA address "
- "(owner=$ownerAddress, mint=$mint, program=$tokenProgramId) → "
- "$ataBase58",
- );
-
- // Also verify the derived address actually exists on-chain
- try {
- final derivedAccountInfo = await rpcClient.getAccountInfo(
- ataBase58,
- encoding: Encoding.jsonParsed,
- );
- if (derivedAccountInfo.value == null) {
- Logging.instance.w(
- "$runtimeType _deriveAtaAddress: WARNING - Derived ATA address "
- "$ataBase58 does not exist on-chain. Recipient must initialize "
- "their token account first.",
- );
- } else {
- Logging.instance.i(
- "$runtimeType _deriveAtaAddress: Derived ATA exists on-chain - "
- "owner=${derivedAccountInfo.value!.owner}, "
- "lamports=${derivedAccountInfo.value!.lamports}",
- );
- }
- } catch (e) {
- Logging.instance.w(
- "$runtimeType _deriveAtaAddress: Could not verify derived ATA exists: $e",
- );
- }
-
return ataBase58;
} catch (e, stackTrace) {
Logging.instance.w(
@@ -1049,12 +890,6 @@ class SolanaTokenWallet extends Wallet {
}
}
- /// Estimate the fee for an token transfer transaction.
- ///
- /// Builds a token transfer message with the given parameters and uses
- /// the RPC `getFeeForMessage` call to get an accurate fee estimate.
- ///
- /// Returns the estimated fee in lamports, or null if estimation fails.
Future<int?> _getEstimatedTokenTransferFee({
required Ed25519HDPublicKey senderTokenAccountKey,
required Ed25519HDPublicKey recipientTokenAccountKey,
@@ -1128,12 +963,6 @@ class SolanaTokenWallet extends Wallet {
}
}
- /// Wait for transaction confirmation on-chain.
- ///
- /// Polls the RPC node until the transaction reaches the desired commitment
- /// level or until timeout is reached.
- ///
- /// Returns true if confirmed, false if timeout or error occurred.
Future<bool> _waitForConfirmation({
required String signature,
required int maxWaitSeconds,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.