Skip to content

Commit

Permalink
make better ux if imported account has wrong word in it
Browse files Browse the repository at this point in the history
  • Loading branch information
scholtz committed Oct 21, 2024
1 parent 59d0670 commit f73e882
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 28 deletions.
26 changes: 16 additions & 10 deletions src/pages/NewAccount/Ed25519.vue
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,14 @@ const makeRandom = () => {
async function skipChallange() {
try {
await store.dispatch("wallet/addPrivateAccount", {
mn: state.w,
name: state.name,
});
router.push("/account/" + state.a);
if (
await store.dispatch("wallet/addPrivateAccount", {
mn: state.w,
name: state.name,
})
) {
router.push("/account/" + state.a);
}
} catch (err: any) {
const error = err.message ?? err;
console.error("failed to create account", error, err);
Expand All @@ -90,11 +93,14 @@ async function skipChallange() {
async function confirmCreate() {
try {
if (state.words[state.r - 1] == state.guess.trim()) {
await store.dispatch("wallet/addPrivateAccount", {
mn: state.w,
name: state.name,
});
router.push("/account/" + state.a);
if (
await store.dispatch("wallet/addPrivateAccount", {
mn: state.w,
name: state.name,
})
) {
router.push("/account/" + state.a);
}
} else {
await store.dispatch("toast/openError", "Invalid word");
}
Expand Down
13 changes: 8 additions & 5 deletions src/pages/NewAccount/RecoverEd25519.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ const router = useRouter();
async function importAccountClick() {
try {
await store.dispatch("wallet/addPrivateAccount", {
mn: state.w,
name: state.name,
});
router.push({ name: "Accounts" });
if (
await store.dispatch("wallet/addPrivateAccount", {
mn: state.w,
name: state.name,
})
) {
router.push({ name: "Accounts" });
}
} catch (err) {
const error = err.message ?? err;
console.error("failed to create account", error, err);
Expand Down
13 changes: 8 additions & 5 deletions src/pages/NewAccount/Shamir.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ const recover = async () => {
const reassembled = Shamir.combine(bytesArr);
const mn = algosdk.mnemonicFromSeed(reassembled);
await store.dispatch("wallet/addPrivateAccount", {
mn: mn,
name: state.name,
});
router.push({ name: "Accounts" });
if (
await store.dispatch("wallet/addPrivateAccount", {
mn: mn,
name: state.name,
})
) {
router.push({ name: "Accounts" });
}
} catch (err: any) {
const error = err?.message ?? err;
await store.dispatch("toast/openError", error);
Expand Down
13 changes: 8 additions & 5 deletions src/pages/NewAccount/Vanity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ async function confirmCreate() {
try {
const words = state.w.split(" ");
if (words[state.r - 1] == state.guess.trim()) {
await store.dispatch("wallet/addPrivateAccount", {
mn: state.w,
name: state.name,
});
router.push({ name: "Accounts" });
if (
await store.dispatch("wallet/addPrivateAccount", {
mn: state.w,
name: state.name,
})
) {
router.push({ name: "Accounts" });
}
} else {
await store.dispatch("toast/openError", "Invalid word");
}
Expand Down
10 changes: 7 additions & 3 deletions src/store/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,13 @@ const actions = {
return true;
} catch (e) {
console.error("error", e);
dispatch("toast/openError", "Account has not been created", {
root: true,
});
dispatch(
"toast/openError",
"Account has not been created: " + e.message,
{
root: true,
}
);
}
},
async addPublicAccount({ dispatch, commit }, { name, addr }) {
Expand Down

0 comments on commit f73e882

Please sign in to comment.