Update package version
This commit is contained in:
parent
af63b9126c
commit
5a04bbe95f
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "web-wallet",
|
"name": "web-wallet",
|
||||||
"version": "0.1.6",
|
"version": "0.1.7",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cerc-io/registry-sdk": "^0.2.5",
|
"@cerc-io/registry-sdk": "^0.2.5",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { useEffect, useCallback } from "react";
|
import { useEffect, useCallback } from "react";
|
||||||
|
|
||||||
import { createWallet } from "../utils/accounts";
|
import { createWallet, isWalletCreated } from "../utils/accounts";
|
||||||
import { sendMessage } from "../utils/misc";
|
import { sendMessage } from "../utils/misc";
|
||||||
import useAccountsData from "./useAccountsData";
|
import useAccountsData from "./useAccountsData";
|
||||||
import { useNetworks } from "../context/NetworksContext";
|
import { useNetworks } from "../context/NetworksContext";
|
||||||
@ -16,14 +16,15 @@ const useGetOrCreateAccounts = () => {
|
|||||||
|
|
||||||
// Wrap the function in useCallback to prevent recreation on each render
|
// Wrap the function in useCallback to prevent recreation on each render
|
||||||
const getOrCreateAccountsForChain = useCallback(async (chainId: string) => {
|
const getOrCreateAccountsForChain = useCallback(async (chainId: string) => {
|
||||||
let accountsData = await getAccountsData(chainId);
|
const isCreated = await isWalletCreated();
|
||||||
|
|
||||||
if (accountsData.length === 0) {
|
if (!isCreated) {
|
||||||
console.log("Accounts not found, creating wallet...");
|
console.log("Accounts not found, creating wallet...");
|
||||||
await createWallet(networksData);
|
await createWallet(networksData);
|
||||||
accountsData = await getAccountsData(chainId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const accountsData = await getAccountsData(chainId);
|
||||||
|
|
||||||
// Update the AccountsContext with the new accounts
|
// Update the AccountsContext with the new accounts
|
||||||
setAccounts(accountsData);
|
setAccounts(accountsData);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user