Skip to content

Commit

Permalink
fix: preserve old info from the previous registry (#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikGul authored Oct 20, 2023
1 parent db86ecf commit 92cc3fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"scripts": {
"build": "substrate-exec-rimraf build/ && substrate-exec-tsc",
"start": "yarn build && node ./build/createRegistry.js",
"start": "yarn build && node ./build/src/createRegistry.js",
"lint": "substrate-dev-run-lint",
"lint:fix": "substrate-dev-run-lint --fix",
"deploy": "yarn build && npm publish"
Expand Down
8 changes: 8 additions & 0 deletions src/createRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ import {
import type { EndpointOption } from '@polkadot/apps-config/endpoints/types';
import fetch from 'node-fetch';

import FinalRegistry from '../registry.json';
import type {
AssetsInfo,
ChainInfoKeys,
ChainName,
ForeignAssetMetadata,
ForeignAssetsInfo,
Expand Down Expand Up @@ -119,6 +121,12 @@ const createChainRegistryFromParas = async (
endpoint.paraId as number
);
if (!reliable) {
// Add to registry if it exists
if (FinalRegistry[chainName][endpoint.paraId as number]) {
registry[chainName][`${endpoint.paraId as number}`] = FinalRegistry[
chainName
][endpoint.paraId as number] as ChainInfoKeys;
}
continue;
}
const res = await fetchChainInfo(endpoint);
Expand Down
17 changes: 10 additions & 7 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ export type TokenRegistry = {
rococo: ChainInfo;
};

export type ChainInfoKeys = {
tokens: string[];
assetsInfo: AssetsInfo;
specName: string;
foreignAssetsInfo: ForeignAssetsInfo;
poolPairsInfo: PoolPairsInfo;
xcAssetsData?: SanitizedXcAssetsData[];
};

export type ChainInfo = {
[key: string]: {
assetsInfo: AssetsInfo;
specName: string;
foreignAssetsInfo: ForeignAssetsInfo;
poolPairsInfo: PoolPairsInfo;
xcAssetsData?: SanitizedXcAssetsData[];
};
[key: string]: ChainInfoKeys;
};

export type PoolPairsInfo = {
Expand Down

0 comments on commit 92cc3fc

Please sign in to comment.