Skip to content

Commit e2eaea2

Browse files
authored
chore: update registry (#173)
1 parent ce22c6d commit e2eaea2

File tree

6 files changed

+1099
-630
lines changed

6 files changed

+1099
-630
lines changed

docs/registry.json

Lines changed: 345 additions & 25 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"author": "Parity Technologies <admin@parity.io>",
2626
"license": "Apache-2.0",
2727
"devDependencies": {
28-
"@polkadot/api": "^14.0.1",
29-
"@polkadot/apps-config": "^0.145.1",
28+
"@polkadot/api": "^15.2.1",
29+
"@polkadot/apps-config": "^0.147.1",
3030
"@substrate/dev": "0.7.1",
3131
"@types/node-fetch": "^2.6.9",
3232
"node-fetch": "2.6.7",

src/consts.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ export const XC_ASSET_CDN_URL =
1919
'https://cdn.jsdelivr.net/gh/colorfulnotion/xcm-global-registry/metadata/xcmgar.json';
2020

2121
export const RPC_BLACK_LIST = [
22+
'wss://polkadot-rpc.publicnode.com',
23+
'wss://api2.zondax.ch/pas/node/rpc',
24+
'wss://heiko-rpc.parallel.fi',
25+
'wss://public-01.mainnet.bifrostnetwork.com/wss',
26+
'wss://public-02.mainnet.bifrostnetwork.com/wss',
27+
'wss://polkadex.public.curie.radiumblock.co/ws',
28+
'wss://public-01.testnet.bifrostnetwork.com/wss',
29+
'wss://public-02.testnet.bifrostnetwork.com/wss',
30+
'wss://parachain-rpc.origin-trail.network',
31+
'wss://polkadot-parallel-rpc.parallel.fi',
32+
'wss://tinkernet-rpc.dwellir.com',
33+
'wss://khala.api.onfinality.io/public-ws',
34+
'wss://chainflip-rpc.dwellir.com',
35+
'wss://khala.public.curie.radiumblock.co/ws',
2236
'wss://polkadot-public-rpc.blockops.network/ws',
2337
'wss://kusama-public-rpc.blockops.network/ws',
2438
'wss://westend-rpc.blockops.network/ws',

src/fetchSystemParachainForeignAssetInfo.ts

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,45 +25,48 @@ export const fetchSystemParachainForeignAssetInfo = async (
2525
if (api.query.foreignAssets !== undefined) {
2626
const assetEntries = await api.query.foreignAssets.asset.entries();
2727

28-
for (const [assetStorageKeyData] of assetEntries) {
29-
const foreignAssetData = assetStorageKeyData.toHuman();
30-
31-
if (foreignAssetData) {
32-
// remove any commas from multilocation key values e.g. Parachain: 2,125 -> Parachain: 2125
33-
const foreignAssetMultiLocationStr = JSON.stringify(
34-
foreignAssetData[0],
35-
).replace(/(\d),/g, '$1');
28+
let foreignAssetMultiLocationStr: string | undefined = undefined;
29+
for (const asset of assetEntries) {
30+
const storageKey = asset[0].toHuman();
31+
if (storageKey && Array.isArray(storageKey) && storageKey.length > 0) {
32+
foreignAssetMultiLocationStr = JSON.stringify(storageKey[0]).replace(
33+
/(\d),/g,
34+
'$1',
35+
);
36+
}
37+
if (!foreignAssetMultiLocationStr) {
38+
throw new Error('Unable to determine asset location');
39+
}
3640

37-
const foreignAssetMultiLocation = JSON.parse(
38-
foreignAssetMultiLocationStr,
39-
) as UnionXcmMultiLocation;
41+
const foreignAssetMultiLocation = JSON.parse(
42+
foreignAssetMultiLocationStr,
43+
) as UnionXcmMultiLocation;
4044

41-
const hexId = stringToHex(JSON.stringify(foreignAssetMultiLocation));
45+
const hexId = stringToHex(JSON.stringify(foreignAssetMultiLocation));
4246

43-
const assetMetadata = (
44-
await api.query.foreignAssets.metadata(foreignAssetMultiLocation)
45-
).toHuman();
47+
const assetMetadata = (
48+
await api.query.foreignAssets.metadata(foreignAssetMultiLocation)
49+
).toHuman();
4650

47-
if (assetMetadata) {
48-
const metadata = assetMetadata as ForeignAssetMetadata;
49-
const assetSymbol = metadata.symbol;
50-
const assetName = metadata.name;
51+
if (assetMetadata) {
52+
const metadata = assetMetadata as ForeignAssetMetadata;
53+
const assetSymbol = metadata.symbol;
54+
const assetName = metadata.name;
5155

52-
// if the symbol exists in metadata use it, otherwise uses the hex of the multilocation as the key
53-
const foreignAssetInfoKey = assetSymbol ? assetSymbol : hexId;
54-
const assetLocation = JSON.stringify(foreignAssetMultiLocation);
56+
// if the symbol exists in metadata use it, otherwise uses the hex of the multilocation as the key
57+
const foreignAssetInfoKey = assetSymbol ? assetSymbol : hexId;
58+
const assetLocation = JSON.stringify(foreignAssetMultiLocation);
5559

56-
const [assetHubReserveLocation, originChainReserveLocation] =
57-
getAssetReserveLocations(assetLocation, chainId);
60+
const [assetHubReserveLocation, originChainReserveLocation] =
61+
getAssetReserveLocations(assetLocation, chainId);
5862

59-
foreignAssetsInfo[foreignAssetInfoKey] = {
60-
symbol: assetSymbol,
61-
name: assetName,
62-
multiLocation: assetLocation,
63-
assetHubReserveLocation,
64-
originChainReserveLocation,
65-
};
66-
}
63+
foreignAssetsInfo[foreignAssetInfoKey] = {
64+
symbol: assetSymbol,
65+
name: assetName,
66+
multiLocation: assetLocation,
67+
assetHubReserveLocation,
68+
originChainReserveLocation,
69+
};
6770
}
6871
}
6972
}

0 commit comments

Comments
 (0)