diff --git a/src/cardano/connect.ts b/src/cardano/connect.ts index f9c3eea..78c1863 100644 --- a/src/cardano/connect.ts +++ b/src/cardano/connect.ts @@ -3,9 +3,9 @@ import { NoAvailableAccountsError } from '@/errors/no-accounts-available-error'; import { NoProviderAvailableError } from '@/errors/no-provider-available-error'; import { web3Window } from '@/types'; import { availableWallets } from './available-wallets'; -import type { CardanoUsedAddress } from './types'; +import type { CardanoUnusedAddresses } from './types'; -export async function connect(wallet?: string): Promise { +export async function connect(wallet?: string): Promise { if (!web3Window.cardano) throw new NotInjectedError() @@ -23,13 +23,13 @@ export async function connect(wallet?: string): Promise { try { const api = await web3Window.cardano[injectedWallet].enable() - const usedAddresses: CardanoUsedAddress[] = await api.getUsedAddresses() - if (usedAddresses.length === 0) + const unusedAddresses: CardanoUnusedAddresses[] = await api.getUnusedAddresses() + if (unusedAddresses.length === 0) throw new NoAvailableAccountsError() - return usedAddresses + return unusedAddresses } catch (error) { - console.log(error) + console.error(error) return [] } } diff --git a/src/cardano/types.ts b/src/cardano/types.ts index 82852ed..4748c37 100644 --- a/src/cardano/types.ts +++ b/src/cardano/types.ts @@ -1,9 +1,11 @@ -import type { AvailableWallet } from './available-wallets'; +import type { CardanoWallet } from './available-wallets'; -export type CardanoProviderProps = Record; +export type CardanoProviderProps = Record<'wallet', CardanoWallet>; export type CardanoUsedAddress = string +export type CardanoUnusedAddresses = string + export interface ApiPromise { getBalance: (address: string) => Promise getUsedAddresses: () => Promise