Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Email when mnemonic is entered if exists #3224

Merged
merged 3 commits into from
Aug 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions packages/playground/src/weblets/profile_manager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,10 @@
validateMnemonic(v) ||
((v.length === 64 || v.length === 66) && isAddress(v.length === 66 ? v : `0x${v}`))
) {
getEmail();
return;
}
email = '';
return {
message: 'Mnemonic or Hex Seed doesn\'t seem to be valid.',
};
Expand Down Expand Up @@ -260,7 +262,8 @@
placeholder="email@example.com"
v-model="email"
v-bind="props"
:disabled="creatingAccount || activatingAccount || activating"
:loading="loadEmail"
:disabled="creatingAccount || activatingAccount || activating || loadEmail"
readonly
ref="emailRef"
@focus="handleFocus(emailRef)"
Expand Down Expand Up @@ -437,14 +440,15 @@ import { useOnline } from "../hooks";
import { useInputRef } from "../hooks/input_validator";
import { useProfileManager } from "../stores";
import { activateAccountAndCreateTwin, createAccount, getGrid, loadBalance, loadProfile } from "../utils/grid";
import { storeEmail } from "../utils/grid";
import { readEmail, storeEmail } from "../utils/grid";
import { normalizeBalance, normalizeError } from "../utils/helpers";

const items = ref([{ id: 1, name: "stellar" }]);
const depositWallet = ref("");
const selectedName = ref("");
const selectedItem = ref(items.value[0]);
const depositFee = ref(0);
const loadEmail = ref<boolean>(false);
interface Credentials {
passwordHash?: string;
mnemonicHash?: string;
Expand Down Expand Up @@ -887,6 +891,13 @@ watch(openAcceptTerms, async () => {
}
}
});

async function getEmail() {
loadEmail.value = true;
const grid = await getGrid({ mnemonic: mnemonic.value, keypairType: keypairType.value });
email.value = await readEmail(grid!);
loadEmail.value = false;
}
</script>

<script lang="ts">
Expand Down
Loading