2018-11-17 06:27:01 +01:00
|
|
|
// next version number
|
2023-01-18 15:47:29 +01:00
|
|
|
import { TransactionStatus } from '../../../shared/constants/transaction';
|
2021-02-04 19:15:23 +01:00
|
|
|
import failTxsThat from './fail-tx';
|
2018-11-17 06:27:01 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const version = 29;
|
2020-08-19 18:27:05 +02:00
|
|
|
|
2018-11-17 06:27:01 +01:00
|
|
|
// time
|
2021-02-04 19:15:23 +01:00
|
|
|
const seconds = 1000;
|
|
|
|
const minutes = 60 * seconds;
|
|
|
|
const hours = 60 * minutes;
|
|
|
|
const unacceptableDelay = 12 * hours;
|
2018-11-17 06:27:01 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
normalizes txParams on unconfirmed txs
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2020-01-09 04:34:58 +01:00
|
|
|
export default {
|
2018-11-17 06:27:01 +01:00
|
|
|
version,
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
migrate: failTxsThat(
|
|
|
|
version,
|
|
|
|
'Stuck in approved state for too long.',
|
|
|
|
(txMeta) => {
|
2023-01-18 15:47:29 +01:00
|
|
|
const isApproved = txMeta.status === TransactionStatus.approved;
|
2021-02-04 19:15:23 +01:00
|
|
|
const createdTime = txMeta.submittedTime;
|
|
|
|
const now = Date.now();
|
|
|
|
return isApproved && now - createdTime > unacceptableDelay;
|
2020-11-03 00:41:28 +01:00
|
|
|
},
|
|
|
|
),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|