update method
Update or sync wallet transactions with blockchain. Return true if data changed. Is ignored if loadingTime is not zero.
Implementation
@override
Future<Result<bool, String>> update() async {
if (_updateCalledTime != 0 && loadingTime < updateTimeout) {
return Err('$walletName update already in progress');
}
_updateCalledTime = DateTime.now().millisecondsSinceEpoch;
final result =
await blockchainAdapter.updateWallet(stakeAddress: stakeAddress);
if (result.isErr()) {
_updateCalledTime = 0;
return Err(result.unwrapErr());
}
bool changed = false;
final update = result.unwrap();
changed = refresh(
balance: update.balance,
transactions: update.transactions,
usedAddresses: update.addresses,
assets: update.assets,
stakeAccounts: update.stakeAccounts);
_updateCalledTime = 0; //reset timeout
return Ok(changed);
}