@chain-registry/utils 0.1.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/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,3 @@
1
+ # chain-registry utils
2
+
3
+ Utility functions for the chain-registry
package/main/index.js ADDED
@@ -0,0 +1,238 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ibcDenom = exports.getTransferChannel = exports.getIbcInfo = exports.getIbcDenomByBase = exports.getIbcDenom = exports.getIbcAssets = void 0;
9
+
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ 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
+
16
+ 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; }
17
+
18
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
19
+
20
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
+
22
+ 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
+
24
+ var _require = require('@keplr-wallet/crypto'),
25
+ Hash = _require.Hash;
26
+
27
+ var ibcDenom = function ibcDenom(paths, coinMinimalDenom) {
28
+ var prefixes = [];
29
+
30
+ var _iterator = _createForOfIteratorHelper(paths),
31
+ _step;
32
+
33
+ try {
34
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
35
+ var path = _step.value;
36
+ prefixes.push("".concat(path.portId, "/").concat(path.channelId));
37
+ }
38
+ } catch (err) {
39
+ _iterator.e(err);
40
+ } finally {
41
+ _iterator.f();
42
+ }
43
+
44
+ var prefix = prefixes.join("/");
45
+ var denom = "".concat(prefix, "/").concat(coinMinimalDenom);
46
+ return "ibc/" + Buffer.from(Hash.sha256(Buffer.from(denom))).toString("hex").toUpperCase();
47
+ };
48
+
49
+ exports.ibcDenom = ibcDenom;
50
+
51
+ var findInfo = function findInfo(ibc, to, from) {
52
+ return ibc.find(function (i) {
53
+ return i['chain-1']['chain-name'] === from && i['chain-2']['chain-name'] === to;
54
+ });
55
+ };
56
+
57
+ ;
58
+ ;
59
+
60
+ var getIbcInfo = function getIbcInfo(ibc, chain, counterparty) {
61
+ return findInfo(ibc, chain, counterparty) || findInfo(ibc, counterparty, chain);
62
+ };
63
+
64
+ exports.getIbcInfo = getIbcInfo;
65
+
66
+ var getTransferChannel = function getTransferChannel(info) {
67
+ return info.channels.find(function (channel) {
68
+ return channel['chain-1']['port-id'] === 'transfer' && channel['chain-2']['port-id'] === 'transfer';
69
+ });
70
+ };
71
+
72
+ exports.getTransferChannel = getTransferChannel;
73
+
74
+ var getIbcDenom = function getIbcDenom(ibc, chain, counterparty, assets, symbol) {
75
+ var ibcInfo = getIbcInfo(ibc, chain, counterparty);
76
+
77
+ if (ibcInfo) {
78
+ var channel = getTransferChannel(ibcInfo);
79
+
80
+ if (!channel) {
81
+ return;
82
+ }
83
+
84
+ var channelInfo;
85
+
86
+ if (ibcInfo['chain-1']['chain-name'] === chain) {
87
+ channelInfo = channel['chain-1'];
88
+ } else {
89
+ channelInfo = channel['chain-2'];
90
+ }
91
+
92
+ var assetInfo = assets.find(function (_ref) {
93
+ var chain_name = _ref.chain_name;
94
+ return chain_name === counterparty;
95
+ });
96
+
97
+ if (!assetInfo) {
98
+ return;
99
+ }
100
+
101
+ var token = assetInfo.assets.find(function (a) {
102
+ return a.symbol === symbol;
103
+ });
104
+ if (!token) return;
105
+ return ibcDenom([{
106
+ portId: channelInfo['port-id'],
107
+ channelId: channelInfo['channel-id']
108
+ }], token.base);
109
+ }
110
+ };
111
+
112
+ exports.getIbcDenom = getIbcDenom;
113
+
114
+ var getIbcDenomByBase = function getIbcDenomByBase(ibc, chain, counterparty, assets, base) {
115
+ var ibcInfo = getIbcInfo(ibc, chain, counterparty);
116
+
117
+ if (ibcInfo) {
118
+ var channel = getTransferChannel(ibcInfo);
119
+
120
+ if (!channel) {
121
+ return;
122
+ }
123
+
124
+ var channelInfo;
125
+
126
+ if (ibcInfo['chain-1']['chain-name'] === chain) {
127
+ channelInfo = channel['chain-1'];
128
+ } else {
129
+ channelInfo = channel['chain-2'];
130
+ }
131
+
132
+ var assetInfo = assets.find(function (_ref2) {
133
+ var chain_name = _ref2.chain_name;
134
+ return chain_name === counterparty;
135
+ });
136
+
137
+ if (!assetInfo) {
138
+ return;
139
+ }
140
+
141
+ return ibcDenom([{
142
+ portId: channelInfo['port-id'],
143
+ channelId: channelInfo['channel-id']
144
+ }], base);
145
+ }
146
+ };
147
+
148
+ exports.getIbcDenomByBase = getIbcDenomByBase;
149
+
150
+ var getIbcAssets = function getIbcAssets(chainName, ibc, assets) {
151
+ var chainIbcInfo = ibc.filter(function (i) {
152
+ return i['chain-1']['chain-name'] === chainName || i['chain-2']['chain-name'] === chainName;
153
+ });
154
+ var ibcAssetLists = chainIbcInfo.map(function (ibcInfo) {
155
+ var counterpartyIs = ibcInfo['chain-1']['chain-name'] === chainName ? 'chain-2' : 'chain-1';
156
+ var chainIs = ibcInfo['chain-1']['chain-name'] === chainName ? 'chain-1' : 'chain-2';
157
+ var counterparty = ibcInfo[counterpartyIs]['chain-name'];
158
+ var counterpartyIbc = ibcInfo[counterpartyIs];
159
+ var chainIbc = ibcInfo[chainIs];
160
+ var counterpartyAssets = assets.find(function (a) {
161
+ return a.chain_name === counterparty;
162
+ });
163
+
164
+ if (!counterpartyAssets) {
165
+ console.warn('asset not found: ' + counterparty);
166
+ return;
167
+ }
168
+
169
+ var ibcAssets = counterpartyAssets.assets.filter(function (a) {
170
+ return !a.base.startsWith('cw20:');
171
+ }).map(function (asset) {
172
+ var denom = getIbcDenomByBase(ibc, chainName, counterparty, //
173
+ assets, asset.base);
174
+
175
+ var newAsset = _objectSpread({}, asset);
176
+
177
+ newAsset.base = denom;
178
+ newAsset.denom_units = newAsset.denom_units.map(function (unit) {
179
+ if (unit.denom === asset.base) {
180
+ var newUnit = _objectSpread({}, unit);
181
+
182
+ newUnit.denom = denom;
183
+ newUnit.aliases = [unit.denom];
184
+ return newUnit;
185
+ }
186
+
187
+ return unit;
188
+ });
189
+ return newAsset;
190
+ });
191
+ var channel = getTransferChannel(ibcInfo);
192
+ return {
193
+ chain: _objectSpread(_objectSpread({}, chainIbc), channel[chainIs]),
194
+ counterparty: _objectSpread(_objectSpread({}, counterpartyIbc), channel[counterpartyIs]),
195
+ assets: ibcAssets
196
+ };
197
+ }).filter(Boolean);
198
+ var hash = ibcAssetLists.reduce(function (m, v) {
199
+ m[v.chain['chain-name']] = m[v.chain['chain-name']] || [];
200
+ var assets = v.assets.map(function (asset) {
201
+ return _objectSpread(_objectSpread({}, asset), {}, {
202
+ ibc: {
203
+ counterparty: {
204
+ // source_channel
205
+ channel: v.counterparty['channel-id'],
206
+ // source_denom
207
+ denom: asset.denom_units[0].aliases[0],
208
+ chain_name: v.counterparty['chain-name'] // port: v.counterparty['port-id']
209
+
210
+ },
211
+ chain: {
212
+ // dst_denom
213
+ channel: v.chain['channel-id'] // chain_name: v.chain['chain-name'],
214
+ // port: v.chain['port-id']
215
+
216
+ }
217
+ }
218
+ });
219
+ });
220
+
221
+ var obj = _objectSpread(_objectSpread({}, v), {}, {
222
+ assets: assets
223
+ });
224
+
225
+ m[v.chain['chain-name']].push(obj);
226
+ return m;
227
+ }, {});
228
+ return Object.keys(hash).map(function (chain) {
229
+ return {
230
+ chain_name: chain,
231
+ assets: hash[chain].reduce(function (m, v) {
232
+ return [].concat((0, _toConsumableArray2["default"])(m), (0, _toConsumableArray2["default"])(v.assets));
233
+ }, [])
234
+ };
235
+ });
236
+ };
237
+
238
+ exports.getIbcAssets = getIbcAssets;
@@ -0,0 +1,183 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+
3
+ 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; }
4
+
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
+
7
+ const {
8
+ Hash
9
+ } = require('@keplr-wallet/crypto');
10
+
11
+ export const ibcDenom = (paths, coinMinimalDenom) => {
12
+ const prefixes = [];
13
+
14
+ for (const path of paths) {
15
+ prefixes.push(`${path.portId}/${path.channelId}`);
16
+ }
17
+
18
+ const prefix = prefixes.join("/");
19
+ const denom = `${prefix}/${coinMinimalDenom}`;
20
+ return "ibc/" + Buffer.from(Hash.sha256(Buffer.from(denom))).toString("hex").toUpperCase();
21
+ };
22
+
23
+ const findInfo = (ibc, to, from) => ibc.find(i => i['chain-1']['chain-name'] === from && i['chain-2']['chain-name'] === to);
24
+
25
+ ;
26
+ ;
27
+ export const getIbcInfo = (ibc, chain, counterparty) => {
28
+ return findInfo(ibc, chain, counterparty) || findInfo(ibc, counterparty, chain);
29
+ };
30
+ export const getTransferChannel = info => {
31
+ return info.channels.find(channel => channel['chain-1']['port-id'] === 'transfer' && channel['chain-2']['port-id'] === 'transfer');
32
+ };
33
+ export const getIbcDenom = (ibc, chain, counterparty, assets, symbol) => {
34
+ const ibcInfo = getIbcInfo(ibc, chain, counterparty);
35
+
36
+ if (ibcInfo) {
37
+ const channel = getTransferChannel(ibcInfo);
38
+
39
+ if (!channel) {
40
+ return;
41
+ }
42
+
43
+ let channelInfo;
44
+
45
+ if (ibcInfo['chain-1']['chain-name'] === chain) {
46
+ channelInfo = channel['chain-1'];
47
+ } else {
48
+ channelInfo = channel['chain-2'];
49
+ }
50
+
51
+ const assetInfo = assets.find(({
52
+ chain_name
53
+ }) => chain_name === counterparty);
54
+
55
+ if (!assetInfo) {
56
+ return;
57
+ }
58
+
59
+ const token = assetInfo.assets.find(a => a.symbol === symbol);
60
+ if (!token) return;
61
+ return ibcDenom([{
62
+ portId: channelInfo['port-id'],
63
+ channelId: channelInfo['channel-id']
64
+ }], token.base);
65
+ }
66
+ };
67
+ export const getIbcDenomByBase = (ibc, chain, counterparty, assets, base) => {
68
+ const ibcInfo = getIbcInfo(ibc, chain, counterparty);
69
+
70
+ if (ibcInfo) {
71
+ const channel = getTransferChannel(ibcInfo);
72
+
73
+ if (!channel) {
74
+ return;
75
+ }
76
+
77
+ let channelInfo;
78
+
79
+ if (ibcInfo['chain-1']['chain-name'] === chain) {
80
+ channelInfo = channel['chain-1'];
81
+ } else {
82
+ channelInfo = channel['chain-2'];
83
+ }
84
+
85
+ const assetInfo = assets.find(({
86
+ chain_name
87
+ }) => chain_name === counterparty);
88
+
89
+ if (!assetInfo) {
90
+ return;
91
+ }
92
+
93
+ return ibcDenom([{
94
+ portId: channelInfo['port-id'],
95
+ channelId: channelInfo['channel-id']
96
+ }], base);
97
+ }
98
+ };
99
+ export const getIbcAssets = (chainName, ibc, assets) => {
100
+ const chainIbcInfo = ibc.filter(i => {
101
+ return i['chain-1']['chain-name'] === chainName || i['chain-2']['chain-name'] === chainName;
102
+ });
103
+ const ibcAssetLists = chainIbcInfo.map(ibcInfo => {
104
+ const counterpartyIs = ibcInfo['chain-1']['chain-name'] === chainName ? 'chain-2' : 'chain-1';
105
+ const chainIs = ibcInfo['chain-1']['chain-name'] === chainName ? 'chain-1' : 'chain-2';
106
+ const counterparty = ibcInfo[counterpartyIs]['chain-name'];
107
+ const counterpartyIbc = ibcInfo[counterpartyIs];
108
+ const chainIbc = ibcInfo[chainIs];
109
+ const counterpartyAssets = assets.find(a => {
110
+ return a.chain_name === counterparty;
111
+ });
112
+
113
+ if (!counterpartyAssets) {
114
+ console.warn('asset not found: ' + counterparty);
115
+ return;
116
+ }
117
+
118
+ const ibcAssets = counterpartyAssets.assets.filter(a => !a.base.startsWith('cw20:')).map(asset => {
119
+ const denom = getIbcDenomByBase(ibc, chainName, counterparty, //
120
+ assets, asset.base);
121
+
122
+ const newAsset = _objectSpread({}, asset);
123
+
124
+ newAsset.base = denom;
125
+ newAsset.denom_units = newAsset.denom_units.map(unit => {
126
+ if (unit.denom === asset.base) {
127
+ const newUnit = _objectSpread({}, unit);
128
+
129
+ newUnit.denom = denom;
130
+ newUnit.aliases = [unit.denom];
131
+ return newUnit;
132
+ }
133
+
134
+ return unit;
135
+ });
136
+ return newAsset;
137
+ });
138
+ const channel = getTransferChannel(ibcInfo);
139
+ return {
140
+ chain: _objectSpread(_objectSpread({}, chainIbc), channel[chainIs]),
141
+ counterparty: _objectSpread(_objectSpread({}, counterpartyIbc), channel[counterpartyIs]),
142
+ assets: ibcAssets
143
+ };
144
+ }).filter(Boolean);
145
+ const hash = ibcAssetLists.reduce((m, v) => {
146
+ m[v.chain['chain-name']] = m[v.chain['chain-name']] || [];
147
+ const assets = v.assets.map(asset => {
148
+ return _objectSpread(_objectSpread({}, asset), {}, {
149
+ ibc: {
150
+ counterparty: {
151
+ // source_channel
152
+ channel: v.counterparty['channel-id'],
153
+ // source_denom
154
+ denom: asset.denom_units[0].aliases[0],
155
+ chain_name: v.counterparty['chain-name'] // port: v.counterparty['port-id']
156
+
157
+ },
158
+ chain: {
159
+ // dst_denom
160
+ channel: v.chain['channel-id'] // chain_name: v.chain['chain-name'],
161
+ // port: v.chain['port-id']
162
+
163
+ }
164
+ }
165
+ });
166
+ });
167
+
168
+ const obj = _objectSpread(_objectSpread({}, v), {}, {
169
+ assets
170
+ });
171
+
172
+ m[v.chain['chain-name']].push(obj);
173
+ return m;
174
+ }, {});
175
+ return Object.keys(hash).map(chain => {
176
+ return {
177
+ chain_name: chain,
178
+ assets: hash[chain].reduce((m, v) => {
179
+ return [...m, ...v.assets];
180
+ }, [])
181
+ };
182
+ });
183
+ };
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@chain-registry/utils",
3
+ "version": "0.1.0",
4
+ "description": "Chain Registry Utils",
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
+ "module": "module/index.js",
10
+ "typings": "types/index.d.ts",
11
+ "directories": {
12
+ "lib": "src",
13
+ "test": "__tests__"
14
+ },
15
+ "files": [
16
+ "types",
17
+ "main",
18
+ "module"
19
+ ],
20
+ "scripts": {
21
+ "build:main": "cross-env BABEL_ENV=production babel src --out-dir main --delete-dir-on-start --extensions \".tsx,.ts,.js\"",
22
+ "build:module": "cross-env MODULE=true babel src --out-dir module --delete-dir-on-start --extensions \".tsx,.ts,.js\"",
23
+ "build": "npm run build:module && npm run build:main",
24
+ "build:ts": "tsc --project ./tsconfig.json",
25
+ "buidl": "npm run build && npm run build:ts",
26
+ "prepare": "npm run build",
27
+ "dev": "cross-env NODE_ENV=development babel-node src/telescope --extensions \".tsx,.ts,.js\"",
28
+ "watch": "cross-env NODE_ENV=development babel-watch src/telescope --extensions \".tsx,.ts,.js\"",
29
+ "file": "cross-env NODE_ENV=development babel-watch src/file --extensions \".tsx,.ts,.js\"",
30
+ "lint": "eslint src --fix",
31
+ "test": "jest",
32
+ "test:watch": "jest --watch",
33
+ "test:debug": "node --inspect node_modules/.bin/jest --runInBand"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/cosmology-tech/chain-registry"
41
+ },
42
+ "keywords": [],
43
+ "bugs": {
44
+ "url": "https://github.com/cosmology-tech/chain-registry/issues"
45
+ },
46
+ "devDependencies": {
47
+ "@babel/cli": "7.17.10",
48
+ "@babel/core": "7.18.5",
49
+ "@babel/eslint-parser": "^7.18.2",
50
+ "@babel/node": "^7.18.5",
51
+ "@babel/plugin-proposal-class-properties": "7.17.12",
52
+ "@babel/plugin-proposal-export-default-from": "7.17.12",
53
+ "@babel/plugin-proposal-object-rest-spread": "7.18.0",
54
+ "@babel/plugin-transform-runtime": "7.18.5",
55
+ "@babel/preset-env": "7.18.2",
56
+ "@babel/preset-typescript": "^7.17.12",
57
+ "@types/jest": "^28.1.1",
58
+ "babel-core": "7.0.0-bridge.0",
59
+ "babel-jest": "28.1.1",
60
+ "babel-watch": "^7.0.0",
61
+ "cross-env": "^7.0.2",
62
+ "eslint": "8.17.0",
63
+ "eslint-config-prettier": "^8.5.0",
64
+ "eslint-plugin-prettier": "^4.0.0",
65
+ "jest": "^28.1.1",
66
+ "long": "^5.2.0",
67
+ "prettier": "^2.7.0",
68
+ "regenerator-runtime": "^0.13.7",
69
+ "ts-jest": "^28.0.5",
70
+ "typescript": "^4.7.3"
71
+ },
72
+ "dependencies": {
73
+ "@babel/runtime": "^7.18.3",
74
+ "@keplr-wallet/crypto": "^0.10.11"
75
+ }
76
+ }
@@ -0,0 +1,49 @@
1
+ export declare const ibcDenom: (paths: {
2
+ portId: string;
3
+ channelId: string;
4
+ }[], coinMinimalDenom: string) => string;
5
+ export interface IBCChainInfo {
6
+ "chain-name": string;
7
+ "client-id": string;
8
+ "connection-id": string;
9
+ }
10
+ export interface IBCChannelPortAndChannel {
11
+ "channel-id": string;
12
+ "port-id": string;
13
+ }
14
+ export interface IBCChannelInfo {
15
+ "chain-1": IBCChannelPortAndChannel;
16
+ "chain-2": IBCChannelPortAndChannel;
17
+ ordering: string;
18
+ version: string;
19
+ tags?: {
20
+ [key: string]: string;
21
+ };
22
+ }
23
+ export interface IBCInfo {
24
+ $schema: string;
25
+ "chain-1": IBCChainInfo;
26
+ "chain-2": IBCChainInfo;
27
+ channels: IBCChannelInfo[];
28
+ }
29
+ export declare const getIbcInfo: (ibc: IBCInfo[], chain: string, counterparty: string) => IBCInfo;
30
+ 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;
49
+ }[];