Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
patnir committed Oct 1, 2024
1 parent 13dd0fb commit 184053e
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions main/api/accounts/handleCreateAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@ import { AccountFormat } from "@ironfish/sdk";
import { contactsStore } from "../../stores/contactsStore";
import { manager } from "../manager";

export async function handleAddContact({
name,
address,
}: {
name: string;
address: string;
}) {
try {
contactsStore.addContact({ name, address });
} catch (error) {
console.error("Failed to add contact", error);
}
}

export async function handleCreateAccount({ name }: { name: string }) {
const ironfish = await manager.getIronfish();
const rpcClient = await ironfish.rpcClient();
Expand All @@ -37,10 +23,14 @@ export async function handleCreateAccount({ name }: { name: string }) {
throw new Error("Failed to get mnemonic phrase");
}

await handleAddContact({
name: createResponse.content.name,
address: createResponse.content.publicAddress,
});
try {
contactsStore.addContact({
name,
address: createResponse.content.publicAddress,
});
} catch (error) {
console.error("Failed to add contact", error);
}

return {
name: createResponse.content.name,
Expand Down

0 comments on commit 184053e

Please sign in to comment.