Skip to content

Commit

Permalink
Merge pull request #7 from cosmology-tech/transition-ibc-type
Browse files Browse the repository at this point in the history
Transition ibc type
  • Loading branch information
pyramation committed Aug 20, 2022
2 parents 98b728a + 9f4dfaa commit 191b1a5
Show file tree
Hide file tree
Showing 40 changed files with 11,045 additions and 6,560 deletions.
4 changes: 2 additions & 2 deletions packages/assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ npm install @chain-registry/assets
```

```js
import { ibc_assets } from '@chain-registry/assets';
const assetList = ibc_assets
import { asset_lists } from '@chain-registry/assets';
const assetList = asset_lists
.find(asset => asset.chain_name === 'osmosis');
```

Expand Down
5 changes: 3 additions & 2 deletions packages/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"build": "npm run build:module && npm run build:main",
"build:ts": "tsc --project ./tsconfig.json",
"buidl": "npm run build && npm run build:ts",
"build:pkg": "babel-node ./scripts/build.js",
"codegen": "babel-node ./scripts/build.js",
"prepare": "npm run build",
"lint": "eslint --ext .ts,.tsx,.js .",
"format": "eslint --fix . --ext .ts,.tsx,.js",
Expand Down Expand Up @@ -75,6 +75,7 @@
"typescript": "^4.7.3"
},
"dependencies": {
"@babel/runtime": "^7.18.3"
"@babel/runtime": "^7.18.3",
"@chain-registry/types": "^0.4.0"
}
}
17 changes: 11 additions & 6 deletions packages/assets/scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
import { getIbcAssets } from '@chain-registry/utils';
import { getAssetLists } from '@chain-registry/utils';
import { assets, ibc } from 'chain-registry';
import { writeFileSync } from 'fs';

const ibc_assets = assets.reduce((m, { chain_name }) => {
return [...m, ...getIbcAssets(chain_name, ibc, assets)];
const asset_lists = assets.reduce((m, { chain_name }) => {
return [...m, ...getAssetLists(chain_name, ibc, assets)];
}, []);

const write = (file, json) => {
const write = (file, json, TypeName, isArray = false) => {
const strfy = JSON.stringify(json, null, 2);
const exportType = isArray ? TypeName + '[]' : TypeName;
writeFileSync(
`${__dirname}/../src/${file}.ts`,
`export default ` + JSON.stringify(json, null, 2) + ';'
`import { ${TypeName} } from '@chain-registry/types';
const ${file}: ${exportType} = ${strfy};
export default ${file};
`
);
};

write(`ibc_assets`, ibc_assets);
write(`asset_lists`, asset_lists, 'AssetList', true);
Loading

0 comments on commit 191b1a5

Please sign in to comment.