mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-19 05:58:50 +02:00
* feat: Integrate Jupiter DEX * feat: Enable internal swaps * feat: implement Jupiter swap execution api and enhance trade handling - Added executeSwap method to handle signed swap transactions via the execute endpoint. - Updated signAndPrepareJupiterSwapTransaction to include request ID and handle swap execution response. - Modified trade details to use txId instead of id for Jupiter trades. - Enhanced error handling for swap execution with user-friendly messages. - Updated sendviewmodel to manage trade state updates after transaction commitment. * fix: null error after successfully swapping * fix: Finallyyy fixed the annoying tx history issue for solana dex swaps * fix: update inputAddress to use toAddress in JupiterExchangeProvider * feat: enhance transaction handling and token balance updates - Cut down tx fetch/update time for transactions update after swapping - Added TransactionFetchResult class to hold parsed transactions and token mints. - Added pollForTransaction method to handle transaction polling with exponential backoff. - Conditionally hide the external send button based on provider type. * feat: add fees to trade object and handle null case * feat: add Jupiter referral fee and account configuration --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
cw_solana
Solana wallet module for Cake Wallet. Provides native SOL and SPL token support built on on_chain/solana with high-throughput RPC usage and safe transaction parsing.
Features
- Connect to Solana RPC (Ankr/Chainstack/custom) via
SolanaRPCover HTTP. - Fetch SOL balances and aggregate SPL token balances across accounts.
- Parse and stream native and SPL token transactions (filters ATA-only and spam-like micro txs).
- Estimate fees per compiled message and enforce rent-exemption checks.
- Create/sign/broadcast SOL and SPL transfers; auto-create recipient ATA when necessary.
- Manage SPL tokens; fetch on-chain metadata (symbol/name) for unknown mints.
- Sign and verify messages.
- Node health checks for SOL and a known SPL token (USDC).
Getting started
If you use hosted RPC providers, add a secrets file for keys (optional unless using those hosts):
// cw_solana/lib/.secrets.g.dart (DO NOT COMMIT)
const String ankrApiKey = 'YOUR_ANKR_KEY';
const String chainStackApiKey = 'YOUR_CHAINSTACK_KEY';
Connect and sync:
final service = SolanaWalletService(walletInfoBox, true);
final wallet = await service.create(SolanaNewWalletCredentials(name: 'My SOL', password: 'secret'));
await wallet.connectToNode(node: Node(uriRaw: 'api.mainnet-beta.solana.com', isSSL: true));
await wallet.startSync();
final sol = wallet.balance[CryptoCurrency.sol]?.balance;
Usage
Send SOL:
final pending = await wallet.createTransaction(
SolanaTransactionCredentials.single(
address: 'SoL...',
cryptoAmount: '0.05',
currency: CryptoCurrency.sol,
),
);
final sig = await pending.commit();
Add an SPL token by mint:
final token = await wallet.getSPLToken('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'); // USDC
if (token != null) {
await wallet.addSPLToken(token);
}
Additional information
- When using
rpc.ankr.comorsolana-mainnet.core.chainstack.com, the client reads API keys from.secrets.g.dart. - See
lib/for APIs:SolanaWalletClient,SolanaWallet,SolanaWalletService, and credential types.