-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add guardian validation + test periods
- Loading branch information
Showing
4 changed files
with
103 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/components/tx-flow/flows/UpsertRecovery/useRecoveryPeriods.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import chains from '@/config/chains' | ||
import { useCurrentChain } from '@/hooks/useChains' | ||
|
||
export const DAY_IN_SECONDS = 60 * 60 * 24 | ||
|
||
const DefaultRecoveryDelayPeriods = [ | ||
{ | ||
label: '2 days', | ||
value: `${DAY_IN_SECONDS * 2}`, | ||
}, | ||
{ | ||
label: '7 days', | ||
value: `${DAY_IN_SECONDS * 7}`, | ||
}, | ||
{ | ||
label: '14 days', | ||
value: `${DAY_IN_SECONDS * 14}`, | ||
}, | ||
{ | ||
label: '28 days', | ||
value: `${DAY_IN_SECONDS * 28}`, | ||
}, | ||
{ | ||
label: '56 days', | ||
value: `${DAY_IN_SECONDS * 56}`, | ||
}, | ||
] | ||
|
||
const DefaultRecoveryExpirationPeriods = [ | ||
{ | ||
label: 'Never', | ||
value: '0', | ||
}, | ||
...DefaultRecoveryDelayPeriods, | ||
] | ||
|
||
const TestRecoveryDelayPeriods = [ | ||
{ | ||
label: '1 minute', | ||
value: 60, | ||
}, | ||
{ | ||
label: '5 minutes', | ||
value: 60 * 5, | ||
}, | ||
{ | ||
label: '1 hour', | ||
value: DAY_IN_SECONDS, | ||
}, | ||
...DefaultRecoveryDelayPeriods, | ||
] | ||
|
||
const TestRecoveryExpirationPeriods = [ | ||
{ | ||
label: 'Never', | ||
value: '0', | ||
}, | ||
...TestRecoveryDelayPeriods, | ||
] | ||
|
||
export function useRecoveryPeriods() { | ||
const chain = useCurrentChain() | ||
|
||
if (!chain || [chains.gor, chains.sep].includes(chain.chainId)) { | ||
return { | ||
delay: TestRecoveryDelayPeriods, | ||
expiration: TestRecoveryExpirationPeriods, | ||
} | ||
} | ||
|
||
return { | ||
delay: DefaultRecoveryDelayPeriods, | ||
expiration: DefaultRecoveryExpirationPeriods, | ||
} | ||
} |