-
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.
exported json
- Loading branch information
Showing
17 changed files
with
275 additions
and
120 deletions.
There are no files selected for viewing
File renamed without changes.
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 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 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,86 @@ | ||
import { | ||
button, | ||
heading, | ||
panel, | ||
text, | ||
divider, | ||
input, | ||
form, | ||
copyable, | ||
} from '@metamask/snaps-sdk'; | ||
|
||
import { getJsonKeyPair } from '../util'; | ||
|
||
/** | ||
* 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: panel([ | ||
heading('Export Account'), | ||
divider(), | ||
text( | ||
'Here, you can export your account as a JSON file, which can be used to import your account in another extension or wallet.'), | ||
form({ | ||
name: 'saveExportedAccount', | ||
children: [ | ||
input({ | ||
inputType: 'password', | ||
label: 'Enter a password to encrypt your export data:', | ||
name: 'password', | ||
placeholder: 'password ...', | ||
}), | ||
button({ | ||
variant: 'primary', | ||
value: 'Export', | ||
name: 'exportAccountBtn', | ||
}), | ||
button({ | ||
variant: 'secondary', | ||
value: 'Back', | ||
name: 'backToHome', | ||
}), | ||
], | ||
}), | ||
]), | ||
}, | ||
}); | ||
} | ||
|
||
/** | ||
* 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: panel([ | ||
heading('Export Account'), | ||
divider(), | ||
text( | ||
'Copy and save the following content in a (.json) file. This file can be imported later in extensions and wallets.', | ||
), | ||
copyable(json), | ||
button({ | ||
variant: 'secondary', | ||
value: 'Back', | ||
name: 'backToHome', | ||
}), | ||
]), | ||
}, | ||
}); | ||
} |
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,6 @@ | ||
export * from './accountDemo'; | ||
export * from './accountInfo'; | ||
export * from './dappList'; | ||
export * from './exportAccount'; | ||
export * from './showConfirmTx'; | ||
export * from './transfer'; |
Oops, something went wrong.