@chain-registry/cosmostation 1.7.0

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ # 1.7.0 (2022-11-10)
7
+
8
+ **Note:** Version bump only for package @chain-registry/cosmostation
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Dan Lynch <pyramation@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # @chain-registry/cosmostation
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" />
5
+ </p>
6
+
7
+ <p align="center" width="100%">
8
+ <a href="https://github.com/cosmology-tech/chain-registry/actions/workflows/run-tests.yml">
9
+ <img height="20" src="https://github.com/cosmology-tech/chain-registry/actions/workflows/run-tests.yml/badge.svg" />
10
+ </a>
11
+ <a href="https://github.com/cosmology-tech/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/cosmostation"><img height="20" src="https://img.shields.io/github/package-json/v/cosmology-tech/chain-registry?filename=packages%2Fcosmostation%2Fpackage.json"></a>
13
+ </p>
14
+
15
+ Cosmostation integration for the chain-registry returning cosmostation's `AddChainParams` type from `@chain-registry/types` `Chain` type.
16
+
17
+ ```
18
+ npm install @chain-registry/cosmostation
19
+ ```
20
+
21
+ ```js
22
+ import { assets, chains } from 'chain-registry';
23
+ import { chainRegistryChainToCosmostation } from '@chain-registry/cosmostation';
24
+ import { AddChainParams } from '@cosmostation/extension-client/types/message';
25
+
26
+ const chain = chains.find(({chain_name})=>chain_name==='osmosis');
27
+ const config: AddChainParams = chainRegistryChainToCosmostation(chain, assets);
28
+
29
+ // you can add options as well to choose endpoints
30
+ const config: AddChainParams = chainRegistryChainToCosmostation(chain, assets, {
31
+ getRestEndpoint: (chain) => chain.apis?.rest[1]?.address
32
+ });
33
+ ```
34
+
35
+ ## Credits
36
+
37
+ 🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.tech/validator)
package/main/index.js ADDED
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.chainRegistryChainToCosmostation = void 0;
7
+ var _utils = require("@chain-registry/utils");
8
+ var getRest = function getRest(chain) {
9
+ var _chain$apis, _chain$apis$rest$;
10
+ return (_chain$apis = chain.apis) === null || _chain$apis === void 0 ? void 0 : (_chain$apis$rest$ = _chain$apis.rest[0]) === null || _chain$apis$rest$ === void 0 ? void 0 : _chain$apis$rest$.address;
11
+ };
12
+
13
+ // chainId: string;
14
+ // chainName: string;
15
+ // restURL: string;
16
+ // imageURL?: string;
17
+ // baseDenom: string;
18
+ // displayDenom: string;
19
+ // decimals?: number;
20
+ // coinType?: string;
21
+ // addressPrefix: string;
22
+ // coinGeckoId?: string;
23
+ // gasRate?: GasRate;
24
+ // sendGas?: string;
25
+ // type?: CosmosType;
26
+
27
+ var chainRegistryChainToCosmostation = function chainRegistryChainToCosmostation(chain, assets) {
28
+ var _assets$find, _chain$staking, _currencies$find;
29
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
30
+ getRestEndpoint: getRest
31
+ };
32
+ if (!options.getRestEndpoint) options.getRestEndpoint = getRest;
33
+ var chainAssets = ((_assets$find = assets.find(function (asset) {
34
+ return asset.chain_name === chain.chain_name;
35
+ })) === null || _assets$find === void 0 ? void 0 : _assets$find.assets) || [];
36
+ var stakingDenoms = ((_chain$staking = chain.staking) === null || _chain$staking === void 0 ? void 0 : _chain$staking.staking_tokens.map(function (stakingToken) {
37
+ return stakingToken.denom;
38
+ })) || [];
39
+ var currencies = chainAssets.map(function (currency) {
40
+ var _currency$logo_URIs$s, _currency$logo_URIs, _currency$logo_URIs2;
41
+ return {
42
+ displayDenom: currency.symbol,
43
+ baseDenom: currency.base,
44
+ coinGeckoId: currency.coingecko_id,
45
+ imageURL: (_currency$logo_URIs$s = (_currency$logo_URIs = currency.logo_URIs) === null || _currency$logo_URIs === void 0 ? void 0 : _currency$logo_URIs.svg) !== null && _currency$logo_URIs$s !== void 0 ? _currency$logo_URIs$s : (_currency$logo_URIs2 = currency.logo_URIs) === null || _currency$logo_URIs2 === void 0 ? void 0 : _currency$logo_URIs2.png
46
+ };
47
+ });
48
+ var stakeCurrency = (_currencies$find = currencies.find(function (currency) {
49
+ return stakingDenoms.includes(currency.baseDenom);
50
+ })) !== null && _currencies$find !== void 0 ? _currencies$find : currencies[0];
51
+ var gasPriceStep = (0, _utils.getGasPriceStep)(chain);
52
+ var chainInfo = {
53
+ chainId: chain.chain_id,
54
+ chainName: chain.pretty_name,
55
+ restURL: options.getRestEndpoint(chain),
56
+ imageURL: stakeCurrency.imageURL,
57
+ baseDenom: stakeCurrency.baseDenom,
58
+ displayDenom: stakeCurrency.displayDenom,
59
+ coinType: chain.slip44.toString(),
60
+ addressPrefix: chain.bech32_prefix,
61
+ coinGeckoId: currencies[0].coinGeckoId,
62
+ gasRate: {
63
+ // optional (default: { average: '0.025', low: '0.0025', tiny: '0.00025' })
64
+ average: gasPriceStep.average.toString(),
65
+ low: gasPriceStep.low.toString(),
66
+ tiny: '0.00025'
67
+ }
68
+ // TODO implement type
69
+ // type: '' | 'ETHERMINT'
70
+ };
71
+
72
+ return chainInfo;
73
+ };
74
+ exports.chainRegistryChainToCosmostation = chainRegistryChainToCosmostation;
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@chain-registry/cosmostation",
3
+ "version": "1.7.0",
4
+ "description": "Chain Registry to Cosmostation",
5
+ "author": "Dan Lynch <pyramation@gmail.com>",
6
+ "homepage": "https://github.com/cosmology-tech/chain-registry",
7
+ "license": "SEE LICENSE IN LICENSE",
8
+ "main": "main/index.js",
9
+ "typings": "types/index.d.ts",
10
+ "directories": {
11
+ "lib": "src",
12
+ "test": "__tests__"
13
+ },
14
+ "files": [
15
+ "types",
16
+ "main"
17
+ ],
18
+ "scripts": {
19
+ "build": "cross-env BABEL_ENV=production babel src --out-dir main --delete-dir-on-start --extensions \".tsx,.ts,.js\"",
20
+ "build:ts": "tsc --project ./tsconfig.json",
21
+ "buidl": "npm run build && npm run build:ts",
22
+ "prepare": "npm run build",
23
+ "dev": "cross-env NODE_ENV=development babel-node src/telescope --extensions \".tsx,.ts,.js\"",
24
+ "watch": "cross-env NODE_ENV=development babel-watch src/telescope --extensions \".tsx,.ts,.js\"",
25
+ "file": "cross-env NODE_ENV=development babel-watch src/file --extensions \".tsx,.ts,.js\"",
26
+ "lint": "eslint --ext .ts,.tsx,.js .",
27
+ "format": "eslint --fix . --ext .ts,.tsx,.js",
28
+ "test": "jest",
29
+ "test:watch": "jest --watch",
30
+ "test:debug": "node --inspect node_modules/.bin/jest --runInBand"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/cosmology-tech/chain-registry"
38
+ },
39
+ "keywords": [],
40
+ "bugs": {
41
+ "url": "https://github.com/cosmology-tech/chain-registry/issues"
42
+ },
43
+ "devDependencies": {
44
+ "@babel/cli": "7.19.3",
45
+ "@babel/core": "7.19.6",
46
+ "@babel/eslint-parser": "^7.19.1",
47
+ "@babel/node": "^7.19.1",
48
+ "@babel/plugin-proposal-class-properties": "7.18.6",
49
+ "@babel/plugin-proposal-export-default-from": "7.18.10",
50
+ "@babel/plugin-proposal-object-rest-spread": "7.19.4",
51
+ "@babel/plugin-transform-runtime": "7.19.6",
52
+ "@babel/preset-env": "7.19.4",
53
+ "@babel/preset-typescript": "^7.17.12",
54
+ "@types/jest": "^29.2.0",
55
+ "@typescript-eslint/eslint-plugin": "5.40.1",
56
+ "@typescript-eslint/parser": "5.40.1",
57
+ "babel-core": "7.0.0-bridge.0",
58
+ "babel-jest": "29.2.1",
59
+ "babel-watch": "^7.0.0",
60
+ "chain-registry": "^1.5.0",
61
+ "cross-env": "^7.0.2",
62
+ "eslint": "8.25.0",
63
+ "eslint-config-prettier": "^8.5.0",
64
+ "eslint-plugin-prettier": "^4.0.0",
65
+ "eslint-plugin-simple-import-sort": "8.0.0",
66
+ "eslint-plugin-unused-imports": "2.0.0",
67
+ "jest": "^29.2.1",
68
+ "long": "^5.2.0",
69
+ "prettier": "^2.7.0",
70
+ "regenerator-runtime": "^0.13.10",
71
+ "ts-jest": "^29.0.3",
72
+ "typescript": "^4.8.4"
73
+ },
74
+ "dependencies": {
75
+ "@babel/runtime": "^7.19.4",
76
+ "@chain-registry/types": "^0.13.1",
77
+ "@cosmostation/extension-client": "0.1.11"
78
+ },
79
+ "gitHead": "c35d96830c1cb4f9cc26643e6238ff659867dfb7"
80
+ }
@@ -0,0 +1,5 @@
1
+ import { AssetList, Chain } from '@chain-registry/types';
2
+ import { AddChainParams } from '@cosmostation/extension-client/types/message';
3
+ export declare const chainRegistryChainToCosmostation: (chain: Chain, assets: AssetList[], options?: {
4
+ getRestEndpoint: (chain: Chain) => string;
5
+ }) => AddChainParams;