mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-26 06:08:40 +01:00
* feat: Add network selector and compatible networks screen to send page for EVMs * feat: add redesigned payanything flow and handle cases for evms, solana and tron * feat: adding the swap part to the entire flow * refactor: update navigation and error handling in send and swap flows * adjust structuring and use the chain badge icons, also fix crypto and currency values not consistent on single network picker * fix: modify guard for non-evm chains and minor cleanup * use multipicker layout for receive section, streamline send to available balances and adjust colors as needed * handle btc case for picker, update style and images across * fix all pending issues with scanning qr and network handling for both evm and non evm, plus token and amount resolving * fix all pending issues with scanning qr and network handling for both evm and non evm, plus token and amount resolving * fix: expand fetch for tokens across networks and fix other issues regarding scanning from homepage * auto-reformat * fix conflict * handle evm qr scan from homepage and add guards for swap and switch flows * chore: Cleanup * chore: set estimated fee to 0 when switching wallet * fix merge conflicts * fix to review comments and reformatting for lints * fix: root cause for token bug reported * chore: cleanup * feat: add improved anypay swap screen which focuses on the receive amount fix: fiat input toggle erro (also present on prod) reformat: anypay related widgets * feat: add alert for unsupported networks in payment requests * fix: prevent rate and provider from showing until amount is calculated and loaded fix: remove send icon in rate widget and align to center fix: adjust network badge in swap confirm widget * feat: embed tokens for solana and tron in QR generated for swap from external * test: add unit tests for Tron, Solana, and ERC681 URI handling and detection * fix: review comments * fix: handle more edgecases * feat: enhance ERC681URI to support raw token amounts and decimals * refactor: streamline EVM chain ID retrieval in send page and recipient network row * fix: minor review comments --------- Co-authored-by: Robert Malikowski <malikowskirobert@gmail.com>
85 lines
2.6 KiB
Dart
85 lines
2.6 KiB
Dart
import "package:cake_wallet/utils/token_utilities.dart";
|
|
import "package:cw_core/crypto_currency.dart";
|
|
import "package:cw_core/erc20_token.dart";
|
|
import "package:cw_core/spl_token.dart";
|
|
import "package:cw_core/tron_token.dart";
|
|
import "package:flutter_test/flutter_test.dart";
|
|
|
|
void main() {
|
|
group("TokenUtilities", () {
|
|
group("findTronTokenContract", () {
|
|
test("returns the contract from a TronToken instance", () {
|
|
final token = TronToken(
|
|
name: "Test Token",
|
|
symbol: "TST",
|
|
contractAddress: "TContractAddress123",
|
|
decimal: 6,
|
|
);
|
|
|
|
expect(TokenUtilities.findTronTokenContract(token), "TContractAddress123");
|
|
});
|
|
|
|
test("resolves a bare currency from the default token list", () {
|
|
expect(
|
|
TokenUtilities.findTronTokenContract(CryptoCurrency.usdttrc20),
|
|
"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
|
|
);
|
|
});
|
|
|
|
test("returns null for native TRX", () {
|
|
expect(TokenUtilities.findTronTokenContract(CryptoCurrency.trx), null);
|
|
});
|
|
|
|
test("does not resolve a token from another network", () {
|
|
expect(TokenUtilities.findTronTokenContract(CryptoCurrency.usdtSol), null);
|
|
});
|
|
});
|
|
|
|
group("findSolanaTokenMint", () {
|
|
test("returns the mint from an SPLToken instance", () {
|
|
final token = SPLToken(
|
|
name: "Test Token",
|
|
symbol: "TST",
|
|
mintAddress: "MintAddress123",
|
|
decimal: 6,
|
|
mint: "tst",
|
|
);
|
|
|
|
expect(TokenUtilities.findSolanaTokenMint(token), "MintAddress123");
|
|
});
|
|
|
|
test("resolves a bare currency from the default token list", () {
|
|
expect(
|
|
TokenUtilities.findSolanaTokenMint(CryptoCurrency.usdtSol),
|
|
"Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
|
|
);
|
|
});
|
|
|
|
test("returns null for native SOL", () {
|
|
expect(TokenUtilities.findSolanaTokenMint(CryptoCurrency.sol), null);
|
|
});
|
|
|
|
test("does not resolve a token from another network", () {
|
|
expect(TokenUtilities.findSolanaTokenMint(CryptoCurrency.usdttrc20), null);
|
|
});
|
|
});
|
|
|
|
group("findErc20TokenForSwap", () {
|
|
test("returns the same instance for an Erc20Token", () {
|
|
final token = Erc20Token(
|
|
name: "Test Token",
|
|
symbol: "TST",
|
|
contractAddress: "0x0000000000000000000000000000000000000001",
|
|
decimal: 18,
|
|
);
|
|
|
|
expect(TokenUtilities.findErc20TokenForSwap(token), same(token));
|
|
});
|
|
|
|
test("returns null for native ETH", () {
|
|
expect(TokenUtilities.findErc20TokenForSwap(CryptoCurrency.eth), null);
|
|
});
|
|
});
|
|
});
|
|
}
|