forked from jsnbuchanan/crowd-funder-for-time-pwa
Mark UserProfileView.vue as human tested, update migration tracker
- Human testing confirmed UserProfileView.vue works correctly - Updated testing tracker with 21 complete migrations (88% success) - Added ImportAccountView.vue to ready-for-testing list - Migration progress: 4 components human tested, 17 ready for testing
This commit is contained in:
@@ -87,13 +87,38 @@ import { Component, Vue } from "vue-facing-decorator";
|
||||
import { Router } from "vue-router";
|
||||
|
||||
import { AppString, NotificationIface } from "../constants/app";
|
||||
import * as databaseUtil from "../db/databaseUtil";
|
||||
import { DEFAULT_ROOT_DERIVATION_PATH } from "../libs/crypto";
|
||||
import { retrieveAccountCount, importFromMnemonic } from "../libs/util";
|
||||
import { logger } from "../utils/logger";
|
||||
import { PlatformServiceMixin } from "@/utils/PlatformServiceMixin";
|
||||
import { createNotifyHelpers, TIMEOUTS } from "@/utils/notify";
|
||||
|
||||
/**
|
||||
* Import Account View Component
|
||||
*
|
||||
* Allows users to import existing identifiers using seed phrases:
|
||||
* - Secure mnemonic phrase input with validation
|
||||
* - Advanced options for custom derivation paths
|
||||
* - Legacy uPort compatibility support
|
||||
* - Test environment utilities for development
|
||||
*
|
||||
* Features:
|
||||
* - Secure seed phrase import functionality
|
||||
* - Custom derivation path configuration
|
||||
* - Account erasure options for fresh imports
|
||||
* - Development mode test utilities
|
||||
* - Comprehensive error handling and validation
|
||||
*
|
||||
* Security Considerations:
|
||||
* - Seed phrases are handled securely and not logged
|
||||
* - Import process includes validation and error recovery
|
||||
* - Advanced options are hidden by default
|
||||
*
|
||||
* @author Matthew Raymer
|
||||
*/
|
||||
@Component({
|
||||
components: {},
|
||||
mixins: [PlatformServiceMixin],
|
||||
})
|
||||
export default class ImportAccountView extends Vue {
|
||||
TEST_USER_0_MNEMONIC =
|
||||
@@ -105,6 +130,8 @@ export default class ImportAccountView extends Vue {
|
||||
$notify!: (notification: NotificationIface, timeout?: number) => void;
|
||||
$router!: Router;
|
||||
|
||||
notify!: ReturnType<typeof createNotifyHelpers>;
|
||||
|
||||
apiServer = "";
|
||||
derivationPath = DEFAULT_ROOT_DERIVATION_PATH;
|
||||
mnemonic = "";
|
||||
@@ -112,21 +139,62 @@ export default class ImportAccountView extends Vue {
|
||||
showAdvanced = false;
|
||||
shouldErase = false;
|
||||
|
||||
async created() {
|
||||
/**
|
||||
* Initializes notification helpers
|
||||
*/
|
||||
created() {
|
||||
this.notify = createNotifyHelpers(this.$notify);
|
||||
}
|
||||
|
||||
/**
|
||||
* Component initialization
|
||||
*
|
||||
* Loads account count and server settings for import configuration
|
||||
* Uses PlatformServiceMixin for secure database access
|
||||
*/
|
||||
async mounted() {
|
||||
await this.initializeSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes component settings and account information
|
||||
*/
|
||||
private async initializeSettings() {
|
||||
this.numAccounts = await retrieveAccountCount();
|
||||
// get the server, to help with import on the test server
|
||||
const settings = await databaseUtil.retrieveSettingsForActiveAccount();
|
||||
const settings = await this.$accountSettings();
|
||||
this.apiServer = settings.apiServer || "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles cancel button click
|
||||
*
|
||||
* Navigates back to previous view
|
||||
*/
|
||||
public onCancelClick() {
|
||||
this.$router.back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if running on production server
|
||||
*
|
||||
* @returns True if not on production server (enables test utilities)
|
||||
*/
|
||||
public isNotProdServer() {
|
||||
return this.apiServer !== AppString.PROD_ENDORSER_API_SERVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports identifier from mnemonic phrase
|
||||
*
|
||||
* Processes the mnemonic phrase with optional custom derivation path
|
||||
* and account erasure options. Handles validation and error scenarios
|
||||
* with appropriate user feedback.
|
||||
*
|
||||
* Error Handling:
|
||||
* - Invalid mnemonic format validation
|
||||
* - Import process failure recovery
|
||||
* - User-friendly error messaging
|
||||
*/
|
||||
public async fromMnemonic() {
|
||||
try {
|
||||
await importFromMnemonic(
|
||||
@@ -139,24 +207,14 @@ export default class ImportAccountView extends Vue {
|
||||
} catch (err: any) {
|
||||
logger.error("Error importing from mnemonic:", err);
|
||||
if (err == "Error: invalid mnemonic") {
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "danger",
|
||||
title: "Invalid Mnemonic",
|
||||
text: "Please check your mnemonic and try again.",
|
||||
},
|
||||
5000,
|
||||
this.notify.error(
|
||||
"Please check your mnemonic and try again.",
|
||||
TIMEOUTS.LONG
|
||||
);
|
||||
} else {
|
||||
this.$notify(
|
||||
{
|
||||
group: "alert",
|
||||
type: "danger",
|
||||
title: "Error",
|
||||
text: "Got an error creating that identifier.",
|
||||
},
|
||||
5000,
|
||||
this.notify.error(
|
||||
"Got an error creating that identifier.",
|
||||
TIMEOUTS.LONG
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user