mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-18 16:55:58 +00:00
Merge branch 'main' into CW-876-Fix-node-QR-Code-URI-parsing
This commit is contained in:
commit
1fa64884b9
3 changed files with 41 additions and 21 deletions
|
@ -481,6 +481,9 @@ class SolanaWalletClient {
|
|||
final destinationOwner = Ed25519HDPublicKey.fromBase58(destinationAddress);
|
||||
final mint = Ed25519HDPublicKey.fromBase58(tokenMint);
|
||||
|
||||
// Input by the user
|
||||
final amount = (inputAmount * math.pow(10, tokenDecimals)).toInt();
|
||||
|
||||
ProgramAccount? associatedRecipientAccount;
|
||||
ProgramAccount? associatedSenderAccount;
|
||||
|
||||
|
@ -503,18 +506,46 @@ class SolanaWalletClient {
|
|||
}
|
||||
|
||||
try {
|
||||
associatedRecipientAccount ??= await _client!.createAssociatedTokenAccount(
|
||||
mint: mint,
|
||||
owner: destinationOwner,
|
||||
funder: ownerKeypair,
|
||||
);
|
||||
if (associatedRecipientAccount == null) {
|
||||
final derivedAddress = await findAssociatedTokenAddress(
|
||||
owner: destinationOwner,
|
||||
mint: mint,
|
||||
);
|
||||
|
||||
final instruction = AssociatedTokenAccountInstruction.createAccount(
|
||||
mint: mint,
|
||||
address: derivedAddress,
|
||||
owner: ownerKeypair.publicKey,
|
||||
funder: ownerKeypair.publicKey,
|
||||
);
|
||||
|
||||
final _signedTx = await _signTransactionInternal(
|
||||
message: Message.only(instruction),
|
||||
signers: [ownerKeypair],
|
||||
commitment: commitment,
|
||||
latestBlockhash: await _getLatestBlockhash(commitment),
|
||||
);
|
||||
|
||||
await sendTransaction(
|
||||
signedTransaction: _signedTx,
|
||||
commitment: commitment,
|
||||
);
|
||||
|
||||
associatedRecipientAccount = ProgramAccount(
|
||||
pubkey: derivedAddress.toBase58(),
|
||||
account: Account(
|
||||
owner: destinationOwner.toBase58(),
|
||||
lamports: 0,
|
||||
executable: false,
|
||||
rentEpoch: BigInt.zero,
|
||||
data: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
throw SolanaCreateAssociatedTokenAccountException(e.toString());
|
||||
}
|
||||
|
||||
// Input by the user
|
||||
final amount = (inputAmount * math.pow(10, tokenDecimals)).toInt();
|
||||
|
||||
final instruction = TokenInstruction.transfer(
|
||||
source: Ed25519HDPublicKey.fromBase58(associatedSenderAccount.pubkey),
|
||||
destination: Ed25519HDPublicKey.fromBase58(associatedRecipientAccount.pubkey),
|
||||
|
@ -587,6 +618,8 @@ class SolanaWalletClient {
|
|||
signedTransaction.encode(),
|
||||
preflightCommitment: commitment,
|
||||
);
|
||||
print("#########");
|
||||
print(signature);
|
||||
|
||||
_client!.waitForSignatureStatus(signature, status: commitment);
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||
import 'package:solana/base58.dart';
|
||||
import 'package:solana/metaplex.dart' as metaplex;
|
||||
import 'package:solana/solana.dart';
|
||||
import 'package:solana/src/crypto/ed25519_hd_keypair.dart';
|
||||
|
||||
part 'solana_wallet.g.dart';
|
||||
|
||||
|
|
|
@ -259,25 +259,13 @@ class AddressResolver {
|
|||
}
|
||||
}
|
||||
|
||||
print("@@@@@@@@");
|
||||
print(formattedName);
|
||||
print(domainParts);
|
||||
print(name);
|
||||
|
||||
if (formattedName.contains(".")) {
|
||||
if (settingsStore.lookupsOpenAlias) {
|
||||
final txtRecord = await OpenaliasRecord.lookupOpenAliasRecord(formattedName);
|
||||
|
||||
print("@@@@@@@@");
|
||||
print(txtRecord);
|
||||
if (txtRecord != null) {
|
||||
final record = await OpenaliasRecord.fetchAddressAndName(
|
||||
formattedName: formattedName, ticker: ticker.toLowerCase(), txtRecord: txtRecord);
|
||||
print("@@@@@@@@");
|
||||
print(record);
|
||||
print(record.name);
|
||||
print(record.address);
|
||||
print(record.description);
|
||||
return ParsedAddress.fetchOpenAliasAddress(record: record, name: text);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue