Skip to content

Commit

Permalink
added interval seconds variable to env
Browse files Browse the repository at this point in the history
  • Loading branch information
LiorAgnin committed May 4, 2020
1 parent 244c543 commit 21bcd8f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions .env_example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
MODE=production
INTERVAL_SECONDS=5
FUSE_CHAIN_ID=122
FOREIGN_NETWORK_ID=1
FOREIGN_PROVIDER_URL=https://mainnet.infura.io/v3/b907f6ff22bc484ca33cf4af39ebcf86
Expand Down
1 change: 1 addition & 0 deletions .env_prod
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
MODE=production
INTERVAL_SECONDS=5
FUSE_CHAIN_ID=122
FOREIGN_NETWORK_ID=1
FOREIGN_PROVIDER_URL=https://mainnet.infura.io/v3/b907f6ff22bc484ca33cf4af39ebcf86
Expand Down
1 change: 1 addition & 0 deletions .env_qa
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
MODE=development
INTERVAL_SECONDS=5
FUSE_CHAIN_ID=122
FOREIGN_NETWORK_ID=3
FOREIGN_PROVIDER_URL=https://ropsten.infura.io/v3/b907f6ff22bc484ca33cf4af39ebcf86
Expand Down
9 changes: 5 additions & 4 deletions lib/redux/actions/cash_wallet_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'package:fusecash/redux/actions/pro_mode_wallet_actions.dart';
import 'package:fusecash/redux/actions/user_actions.dart';
import 'package:fusecash/utils/addresses.dart';
import 'package:fusecash/redux/state/store.dart';
import 'package:fusecash/utils/constans.dart';
import 'package:fusecash/utils/format.dart';
import 'package:fusecash/utils/phone.dart';
import 'package:http/http.dart';
Expand Down Expand Up @@ -393,7 +394,7 @@ ThunkAction startBalanceFetchingCall() {
if (tokenAddress != null) {
store.dispatch(getTokenBalanceCall(tokenAddress));
}
new Timer.periodic(Duration(seconds: 3), (Timer t) async {
new Timer.periodic(Duration(seconds: intervalSeconds), (Timer t) async {
if (store.state.cashWalletState.walletAddress == '') {
t.cancel();
return;
Expand Down Expand Up @@ -423,7 +424,7 @@ ThunkAction startTransfersFetchingCall() {
store.dispatch(getTokenTransfersListCall(tokenAddress));
store.dispatch(getTokenBalanceCall(tokenAddress));
}
new Timer.periodic(Duration(seconds: 3), (Timer t) async {
new Timer.periodic(Duration(seconds: intervalSeconds), (Timer t) async {
if (store.state.cashWalletState.walletAddress == '') {
t.cancel();
return;
Expand Down Expand Up @@ -613,7 +614,7 @@ ThunkAction startFetchingJobCall(
String jobId, Function(Job) fetchSuccessCallback,
{bool untilDone: true}) {
return (Store store) async {
new Timer.periodic(Duration(seconds: 3), (Timer timer) async {
new Timer.periodic(Duration(seconds: intervalSeconds), (Timer timer) async {
store.dispatch(fetchJobCall(jobId, fetchSuccessCallback,
timer: timer, untilDone: untilDone));
});
Expand Down Expand Up @@ -660,7 +661,7 @@ ThunkAction processingJobsCall(Timer timer) {

ThunkAction startProcessingJobsCall() {
return (Store store) async {
new Timer.periodic(Duration(seconds: 3), (Timer timer) async {
new Timer.periodic(Duration(seconds: intervalSeconds), (Timer timer) async {
store.dispatch(processingJobsCall(timer));
});
store.dispatch(JobProcessingStarted());
Expand Down
9 changes: 5 additions & 4 deletions lib/redux/actions/pro_mode_wallet_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:fusecash/redux/actions/error_actions.dart';
import 'package:fusecash/redux/state/store.dart';
import 'package:fusecash/services.dart';
import 'package:fusecash/utils/addresses.dart';
import 'package:fusecash/utils/constans.dart';
import 'package:redux_thunk/redux_thunk.dart';
import 'package:redux/redux.dart';
import 'package:wallet_core/wallet_core.dart' as wallet_core;
Expand Down Expand Up @@ -82,7 +83,7 @@ ThunkAction initWeb3ProMode({

ThunkAction startListenToTransferEvents() {
return (Store store) async {
new Timer.periodic(Duration(seconds: 5), (Timer timer) async {
new Timer.periodic(Duration(seconds: intervalSeconds), (Timer timer) async {
String walletAddress = store.state.userState.walletAddress;
dynamic response = await graph.getTransferEvents(
foreignNetwork: foreignNetwork, to: walletAddress);
Expand All @@ -102,7 +103,7 @@ ThunkAction fetchTokensBalances() {
bool isFetchTokensBalances = store.state.proWalletState?.isFetchTokensBalances ?? false;
if (!isFetchTokensBalances) {
UserState userState = store.state.userState;
new Timer.periodic(Duration(seconds: 3), (Timer timer) async {
new Timer.periodic(Duration(seconds: intervalSeconds), (Timer timer) async {
ProWalletState proWalletState = store.state.proWalletState;
for (Token token in proWalletState.erc20Tokens.values) {
void Function(BigInt) onDone = (BigInt balance) {
Expand Down Expand Up @@ -171,7 +172,7 @@ ThunkAction startFetchTransferEventsCall() {
return (Store store) async {
bool isFetchTransferEvents = store.state.proWalletState?.isFetchTransferEvents ?? false;
if (!isFetchTransferEvents) {
new Timer.periodic(Duration(seconds: 10), (Timer timer) async {
new Timer.periodic(Duration(seconds: (intervalSeconds * 2)), (Timer timer) async {
ProWalletState proWalletState = store.state.proWalletState;
List<String> tokenAddresses = List<String>.from(proWalletState.erc20Tokens.keys);
for (String tokenAddress in tokenAddresses) {
Expand Down Expand Up @@ -293,7 +294,7 @@ ThunkAction startProcessingTokensJobsCall() {
return (Store store) async {
bool isProcessingTokensJobs = store.state.proWalletState?.isProcessingTokensJobs ?? false;
if (!isProcessingTokensJobs) {
new Timer.periodic(Duration(seconds: 3), (Timer timer) async {
new Timer.periodic(Duration(seconds: intervalSeconds), (Timer timer) async {
store.dispatch(processingTokenJobsCall(timer));
});
store.dispatch(new StartProcessingTokensJobs());
Expand Down
3 changes: 3 additions & 0 deletions lib/utils/constans.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import 'package:flutter_dotenv/flutter_dotenv.dart';

final int intervalSeconds = int.parse(DotEnv().env['INTERVAL_SECONDS']);

0 comments on commit 21bcd8f

Please sign in to comment.