-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use new components to polish style
- Loading branch information
Showing
19 changed files
with
297 additions
and
259 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,97 @@ | ||
|
||
import { getJsonKeyPair } from '../util'; | ||
import { Text, Box, Button, Container, Divider, Field, Footer, Form, Heading, Icon, Input, Section, Copyable } from '@metamask/snaps-sdk/jsx'; | ||
|
||
/** | ||
* This will show the alert to get password to export account as JSON file. | ||
* | ||
* @param id - The id of UI interface to be updated. | ||
*/ | ||
export async function exportAccount(id: string) { | ||
await snap.request({ | ||
method: 'snap_updateInterface', | ||
params: { | ||
id, | ||
ui: ui() | ||
}, | ||
}); | ||
} | ||
|
||
const ui = () => { | ||
|
||
return ( | ||
<Container> | ||
<Box direction="vertical" alignment="start"> | ||
<Section> | ||
<Box direction='horizontal' alignment='start'> | ||
<Icon name="export" size="md" /> | ||
<Heading>Export Account!</Heading> | ||
</Box> | ||
<Divider /> | ||
<Text alignment='start'> Here, you can export your account as a JSON file, which can be used to import your account in another extension or wallet.</Text> | ||
<Box> | ||
<Form name="saveExportedAccount"> | ||
<Field label="Enter a password to encrypt your data" error='Password can not be empty'> | ||
<Input name="password" placeholder="password ..." type='password' /> | ||
</Field> | ||
<Button name='exportAccountBtn' type="submit" variant="primary"> | ||
Export | ||
</Button> | ||
</Form> | ||
</Box> | ||
</Section> | ||
</Box> | ||
<Footer> | ||
<Button name='backToHome' variant="destructive"> | ||
Back | ||
</Button> | ||
</Footer> | ||
</Container> | ||
); | ||
}; | ||
|
||
|
||
/** | ||
* This will show the exported account content that can be copied in a file. | ||
* | ||
* @param id - The id of UI interface to be updated. | ||
* @param password - The password to encode the content. | ||
*/ | ||
export async function showJsonContent(id: string, password: string | null) { | ||
if (!password) { | ||
return; | ||
} | ||
const json = await getJsonKeyPair(password); | ||
|
||
await snap.request({ | ||
method: 'snap_updateInterface', | ||
params: { | ||
id, | ||
ui: jsonContentUi(json) | ||
}, | ||
}); | ||
} | ||
|
||
const jsonContentUi = (json: string) => { | ||
|
||
return ( | ||
<Container> | ||
<Box direction="vertical" alignment="start"> | ||
<Section> | ||
<Box direction='horizontal' alignment='start'> | ||
<Icon name="export" size="md" /> | ||
<Heading>Export Account!</Heading> | ||
</Box> | ||
<Divider /> | ||
<Text alignment='start'>Copy and save the following content in a (.json) file. This file can be imported later in extensions and wallets.</Text> | ||
<Copyable value={json} /> | ||
</Section> | ||
</Box> | ||
<Footer> | ||
<Button name='backToHome' variant="destructive"> | ||
Back | ||
</Button> | ||
</Footer> | ||
</Container> | ||
); | ||
}; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
// Copyright 2023-2024 @polkagate/snap authors & contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
export * from './partials/accountDemo'; | ||
export * from './accountInfo'; | ||
export * from './dappList'; | ||
export * from './exportAccount'; | ||
export * from './partials/accountDemo'; | ||
export * from './polkagateApps'; | ||
export * from './review/'; | ||
export * from './showSpinner'; | ||
export * from './staking'; | ||
export * from './transfer'; | ||
export * from './voting'; |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.