keplr-wallet icon indicating copy to clipboard operation
keplr-wallet copied to clipboard

Call window.keplr.experimentalSuggestChain({…}) in turn to add a new chain. When the value prefix of the parameter chain-id is the same, only the first one is added successfully.

Open zccst opened this issue 2 years ago • 8 comments

Describe the bug When I call window.keplr.experimentalSuggestChain({…}) to Keplr Browser Extension in turn, the chainId is passed exchain-65 for the first time and exchain-66 for the second time, and there is only a pop-up window prompting me to add exchain-65 chain, the chain corresponding to exchain-66 is not responding.

The result is that the two chains whose chainId is exchain-65 and exchain-66 cannot join the Keplr Browser Extension at the same time. After Keplr Browser Extension has added the exchain-65 chain, if you want to use the exchain-66 chain, you need to manually delete the exchain-65 chain before adding it successfully. In the same way, if you want to use exchain-65, you need to delete exchain-66 first, and the experience is very bad.

However, when I set the chainId to exchain-65 and xchain-66 in turn, the pop-up window successfully allows me to join the two chains of exchain-65 and xchain-66, which is in line with expectations. It can be seen that if the prefix is ​​the same, it will fail to be added, and if it is different, it can be added successfully.

To Reproduce Steps to reproduce the behavior: call in sequence

window.keplr.experimentalSuggestChain({
    chainId: "exchain-65",
    chainName: "OKC testnet",
    rpc: "https://exchaintesttmrpc.okex.org",
    rest: "https://exchaintestrpc.okex.org",
    stakeCurrency: {
        coinDenom: "OKT",
        coinMinimalDenom: "wei",
        coinDecimals: 18,
        coinGeckoId: "oec-token"
    },
    bip44: {
        coinType: 60,
    },
    bech32Config: {
        bech32PrefixAccAddr: "ex",
        bech32PrefixAccPub: "expub",
        bech32PrefixValAddr: "exvaloper",
        bech32PrefixValPub: "exvaloperpub",
        bech32PrefixConsAddr: "exvalcons",
        bech32PrefixConsPub: "exvalconspub"
    },
    currencies: [{
        coinDenom: "OKT",
        coinMinimalDenom: "wei",
        coinDecimals: 18,
        coinGeckoId: "oec-token"
    }],
    feeCurrencies: [{
        coinDenom: "OKT",
        coinMinimalDenom: "wei",
        coinDecimals: 18,
        coinGeckoId: "oec-token"
    }],
    coinType: 60,
    gasPriceStep: {
        low: 200000000,
        average: 250000000,
        high: 400000000
    },
    features: ["stargate", "ibc-transfer", "no-legacy-stdTx", "ibc-go"],
});

window.keplr.experimentalSuggestChain({
    chainId: "exchain-66",
    chainName: "OKC mainnet",
    rpc: "https://exchaintmrpc.okex.org",
    rest: "https://exchainrpc.okex.org",
    stakeCurrency: {
        coinDenom: "OKT",
        coinMinimalDenom: "wei",
        coinDecimals: 18,
        coinGeckoId: "oec-token"
    },
    bip44: {
        coinType: 60,
    },
    bech32Config: {
        bech32PrefixAccAddr: "ex",
        bech32PrefixAccPub: "expub",
        bech32PrefixValAddr: "exvaloper",
        bech32PrefixValPub: "exvaloperpub",
        bech32PrefixConsAddr: "exvalcons",
        bech32PrefixConsPub: "exvalconspub"
    },
    currencies: [{
        coinDenom: "OKT",
        coinMinimalDenom: "wei",
        coinDecimals: 18,
        coinGeckoId: "oec-token"
    }],
    feeCurrencies: [{
        coinDenom: "OKT",
        coinMinimalDenom: "wei",
        coinDecimals: 18,
        coinGeckoId: "oec-token"
    }],
    coinType: 60,
    gasPriceStep: {
        low: 200000000,
        average: 250000000,
        high: 400000000
    },
    features: ["stargate", "ibc-transfer", "no-legacy-stdTx", "ibc-go"],
});

Expected behavior When calling window.keplr.experimentalSuggestChain({chainId: exchain-65,}), window.keplr.experimentalSuggestChain({chainId: exchain-66,}) in turn, the value prefix of chainId is not used for distinction.

The two chains whose chainId is exchain-65 and exchain-66 can be successfully added to the Keplr Browser Extension in turn, and the two chains can be used at the same time, without the need to delete one of them.

Screenshots N/A

Device details (please complete the following information):

  • OS: OS X
  • Browser: Chrome Version 103.0.5060.53 (Official Build)
  • Keplr Browser Extension Version: 0.10.1

Additional context N/A

zccst avatar Jun 28 '22 14:06 zccst

This is completely intentional.

First, in cosmos chains, when the chain is updated, the prefixed version of the chain id increases by 1 as a de-facto standard. And in ibc, chain update is handled through the version of prefix of chain id in the same way.

Chain updates are handled in Keplr in the same way. Since there cannot be two identical chains, the prefixed version is ignored when chains are added.

Thunnini avatar Jun 28 '22 14:06 Thunnini

Thank you for your quick reply, can you use the full name of chain-id to distinguish instead of prefix ? @Thunnini

zccst avatar Jun 28 '22 14:06 zccst

No

Thunnini avatar Jun 29 '22 12:06 Thunnini

No

So how do I solve the problem that the chain-id equal to exchain-65 and exchain-66 cannot be added at the same time?

zccst avatar Jun 30 '22 03:06 zccst

Change the chain ids

Thunnini avatar Jun 30 '22 04:06 Thunnini

Can you explain why the chain id have different numbers at the end? I would be able to offer some advice for the integration if I have context.

If the numbers are necessary, you might want to take a look at EVMOS, which has chain id with numbers using underscore.

Thunnini avatar Jun 30 '22 12:06 Thunnini

Can you explain why the chain id have different numbers at the end? I would be able to offer some advice for the integration if I have context.

If the numbers are necessary, you might want to take a look at EVMOS, which has chain id with numbers using underscore.

Hi, we are using the "prefix-number" format as our chain-id such as exchain-65. Because we are compatible with EVM (it's similar to EVMOS). So the number was used as EVM side chain-id and the prefix was used as cosmos side chain-id. In most use cases of using testnet or mainnet is EVM, so we just focused on the number zone. Now we are going to integrate ibc and cosmwasm to our chain but chain-id has been already configured to our net while a long time, so it's hard to change our chain-id directly to be compatible with keplr wallet(some historical reasons). so we are here to ask for some help

KamiD avatar Jul 02 '22 10:07 KamiD

Can you explain why the chain id have different numbers at the end? I would be able to offer some advice for the integration if I have context. If the numbers are necessary, you might want to take a look at EVMOS, which has chain id with numbers using underscore.

Hi, we are using the "prefix-number" format as our chain-id such as exchain-65. Because we are compatible with EVM (it's similar to EVMOS). So the number was used as EVM side chain-id and the prefix was used as cosmos side chain-id. In most use cases of using testnet or mainnet is EVM, so we just focused on the number zone. Now we are going to integrate ibc and cosmwasm to our chain but chain-id has been already configured to our net while a long time, so it's hard to change our chain-id directly to be compatible with keplr wallet(some historical reasons). so we are here to ask for some help

@Thunnini For the above reasons, what is your advice?

zccst avatar Jul 05 '22 08:07 zccst