@chain-registry/utils 0.8.0 → 0.10.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 +16 -0
- package/README.md +6 -6
- package/main/registry.js +22 -21
- package/main/utils.js +11 -12
- package/package.json +24 -28
- package/types/registry.d.ts +8 -8
- package/module/index.js +0 -2
- package/module/registry.js +0 -216
- package/module/utils.js +0 -341
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.10.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.9.0...@chain-registry/utils@0.10.0) (2022-09-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @chain-registry/utils
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [0.9.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.8.0...@chain-registry/utils@0.9.0) (2022-09-16)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @chain-registry/utils
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [0.8.0](https://github.com/cosmology-tech/chain-registry/compare/@chain-registry/utils@0.7.3...@chain-registry/utils@0.8.0) (2022-09-14)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @chain-registry/utils
|
package/README.md
CHANGED
|
@@ -18,9 +18,9 @@ Utility functions for the chain-registry
|
|
|
18
18
|
## Usage
|
|
19
19
|
|
|
20
20
|
```js
|
|
21
|
-
import {
|
|
21
|
+
import { ChainRegistryFetcher, ChainRegistryFetcherOptions } from '@chain-registry/utils';
|
|
22
22
|
|
|
23
|
-
const options:
|
|
23
|
+
const options: ChainRegistryFetcherOptions = {
|
|
24
24
|
urls: [
|
|
25
25
|
'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/chain.json',
|
|
26
26
|
'https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/assetlist.json',
|
|
@@ -71,7 +71,7 @@ You can get generated `AssetList[]` objects directly from the `ChainRegistry` vi
|
|
|
71
71
|
```js
|
|
72
72
|
// you can also get generated assets from ChainInfo object
|
|
73
73
|
const chainInfo: Chain = registry.getChainInfo('osmosis');
|
|
74
|
-
const generatedAssets: AssetList[] = chainInfo.assetLists
|
|
74
|
+
const generatedAssets: AssetList[] = chainInfo.assetLists;
|
|
75
75
|
```
|
|
76
76
|
## Chain info
|
|
77
77
|
|
|
@@ -88,13 +88,13 @@ or get the `ChainInfo` object:
|
|
|
88
88
|
const chainInfo: ChainInfo = registry.getChainInfo('osmosis');
|
|
89
89
|
|
|
90
90
|
// AssetList[] of the generated assets
|
|
91
|
-
const assetes: AssetList[] = chainInfo.assetLists
|
|
91
|
+
const assetes: AssetList[] = chainInfo.assetLists;
|
|
92
92
|
|
|
93
93
|
// Chain
|
|
94
|
-
const chain: Chain = chainInfo.chain
|
|
94
|
+
const chain: Chain = chainInfo.chain;
|
|
95
95
|
|
|
96
96
|
// AssetList[] of the native assets
|
|
97
|
-
const assetes: AssetList[] = chainInfo.nativeAssetLists
|
|
97
|
+
const assetes: AssetList[] = chainInfo.nativeAssetLists;
|
|
98
98
|
```
|
|
99
99
|
|
|
100
100
|
## Credits
|
package/main/registry.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
8
|
+
exports.ChainRegistryFetcher = exports.ChainInfo = void 0;
|
|
9
9
|
|
|
10
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
11
|
|
|
@@ -37,22 +37,22 @@ var ChainInfo = /*#__PURE__*/function () {
|
|
|
37
37
|
function ChainInfo(options) {
|
|
38
38
|
(0, _classCallCheck2["default"])(this, ChainInfo);
|
|
39
39
|
(0, _defineProperty2["default"])(this, "chain_name", void 0);
|
|
40
|
-
(0, _defineProperty2["default"])(this, "
|
|
40
|
+
(0, _defineProperty2["default"])(this, "fetcher", void 0);
|
|
41
41
|
(0, _defineProperty2["default"])(this, "_asset_list", void 0);
|
|
42
42
|
(0, _defineProperty2["default"])(this, "_asset_lists", void 0);
|
|
43
43
|
(0, _defineProperty2["default"])(this, "_chain", void 0);
|
|
44
44
|
(0, _defineProperty2["default"])(this, "_ibc_data", []);
|
|
45
45
|
this.chain_name = options.chain_name;
|
|
46
|
-
this.
|
|
46
|
+
this.fetcher = options.fetcher;
|
|
47
47
|
this.refresh();
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
(0, _createClass2["default"])(ChainInfo, [{
|
|
51
51
|
key: "refresh",
|
|
52
52
|
value: function refresh() {
|
|
53
|
-
this._asset_list = this.
|
|
54
|
-
this._ibc_data = this.
|
|
55
|
-
this._chain = this.
|
|
53
|
+
this._asset_list = this.fetcher.getChainAssetList(this.chain_name);
|
|
54
|
+
this._ibc_data = this.fetcher.getChainIbcData(this.chain_name);
|
|
55
|
+
this._chain = this.fetcher.getChain(this.chain_name);
|
|
56
56
|
|
|
57
57
|
var supportedChains = this._ibc_data.reduce(function (m, v) {
|
|
58
58
|
if (!m.includes(v.chain_1.chain_name)) m.push(v.chain_1.chain_name);
|
|
@@ -60,35 +60,36 @@ var ChainInfo = /*#__PURE__*/function () {
|
|
|
60
60
|
return m;
|
|
61
61
|
}, []);
|
|
62
62
|
|
|
63
|
-
this._asset_lists = this.
|
|
63
|
+
this._asset_lists = this.fetcher.assetLists.filter(function (list) {
|
|
64
64
|
return supportedChains.includes(list.chain_name);
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
}, {
|
|
68
68
|
key: "nativeAssetLists",
|
|
69
|
-
|
|
69
|
+
get: function get() {
|
|
70
70
|
return this._asset_list;
|
|
71
71
|
}
|
|
72
72
|
}, {
|
|
73
73
|
key: "chain",
|
|
74
|
-
|
|
74
|
+
get: function get() {
|
|
75
75
|
return this._chain;
|
|
76
76
|
}
|
|
77
77
|
}, {
|
|
78
78
|
key: "assetLists",
|
|
79
|
-
|
|
79
|
+
get: function get() {
|
|
80
80
|
return (0, _utils.getAssetLists)(this.chain_name, this._ibc_data, this._asset_lists);
|
|
81
81
|
}
|
|
82
82
|
}]);
|
|
83
83
|
return ChainInfo;
|
|
84
|
-
}();
|
|
84
|
+
}(); // QUESTION: should ChainRegistryFetcher just be ChainRegistry?
|
|
85
|
+
|
|
85
86
|
|
|
86
87
|
exports.ChainInfo = ChainInfo;
|
|
87
88
|
|
|
88
|
-
var
|
|
89
|
-
function
|
|
89
|
+
var ChainRegistryFetcher = /*#__PURE__*/function () {
|
|
90
|
+
function ChainRegistryFetcher() {
|
|
90
91
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
91
|
-
(0, _classCallCheck2["default"])(this,
|
|
92
|
+
(0, _classCallCheck2["default"])(this, ChainRegistryFetcher);
|
|
92
93
|
(0, _defineProperty2["default"])(this, "_asset_lists", []);
|
|
93
94
|
(0, _defineProperty2["default"])(this, "_chains", []);
|
|
94
95
|
(0, _defineProperty2["default"])(this, "_ibc_data", []);
|
|
@@ -112,9 +113,9 @@ var ChainRegistry = /*#__PURE__*/function () {
|
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
|
|
115
|
-
(0, _createClass2["default"])(
|
|
116
|
+
(0, _createClass2["default"])(ChainRegistryFetcher, [{
|
|
116
117
|
key: "assetLists",
|
|
117
|
-
|
|
118
|
+
get: function get() {
|
|
118
119
|
return this._asset_lists;
|
|
119
120
|
}
|
|
120
121
|
}, {
|
|
@@ -131,7 +132,7 @@ var ChainRegistry = /*#__PURE__*/function () {
|
|
|
131
132
|
}
|
|
132
133
|
}, {
|
|
133
134
|
key: "chains",
|
|
134
|
-
|
|
135
|
+
get: function get() {
|
|
135
136
|
return this._chains;
|
|
136
137
|
}
|
|
137
138
|
}, {
|
|
@@ -143,7 +144,7 @@ var ChainRegistry = /*#__PURE__*/function () {
|
|
|
143
144
|
}
|
|
144
145
|
}, {
|
|
145
146
|
key: "ibcData",
|
|
146
|
-
|
|
147
|
+
get: function get() {
|
|
147
148
|
return this._ibc_data;
|
|
148
149
|
}
|
|
149
150
|
}, {
|
|
@@ -158,7 +159,7 @@ var ChainRegistry = /*#__PURE__*/function () {
|
|
|
158
159
|
value: function getChainInfo(chainName) {
|
|
159
160
|
return new ChainInfo({
|
|
160
161
|
chain_name: chainName,
|
|
161
|
-
|
|
162
|
+
fetcher: this
|
|
162
163
|
});
|
|
163
164
|
}
|
|
164
165
|
}, {
|
|
@@ -306,7 +307,7 @@ var ChainRegistry = /*#__PURE__*/function () {
|
|
|
306
307
|
return fetchUrls;
|
|
307
308
|
}()
|
|
308
309
|
}]);
|
|
309
|
-
return
|
|
310
|
+
return ChainRegistryFetcher;
|
|
310
311
|
}();
|
|
311
312
|
|
|
312
|
-
exports.
|
|
313
|
+
exports.ChainRegistryFetcher = ChainRegistryFetcher;
|
package/main/utils.js
CHANGED
|
@@ -119,17 +119,16 @@ var getIbcDenomByBase = function getIbcDenomByBase(ibc, chain, counterparty, ass
|
|
|
119
119
|
|
|
120
120
|
var traces = [];
|
|
121
121
|
|
|
122
|
-
if (assetInfo.ibc) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
});
|
|
122
|
+
if (assetInfo.ibc) {// traces.push({
|
|
123
|
+
// type: 'ibc',
|
|
124
|
+
// counterparty: {
|
|
125
|
+
// denom: assetInfo.ibc.source_denom,
|
|
126
|
+
// channel: assetInfo.ibc.source_channel
|
|
127
|
+
// },
|
|
128
|
+
// chain: {
|
|
129
|
+
// channel: assetInfo.ibc.dst_channel
|
|
130
|
+
// }
|
|
131
|
+
// });
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
if (assetInfo.traces && assetInfo.traces.length) {
|
|
@@ -353,7 +352,7 @@ var getCw20Assets = function getCw20Assets(chainName, ibc, assets) {
|
|
|
353
352
|
var assets = v.assets.map(function (asset) {
|
|
354
353
|
return _objectSpread(_objectSpread({}, asset), {}, {
|
|
355
354
|
traces: [{
|
|
356
|
-
type: 'ibc',
|
|
355
|
+
type: 'ibc-cw20',
|
|
357
356
|
counterparty: {
|
|
358
357
|
port: v.counterparty.port_id,
|
|
359
358
|
// source_channel
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chain-registry/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Chain Registry Utils",
|
|
5
5
|
"author": "Dan Lynch <pyramation@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/cosmology-tech/chain-registry",
|
|
7
7
|
"license": "SEE LICENSE IN LICENSE",
|
|
8
8
|
"main": "main/index.js",
|
|
9
|
-
"module": "module/index.js",
|
|
10
9
|
"typings": "types/index.d.ts",
|
|
11
10
|
"directories": {
|
|
12
11
|
"lib": "src",
|
|
@@ -14,13 +13,10 @@
|
|
|
14
13
|
},
|
|
15
14
|
"files": [
|
|
16
15
|
"types",
|
|
17
|
-
"main"
|
|
18
|
-
"module"
|
|
16
|
+
"main"
|
|
19
17
|
],
|
|
20
18
|
"scripts": {
|
|
21
|
-
"build
|
|
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",
|
|
19
|
+
"build": "cross-env BABEL_ENV=production babel src --out-dir main --delete-dir-on-start --extensions \".tsx,.ts,.js\"",
|
|
24
20
|
"build:ts": "tsc --project ./tsconfig.json",
|
|
25
21
|
"buidl": "npm run build && npm run build:ts",
|
|
26
22
|
"prepare": "npm run build",
|
|
@@ -45,42 +41,42 @@
|
|
|
45
41
|
"url": "https://github.com/cosmology-tech/chain-registry/issues"
|
|
46
42
|
},
|
|
47
43
|
"devDependencies": {
|
|
48
|
-
"@babel/cli": "7.
|
|
49
|
-
"@babel/core": "7.
|
|
50
|
-
"@babel/eslint-parser": "^7.
|
|
51
|
-
"@babel/node": "^7.
|
|
52
|
-
"@babel/plugin-proposal-class-properties": "7.
|
|
53
|
-
"@babel/plugin-proposal-export-default-from": "7.
|
|
54
|
-
"@babel/plugin-proposal-object-rest-spread": "7.18.
|
|
55
|
-
"@babel/plugin-transform-runtime": "7.
|
|
56
|
-
"@babel/preset-env": "7.
|
|
44
|
+
"@babel/cli": "7.18.10",
|
|
45
|
+
"@babel/core": "7.19.1",
|
|
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.18.9",
|
|
51
|
+
"@babel/plugin-transform-runtime": "7.19.1",
|
|
52
|
+
"@babel/preset-env": "7.19.1",
|
|
57
53
|
"@babel/preset-typescript": "^7.17.12",
|
|
58
|
-
"@types/jest": "^
|
|
54
|
+
"@types/jest": "^29.0.2",
|
|
59
55
|
"@types/sha.js": "^2.4.0",
|
|
60
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
61
|
-
"@typescript-eslint/parser": "5.
|
|
56
|
+
"@typescript-eslint/eslint-plugin": "5.37.0",
|
|
57
|
+
"@typescript-eslint/parser": "5.37.0",
|
|
62
58
|
"babel-core": "7.0.0-bridge.0",
|
|
63
|
-
"babel-jest": "
|
|
59
|
+
"babel-jest": "29.0.3",
|
|
64
60
|
"babel-watch": "^7.0.0",
|
|
65
61
|
"cross-env": "^7.0.2",
|
|
66
|
-
"eslint": "8.
|
|
62
|
+
"eslint": "8.23.1",
|
|
67
63
|
"eslint-config-prettier": "^8.5.0",
|
|
68
64
|
"eslint-plugin-prettier": "^4.0.0",
|
|
69
|
-
"eslint-plugin-simple-import-sort": "
|
|
65
|
+
"eslint-plugin-simple-import-sort": "8.0.0",
|
|
70
66
|
"eslint-plugin-unused-imports": "2.0.0",
|
|
71
|
-
"jest": "^
|
|
67
|
+
"jest": "^29.0.3",
|
|
72
68
|
"long": "^5.2.0",
|
|
73
69
|
"prettier": "^2.7.0",
|
|
74
70
|
"regenerator-runtime": "^0.13.7",
|
|
75
|
-
"ts-jest": "^
|
|
76
|
-
"typescript": "^4.
|
|
71
|
+
"ts-jest": "^29.0.1",
|
|
72
|
+
"typescript": "^4.8.3"
|
|
77
73
|
},
|
|
78
74
|
"dependencies": {
|
|
79
|
-
"@babel/runtime": "^7.
|
|
80
|
-
"@chain-registry/types": "^0.
|
|
75
|
+
"@babel/runtime": "^7.19.0",
|
|
76
|
+
"@chain-registry/types": "^0.10.0",
|
|
81
77
|
"bfs-path": "^1.0.2",
|
|
82
78
|
"cross-fetch": "^3.1.5",
|
|
83
79
|
"sha.js": "^2.4.11"
|
|
84
80
|
},
|
|
85
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "85c4d099a79b176a95e488af82b4b6b365c03732"
|
|
86
82
|
}
|
package/types/registry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetList, Chain, IBCInfo } from '@chain-registry/types';
|
|
1
|
+
import { AssetList, Chain, ChainRegistry, IBCInfo } from '@chain-registry/types';
|
|
2
2
|
export interface ChainRegistryOptions {
|
|
3
3
|
assetLists?: AssetList[];
|
|
4
4
|
chains?: Chain[];
|
|
@@ -18,22 +18,22 @@ export declare class ChainInfo {
|
|
|
18
18
|
protected _ibc_data: IBCInfo[];
|
|
19
19
|
constructor(options: ChainInfoOptions);
|
|
20
20
|
refresh(): void;
|
|
21
|
-
nativeAssetLists(): AssetList;
|
|
22
|
-
chain(): Chain;
|
|
23
|
-
assetLists(): any[];
|
|
21
|
+
get nativeAssetLists(): AssetList;
|
|
22
|
+
get chain(): Chain;
|
|
23
|
+
get assetLists(): any[];
|
|
24
24
|
}
|
|
25
|
-
export declare class ChainRegistry {
|
|
25
|
+
export declare class ChainRegistryFetcher implements ChainRegistry {
|
|
26
26
|
protected _asset_lists: AssetList[];
|
|
27
27
|
protected _chains: Chain[];
|
|
28
28
|
protected _ibc_data: IBCInfo[];
|
|
29
29
|
urls: string[];
|
|
30
30
|
constructor(options?: ChainRegistryOptions);
|
|
31
|
-
assetLists(): AssetList[];
|
|
31
|
+
get assetLists(): AssetList[];
|
|
32
32
|
getChainAssetList(chainName: string): AssetList;
|
|
33
33
|
getGeneratedAssetLists(chainName: string): AssetList[];
|
|
34
|
-
chains(): Chain[];
|
|
34
|
+
get chains(): Chain[];
|
|
35
35
|
getChain(chainName: string): Chain;
|
|
36
|
-
ibcData(): IBCInfo[];
|
|
36
|
+
get ibcData(): IBCInfo[];
|
|
37
37
|
getChainIbcData(chainName: string): IBCInfo[];
|
|
38
38
|
getChainInfo(chainName: string): ChainInfo;
|
|
39
39
|
upsertChain(data: Chain): void;
|
package/module/index.js
DELETED
package/module/registry.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { basename } from 'bfs-path';
|
|
3
|
-
import fetch from 'cross-fetch';
|
|
4
|
-
import { getAssetLists } from './utils';
|
|
5
|
-
|
|
6
|
-
const fetchUrl = url => {
|
|
7
|
-
return fetch(url).then(res => {
|
|
8
|
-
if (res.status >= 400) {
|
|
9
|
-
throw new Error('Bad response');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return res.json();
|
|
13
|
-
});
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export class ChainInfo {
|
|
17
|
-
constructor(options) {
|
|
18
|
-
_defineProperty(this, "chain_name", void 0);
|
|
19
|
-
|
|
20
|
-
_defineProperty(this, "registry", void 0);
|
|
21
|
-
|
|
22
|
-
_defineProperty(this, "_asset_list", void 0);
|
|
23
|
-
|
|
24
|
-
_defineProperty(this, "_asset_lists", void 0);
|
|
25
|
-
|
|
26
|
-
_defineProperty(this, "_chain", void 0);
|
|
27
|
-
|
|
28
|
-
_defineProperty(this, "_ibc_data", []);
|
|
29
|
-
|
|
30
|
-
this.chain_name = options.chain_name;
|
|
31
|
-
this.registry = options.registry;
|
|
32
|
-
this.refresh();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
refresh() {
|
|
36
|
-
this._asset_list = this.registry.getChainAssetList(this.chain_name);
|
|
37
|
-
this._ibc_data = this.registry.getChainIbcData(this.chain_name);
|
|
38
|
-
this._chain = this.registry.getChain(this.chain_name);
|
|
39
|
-
|
|
40
|
-
const supportedChains = this._ibc_data.reduce((m, v) => {
|
|
41
|
-
if (!m.includes(v.chain_1.chain_name)) m.push(v.chain_1.chain_name);
|
|
42
|
-
if (!m.includes(v.chain_2.chain_name)) m.push(v.chain_2.chain_name);
|
|
43
|
-
return m;
|
|
44
|
-
}, []);
|
|
45
|
-
|
|
46
|
-
this._asset_lists = this.registry.assetLists().filter(list => supportedChains.includes(list.chain_name));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
nativeAssetLists() {
|
|
50
|
-
return this._asset_list;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
chain() {
|
|
54
|
-
return this._chain;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
assetLists() {
|
|
58
|
-
return getAssetLists(this.chain_name, this._ibc_data, this._asset_lists);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
export class ChainRegistry {
|
|
63
|
-
constructor(options = {}) {
|
|
64
|
-
_defineProperty(this, "_asset_lists", []);
|
|
65
|
-
|
|
66
|
-
_defineProperty(this, "_chains", []);
|
|
67
|
-
|
|
68
|
-
_defineProperty(this, "_ibc_data", []);
|
|
69
|
-
|
|
70
|
-
_defineProperty(this, "urls", []);
|
|
71
|
-
|
|
72
|
-
//
|
|
73
|
-
if (options.assetLists) {
|
|
74
|
-
this._asset_lists = options.assetLists;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (options.chains) {
|
|
78
|
-
this._chains = options.chains;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (options.ibcData) {
|
|
82
|
-
this._ibc_data = options.ibcData;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (options.urls) {
|
|
86
|
-
this.urls = options.urls;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
assetLists() {
|
|
91
|
-
return this._asset_lists;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
getChainAssetList(chainName) {
|
|
95
|
-
return this._asset_lists.find(list => list.chain_name === chainName);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
getGeneratedAssetLists(chainName) {
|
|
99
|
-
return getAssetLists(chainName, this._ibc_data, this._asset_lists);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
chains() {
|
|
103
|
-
return this._chains;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
getChain(chainName) {
|
|
107
|
-
return this._chains.find(chain => chain.chain_name === chainName);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
ibcData() {
|
|
111
|
-
return this._ibc_data;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
getChainIbcData(chainName) {
|
|
115
|
-
return this._ibc_data.filter(info => info.chain_1.chain_name === chainName || info.chain_2.chain_name === chainName);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
getChainInfo(chainName) {
|
|
119
|
-
return new ChainInfo({
|
|
120
|
-
chain_name: chainName,
|
|
121
|
-
registry: this
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
upsertChain(data) {
|
|
126
|
-
const found = this._chains.find(chain => {
|
|
127
|
-
return chain.chain_name === data.chain_name && chain.network_type === data.network_type;
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
if (!found) {
|
|
131
|
-
this._chains.push(data);
|
|
132
|
-
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
this._chains = this._chains.map(chain => {
|
|
137
|
-
if (chain.chain_name === data.chain_name && chain.network_type === data.network_type) {
|
|
138
|
-
return data;
|
|
139
|
-
} else {
|
|
140
|
-
return chain;
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
updateAssetList(data) {
|
|
146
|
-
const found = this._asset_lists.find(list => {
|
|
147
|
-
return list.chain_name === data.chain_name;
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
if (!found) {
|
|
151
|
-
this._asset_lists.push(data);
|
|
152
|
-
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
this._asset_lists = this._asset_lists.map(list => {
|
|
157
|
-
if (list.chain_name === data.chain_name) {
|
|
158
|
-
return data;
|
|
159
|
-
} else {
|
|
160
|
-
return list;
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
upsertIbcData(data) {
|
|
166
|
-
const found = this._ibc_data.find(info => {
|
|
167
|
-
return info.chain_1.chain_name === data.chain_1.chain_name && info.chain_2.chain_name === data.chain_2.chain_name;
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
if (!found) {
|
|
171
|
-
this._ibc_data.push(data);
|
|
172
|
-
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
this._ibc_data = this._ibc_data.map(info => {
|
|
177
|
-
if (info.chain_1.chain_name === data.chain_1.chain_name && info.chain_2.chain_name === data.chain_2.chain_name) {
|
|
178
|
-
return data;
|
|
179
|
-
} else {
|
|
180
|
-
return info;
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
update(data) {
|
|
186
|
-
if (!data.$schema) throw new Error('not a registered JSON schema type');
|
|
187
|
-
const type = basename(data.$schema, '.schema.json');
|
|
188
|
-
|
|
189
|
-
switch (type) {
|
|
190
|
-
case 'chain':
|
|
191
|
-
this.upsertChain(data);
|
|
192
|
-
break;
|
|
193
|
-
|
|
194
|
-
case 'assetlist':
|
|
195
|
-
this.updateAssetList(data);
|
|
196
|
-
break;
|
|
197
|
-
|
|
198
|
-
case 'ibc_data':
|
|
199
|
-
this.upsertIbcData(data);
|
|
200
|
-
break;
|
|
201
|
-
|
|
202
|
-
default:
|
|
203
|
-
throw new Error('unknown schema type');
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
async fetch(url) {
|
|
208
|
-
const data = await fetchUrl(url);
|
|
209
|
-
this.update(data);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
async fetchUrls() {
|
|
213
|
-
return Promise.all(this.urls.map(url => this.fetch(url)));
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
}
|
package/module/utils.js
DELETED
|
@@ -1,341 +0,0 @@
|
|
|
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
|
-
import { sha256 } from 'sha.js';
|
|
8
|
-
export const ibcDenom = (paths, coinMinimalDenom) => {
|
|
9
|
-
const prefixes = [];
|
|
10
|
-
|
|
11
|
-
for (const path of paths) {
|
|
12
|
-
prefixes.push(`${path.portId}/${path.channelId}`);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const prefix = prefixes.join('/');
|
|
16
|
-
const denom = `${prefix}/${coinMinimalDenom}`;
|
|
17
|
-
return 'ibc/' + Buffer.from(new Uint8Array(new sha256().update(Buffer.from(denom)).digest())).toString('hex').toUpperCase();
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const findInfo = (ibc, to, from) => ibc.find(i => i.chain_1.chain_name === from && i.chain_2.chain_name === to);
|
|
21
|
-
|
|
22
|
-
export const getIbcInfo = (ibc, chain, counterparty) => {
|
|
23
|
-
return findInfo(ibc, chain, counterparty) || findInfo(ibc, counterparty, chain);
|
|
24
|
-
};
|
|
25
|
-
export const getTransferChannel = info => {
|
|
26
|
-
return info.channels.find(channel => channel.chain_1.port_id === 'transfer' && channel.chain_2.port_id === 'transfer');
|
|
27
|
-
};
|
|
28
|
-
export const getNonTransferChannel = info => {
|
|
29
|
-
return info.channels.find(channel => channel.chain_1.port_id !== 'transfer' && channel.chain_2.port_id === 'transfer' || channel.chain_1.port_id === 'transfer' && channel.chain_2.port_id !== 'transfer');
|
|
30
|
-
};
|
|
31
|
-
export const getWasmChannel = info => {
|
|
32
|
-
return info.channels.find(channel => channel.chain_1.port_id.startsWith('wasm.') && channel.chain_2.port_id === 'transfer' || channel.chain_1.port_id === 'transfer' && channel.chain_2.port_id.startsWith('wasm'));
|
|
33
|
-
};
|
|
34
|
-
export const getIbcDenomByBase = (ibc, chain, counterparty, assets, base) => {
|
|
35
|
-
const ibcInfo = getIbcInfo(ibc, chain, counterparty);
|
|
36
|
-
|
|
37
|
-
if (ibcInfo) {
|
|
38
|
-
const channel = getTransferChannel(ibcInfo);
|
|
39
|
-
|
|
40
|
-
if (!channel) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
let channelInfo;
|
|
45
|
-
|
|
46
|
-
if (ibcInfo.chain_1.chain_name === chain) {
|
|
47
|
-
channelInfo = channel.chain_1;
|
|
48
|
-
} else {
|
|
49
|
-
channelInfo = channel.chain_2;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const assetList = assets.find(({
|
|
53
|
-
chain_name
|
|
54
|
-
}) => chain_name === counterparty);
|
|
55
|
-
|
|
56
|
-
if (!assetList) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const assetInfo = assetList.assets.find(asset => {
|
|
61
|
-
return asset.base === base;
|
|
62
|
-
}); // if (!assetInfo) {
|
|
63
|
-
// console.warn('missing referrenced asset');
|
|
64
|
-
// }
|
|
65
|
-
// TODO transition later!
|
|
66
|
-
|
|
67
|
-
const traces = [];
|
|
68
|
-
|
|
69
|
-
if (assetInfo.ibc) {
|
|
70
|
-
traces.push({
|
|
71
|
-
type: 'ibc',
|
|
72
|
-
counterparty: {
|
|
73
|
-
denom: assetInfo.ibc.source_denom,
|
|
74
|
-
channel: assetInfo.ibc.source_channel
|
|
75
|
-
},
|
|
76
|
-
chain: {
|
|
77
|
-
channel: assetInfo.ibc.dst_channel
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (assetInfo.traces && assetInfo.traces.length) {
|
|
83
|
-
[].push.apply(traces, assetInfo.traces);
|
|
84
|
-
} // console.log(transition);
|
|
85
|
-
// if (transition.length) {
|
|
86
|
-
// return ibcDenom(
|
|
87
|
-
// [
|
|
88
|
-
// {
|
|
89
|
-
// portId: 'transfer',
|
|
90
|
-
// channelId: assetInfo.ibc.source_channel
|
|
91
|
-
// },
|
|
92
|
-
// {
|
|
93
|
-
// portId: channelInfo.port_id,
|
|
94
|
-
// channelId: channelInfo.channel_id
|
|
95
|
-
// }
|
|
96
|
-
// ],
|
|
97
|
-
// base
|
|
98
|
-
// );
|
|
99
|
-
// }
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return ibcDenom([{
|
|
103
|
-
portId: channelInfo.port_id,
|
|
104
|
-
channelId: channelInfo.channel_id
|
|
105
|
-
}], base);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
export const getIbcDenomByBaseForCw20 = (ibc, chain, counterparty, assets, base) => {
|
|
109
|
-
const ibcInfo = getIbcInfo(ibc, chain, counterparty);
|
|
110
|
-
|
|
111
|
-
if (ibcInfo) {
|
|
112
|
-
const channel = getWasmChannel(ibcInfo);
|
|
113
|
-
|
|
114
|
-
if (!channel) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
let channelInfo;
|
|
119
|
-
|
|
120
|
-
if (ibcInfo.chain_1.chain_name === chain) {
|
|
121
|
-
channelInfo = channel.chain_1;
|
|
122
|
-
} else {
|
|
123
|
-
channelInfo = channel.chain_2;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const assetInfo = assets.find(({
|
|
127
|
-
chain_name
|
|
128
|
-
}) => chain_name === counterparty);
|
|
129
|
-
|
|
130
|
-
if (!assetInfo) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return ibcDenom([{
|
|
135
|
-
portId: channelInfo.port_id,
|
|
136
|
-
channelId: channelInfo.channel_id
|
|
137
|
-
}], base);
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
export const getIbcAssets = (chainName, ibc, assets) => {
|
|
141
|
-
const chainIbcInfo = ibc.filter(i => {
|
|
142
|
-
return i.chain_1.chain_name === chainName || i.chain_2.chain_name === chainName;
|
|
143
|
-
});
|
|
144
|
-
const ibcAssetLists = chainIbcInfo.map(ibcInfo => {
|
|
145
|
-
const counterpartyIs = ibcInfo.chain_1.chain_name === chainName ? 'chain_2' : 'chain_1';
|
|
146
|
-
const chainIs = ibcInfo.chain_1.chain_name === chainName ? 'chain_1' : 'chain_2';
|
|
147
|
-
const counterparty = ibcInfo[counterpartyIs].chain_name;
|
|
148
|
-
const counterpartyIbc = ibcInfo[counterpartyIs];
|
|
149
|
-
const chainIbc = ibcInfo[chainIs];
|
|
150
|
-
const counterpartyAssets = assets.find(a => {
|
|
151
|
-
return a.chain_name === counterparty;
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
if (!counterpartyAssets) {
|
|
155
|
-
// console.warn('asset not found: ' + counterparty);
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const ibcAssets = counterpartyAssets.assets.filter(a => !a.base.startsWith('cw20:')).map(asset => {
|
|
160
|
-
const denom = getIbcDenomByBase(ibc, chainName, counterparty, //
|
|
161
|
-
assets, asset.base);
|
|
162
|
-
|
|
163
|
-
const newAsset = _objectSpread({}, asset);
|
|
164
|
-
|
|
165
|
-
newAsset.base = denom;
|
|
166
|
-
newAsset.denom_units = newAsset.denom_units.map(unit => {
|
|
167
|
-
if (unit.denom === asset.base) {
|
|
168
|
-
const newUnit = _objectSpread({}, unit);
|
|
169
|
-
|
|
170
|
-
newUnit.denom = denom;
|
|
171
|
-
newUnit.aliases = [unit.denom];
|
|
172
|
-
return newUnit;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return unit;
|
|
176
|
-
});
|
|
177
|
-
return newAsset;
|
|
178
|
-
});
|
|
179
|
-
const channel = getTransferChannel(ibcInfo);
|
|
180
|
-
return {
|
|
181
|
-
chain: _objectSpread(_objectSpread({}, chainIbc), channel[chainIs]),
|
|
182
|
-
counterparty: _objectSpread(_objectSpread({}, counterpartyIbc), channel[counterpartyIs]),
|
|
183
|
-
assets: ibcAssets
|
|
184
|
-
};
|
|
185
|
-
}).filter(Boolean);
|
|
186
|
-
const hash = ibcAssetLists.reduce((m, v) => {
|
|
187
|
-
m[v.chain.chain_name] = m[v.chain.chain_name] || [];
|
|
188
|
-
const assets = v.assets.map(asset => {
|
|
189
|
-
return _objectSpread(_objectSpread({}, asset), {}, {
|
|
190
|
-
traces: [{
|
|
191
|
-
type: 'ibc',
|
|
192
|
-
counterparty: {
|
|
193
|
-
// source_channel
|
|
194
|
-
channel: v.counterparty.channel_id,
|
|
195
|
-
// source_denom
|
|
196
|
-
denom: asset.denom_units[0].aliases[0],
|
|
197
|
-
chain_name: v.counterparty.chain_name // port: v.counterparty.port_id
|
|
198
|
-
|
|
199
|
-
},
|
|
200
|
-
chain: {
|
|
201
|
-
// dst_denom
|
|
202
|
-
channel: v.chain.channel_id // chain_name: v.chain.chain_name,
|
|
203
|
-
// port: v.chain.port_id
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
}]
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
const obj = _objectSpread(_objectSpread({}, v), {}, {
|
|
211
|
-
assets
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
m[v.chain.chain_name].push(obj);
|
|
215
|
-
return m;
|
|
216
|
-
}, {});
|
|
217
|
-
return Object.keys(hash).map(chain => {
|
|
218
|
-
return {
|
|
219
|
-
chain_name: chain,
|
|
220
|
-
assets: hash[chain].reduce((m, v) => {
|
|
221
|
-
return [...m, ...v.assets];
|
|
222
|
-
}, [])
|
|
223
|
-
};
|
|
224
|
-
});
|
|
225
|
-
};
|
|
226
|
-
export const getCw20Assets = (chainName, ibc, assets) => {
|
|
227
|
-
const chainIbcInfo = ibc.filter(i => {
|
|
228
|
-
return i.chain_1.chain_name === chainName || i.chain_2.chain_name === chainName;
|
|
229
|
-
});
|
|
230
|
-
const cw20AssetLists = chainIbcInfo.map(ibcInfo => {
|
|
231
|
-
const counterpartyIs = ibcInfo.chain_1.chain_name === chainName ? 'chain_2' : 'chain_1';
|
|
232
|
-
const chainIs = ibcInfo.chain_1.chain_name === chainName ? 'chain_1' : 'chain_2';
|
|
233
|
-
const counterparty = ibcInfo[counterpartyIs].chain_name;
|
|
234
|
-
const counterpartyIbc = ibcInfo[counterpartyIs];
|
|
235
|
-
const chainIbc = ibcInfo[chainIs];
|
|
236
|
-
const counterpartyAssets = assets.find(a => {
|
|
237
|
-
return a.chain_name === counterparty;
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
if (!counterpartyAssets) {
|
|
241
|
-
// console.warn('asset not found: ' + counterparty);
|
|
242
|
-
return;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
const cw20Assets = counterpartyAssets.assets.filter(a => a.base.startsWith('cw20:')).map(asset => {
|
|
246
|
-
const denom = getIbcDenomByBaseForCw20(ibc, chainName, counterparty, //
|
|
247
|
-
assets, asset.base);
|
|
248
|
-
|
|
249
|
-
const newAsset = _objectSpread({}, asset);
|
|
250
|
-
|
|
251
|
-
newAsset.base = denom;
|
|
252
|
-
newAsset.denom_units = newAsset.denom_units.map(unit => {
|
|
253
|
-
if (unit.denom === asset.base) {
|
|
254
|
-
const newUnit = _objectSpread({}, unit);
|
|
255
|
-
|
|
256
|
-
newUnit.denom = denom;
|
|
257
|
-
newUnit.aliases = [unit.denom];
|
|
258
|
-
return newUnit;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
return unit;
|
|
262
|
-
});
|
|
263
|
-
return newAsset;
|
|
264
|
-
});
|
|
265
|
-
if (!cw20Assets.length) return;
|
|
266
|
-
const channel = getWasmChannel(ibcInfo);
|
|
267
|
-
|
|
268
|
-
if (!channel) {
|
|
269
|
-
// console.warn(
|
|
270
|
-
// chainIbc.chain_name,
|
|
271
|
-
// '<>',
|
|
272
|
-
// counterpartyIbc.chain_name,
|
|
273
|
-
// 'MISSING cw20 IBC info'
|
|
274
|
-
// );
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return {
|
|
279
|
-
chain: _objectSpread(_objectSpread({}, chainIbc), channel[chainIs]),
|
|
280
|
-
counterparty: _objectSpread(_objectSpread({}, counterpartyIbc), channel[counterpartyIs]),
|
|
281
|
-
assets: cw20Assets
|
|
282
|
-
};
|
|
283
|
-
}).filter(Boolean);
|
|
284
|
-
const hash = cw20AssetLists.reduce((m, v) => {
|
|
285
|
-
m[v.chain.chain_name] = m[v.chain.chain_name] || [];
|
|
286
|
-
const assets = v.assets.map(asset => {
|
|
287
|
-
return _objectSpread(_objectSpread({}, asset), {}, {
|
|
288
|
-
traces: [{
|
|
289
|
-
type: 'ibc',
|
|
290
|
-
counterparty: {
|
|
291
|
-
port: v.counterparty.port_id,
|
|
292
|
-
// source_channel
|
|
293
|
-
channel: v.counterparty.channel_id,
|
|
294
|
-
// source_denom
|
|
295
|
-
denom: asset.denom_units[0].aliases[0],
|
|
296
|
-
chain_name: v.counterparty.chain_name
|
|
297
|
-
},
|
|
298
|
-
chain: {
|
|
299
|
-
// dst_denom
|
|
300
|
-
port: v.chain.port_id,
|
|
301
|
-
channel: v.chain.channel_id // chain_name: v.chain.chain_name,
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
}]
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
const obj = _objectSpread(_objectSpread({}, v), {}, {
|
|
309
|
-
assets
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
m[v.chain.chain_name].push(obj);
|
|
313
|
-
return m;
|
|
314
|
-
}, {});
|
|
315
|
-
return Object.keys(hash).map(chain => {
|
|
316
|
-
return {
|
|
317
|
-
chain_name: chain,
|
|
318
|
-
assets: hash[chain].reduce((m, v) => {
|
|
319
|
-
return [...m, ...v.assets];
|
|
320
|
-
}, [])
|
|
321
|
-
};
|
|
322
|
-
});
|
|
323
|
-
};
|
|
324
|
-
export const getAssetLists = (chainName, ibc, assets) => {
|
|
325
|
-
const ibcAssetLists = getIbcAssets(chainName, ibc, assets);
|
|
326
|
-
const cw20Assets = getCw20Assets(chainName, ibc, assets);
|
|
327
|
-
return ibcAssetLists.reduce((m, v) => {
|
|
328
|
-
const chain = v.chain_name;
|
|
329
|
-
const assets = [...v.assets];
|
|
330
|
-
const cw20 = cw20Assets.find(a => a.chain_name === chain);
|
|
331
|
-
|
|
332
|
-
if (cw20) {
|
|
333
|
-
[].push.apply(assets, cw20.assets);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
return [{
|
|
337
|
-
chain_name: chain,
|
|
338
|
-
assets
|
|
339
|
-
}, ...m];
|
|
340
|
-
}, []);
|
|
341
|
-
};
|