Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

Commit

Permalink
WIP added a bunch of possible dynamic loading code, can't tell if it …
Browse files Browse the repository at this point in the history
…works. Some is commented out, some is not, some commented code is from the original imports
  • Loading branch information
Sheng-Long authored and QuestofIranon committed Sep 18, 2019
1 parent 80b9cf3 commit e7769d0
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 9 deletions.
54 changes: 46 additions & 8 deletions src/components/ModalAccessByPrivateKey.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ import {
createComponent,
SetupContext,
PropType,
watch
watch,
ref
} from "@vue/composition-api";
import { Ed25519PrivateKey } from "@hashgraph/sdk";
// import { Ed25519PrivateKey } from "@hashgraph/sdk";
export interface State {
modalIsOpen: boolean;
Expand Down Expand Up @@ -76,13 +78,35 @@ export default createComponent({
state: (Object as unknown) as PropType<State>
},
setup(props: { state: State }, context: SetupContext) {
const valid = computed(() => {
if (props.state.rawPrivateKey.length === 0) {
// Back out now if we have an empty value
return false;
}
// const valid = computed(() => {
// if (props.state.rawPrivateKey.length === 0) {
// // Back out now if we have an empty value
// return false;
// }
// try {
// Ed25519PrivateKey.fromString(props.state.rawPrivateKey);
// return true;
// } catch (error) {
// if (error instanceof Error) {
// // The exception message changes depending on the input
// if (
// error.message ===
// "invalid private key: " + props.state.rawPrivateKey
// ) {
// return false;
// }
// }
// throw error;
// }
// });
const valid = ref<boolean>(false);
async function isValid(): Promise<boolean> {
try {
const { Ed25519PrivateKey } = await import("@hashgraph/sdk");
Ed25519PrivateKey.fromString(props.state.rawPrivateKey);
return true;
} catch (error) {
Expand All @@ -98,7 +122,21 @@ export default createComponent({
throw error;
}
});
}
watch(
() => props.state.rawPrivateKey,
(newVal: string) => {
if (props.state.rawPrivateKey.length === 0) {
// Back out now if we have an empty value
valid.value = false;
}
isValid().then(result => {
valid.value = result;
});
}
);
function handleModalChangeIsOpen(isOpen: boolean): void {
context.emit("change", { ...props.state, modalIsOpen: isOpen });
Expand Down
1 change: 1 addition & 0 deletions src/components/ModalCreateByPhrase.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import {
SetupContext
} from "@vue/composition-api";
import { MnemonicResult, Ed25519PrivateKey } from "@hashgraph/sdk/src/Keys";
// type MnemonicResult = import("@hashgraph/sdk/src/Keys").MnemonicResult;
interface Props {
isOpen: boolean;
Expand Down
5 changes: 4 additions & 1 deletion src/views/AccessMyAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ import ModalAccessBySoftware, {
AccessSoftwareOption
} from "../components/ModalAccessBySoftware.vue";
import ModalAccessByPhrase from "../components/ModalAccessByPhrase.vue";
import ModalAccessByPrivateKey from "../components/ModalAccessByPrivateKey.vue";
const ModalAccessByPrivateKey = (): Promise<
typeof import("/home/shenglong/Documents/dev/myhbarwallet/src/components/ModalAccessByPrivateKey.vue")
> => import("../components/ModalAccessByPrivateKey.vue");
// import ModalAccessByPrivateKey from "../components/ModalAccessByPrivateKey.vue";
import ModalEnterAccountId from "../components/ModalEnterAccountId.vue";
import PageTitle from "../components/PageTitle.vue";
import ModalKeystoreFilePassword from "../components/ModalKeystoreFilePassword.vue";
Expand Down
5 changes: 5 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ module.exports = {
HEDERA_NETWORK: `"${process.env.HEDERA_NETWORK || "testnet"}"`
})
]
// ,
// entry: {
// home: "./src/app.vue",
// access: "./src/views/AccessMyAccount.vue"
// }
},
chainWebpack(config) {
// Use a standard HTML template instead of rolling our own (which is default)
Expand Down

0 comments on commit e7769d0

Please sign in to comment.