Browse Source

add way to quickly import test data when on a test instance

master
Trent Larson 2 weeks ago
parent
commit
d8712215a4
  1. 27
      src/views/ImportAccountView.vue

27
src/views/ImportAccountView.vue

@ -53,6 +53,13 @@
<input type="checkbox" class="mr-2" v-model="shouldErase" /> <input type="checkbox" class="mr-2" v-model="shouldErase" />
<label>Erase the previous identifier.</label> <label>Erase the previous identifier.</label>
</div> </div>
<div v-if="isNotProdServer()" class="mt-4 text-blue-500">
<!-- if they click this, fill in the mnemonic seed-input with the test mnemonic -->
<button @click="mnemonic = TEST_USER_0_MNEMONIC">
Use mnemonic for Test User #0
</button>
</div>
</div> </div>
<div class="mt-8"> <div class="mt-8">
@ -79,8 +86,8 @@
import { Component, Vue } from "vue-facing-decorator"; import { Component, Vue } from "vue-facing-decorator";
import { Router } from "vue-router"; import { Router } from "vue-router";
import { NotificationIface } from "@/constants/app"; import { AppString, NotificationIface } from "@/constants/app";
import { accountsDB, db } from "@/db/index"; import { accountsDB, db, retrieveSettingsForActiveAccount } from "@/db/index";
import { MASTER_SETTINGS_KEY } from "@/db/tables/settings"; import { MASTER_SETTINGS_KEY } from "@/db/tables/settings";
import { import {
DEFAULT_ROOT_DERIVATION_PATH, DEFAULT_ROOT_DERIVATION_PATH,
@ -92,28 +99,40 @@ import {
components: {}, components: {},
}) })
export default class ImportAccountView extends Vue { export default class ImportAccountView extends Vue {
TEST_USER_0_MNEMONIC =
"rigid shrug mobile smart veteran half all pond toilet brave review universe ship congress found yard skate elite apology jar uniform subway slender luggage";
UPORT_DERIVATION_PATH = "m/7696500'/0'/0'/0'"; // for legacy imports, likely never used UPORT_DERIVATION_PATH = "m/7696500'/0'/0'/0'"; // for legacy imports, likely never used
AppString = AppString;
$notify!: (notification: NotificationIface, timeout?: number) => void; $notify!: (notification: NotificationIface, timeout?: number) => void;
mnemonic = ""; apiServer = "";
address = ""; address = "";
derivationPath = DEFAULT_ROOT_DERIVATION_PATH;
mnemonic = "";
numAccounts = 0; numAccounts = 0;
privateHex = ""; privateHex = "";
publicHex = ""; publicHex = "";
derivationPath = DEFAULT_ROOT_DERIVATION_PATH;
showAdvanced = false; showAdvanced = false;
shouldErase = false; shouldErase = false;
async created() { async created() {
await accountsDB.open(); await accountsDB.open();
this.numAccounts = await accountsDB.accounts.count(); this.numAccounts = await accountsDB.accounts.count();
// get the server, to help with import on the test server
const settings = await retrieveSettingsForActiveAccount();
this.apiServer = settings.apiServer || "";
} }
public onCancelClick() { public onCancelClick() {
(this.$router as Router).back(); (this.$router as Router).back();
} }
public isNotProdServer() {
return this.apiServer !== AppString.PROD_ENDORSER_API_SERVER;
}
public async fromMnemonic() { public async fromMnemonic() {
const mne: string = this.mnemonic.trim().toLowerCase(); const mne: string = this.mnemonic.trim().toLowerCase();
try { try {

Loading…
Cancel
Save