feat: Load default ERC20 Tokens for existing ETH and Polygon Wallets (#2274)

This commit is contained in:
Konstantin Ullrich 2025-05-15 21:57:02 +02:00 committed by GitHub
parent bc52cf485e
commit c12daced40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 24 additions and 9 deletions

View file

@ -18,7 +18,7 @@ class DefaultEthereumErc20Tokens {
enabled: true,
),
Erc20Token(
name: "Digital Euro",
name: "Decentralized Euro",
symbol: "DEURO",
contractAddress: "0xbA3f535bbCcCcA2A154b573Ca6c5A49BAAE0a3ea",
decimal: 18,

View file

@ -31,11 +31,14 @@ class EthereumWallet extends EVMChainWallet {
}) : super(nativeCurrency: CryptoCurrency.eth);
@override
void addInitialTokens() {
void addInitialTokens([bool isMigration = false]) {
final initialErc20Tokens = DefaultEthereumErc20Tokens().initialErc20Tokens;
for (var token in initialErc20Tokens) {
evmChainErc20TokensBox.put(token.contractAddress, token);
for (final token in initialErc20Tokens) {
if (!evmChainErc20TokensBox.containsKey(token.contractAddress)) {
if (isMigration) token.enabled = false;
evmChainErc20TokensBox.put(token.contractAddress, token);
}
}
}

View file

@ -53,6 +53,7 @@ class EthereumWalletService extends EVMChainWalletService<EthereumWallet> {
);
await wallet.init();
wallet.addInitialTokens(true);
await wallet.save();
saveBackup(name);
return wallet;