mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-06-28 12:29:51 +00:00
feat: Load default ERC20 Tokens for existing ETH and Polygon Wallets (#2274)
This commit is contained in:
parent
bc52cf485e
commit
c12daced40
8 changed files with 24 additions and 9 deletions
|
@ -18,7 +18,7 @@ class DefaultEthereumErc20Tokens {
|
|||
enabled: true,
|
||||
),
|
||||
Erc20Token(
|
||||
name: "Digital Euro",
|
||||
name: "Decentralized Euro",
|
||||
symbol: "DEURO",
|
||||
contractAddress: "0xbA3f535bbCcCcA2A154b573Ca6c5A49BAAE0a3ea",
|
||||
decimal: 18,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ class EthereumWalletService extends EVMChainWalletService<EthereumWallet> {
|
|||
);
|
||||
|
||||
await wallet.init();
|
||||
wallet.addInitialTokens(true);
|
||||
await wallet.save();
|
||||
saveBackup(name);
|
||||
return wallet;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue