mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-01 01:47:41 +00:00
6414364602
* New price API * Fix test app package id * Fix workflow * change environment variable to use pr number [skip ci] * Fix un-needed padding * Fix raw value for usdtSol * Remove duplicate fetching for balance and transactions at start [skip ci] * Fix address validation of spl tokens * Add Service Status * Update lib/src/widgets/service_status_tile.dart Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com> * Update lib/src/widgets/services_updates_widget.dart Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com> * Update monero version * update sodium script * Change automatic priority fee rate --------- Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>
118 lines
3.7 KiB
Dart
118 lines
3.7 KiB
Dart
part of 'solana.dart';
|
|
|
|
class CWSolana extends Solana {
|
|
@override
|
|
List<String> getSolanaWordList(String language) => SolanaMnemonics.englishWordlist;
|
|
|
|
WalletService createSolanaWalletService(Box<WalletInfo> walletInfoSource) =>
|
|
SolanaWalletService(walletInfoSource);
|
|
|
|
@override
|
|
WalletCredentials createSolanaNewWalletCredentials({
|
|
required String name,
|
|
WalletInfo? walletInfo,
|
|
}) =>
|
|
SolanaNewWalletCredentials(name: name, walletInfo: walletInfo);
|
|
|
|
@override
|
|
WalletCredentials createSolanaRestoreWalletFromSeedCredentials({
|
|
required String name,
|
|
required String mnemonic,
|
|
required String password,
|
|
}) =>
|
|
SolanaRestoreWalletFromSeedCredentials(name: name, password: password, mnemonic: mnemonic);
|
|
|
|
@override
|
|
WalletCredentials createSolanaRestoreWalletFromPrivateKey({
|
|
required String name,
|
|
required String privateKey,
|
|
required String password,
|
|
}) =>
|
|
SolanaRestoreWalletFromPrivateKey(name: name, password: password, privateKey: privateKey);
|
|
|
|
@override
|
|
String getAddress(WalletBase wallet) => (wallet as SolanaWallet).walletAddresses.address;
|
|
|
|
@override
|
|
String getPrivateKey(WalletBase wallet) => (wallet as SolanaWallet).privateKey;
|
|
|
|
@override
|
|
String getPublicKey(WalletBase wallet) => (wallet as SolanaWallet).keys.publicKey.toBase58();
|
|
|
|
@override
|
|
Ed25519HDKeyPair? getWalletKeyPair(WalletBase wallet) => (wallet as SolanaWallet).walletKeyPair;
|
|
|
|
Object createSolanaTransactionCredentials(
|
|
List<Output> outputs, {
|
|
required CryptoCurrency currency,
|
|
}) =>
|
|
SolanaTransactionCredentials(
|
|
outputs
|
|
.map((out) => OutputInfo(
|
|
fiatAmount: out.fiatAmount,
|
|
cryptoAmount: out.cryptoAmount,
|
|
address: out.address,
|
|
note: out.note,
|
|
sendAll: out.sendAll,
|
|
extractedAddress: out.extractedAddress,
|
|
isParsedAddress: out.isParsedAddress,
|
|
formattedCryptoAmount: out.formattedCryptoAmount))
|
|
.toList(),
|
|
currency: currency,
|
|
);
|
|
|
|
Object createSolanaTransactionCredentialsRaw(
|
|
List<OutputInfo> outputs, {
|
|
required CryptoCurrency currency,
|
|
}) =>
|
|
SolanaTransactionCredentials(outputs, currency: currency);
|
|
|
|
@override
|
|
List<SPLToken> getSPLTokenCurrencies(WalletBase wallet) {
|
|
final solanaWallet = wallet as SolanaWallet;
|
|
return solanaWallet.splTokenCurrencies;
|
|
}
|
|
|
|
@override
|
|
Future<void> addSPLToken(WalletBase wallet, CryptoCurrency token) async =>
|
|
await (wallet as SolanaWallet).addSPLToken(token as SPLToken);
|
|
|
|
@override
|
|
Future<void> deleteSPLToken(WalletBase wallet, CryptoCurrency token) async =>
|
|
await (wallet as SolanaWallet).deleteSPLToken(token as SPLToken);
|
|
|
|
@override
|
|
Future<SPLToken?> getSPLToken(WalletBase wallet, String mintAddress) async {
|
|
final solanaWallet = wallet as SolanaWallet;
|
|
return await solanaWallet.getSPLToken(mintAddress);
|
|
}
|
|
|
|
@override
|
|
CryptoCurrency assetOfTransaction(WalletBase wallet, TransactionInfo transaction) {
|
|
transaction as SolanaTransactionInfo;
|
|
if (transaction.tokenSymbol == CryptoCurrency.sol.title) {
|
|
return CryptoCurrency.sol;
|
|
}
|
|
|
|
wallet as SolanaWallet;
|
|
return wallet.splTokenCurrencies
|
|
.firstWhere((element) => transaction.tokenSymbol == element.symbol);
|
|
}
|
|
|
|
@override
|
|
double getTransactionAmountRaw(TransactionInfo transactionInfo) {
|
|
return (transactionInfo as SolanaTransactionInfo).solAmount.toDouble();
|
|
}
|
|
|
|
@override
|
|
String getTokenAddress(CryptoCurrency asset) => (asset as SPLToken).mintAddress;
|
|
|
|
@override
|
|
List<int>? getValidationLength(CryptoCurrency type) {
|
|
if (type is SPLToken) {
|
|
return [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|