1

I am working on a light wallet integration. The recommended way of integrating with wallets is defined in CIP30.

When I select Nami and call: (await api.getUsedAddresses() || await api.getUnusedAddresses() || []) everything works fine and I receive at least one wallet address - a non empty array. But using the same code for eternl/ ccvault I always receive an empty array.

Is this a missing implementation error on their end or a mistake on my end? getChangeAddress() works fine for both wallets.

Here some code snippets for more context:

export const isBrowser = () => typeof window !== "undefined";
export type Cardano = {
  [key: string]: {
    name: string;
    icon: string;
    version: string;
    api?: WalletApi,
    enable: () => Promise<WalletApi>;
    isEnabled: () => Promise<boolean>;
  };
};

export const getCardano = (): Cardano | undefined => {
  const cardano = isBrowser() && window.cardano;
  return cardano;
};

and then later in the app:

async (actions, target, { getStoreActions }) => {
      const walletName: string = target.payload;
      const cardano = getCardano()!;
      const api = await cardano[walletName]!.enable();
      const addresses = (await api.getUsedAddresses()
                      || await api.getUnusedAddresses()
                      || []);
{...}

1 Answer 1

2

Thanks to Marcel - founder of eternl I've found my mistake.

await api.getUsedAddresses() actually returns an empty array - I thought both calls return undefined and it defaults to [].

After calling await api.getUsedAddresses() and await api.getUnusedAddresses() separately they both work as expected since my test wallet currently does not have used addresses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.