Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
chore: update registry pjs deps and rpc black list
  • Loading branch information
marshacb committed Jan 11, 2025
commit 0d6ab3272c9ee92908c025007b75fe072e88c614
370 changes: 345 additions & 25 deletions docs/registry.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"author": "Parity Technologies <admin@parity.io>",
"license": "Apache-2.0",
"devDependencies": {
"@polkadot/api": "^14.0.1",
"@polkadot/apps-config": "^0.145.1",
"@polkadot/api": "^15.2.1",
"@polkadot/apps-config": "^0.147.1",
"@substrate/dev": "0.7.1",
"@types/node-fetch": "^2.6.9",
"node-fetch": "2.6.7",
Expand Down
14 changes: 14 additions & 0 deletions src/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ export const XC_ASSET_CDN_URL =
'https://cdn.jsdelivr.net/gh/colorfulnotion/xcm-global-registry/metadata/xcmgar.json';

export const RPC_BLACK_LIST = [
'wss://polkadot-rpc.publicnode.com',
'wss://api2.zondax.ch/pas/node/rpc',
'wss://heiko-rpc.parallel.fi',
'wss://public-01.mainnet.bifrostnetwork.com/wss',
'wss://public-02.mainnet.bifrostnetwork.com/wss',
'wss://polkadex.public.curie.radiumblock.co/ws',
'wss://public-01.testnet.bifrostnetwork.com/wss',
'wss://public-02.testnet.bifrostnetwork.com/wss',
'wss://parachain-rpc.origin-trail.network',
'wss://polkadot-parallel-rpc.parallel.fi',
'wss://tinkernet-rpc.dwellir.com',
'wss://khala.api.onfinality.io/public-ws',
'wss://chainflip-rpc.dwellir.com',
'wss://khala.public.curie.radiumblock.co/ws',
'wss://polkadot-public-rpc.blockops.network/ws',
'wss://kusama-public-rpc.blockops.network/ws',
'wss://westend-rpc.blockops.network/ws',
Expand Down
67 changes: 35 additions & 32 deletions src/fetchSystemParachainForeignAssetInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,45 +25,48 @@ export const fetchSystemParachainForeignAssetInfo = async (
if (api.query.foreignAssets !== undefined) {
const assetEntries = await api.query.foreignAssets.asset.entries();

for (const [assetStorageKeyData] of assetEntries) {
const foreignAssetData = assetStorageKeyData.toHuman();

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

const foreignAssetMultiLocation = JSON.parse(
foreignAssetMultiLocationStr,
) as UnionXcmMultiLocation;
const foreignAssetMultiLocation = JSON.parse(
foreignAssetMultiLocationStr,
) as UnionXcmMultiLocation;

const hexId = stringToHex(JSON.stringify(foreignAssetMultiLocation));
const hexId = stringToHex(JSON.stringify(foreignAssetMultiLocation));

const assetMetadata = (
await api.query.foreignAssets.metadata(foreignAssetMultiLocation)
).toHuman();
const assetMetadata = (
await api.query.foreignAssets.metadata(foreignAssetMultiLocation)
).toHuman();

if (assetMetadata) {
const metadata = assetMetadata as ForeignAssetMetadata;
const assetSymbol = metadata.symbol;
const assetName = metadata.name;
if (assetMetadata) {
const metadata = assetMetadata as ForeignAssetMetadata;
const assetSymbol = metadata.symbol;
const assetName = metadata.name;

// if the symbol exists in metadata use it, otherwise uses the hex of the multilocation as the key
const foreignAssetInfoKey = assetSymbol ? assetSymbol : hexId;
const assetLocation = JSON.stringify(foreignAssetMultiLocation);
// if the symbol exists in metadata use it, otherwise uses the hex of the multilocation as the key
const foreignAssetInfoKey = assetSymbol ? assetSymbol : hexId;
const assetLocation = JSON.stringify(foreignAssetMultiLocation);

const [assetHubReserveLocation, originChainReserveLocation] =
getAssetReserveLocations(assetLocation, chainId);
const [assetHubReserveLocation, originChainReserveLocation] =
getAssetReserveLocations(assetLocation, chainId);

foreignAssetsInfo[foreignAssetInfoKey] = {
symbol: assetSymbol,
name: assetName,
multiLocation: assetLocation,
assetHubReserveLocation,
originChainReserveLocation,
};
}
foreignAssetsInfo[foreignAssetInfoKey] = {
symbol: assetSymbol,
name: assetName,
multiLocation: assetLocation,
assetHubReserveLocation,
originChainReserveLocation,
};
}
}
}
Expand Down
Loading
Loading