[cosmos-extension-metamask]Coin type 60 is forbidden

27 Views Asked by At

We are running into a situation when building a dapp with cosmos-kit react wallet on Injective chain

  • @cosmos-kit/cosmos-extension-metamask
  • @cosmos-kit/react

import { wallets as metaMaskWallets } from '@cosmos-kit/cosmos-extension-metamask';
import { wallets as keplrWallets } from '@cosmos-kit/keplr';

export const CosmosWalletProvider: FC<PropsWithChildren> = ({ children }) => {

  return (
    <ChainProvider
      chains={[injChain]} // https://github.com/cosmos/chain-registry/blob/master/injective/chain.json
      assetLists={[assetList]}
      wallets={[...keplrWallets, ...metaMaskWallets]}
    >
      {children}
    </ChainProvider>
  );
};

Keplr is working like a charm, but Metamask is not working as expected. There are two scenarios:

  1. The wallet is successfully connected, but the "inj" address seems not correct. (different from the one showing in injective hub. See the video below):

https://github.com/cosmology-tech/cosmos-kit/assets/127958634/6bfdef5c-1d6f-4354-b5d9-f1b31504df73

  1. The error Coin type 60 is forbidden is thrown when I try to use client.signArbitrary.

Code:

 const { client, status } = useWalletClient();
//...

        <div
          onClick={() => {
            if (client?.signArbitrary && client.getAccount) {
              client.getAccount('injective-1').then((account) => {
                // Along with the following 'arr', I also tried inj addr and eth hex addr. But still no luck
                const arr = Buffer.from(
                  new Uint8Array(Object.values(account.pubkey)),
                ).toString('base64');
                console.log({ addr: arr });
                client?.signArbitrary?.('injective-1', arr, 'test');
              });
            }
          }}
        >
          Sign with metamask
       </div>
//...

Not sure if it is caused by INJ chain's being not supported. Or I am missing anything.

0

There are 0 best solutions below