hyperweb-io / hyperweb-io/cosmos-kit

Chain provider has error with chains

Open
#565 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
201
Forks
159
PR merge metrics
No merged PRs in 30d

Description

Hello, I have the error
```react-dom.development.js:22878 Uncaught TypeError: Cannot read properties of undefined (reading 'includes')
at KeplrExtensionWallet.makeFinalEndpoints (main-wallet.js:77:1)
at eval (main-wallet.js:111:1)
at Array.forEach ()
at KeplrExtensionWallet.setChains (main-wallet.js:108:1)
at eval (manager.js:73:1)
at Array.map ()
at WalletManager.init (manager.js:68:1)
at new WalletManager (manager.js:58:1)
at eval (provider.js:20:1)
at commitHookEffectListMount (react-dom.development.js:23189:1)
at invokePassiveEffectMountInDEV (react-dom.development.js:25193:1)
at invokeEffectsInDev (react-dom.development.js:27390:1)
at commitDoubleInvokeEffectsInDEV (react-dom.development.js:27369:1)
at flushPassiveEffectsImpl (react-dom.development.js:27095:1)
at flushPassiveEffects (react-dom.development.js:27023:1)
at eval (react-dom.development.js:26808:1)
at workLoop (scheduler.development.js:266:1)
at flushWork (scheduler.development.js:239:1)
at MessagePort.performWorkUntilDeadline (scheduler.development.js:533:1)
```
my code

```js
import { chains, assetLists } from 'chain-registry';
import { wallets } from '@cosmos-kit/keplr';

const newChains = chains.filter((c) => [ 'cosmoshub', 'mantrachain' ].includes(c.chainName));
const newAssetLists = assetLists.filter((a) => [ 'cosmoshub', 'mantrachain' ].includes(a.chainName));

```
version library
```json
"chain-registry": "^2.0.24",
"@cosmos-kit/core": "^2.16.1",
"@cosmos-kit/keplr": "^2.15.1",
"@cosmos-kit/react": "^2.22.1",
```
code package
```js
makeFinalEndpoints(chain) {
const isTestNet = chain.name.includes('testnet');
const preferredEndpoints = {
isLazy: chain.preferredEndpoints?.isLazy,
rpc: [
...(chain.preferredEndpoints?.rpc || []),
...(this.preferredEndpoints?.[chain.name]?.rpc || []),
...(chain.chain?.apis?.rpc?.map((e) => e.address) || []),
isTestNet
? `https://rpc.testcosmos.directory/${chain.name}`
: `https://rpc.cosmos.directory/${chain.name}`,
],
rest: [
...(chain.preferredEndpoints?.rest || []),
...(this.preferredEndpoints?.[chain.name]?.rest || []),
...(chain.chain?.apis?.rest?.map((e) => e.address) || []),
isTestNet
? `https://rest.testcosmos.directory/${chain.name}`
: `https://rest.cosmos.directory/${chain.name}`,
],
};
return preferredEndpoints;
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.