@chain-registry/keplr 1.74.239 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/README.md +27 -26
  2. package/esm/index.js +18 -18
  3. package/index.js +20 -20
  4. package/package.json +17 -23
package/README.md CHANGED
@@ -1,38 +1,39 @@
1
- # @chain-registry/keplr
1
+ # keplr
2
2
 
3
- <p align="center" width="100%">
4
- <img height="90" src="https://user-images.githubusercontent.com/545047/190171475-b416f99e-2831-4786-9ba3-a7ff4d95b0d3.svg" />
3
+ <p align="center">
4
+ <img src="https://user-images.githubusercontent.com/545047/188804067-28e67e5e-0214-4449-ab04-2e0c564a6885.svg" width="80"><br />
5
+ Chain Registry to Keplr
5
6
  </p>
6
7
 
7
- <p align="center" width="100%">
8
- <a href="https://github.com/hyperweb-io/chain-registry/actions/workflows/run-tests.yml">
9
- <img height="20" src="https://github.com/hyperweb-io/chain-registry/actions/workflows/run-tests.yml/badge.svg" />
10
- </a>
11
- <a href="https://github.com/hyperweb-io/chain-registry/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"></a>
12
- <a href="https://www.npmjs.com/package/@chain-registry/keplr"><img height="20" src="https://img.shields.io/github/package-json/v/hyperweb-io/chain-registry?filename=v1%2Fpackages%2Fkeplr%2Fpackage.json"></a>
13
- </p>
14
-
15
- Keplr integration for the chain-registry returning keplr's `ChainInfo` type from `@chain-registry/types` `Chain` type.
8
+ ## install
16
9
 
10
+ ```sh
11
+ npm install keplr
17
12
  ```
18
- npm install @chain-registry/keplr
19
- ```
13
+ ## Table of contents
20
14
 
21
- ```js
22
- import { assets, chains } from 'chain-registry';
23
- import { chainRegistryChainToKeplr } from '@chain-registry/keplr';
24
- import { ChainInfo } from '@keplr-wallet/types';
15
+ - [keplr](#keplr)
16
+ - [Install](#install)
17
+ - [Table of contents](#table-of-contents)
18
+ - [Developing](#developing)
19
+ - [Credits](#credits)
25
20
 
26
- const chain = chains.find(({chain_name})=>chain_name==='osmosis');
27
- const config: ChainInfo = chainRegistryChainToKeplr(chain, assets);
21
+ ## Developing
22
+
23
+ When first cloning the repo:
24
+
25
+ ```sh
26
+ yarn
27
+ # build the prod packages. When devs would like to navigate to the source code, this will only navigate from references to their definitions (.d.ts files) between packages.
28
+ yarn build
29
+ ```
28
30
 
29
- // you can add options as well to choose endpoints
30
- const config: ChainInfo = chainRegistryChainToKeplr(chain, assets, {
31
- getExplorer: () => 'https://myexplorer.com',
32
- getRestEndpoint: (chain) => chain.apis?.rest[1]?.address
33
- getRpcEndpoint: (chain) => chain.apis?.rpc[1]?.address
34
- });
31
+ Or if you want to make your dev process smoother, you can run:
35
32
 
33
+ ```sh
34
+ yarn
35
+ # build the dev packages with .map files, this enables navigation from references to their source code between packages.
36
+ yarn build:dev
36
37
  ```
37
38
 
38
39
  ## Interchain JavaScript Stack ⚛️
package/esm/index.js CHANGED
@@ -63,15 +63,15 @@ export const chainRegistryChainToKeplr = (chain, assets, options = {
63
63
  options.getExplorer = getExplr;
64
64
  const features = [];
65
65
  // check if it's a Cosmos SDK chain (either new or old format)
66
- const isCosmosSDKChain = chain.codebase?.sdk?.type === 'cosmos' || !!chain.codebase?.cosmos_sdk_version;
66
+ const isCosmosSDKChain = chain.codebase?.sdk?.type === 'cosmos' || !!chain.codebase?.cosmosSdkVersion;
67
67
  if (isCosmosSDKChain) {
68
68
  // determine SDK version
69
69
  let sdkVer;
70
70
  if (chain.codebase?.sdk?.type === 'cosmos' && chain.codebase.sdk.version) {
71
71
  sdkVer = extractVersion(chain.codebase.sdk.version);
72
72
  }
73
- else if (chain.codebase?.cosmos_sdk_version) {
74
- sdkVer = extractVersion(chain.codebase.cosmos_sdk_version);
73
+ else if (chain.codebase?.cosmosSdkVersion) {
74
+ sdkVer = extractVersion(chain.codebase.cosmosSdkVersion);
75
75
  }
76
76
  else {
77
77
  // if NOT specified, we assume stargate, sorry not sorry
@@ -89,32 +89,32 @@ export const chainRegistryChainToKeplr = (chain, assets, options = {
89
89
  if (semver.satisfies(sdkVer, '>=0.45'))
90
90
  features.push('ibc-go');
91
91
  // CosmWasm feature detection
92
- const cosmwasmEnabled = chain.codebase?.cosmwasm?.enabled ?? chain.codebase?.cosmwasm_enabled ?? false;
92
+ const cosmwasmEnabled = chain.codebase?.cosmwasm?.enabled ?? chain.codebase?.cosmwasmEnabled ?? false;
93
93
  if (cosmwasmEnabled) {
94
94
  features.push('cosmwasm');
95
- const wasmVer = extractVersion(chain.codebase?.cosmwasm?.version ?? chain.codebase?.cosmwasm_version ?? '0.24.0');
95
+ const wasmVer = extractVersion(chain.codebase?.cosmwasm?.version ?? chain.codebase?.cosmwasmVersion ?? '0.24.0');
96
96
  if (semver.satisfies(wasmVer, '>=0.24.0'))
97
97
  features.push('wasmd_0.24+');
98
98
  }
99
99
  }
100
- const chainAssets = assets.find((asset) => asset.chain_name === chain.chain_name)?.assets || [];
101
- const feeDenoms = chain.fees?.fee_tokens.map((feeToken) => feeToken.denom) || [];
102
- const gasPriceSteps = chain.fees?.fee_tokens?.reduce((m, feeToken) => {
100
+ const chainAssets = assets.find((asset) => asset.chainName === chain.chainName)?.assets || [];
101
+ const feeDenoms = chain.fees?.feeTokens.map((feeToken) => feeToken.denom) || [];
102
+ const gasPriceSteps = chain.fees?.feeTokens?.reduce((m, feeToken) => {
103
103
  m[feeToken.denom] = {
104
- low: feeToken.low_gas_price ?? 0.01,
105
- average: feeToken.average_gas_price ?? 0.025,
106
- high: feeToken.high_gas_price ?? 0.04
104
+ low: feeToken.lowGasPrice ?? 0.01,
105
+ average: feeToken.averageGasPrice ?? 0.025,
106
+ high: feeToken.highGasPrice ?? 0.04
107
107
  };
108
108
  return m;
109
109
  }, {});
110
- const stakingDenoms = chain.staking?.staking_tokens.map((stakingToken) => stakingToken.denom) || [];
110
+ const stakingDenoms = chain.staking?.stakingTokens.map((stakingToken) => stakingToken.denom) || [];
111
111
  const currencies = chainAssets.map((currency) => {
112
112
  return {
113
113
  coinDenom: currency.symbol,
114
114
  coinMinimalDenom: currency.base,
115
- coinDecimals: currency.denom_units.filter((denomUnit) => denomUnit.denom === currency.display)[0]?.exponent,
116
- coinGeckoId: currency.coingecko_id || undefined,
117
- coinImageUrl: currency.logo_URIs?.svg ?? currency.logo_URIs?.png
115
+ coinDecimals: currency.denomUnits.filter((denomUnit) => denomUnit.denom === currency.display)[0]?.exponent,
116
+ coinGeckoId: currency.coingeckoId || undefined,
117
+ coinImageUrl: currency.logoURIs?.svg ?? currency.logoURIs?.png
118
118
  };
119
119
  });
120
120
  const stakeCurrency = currencies.find((currency) => stakingDenoms.includes(currency.coinDenom)) ??
@@ -150,12 +150,12 @@ export const chainRegistryChainToKeplr = (chain, assets, options = {
150
150
  const chainInfo = {
151
151
  rpc: options.getRpcEndpoint(chain),
152
152
  rest: options.getRestEndpoint(chain),
153
- chainId: chain.chain_id,
154
- chainName: chain.pretty_name,
153
+ chainId: chain.chainId,
154
+ chainName: chain.prettyName,
155
155
  bip44: {
156
156
  coinType: chain.slip44
157
157
  },
158
- bech32Config: Bech32Address.defaultBech32Config(chain.bech32_prefix),
158
+ bech32Config: Bech32Address.defaultBech32Config(chain.bech32Prefix),
159
159
  currencies: currencies,
160
160
  stakeCurrency: stakeCurrency || currencies[0],
161
161
  feeCurrencies: feeCurrencies.length !== 0 ? feeCurrencies : feeCurrenciesDefault,
package/index.js CHANGED
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.chainRegistryChainToKeplr = exports.extractVersion = void 0;
6
+ exports.chainRegistryChainToKeplr = void 0;
7
+ exports.extractVersion = extractVersion;
7
8
  const cosmos_1 = require("@keplr-wallet/cosmos");
8
9
  const semver_1 = __importDefault(require("semver"));
9
10
  const getRpc = (chain) => chain.apis?.rpc?.[0]?.address ?? '';
@@ -48,7 +49,6 @@ function extractVersion(input) {
48
49
  }
49
50
  return version ? normalizeVersion(version) : null;
50
51
  }
51
- exports.extractVersion = extractVersion;
52
52
  function normalizeVersion(version) {
53
53
  // Ensures the version is normalized to the 'x.y.z' format, if applicable
54
54
  const parts = version.split('.');
@@ -70,15 +70,15 @@ const chainRegistryChainToKeplr = (chain, assets, options = {
70
70
  options.getExplorer = getExplr;
71
71
  const features = [];
72
72
  // check if it's a Cosmos SDK chain (either new or old format)
73
- const isCosmosSDKChain = chain.codebase?.sdk?.type === 'cosmos' || !!chain.codebase?.cosmos_sdk_version;
73
+ const isCosmosSDKChain = chain.codebase?.sdk?.type === 'cosmos' || !!chain.codebase?.cosmosSdkVersion;
74
74
  if (isCosmosSDKChain) {
75
75
  // determine SDK version
76
76
  let sdkVer;
77
77
  if (chain.codebase?.sdk?.type === 'cosmos' && chain.codebase.sdk.version) {
78
78
  sdkVer = extractVersion(chain.codebase.sdk.version);
79
79
  }
80
- else if (chain.codebase?.cosmos_sdk_version) {
81
- sdkVer = extractVersion(chain.codebase.cosmos_sdk_version);
80
+ else if (chain.codebase?.cosmosSdkVersion) {
81
+ sdkVer = extractVersion(chain.codebase.cosmosSdkVersion);
82
82
  }
83
83
  else {
84
84
  // if NOT specified, we assume stargate, sorry not sorry
@@ -96,32 +96,32 @@ const chainRegistryChainToKeplr = (chain, assets, options = {
96
96
  if (semver_1.default.satisfies(sdkVer, '>=0.45'))
97
97
  features.push('ibc-go');
98
98
  // CosmWasm feature detection
99
- const cosmwasmEnabled = chain.codebase?.cosmwasm?.enabled ?? chain.codebase?.cosmwasm_enabled ?? false;
99
+ const cosmwasmEnabled = chain.codebase?.cosmwasm?.enabled ?? chain.codebase?.cosmwasmEnabled ?? false;
100
100
  if (cosmwasmEnabled) {
101
101
  features.push('cosmwasm');
102
- const wasmVer = extractVersion(chain.codebase?.cosmwasm?.version ?? chain.codebase?.cosmwasm_version ?? '0.24.0');
102
+ const wasmVer = extractVersion(chain.codebase?.cosmwasm?.version ?? chain.codebase?.cosmwasmVersion ?? '0.24.0');
103
103
  if (semver_1.default.satisfies(wasmVer, '>=0.24.0'))
104
104
  features.push('wasmd_0.24+');
105
105
  }
106
106
  }
107
- const chainAssets = assets.find((asset) => asset.chain_name === chain.chain_name)?.assets || [];
108
- const feeDenoms = chain.fees?.fee_tokens.map((feeToken) => feeToken.denom) || [];
109
- const gasPriceSteps = chain.fees?.fee_tokens?.reduce((m, feeToken) => {
107
+ const chainAssets = assets.find((asset) => asset.chainName === chain.chainName)?.assets || [];
108
+ const feeDenoms = chain.fees?.feeTokens.map((feeToken) => feeToken.denom) || [];
109
+ const gasPriceSteps = chain.fees?.feeTokens?.reduce((m, feeToken) => {
110
110
  m[feeToken.denom] = {
111
- low: feeToken.low_gas_price ?? 0.01,
112
- average: feeToken.average_gas_price ?? 0.025,
113
- high: feeToken.high_gas_price ?? 0.04
111
+ low: feeToken.lowGasPrice ?? 0.01,
112
+ average: feeToken.averageGasPrice ?? 0.025,
113
+ high: feeToken.highGasPrice ?? 0.04
114
114
  };
115
115
  return m;
116
116
  }, {});
117
- const stakingDenoms = chain.staking?.staking_tokens.map((stakingToken) => stakingToken.denom) || [];
117
+ const stakingDenoms = chain.staking?.stakingTokens.map((stakingToken) => stakingToken.denom) || [];
118
118
  const currencies = chainAssets.map((currency) => {
119
119
  return {
120
120
  coinDenom: currency.symbol,
121
121
  coinMinimalDenom: currency.base,
122
- coinDecimals: currency.denom_units.filter((denomUnit) => denomUnit.denom === currency.display)[0]?.exponent,
123
- coinGeckoId: currency.coingecko_id || undefined,
124
- coinImageUrl: currency.logo_URIs?.svg ?? currency.logo_URIs?.png
122
+ coinDecimals: currency.denomUnits.filter((denomUnit) => denomUnit.denom === currency.display)[0]?.exponent,
123
+ coinGeckoId: currency.coingeckoId || undefined,
124
+ coinImageUrl: currency.logoURIs?.svg ?? currency.logoURIs?.png
125
125
  };
126
126
  });
127
127
  const stakeCurrency = currencies.find((currency) => stakingDenoms.includes(currency.coinDenom)) ??
@@ -157,12 +157,12 @@ const chainRegistryChainToKeplr = (chain, assets, options = {
157
157
  const chainInfo = {
158
158
  rpc: options.getRpcEndpoint(chain),
159
159
  rest: options.getRestEndpoint(chain),
160
- chainId: chain.chain_id,
161
- chainName: chain.pretty_name,
160
+ chainId: chain.chainId,
161
+ chainName: chain.prettyName,
162
162
  bip44: {
163
163
  coinType: chain.slip44
164
164
  },
165
- bech32Config: cosmos_1.Bech32Address.defaultBech32Config(chain.bech32_prefix),
165
+ bech32Config: cosmos_1.Bech32Address.defaultBech32Config(chain.bech32Prefix),
166
166
  currencies: currencies,
167
167
  stakeCurrency: stakeCurrency || currencies[0],
168
168
  feeCurrencies: feeCurrencies.length !== 0 ? feeCurrencies : feeCurrenciesDefault,
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@chain-registry/keplr",
3
- "version": "1.74.239",
4
- "description": "Chain Registry to Keplr",
3
+ "version": "2.0.1",
5
4
  "author": "Dan Lynch <pyramation@gmail.com>",
6
- "homepage": "https://github.com/hyperweb-io/chain-registry",
7
- "license": "SEE LICENSE IN LICENSE",
5
+ "description": "Chain Registry to Keplr",
8
6
  "main": "index.js",
9
7
  "module": "esm/index.js",
10
8
  "types": "index.d.ts",
9
+ "homepage": "https://github.com/hyperweb-io/chain-registry",
10
+ "license": "SEE LICENSE IN LICENSE",
11
11
  "publishConfig": {
12
12
  "access": "public",
13
13
  "directory": "dist"
@@ -19,30 +19,24 @@
19
19
  "bugs": {
20
20
  "url": "https://github.com/hyperweb-io/chain-registry/issues"
21
21
  },
22
+ "dependencies": {
23
+ "@chain-registry/types": "^2.0.1",
24
+ "@keplr-wallet/cosmos": "0.12.28",
25
+ "@keplr-wallet/crypto": "0.12.28",
26
+ "@types/semver": "^7.5.8",
27
+ "chain-registry": "^2.0.1",
28
+ "semver": "^7.5.0"
29
+ },
22
30
  "scripts": {
23
- "copy": "copyfiles -f LICENSE README.md package.json dist",
31
+ "copy": "copyfiles -f ../../LICENSE README.md package.json dist",
24
32
  "clean": "rimraf dist/**",
25
33
  "prepare": "npm run build",
26
34
  "build": "npm run clean; tsc; tsc -p tsconfig.esm.json; npm run copy",
35
+ "build:dev": "npm run clean; tsc --declarationMap; tsc -p tsconfig.esm.json; npm run copy",
36
+ "lint": "eslint . --fix",
27
37
  "test": "jest",
28
38
  "test:watch": "jest --watch"
29
39
  },
30
- "devDependencies": {
31
- "@types/semver": "^7.5.8",
32
- "chain-registry": "^1.69.239"
33
- },
34
- "dependencies": {
35
- "@chain-registry/types": "^0.50.148",
36
- "@keplr-wallet/cosmos": "0.12.28",
37
- "@keplr-wallet/crypto": "0.12.28",
38
- "semver": "^7.5.0"
39
- },
40
- "keywords": [
41
- "chain-registry",
42
- "web3",
43
- "cosmos",
44
- "interchain",
45
- "keplr"
46
- ],
47
- "gitHead": "5c1b42e3ebff0d5b1a4523d808b9edd7f35a75a5"
40
+ "keywords": [],
41
+ "gitHead": "305d26dcd259fd31a0e30444f02273abaf40e298"
48
42
  }