-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scaffold remove snap keyring warning
- Loading branch information
1 parent
6036bcb
commit d0114ca
Showing
6 changed files
with
125 additions
and
21 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...mponents/Views/Snaps/SnapSettings/KeyringSnapRemovalWarning/KeyringRemovalSnapWarning.tsx
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,45 @@ | ||
import React, { useEffect, useRef, useState } from 'react'; | ||
|
||
import { Snap } from '@metamask/snaps-utils'; | ||
import BottomSheet, { BottomSheetRef } from 'app/component-library/components/BottomSheets/BottomSheet'; | ||
import { selectProviderConfig } from 'app/selectors/networkController'; | ||
import { useSelector } from 'react-redux'; | ||
import Text, { TextVariant } from 'app/component-library/components/Texts/Text'; | ||
|
||
interface KeyringRemovalSnapWarningProps { | ||
snap: Snap; | ||
keyringAccounts: { name: string; address: string }[]; | ||
onCancel: () => void; | ||
onClose: () => void; | ||
onSubmit: () => void; | ||
onBack: () => void; | ||
} | ||
|
||
export default function KeyringRemovalSnapWarning({ snap, | ||
keyringAccounts, | ||
onCancel, | ||
onClose, | ||
onSubmit, | ||
onBack, | ||
}: KeyringRemovalSnapWarningProps) { | ||
|
||
|
||
const [showConfirmation, setShowConfirmation] = useState(false); | ||
const [confirmedRemoval, setConfirmedRemoval] = useState(false); | ||
const [confirmationInput, setConfirmationInput] = useState(''); | ||
const [error, setError] = useState(false); | ||
const { chainId } = useSelector(selectProviderConfig); | ||
|
||
const bottomSheetRef = useRef<BottomSheetRef>(null); | ||
|
||
useEffect(() => { | ||
setShowConfirmation(keyringAccounts.length === 0); | ||
}, [keyringAccounts]); | ||
|
||
return ( | ||
<BottomSheet ref={bottomSheetRef} onClose={onClose} > | ||
<Text variant={TextVariant.HeadingSM}>This is a warning</Text>; | ||
</BottomSheet > | ||
); | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
app/components/Views/Snaps/SnapSettings/KeyringSnapRemovalWarning/index.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 @@ | ||
export { default } from './KeyringRemovalSnapWarning'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { SnapKeyring } from '@metamask/eth-snap-keyring'; | ||
import { SnapId } from '@metamask/snaps-sdk'; | ||
import Engine from 'app/core/Engine'; | ||
|
||
/** | ||
* Get the addresses of the accounts managed by a given Snap. | ||
* | ||
* @param snapId - Snap ID to get accounts for. | ||
* @returns The addresses of the accounts. | ||
*/ | ||
export const getAccountsBySnapId = async ( | ||
snapId: SnapId, | ||
) => { | ||
const snapKeyring: SnapKeyring = await Engine.getSnapKeyring() as SnapKeyring; | ||
return await snapKeyring.getAccountsBySnapId(snapId); | ||
}; |
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