mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
check and update primary node if primary node is a default node that was updated
This commit is contained in:
parent
a57fac4952
commit
b6a2840368
2 changed files with 25 additions and 0 deletions
|
@ -39,6 +39,19 @@ class NodeService extends ChangeNotifier {
|
|||
key: savedNode.id,
|
||||
value: defaultNode.copyWith(enabled: savedNode.enabled));
|
||||
}
|
||||
|
||||
// check if a default node is the primary node for the crypto currency
|
||||
// and update it if needed
|
||||
final coin = coinFromPrettyName(defaultNode.coinName);
|
||||
final primaryNode = getPrimaryNodeFor(coin: coin);
|
||||
if (primaryNode != null && primaryNode.id == defaultNode.id) {
|
||||
await setPrimaryNodeFor(
|
||||
coin: coin,
|
||||
node: defaultNode.copyWith(
|
||||
enabled: primaryNode.enabled,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -181,25 +181,32 @@ Coin coinFromPrettyName(String name) {
|
|||
case "Bitcoin":
|
||||
case "bitcoin":
|
||||
return Coin.bitcoin;
|
||||
|
||||
case "Bitcoincash":
|
||||
case "bitcoincash":
|
||||
case "Bitcoin Cash":
|
||||
return Coin.bitcoincash;
|
||||
|
||||
case "Dogecoin":
|
||||
case "dogecoin":
|
||||
return Coin.dogecoin;
|
||||
|
||||
case "Epic Cash":
|
||||
case "epicCash":
|
||||
return Coin.epicCash;
|
||||
|
||||
case "Firo":
|
||||
case "firo":
|
||||
return Coin.firo;
|
||||
|
||||
case "Monero":
|
||||
case "monero":
|
||||
return Coin.monero;
|
||||
|
||||
case "Namecoin":
|
||||
case "namecoin":
|
||||
return Coin.namecoin;
|
||||
|
||||
case "Bitcoin Testnet":
|
||||
case "tBitcoin":
|
||||
case "bitcoinTestNet":
|
||||
|
@ -208,19 +215,24 @@ Coin coinFromPrettyName(String name) {
|
|||
case "Bitcoincash Testnet":
|
||||
case "tBitcoin Cash":
|
||||
case "Bitcoin Cash Testnet":
|
||||
case "bitcoincashTestnet":
|
||||
return Coin.bitcoincashTestnet;
|
||||
|
||||
case "Firo Testnet":
|
||||
case "tFiro":
|
||||
case "firoTestNet":
|
||||
return Coin.firoTestNet;
|
||||
|
||||
case "Dogecoin Testnet":
|
||||
case "tDogecoin":
|
||||
case "dogecoinTestNet":
|
||||
return Coin.dogecoinTestNet;
|
||||
|
||||
case "Wownero":
|
||||
case "tWownero":
|
||||
case "wownero":
|
||||
return Coin.wownero;
|
||||
|
||||
default:
|
||||
throw ArgumentError.value(
|
||||
name, "name", "No Coin enum value with that prettyName");
|
||||
|
|
Loading…
Reference in a new issue