Skip to content

Commit

Permalink
fix export
Browse files Browse the repository at this point in the history
  • Loading branch information
Zetazzz committed Jan 31, 2024
1 parent 66d2ff0 commit 80c6273
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 9 deletions.
15 changes: 15 additions & 0 deletions packages/assets/examples/examples.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// backward compatibility: get asset_lists as before:
import { asset_lists } from '../src';

console.log(asset_lists);

// get mainnet asset lists only
import main_asset_lists from '../src/mainnet/assets';

console.log(main_asset_lists);

// get single assets
import assets from '../src/mainnet/akash';

console.log(assets);

13 changes: 10 additions & 3 deletions packages/assets/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ const writeRootAssets = (filePath, obj) => {
${importStat}
const assets: AssetList[] = [${validNetwork
const asset_lists: AssetList[] = [${validNetwork
.map((network_type) => {
return `..._${network_type}`;
})
.join(',')}];
export default assets;
export default asset_lists;
`
);

Expand All @@ -128,7 +128,14 @@ const writeRootIndex = (filePath, obj) => {
.filter(Boolean)
.join(';\n');

imports = `${imports}; export * from './asset_lists';`;
imports = `${imports}; import asset_lists from './asset_lists';
export default {
asset_lists
};
export { asset_lists };
`;

writeFileSync(filePath, `${imports}`);
};
Expand Down
4 changes: 2 additions & 2 deletions packages/assets/src/asset_lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ import _mainnet from './mainnet/assets';
import _testnet from './testnet/assets';
import _noncosmos from './noncosmos/assets';

const assets: AssetList[] = [..._mainnet, ..._testnet, ..._noncosmos];
const asset_lists: AssetList[] = [..._mainnet, ..._testnet, ..._noncosmos];

export default assets;
export default asset_lists;
8 changes: 7 additions & 1 deletion packages/assets/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export * from './mainnet';
export * from './testnet';
export * from './noncosmos';
export * from './asset_lists';
import asset_lists from './asset_lists';

export default {
asset_lists
};

export { asset_lists };
7 changes: 6 additions & 1 deletion packages/chain-registry/examples/examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import { akash, akashtestnet } from '../src';
console.log(akash.chain.apis, akashtestnet.chain.apis);

// backward compatibility using "all.ts": get all chains at once:
import { chains } from '../src/all';
import { chains as all_chains } from '../src/all';

console.log(all_chains.find((chain) => chain.chain_name === 'akash'));

// backward compatibility by default: get all chains at once:
import { chains } from '../src';

console.log(chains.find((chain) => chain.chain_name === 'akash'));

Expand Down
9 changes: 8 additions & 1 deletion packages/chain-registry/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,14 @@ const writeRootIndex = (filePath, obj) => {
.filter(Boolean)
.join(';\n');

imports = `${imports}; export * from './all';`;
imports = `${imports}; import all from './all';
export default all;
const { assets, chains, ibc }= all;
export { assets, chains, ibc };
`;

fs.writeFileSync(filePath, `${imports}`);
};
Expand Down
8 changes: 7 additions & 1 deletion packages/chain-registry/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ export * from './mainnet';
export * from './testnet';
export * from './devnet';
export * from './noncosmos';
export * from './all';
import all from './all';

export default all;

const { assets, chains, ibc } = all;

export { assets, chains, ibc };

0 comments on commit 80c6273

Please sign in to comment.