Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update time options for inheritance key #6087

Open
wants to merge 1 commit into
base: sprint
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 34 additions & 24 deletions src/components/OptionDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Pressable, useColorMode } from 'native-base';
import { Box, Pressable, ScrollView, useColorMode } from 'native-base';
import { StyleSheet, TouchableOpacity } from 'react-native';
import RightArrowIcon from 'src/assets/images/icon_arrow.svg';
import { hp, wp } from 'src/constants/responsive';
Expand Down Expand Up @@ -81,29 +81,35 @@ function OptionDropdown({ label, options, selectedOption, onOptionSelect }: Prop
backgroundColor={`${colorMode}.boxSecondaryBackground`}
style={styles.optionsContainer}
>
{options.map((option, index) => (
<TouchableOpacity
key={option.value.toString()}
onPress={() => handleOptionSelect(option)}
>
<Box style={styles.optionContainer}>
<Text
color={
internalSelectedOption?.value === option.value
? `${colorMode}.greenText`
: `${colorMode}.GreyText`
}
style={styles.optionText}
>
{`${option.label}`}
</Text>
{internalSelectedOption?.value === option.value && <TickIcon />}
</Box>
{index !== options.length - 1 && (
<Box backgroundColor={`${colorMode}.dullGreyBorder`} style={styles.separator} />
)}
</TouchableOpacity>
))}
<ScrollView
style={styles.scrollView}
showsVerticalScrollIndicator={false}
nestedScrollEnabled={false}
>
{options.map((option, index) => (
<TouchableOpacity
key={option.value.toString()}
onPress={() => handleOptionSelect(option)}
>
<Box style={styles.optionContainer}>
<Text
color={
internalSelectedOption?.value === option.value
? `${colorMode}.greenText`
: `${colorMode}.GreyText`
}
style={styles.optionText}
>
{`${option.label}`}
</Text>
{internalSelectedOption?.value === option.value && <TickIcon />}
</Box>
{index !== options.length - 1 && (
<Box backgroundColor={`${colorMode}.dullGreyBorder`} style={styles.separator} />
)}
</TouchableOpacity>
))}
</ScrollView>
</Box>
)}
</Box>
Expand Down Expand Up @@ -152,6 +158,7 @@ const styles = StyleSheet.create({
marginTop: hp(5),
borderBottomLeftRadius: 10,
borderBottomRightRadius: 10,
maxHeight: hp(200),
},
optionContainer: {
flexDirection: 'row',
Expand All @@ -161,6 +168,9 @@ const styles = StyleSheet.create({
paddingBottom: hp(15),
paddingHorizontal: wp(20),
},
scrollView: {
maxHeight: hp(200),
},
separator: {
height: 1,
alignSelf: 'center',
Expand Down
17 changes: 15 additions & 2 deletions src/screens/Vault/AddReserveKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ import KEEPERAPPLIGHT from 'src/assets/images/KeeperIconLight.svg';
import Buttons from 'src/components/Buttons';
import { SDIcons } from './SigningDeviceIcons';
import HorizontalSignerCard from '../AddSigner/HorizontalSignerCard';
import { MONTHS_12, MONTHS_24, MONTHS_18 } from './constants';
import {
MONTHS_12,
MONTHS_24,
MONTHS_18,
MONTHS_6,
MONTHS_3,
MONTHS_30,
MONTHS_36,
} from './constants';
import { getKeyUID } from 'src/utils/utilities';
import { MiniscriptTypes, VaultType } from 'src/services/wallets/enums';
import useVault from 'src/hooks/useVault';
Expand All @@ -32,11 +40,16 @@ import SuccessIcon from 'src/assets/images/successSvg.svg';
import WalletUtilities from 'src/services/wallets/operations/utils';
import { INHERITANCE_KEY1_IDENTIFIER } from 'src/services/wallets/operations/miniscript/default/InheritanceVault';

const DEFAULT_INHERITANCE_TIMELOCK = { label: MONTHS_12, value: 12 * 30 * 24 * 60 * 60 * 1000 };
const DEFAULT_INHERITANCE_TIMELOCK = { label: MONTHS_3, value: 3 * 30 * 24 * 60 * 60 * 1000 };
const INHERITANCE_TIMELOCK_DURATIONS = [
DEFAULT_INHERITANCE_TIMELOCK,

{ label: MONTHS_6, value: 6 * 30 * 24 * 60 * 60 * 1000 },
{ label: MONTHS_12, value: 12 * 30 * 24 * 60 * 60 * 1000 },
{ label: MONTHS_18, value: 18 * 30 * 24 * 60 * 60 * 1000 },
{ label: MONTHS_24, value: 24 * 30 * 24 * 60 * 60 * 1000 },
{ label: MONTHS_30, value: 30 * 30 * 24 * 60 * 60 * 1000 },
{ label: MONTHS_36, value: 36 * 30 * 24 * 60 * 60 * 1000 },
];

function AddReserveKey({ route }) {
Expand Down
16 changes: 14 additions & 2 deletions src/screens/Vault/ResetInheritanceKey.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,25 @@ import { getSignerDescription } from 'src/hardware';
import IKSInfocard from './components/IKSInfoCard';
import { SDIcons } from './SigningDeviceIcons';
import VaultMigrationController from './VaultMigrationController';
import { MONTHS_12, MONTHS_18, MONTHS_24 } from './constants';
import {
MONTHS_12,
MONTHS_18,
MONTHS_24,
MONTHS_3,
MONTHS_6,
MONTHS_30,
MONTHS_36,
} from './constants';

const DEFAULT_INHERITANCE_TIMELOCK = { label: MONTHS_12, value: 12 * 30 * 24 * 60 * 60 * 1000 };
const DEFAULT_INHERITANCE_TIMELOCK = { label: MONTHS_3, value: 3 * 30 * 24 * 60 * 60 * 1000 };
const INHERITANCE_TIMELOCK_DURATIONS = [
DEFAULT_INHERITANCE_TIMELOCK,
{ label: MONTHS_6, value: 6 * 30 * 24 * 60 * 60 * 1000 },
{ label: MONTHS_12, value: 12 * 30 * 24 * 60 * 60 * 1000 },
{ label: MONTHS_18, value: 18 * 30 * 24 * 60 * 60 * 1000 },
{ label: MONTHS_24, value: 24 * 30 * 24 * 60 * 60 * 1000 },
{ label: MONTHS_30, value: 30 * 30 * 24 * 60 * 60 * 1000 },
{ label: MONTHS_36, value: 36 * 30 * 24 * 60 * 60 * 1000 },
];

function ResetInheritanceKey({ route }) {
Expand Down
14 changes: 13 additions & 1 deletion src/screens/Vault/VaultMigrationController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ import {
INHERITANCE_VAULT_TIMELOCKS_MAINNET,
INHERITANCE_VAULT_TIMELOCKS_TESTNET,
} from 'src/services/wallets/operations/miniscript/default/InheritanceVault';
import { MONTHS_12, MONTHS_3, MONTHS_6, MONTHS_18, MONTHS_24 } from './constants';
import {
MONTHS_12,
MONTHS_3,
MONTHS_6,
MONTHS_18,
MONTHS_24,
MONTHS_30,
MONTHS_36,
} from './constants';

function VaultMigrationController({
vaultCreating,
Expand Down Expand Up @@ -194,6 +202,10 @@ function VaultMigrationController({
? 'MONTHS_18'
: selectedDuration === MONTHS_24
? 'MONTHS_24'
: selectedDuration === MONTHS_30
? 'MONTHS_30'
: selectedDuration === MONTHS_36
? 'MONTHS_36'
: null;

if (!durationIdentifier) {
Expand Down
4 changes: 3 additions & 1 deletion src/screens/Vault/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ export const MONTHS_6 = '6 months';
export const MONTHS_12 = '1 year';
export const MONTHS_18 = '1.5 years';
export const MONTHS_24 = '2 years';
export const MONTHS_30 = '2.5 years';
export const MONTHS_36 = '3 years';

export const TIMELOCK_DURATIONS = [MONTHS_3, MONTHS_6, MONTHS_12, MONTHS_24];
export const TIMELOCK_DURATIONS = [MONTHS_3, MONTHS_6, MONTHS_12, MONTHS_24, MONTHS_30, MONTHS_36];
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export const INHERITANCE_VAULT_TIMELOCKS_TESTNET = {
MONTHS_12: 12,
MONTHS_18: 18,
MONTHS_24: 24,
MONTHS_30: 30,
MONTHS_36: 36,
};

export const INHERITANCE_VAULT_TIMELOCKS_MAINNET = {
Expand All @@ -16,6 +18,8 @@ export const INHERITANCE_VAULT_TIMELOCKS_MAINNET = {
MONTHS_12: 52560,
MONTHS_18: 78840,
MONTHS_24: 105120,
MONTHS_30: 131400,
MONTHS_36: 157680,
};

export const INHERITANCE_KEY1_IDENTIFIER = 'IK1';
Expand Down
Loading