diff --git a/components/WalletHeader.tsx b/components/WalletHeader.tsx index 3de14736a..ad8fe2bef 100644 --- a/components/WalletHeader.tsx +++ b/components/WalletHeader.tsx @@ -339,7 +339,8 @@ export default class WalletHeader extends React.Component< }; const CustodialBadge = () => { - return implementation === 'lndhub' ? ( + return implementation === 'lndhub' && + !selectedNode.dismissCustodialWarning ? ( navigation.navigate('CustodialWalletWarning') diff --git a/locales/en.json b/locales/en.json index 55f19a142..6e13aaac0 100644 --- a/locales/en.json +++ b/locales/en.json @@ -1140,6 +1140,12 @@ "views.Settings.CustodialWalletWarning.graph3": "ZEUS has the ability to create a self-custodial wallet in the app. This wallet provides you with a 24-word seed phrase that gives you full control of your funds.", "views.Settings.CustodialWalletWarning.graph4": "To get started with your own self-custodial wallet, press the button below, and hit the 'Create mainnet wallet' button on the next screen.", "views.Settings.CustodialWalletWarning.create": "Create self-custodial wallet", + "views.Settings.CustodialWalletWarning.dismissWarning": "Dismiss warning", + "views.Settings.CustodialWalletWarning.dismissWarningHeader": "Please confirm the following to dismiss the warning:", + "views.Settings.CustodialWalletWarning.dismissWarning1": "I know that I don't have custody of the funds in this wallet without the 12 or 24 word seed phrase", + "views.Settings.CustodialWalletWarning.dismissWarning2": "I know that an LNDHub account password is not the same as a seed phrase", + "views.Settings.CustodialWalletWarning.dismissWarning3": "I either set up this connection myself or I trust the person who set it up", + "views.Settings.CustodialWalletWarning.dismissWarning4": "I'm not just lying to get this over with", "views.PayCode.bolt12": "BOLT 12", "views.PayCode.offerId": "Offer ID", "views.PayCode.createOffer": "Create pay code", diff --git a/stores/SettingsStore.ts b/stores/SettingsStore.ts index 8813255f2..8d7370a6c 100644 --- a/stores/SettingsStore.ts +++ b/stores/SettingsStore.ts @@ -22,6 +22,7 @@ export interface Node { certVerification?: boolean; enableTor?: boolean; nickname?: string; + dismissCustodialWarning: boolean; photo?: string; // LNC pairingPhrase?: string; @@ -1195,6 +1196,7 @@ export default class SettingsStore { @observable username: string; @observable password: string; @observable lndhubUrl: string; + @observable dismissCustodialWarning: boolean = false; @observable public createAccountError: string; @observable public createAccountSuccess: string; @observable public accessToken: string; @@ -1544,6 +1546,7 @@ export default class SettingsStore { this.macaroonHex = node.macaroonHex; this.rune = node.rune; this.accessKey = node.accessKey; + this.dismissCustodialWarning = node.dismissCustodialWarning; this.implementation = node.implementation || 'lnd'; this.certVerification = node.certVerification || false; this.enableTor = node.enableTor; diff --git a/views/Settings/CustodialWalletWarning.tsx b/views/Settings/CustodialWalletWarning.tsx index b76fad7c1..1ddbb384e 100644 --- a/views/Settings/CustodialWalletWarning.tsx +++ b/views/Settings/CustodialWalletWarning.tsx @@ -1,7 +1,8 @@ import * as React from 'react'; -import { StyleSheet, Text, View, ScrollView } from 'react-native'; +import { StyleSheet, Text, View, ScrollView, Modal } from 'react-native'; import { inject, observer } from 'mobx-react'; import { StackNavigationProp } from '@react-navigation/stack'; +import { CheckBox } from 'react-native-elements'; import Button from '../../components/Button'; import Header from '../../components/Header'; @@ -12,6 +13,14 @@ import { themeColor } from '../../utils/ThemeUtils'; import SettingsStore from '../../stores/SettingsStore'; +interface CustodialWalletWarningState { + checkbox1: boolean; + checkbox2: boolean; + checkbox3: boolean; + checkbox4: boolean; + showModal: boolean; +} + interface CustodialWalletWarningProps { SettingsStore: SettingsStore; navigation: StackNavigationProp; @@ -21,10 +30,72 @@ interface CustodialWalletWarningProps { @observer export default class CustodialWalletWarning extends React.Component< CustodialWalletWarningProps, - {} + CustodialWalletWarningState > { + constructor(props: CustodialWalletWarningProps) { + super(props); + this.state = { + checkbox1: false, + checkbox2: false, + checkbox3: false, + checkbox4: false, + showModal: false + }; + } + + areAllChecked = () => { + const { checkbox1, checkbox2, checkbox3, checkbox4 } = this.state; + return checkbox1 && checkbox2 && checkbox3 && checkbox4; + }; + + toggleModal = () => { + this.setState({ + showModal: !this.state.showModal, + checkbox1: false, + checkbox2: false, + checkbox3: false, + checkbox4: false + }); + }; + + updateNode = () => { + const { SettingsStore } = this.props; + const { settings, updateSettings } = SettingsStore; + const { nodes, selectedNode } = settings; + + if (nodes && nodes.length > 0) { + const currentNodeIndex = selectedNode || 0; + const currentNode = nodes[currentNodeIndex]; + + // Update the dismissCustodialWarning property + const updatedNode = { + ...currentNode, + dismissCustodialWarning: true + }; + + // Replace the current node with the updated node + const updatedNodes = [...nodes]; + updatedNodes[currentNodeIndex] = updatedNode; + + // Save the updated nodes array back to the settings + updateSettings({ nodes: updatedNodes }) + .then(() => { + console.log('Node configuration updated successfully.'); + }) + .catch((error) => { + console.error( + 'Failed to update node configuration:', + error + ); + }); + } else { + console.error('No nodes available to update.'); + } + }; + render() { const { SettingsStore, navigation } = this.props; + const { showModal } = this.state; const nodes = SettingsStore?.settings?.nodes || []; // check if user has embedded node wallet configured already @@ -111,10 +182,7 @@ export default class CustodialWalletWarning extends React.Component<