Extract actions to separate files

This commit is contained in:
Valtteri Karesto
2021-12-13 22:23:37 +02:00
parent 59637e32fe
commit 4d4b96bede
21 changed files with 620 additions and 585 deletions

View File

@@ -0,0 +1,28 @@
import toast from "react-hot-toast";
import { derive } from "xrpl-accountlib";
import state from '../index';
import { names } from './addFaucetAccount';
export const importAccount = (secret: string) => {
if (!secret) {
return toast.error("You need to add secret!");
}
if (state.accounts.find((acc) => acc.secret === secret)) {
return toast.error("Account already added!");
}
const account = derive.familySeed(secret);
if (!account.secret.familySeed) {
return toast.error(`Couldn't create account!`);
}
state.accounts.push({
name: names[state.accounts.length],
address: account.address || "",
secret: account.secret.familySeed || "",
xrp: "0",
sequence: 1,
hooks: [],
isLoading: false,
});
return toast.success("Account imported successfully!");
};