@chain-registry/utils 0.2.0 → 0.3.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.3.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.3.0...@chain-registry/utils@0.3.1) (2022-08-13)
7
+
8
+ **Note:** Version bump only for package @chain-registry/utils
9
+
10
+
11
+
12
+
13
+
14
+ # [0.3.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.2.1...@chain-registry/utils@0.3.0) (2022-08-13)
15
+
16
+ **Note:** Version bump only for package @chain-registry/utils
17
+
18
+
19
+
20
+
21
+
22
+ ## [0.2.1](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.2.0...@chain-registry/utils@0.2.1) (2022-08-13)
23
+
24
+ **Note:** Version bump only for package @chain-registry/utils
25
+
26
+
27
+
28
+
29
+
6
30
  # 0.2.0 (2022-08-13)
7
31
 
8
32
  **Note:** Version bump only for package @chain-registry/utils
package/README.md CHANGED
@@ -1,3 +1,15 @@
1
- # chain-registry utils
1
+ # @chain-registry/utils
2
+
3
+ <p align="center" width="100%">
4
+ <img height="90" src="https://user-images.githubusercontent.com/545047/184277736-69fef40f-1991-4c0e-b979-da125cf7fd8f.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/utils"><img height="20" src="https://img.shields.io/github/package-json/v/cosmology-tech/chain-registry?filename=packages%2Futils%2Fpackage.json"></a>
13
+ </p>
2
14
 
3
15
  Utility functions for the chain-registry
package/main/index.js CHANGED
@@ -11,6 +11,8 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
11
11
 
12
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
13
 
14
+ var _crypto = require("@keplr-wallet/crypto");
15
+
14
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
17
 
16
18
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -21,9 +23,6 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
21
23
 
22
24
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
23
25
 
24
- var _require = require('@keplr-wallet/crypto'),
25
- Hash = _require.Hash;
26
-
27
26
  var ibcDenom = function ibcDenom(paths, coinMinimalDenom) {
28
27
  var prefixes = [];
29
28
 
@@ -41,9 +40,9 @@ var ibcDenom = function ibcDenom(paths, coinMinimalDenom) {
41
40
  _iterator.f();
42
41
  }
43
42
 
44
- var prefix = prefixes.join("/");
43
+ var prefix = prefixes.join('/');
45
44
  var denom = "".concat(prefix, "/").concat(coinMinimalDenom);
46
- return "ibc/" + Buffer.from(Hash.sha256(Buffer.from(denom))).toString("hex").toUpperCase();
45
+ return 'ibc/' + Buffer.from(_crypto.Hash.sha256(Buffer.from(denom))).toString('hex').toUpperCase();
47
46
  };
48
47
 
49
48
  exports.ibcDenom = ibcDenom;
@@ -54,9 +53,6 @@ var findInfo = function findInfo(ibc, to, from) {
54
53
  });
55
54
  };
56
55
 
57
- ;
58
- ;
59
-
60
56
  var getIbcInfo = function getIbcInfo(ibc, chain, counterparty) {
61
57
  return findInfo(ibc, chain, counterparty) || findInfo(ibc, counterparty, chain);
62
58
  };
package/module/index.js CHANGED
@@ -4,10 +4,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
4
4
 
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
6
 
7
- const {
8
- Hash
9
- } = require('@keplr-wallet/crypto');
10
-
7
+ import { Hash } from '@keplr-wallet/crypto';
11
8
  export const ibcDenom = (paths, coinMinimalDenom) => {
12
9
  const prefixes = [];
13
10
 
@@ -15,15 +12,13 @@ export const ibcDenom = (paths, coinMinimalDenom) => {
15
12
  prefixes.push(`${path.portId}/${path.channelId}`);
16
13
  }
17
14
 
18
- const prefix = prefixes.join("/");
15
+ const prefix = prefixes.join('/');
19
16
  const denom = `${prefix}/${coinMinimalDenom}`;
20
- return "ibc/" + Buffer.from(Hash.sha256(Buffer.from(denom))).toString("hex").toUpperCase();
17
+ return 'ibc/' + Buffer.from(Hash.sha256(Buffer.from(denom))).toString('hex').toUpperCase();
21
18
  };
22
19
 
23
20
  const findInfo = (ibc, to, from) => ibc.find(i => i['chain-1']['chain-name'] === from && i['chain-2']['chain-name'] === to);
24
21
 
25
- ;
26
- ;
27
22
  export const getIbcInfo = (ibc, chain, counterparty) => {
28
23
  return findInfo(ibc, chain, counterparty) || findInfo(ibc, counterparty, chain);
29
24
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chain-registry/utils",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Chain Registry Utils",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "homepage": "https://github.com/cosmology-tech/chain-registry",
@@ -27,7 +27,8 @@
27
27
  "dev": "cross-env NODE_ENV=development babel-node src/telescope --extensions \".tsx,.ts,.js\"",
28
28
  "watch": "cross-env NODE_ENV=development babel-watch src/telescope --extensions \".tsx,.ts,.js\"",
29
29
  "file": "cross-env NODE_ENV=development babel-watch src/file --extensions \".tsx,.ts,.js\"",
30
- "lint": "eslint src --fix",
30
+ "lint": "eslint --ext .ts,.tsx,.js .",
31
+ "format": "eslint --fix . --ext .ts,.tsx,.js",
31
32
  "test": "jest",
32
33
  "test:watch": "jest --watch",
33
34
  "test:debug": "node --inspect node_modules/.bin/jest --runInBand"
@@ -55,13 +56,17 @@
55
56
  "@babel/preset-env": "7.18.2",
56
57
  "@babel/preset-typescript": "^7.17.12",
57
58
  "@types/jest": "^28.1.1",
59
+ "@typescript-eslint/eslint-plugin": "5.31.0",
60
+ "@typescript-eslint/parser": "5.31.0",
58
61
  "babel-core": "7.0.0-bridge.0",
59
62
  "babel-jest": "28.1.1",
60
63
  "babel-watch": "^7.0.0",
61
64
  "cross-env": "^7.0.2",
62
- "eslint": "8.17.0",
65
+ "eslint": "8.20.0",
63
66
  "eslint-config-prettier": "^8.5.0",
64
67
  "eslint-plugin-prettier": "^4.0.0",
68
+ "eslint-plugin-simple-import-sort": "7.0.0",
69
+ "eslint-plugin-unused-imports": "2.0.0",
65
70
  "jest": "^28.1.1",
66
71
  "long": "^5.2.0",
67
72
  "prettier": "^2.7.0",
@@ -73,5 +78,5 @@
73
78
  "@babel/runtime": "^7.18.3",
74
79
  "@keplr-wallet/crypto": "^0.10.11"
75
80
  },
76
- "gitHead": "6cc961b3a41e5afc15122da8b57c93a150a293b8"
81
+ "gitHead": "fcedd250d10e62e99427e7760a13e9356ac2c724"
77
82
  }
package/types/index.d.ts CHANGED
@@ -1,49 +1,72 @@
1
- export declare const ibcDenom: (paths: {
1
+ export declare const ibcDenom: (
2
+ paths: {
2
3
  portId: string;
3
4
  channelId: string;
4
- }[], coinMinimalDenom: string) => string;
5
+ }[],
6
+ coinMinimalDenom: string
7
+ ) => string;
5
8
  export interface IBCChainInfo {
6
- "chain-name": string;
7
- "client-id": string;
8
- "connection-id": string;
9
+ 'chain-name': string;
10
+ 'client-id': string;
11
+ 'connection-id': string;
9
12
  }
10
13
  export interface IBCChannelPortAndChannel {
11
- "channel-id": string;
12
- "port-id": string;
14
+ 'channel-id': string;
15
+ 'port-id': string;
13
16
  }
14
17
  export interface IBCChannelInfo {
15
- "chain-1": IBCChannelPortAndChannel;
16
- "chain-2": IBCChannelPortAndChannel;
17
- ordering: string;
18
- version: string;
19
- tags?: {
20
- [key: string]: string;
21
- };
18
+ 'chain-1': IBCChannelPortAndChannel;
19
+ 'chain-2': IBCChannelPortAndChannel;
20
+ ordering: string;
21
+ version: string;
22
+ tags?: {
23
+ [key: string]: string;
24
+ };
22
25
  }
23
26
  export interface IBCInfo {
24
- $schema: string;
25
- "chain-1": IBCChainInfo;
26
- "chain-2": IBCChainInfo;
27
- channels: IBCChannelInfo[];
27
+ $schema: string;
28
+ 'chain-1': IBCChainInfo;
29
+ 'chain-2': IBCChainInfo;
30
+ channels: IBCChannelInfo[];
28
31
  }
29
- export declare const getIbcInfo: (ibc: IBCInfo[], chain: string, counterparty: string) => IBCInfo;
32
+ export declare const getIbcInfo: (
33
+ ibc: IBCInfo[],
34
+ chain: string,
35
+ counterparty: string
36
+ ) => IBCInfo;
30
37
  export declare const getTransferChannel: (info: IBCInfo) => IBCChannelInfo;
31
- export declare const getIbcDenom: (ibc: IBCInfo[], chain: string, counterparty: string, assets: any[], symbol: string) => string;
32
- export declare const getIbcDenomByBase: (ibc: IBCInfo[], chain: string, counterparty: string, assets: any[], base: string) => string;
33
- export declare const getIbcAssets: (chainName: string, ibc: IBCInfo[], assets: any[]) => {
34
- chain: {
35
- "channel-id": string;
36
- "port-id": string;
37
- "chain-name": string;
38
- "client-id": string;
39
- "connection-id": string;
40
- };
41
- counterparty: {
42
- "channel-id": string;
43
- "port-id": string;
44
- "chain-name": string;
45
- "client-id": string;
46
- "connection-id": string;
47
- };
48
- assets: any;
38
+ export declare const getIbcDenom: (
39
+ ibc: IBCInfo[],
40
+ chain: string,
41
+ counterparty: string,
42
+ assets: any[],
43
+ symbol: string
44
+ ) => string;
45
+ export declare const getIbcDenomByBase: (
46
+ ibc: IBCInfo[],
47
+ chain: string,
48
+ counterparty: string,
49
+ assets: any[],
50
+ base: string
51
+ ) => string;
52
+ export declare const getIbcAssets: (
53
+ chainName: string,
54
+ ibc: IBCInfo[],
55
+ assets: any[]
56
+ ) => {
57
+ chain: {
58
+ 'channel-id': string;
59
+ 'port-id': string;
60
+ 'chain-name': string;
61
+ 'client-id': string;
62
+ 'connection-id': string;
63
+ };
64
+ counterparty: {
65
+ 'channel-id': string;
66
+ 'port-id': string;
67
+ 'chain-name': string;
68
+ 'client-id': string;
69
+ 'connection-id': string;
70
+ };
71
+ assets: any;
49
72
  }[];