Skip to content

Commit

Permalink
move subsocial to polkadot group & update networks
Browse files Browse the repository at this point in the history
  • Loading branch information
uiii committed Nov 8, 2023
1 parent ea2b2cb commit 9a6df19
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 59 deletions.
8 changes: 7 additions & 1 deletion scripts/update-networks/config/prop-resolution.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SourceData, SourceType } from "../model";
import { Network, NetworkResolvableProps, SourceData, SourceType } from "../model";

export const forceSource: Record<string, Partial<Record<keyof SourceData, SourceType>>> = {
"equilibrium": {
Expand All @@ -14,3 +14,9 @@ export const forceSource: Record<string, Partial<Record<keyof SourceData, Source
"prefix": SourceType.SS58_REGISTRY
}
};

export const forceValues: Record<string, Partial<NetworkResolvableProps>> = {
"subsocial": {
"relayChain": "polkadot"
}
};
5 changes: 4 additions & 1 deletion scripts/update-networks/utils/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import colors from "colors";

// overwrite console.* with noop because @polkadot/api has hardcoded logger which cannot be disabled
const consoleLog = console.log;
console.log = () => {}; console.warn = () => {}; console.error = () => {}; console.info = () => {};

if (!process.argv.includes("--debug")) {
console.log = () => {}; console.warn = () => {}; console.error = () => {}; console.info = () => {};
}

let logPrinted = false;

Expand Down
50 changes: 29 additions & 21 deletions scripts/update-networks/utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import path from "path";
import colors from "colors";
import archivesJson from "@subsquid/archive-registry/archives.json";

import { forceSquidUrl, squidTypes, squidUrlTemplates } from "../config/squids";
import { archiveRegistryArchiveNetworkNames } from "../config/archive-registry";
import { coinGeckoId } from "../config/coingecko";
import { forceValues } from "../config/prop-resolution";
import { forceSquidUrl, squidTypes, squidUrlTemplates } from "../config/squids";

import { CoinGeckoCoin, Network, NetworkResolvableProps, SourceData, SourceType } from "../model";

Expand All @@ -23,34 +24,41 @@ export function resolveIcon(network: Network) {
}

export function resolveProperty<K extends keyof NetworkResolvableProps>(network: Network, prop: K, sources: SourceData[], path: SourceType[], forceSource?: SourceType) {
const values = path.map(type => {
const source = sources.find(source => source.type === type);
if (!source) {
throw new Error(`Source ${type} not found`);
}
let value: Network[K] | undefined = undefined;

return source[prop];
});
if (prop in (forceValues[network.name] || {})) {
log(log.warn, `Value for property ${prop} is forced`);
value = forceValues[network.name]?.[prop];
} else {
const values = path.map(type => {
const source = sources.find(source => source.type === type);
if (!source) {
throw new Error(`Source ${type} not found`);
}

if (!allEqualOrUndefined(values)) {
log(forceSource ? log.warn : log.error, `Source values of ${prop} differ`);
for(const type of path) {
log(`- ${type}:`.padEnd(20), sources.find(it => it.type === type)?.[prop]);
}
return source[prop];
});

if (!forceSource) {
return;
if (!allEqualOrUndefined(values)) {
log(forceSource ? log.warn : log.error, `Source values of ${prop} differ`);
for(const type of path) {
log(`- ${type}:`.padEnd(20), sources.find(it => it.type === type)?.[prop]);
}

if (!forceSource) {
return;
}
}
}

let value = values.filter(it => it !== undefined)[0];
value = values.filter(it => it !== undefined)[0] as Network[K];

if (forceSource) {
log(log.warn, `Source ${forceSource} forced for ${prop} value`);
value = values[path.indexOf(forceSource)];
if (forceSource) {
log(log.warn, `Source ${forceSource} forced for ${prop} value`);
value = values[path.indexOf(forceSource)] as Network[K];
}
}

network[prop] = value as Network[K];
network[prop] = value;
}

export async function resolveCoinGeckoCoin(network: Network, coins: CoinGeckoCoin[]) {
Expand Down
58 changes: 22 additions & 36 deletions src/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"decimals": 12,
"symbol": "TZERO",
"squids": {
"archive": "https://aleph-zero-testnet.explorer.subsquid.io/graphql"
"archive": "https://aleph-zero-testnet.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-aleph-zero-testnet/graphql"
}
},
{
Expand Down Expand Up @@ -78,6 +79,7 @@
"symbol": "BAJU",
"squids": {
"archive": "https://bajun.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-bajun/graphql",
"main": "https://squid.subsquid.io/gs-main-bajun/graphql"
},
"coinGeckoId": "ajuna-network"
Expand All @@ -95,8 +97,7 @@
"symbol": "BNC",
"squids": {
"archive": "https://bifrost.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-bifrost/graphql",
"main": "https://squid.subsquid.io/gs-main-bifrost/graphql"
"explorer": "https://squid.subsquid.io/gs-explorer-bifrost/graphql"
},
"coinGeckoId": "bifrost-native-coin"
},
Expand All @@ -118,24 +119,6 @@
},
"coinGeckoId": "calamari-network"
},
{
"name": "efinity",
"displayName": "Efinity",
"icon": "/assets/network-icons/efinity.svg",
"color": "#496ddb",
"website": "https://efinity.io/",
"parachainId": 2021,
"relayChain": "polkadot",
"prefix": 1110,
"decimals": 18,
"symbol": "EFI",
"squids": {
"archive": "https://efinity.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-efinity/graphql",
"main": "https://squid.subsquid.io/gs-main-efinity/graphql"
},
"coinGeckoId": "efinity"
},
{
"name": "equilibrium",
"displayName": "Equilibrium",
Expand All @@ -153,7 +136,6 @@
"name": "gmordie",
"displayName": "GM",
"icon": "/assets/network-icons/gmordie.png",
"color": "#f47b36",
"website": "https://gmordie.com/",
"parachainId": 2123,
"relayChain": "kusama",
Expand All @@ -162,7 +144,6 @@
"symbol": "FREN",
"squids": {
"archive": "https://gmordie.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-gmordie/graphql",
"main": "https://squid.subsquid.io/gs-main-gmordie/graphql"
}
},
Expand Down Expand Up @@ -197,16 +178,14 @@
"symbol": "INTR",
"squids": {
"archive": "https://interlay.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-interlay/graphql",
"main": "https://squid.subsquid.io/gs-main-interlay/graphql"
"explorer": "https://squid.subsquid.io/gs-explorer-interlay/graphql"
},
"coinGeckoId": "interlay"
},
{
"name": "invarch-tinkernet",
"displayName": "InvArch Tinkernet",
"icon": "/assets/network-icons/invarch-tinkernet.svg",
"color": "#161616",
"website": "https://invarch.network/tinkernet/",
"parachainId": 2125,
"relayChain": "kusama",
Expand All @@ -227,7 +206,8 @@
"decimals": 10,
"symbol": "JOY",
"squids": {
"archive": "https://joystream.explorer.subsquid.io/graphql"
"archive": "https://joystream.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-joystream/graphql"
},
"coinGeckoId": "joystream"
},
Expand Down Expand Up @@ -279,7 +259,8 @@
"decimals": 12,
"symbol": "KINT",
"squids": {
"archive": "https://kintsugi.explorer.subsquid.io/graphql"
"archive": "https://kintsugi.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-kintsugi/graphql"
},
"coinGeckoId": "kintsugi"
},
Expand Down Expand Up @@ -316,6 +297,7 @@
"symbol": "LIT",
"squids": {
"archive": "https://litentry.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-litentry/graphql",
"main": "https://squid.subsquid.io/gs-main-litentry/graphql"
},
"coinGeckoId": "litentry"
Expand All @@ -333,6 +315,7 @@
"symbol": "LIT",
"squids": {
"archive": "https://litmus.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-litmus/graphql",
"main": "https://squid.subsquid.io/gs-main-litmus/graphql"
},
"coinGeckoId": "litentry"
Expand Down Expand Up @@ -382,7 +365,8 @@
"decimals": 18,
"symbol": "PEAQ",
"squids": {
"archive": "https://peaq.explorer.subsquid.io/graphql"
"archive": "https://peaq.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-peaq/graphql"
}
},
{
Expand All @@ -397,6 +381,7 @@
"symbol": "PEN",
"squids": {
"archive": "https://pendulum.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-pendulum/graphql",
"main": "https://squid.subsquid.io/gs-main-pendulum/graphql"
},
"coinGeckoId": "pendulum-chain"
Expand All @@ -414,7 +399,6 @@
"symbol": "PHA",
"squids": {
"archive": "https://phala.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-phala/graphql",
"main": "https://squid.subsquid.io/gs-main-phala/graphql"
},
"coinGeckoId": "pha"
Expand Down Expand Up @@ -452,6 +436,7 @@
"symbol": "XRT",
"squids": {
"archive": "https://robonomics.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-robonomics/graphql",
"main": "https://squid.subsquid.io/gs-main-robonomics/graphql"
},
"coinGeckoId": "robonomics-network"
Expand Down Expand Up @@ -505,7 +490,6 @@
"name": "statemine",
"displayName": "Statemine",
"icon": "/assets/network-icons/statemine.png",
"color": "#113911",
"website": "https://www.parity.io/",
"parachainId": 1000,
"relayChain": "kusama",
Expand All @@ -531,8 +515,7 @@
"symbol": "DOT",
"squids": {
"archive": "https://statemint.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-statemint/graphql",
"main": "https://squid.subsquid.io/gs-main-statemint/graphql"
"explorer": "https://squid.subsquid.io/gs-explorer-statemint/graphql"
},
"coinGeckoId": "polkadot"
},
Expand All @@ -542,6 +525,7 @@
"icon": "/assets/network-icons/subsocial.png",
"color": "#69058c",
"website": "http://subsocial.network/",
"relayChain": "polkadot",
"prefix": 28,
"decimals": 10,
"symbol": "SUB",
Expand All @@ -563,7 +547,8 @@
"decimals": 12,
"symbol": "T0RN",
"squids": {
"archive": "https://t0rn.explorer.subsquid.io/graphql"
"archive": "https://t0rn.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-t0rn/graphql"
}
},
{
Expand All @@ -576,7 +561,8 @@
"decimals": 12,
"symbol": "VARA",
"squids": {
"archive": "https://vara.explorer.subsquid.io/graphql"
"archive": "https://vara.explorer.subsquid.io/graphql",
"explorer": "https://squid.subsquid.io/gs-explorer-vara/graphql"
}
},
{
Expand All @@ -592,4 +578,4 @@
},
"coinGeckoId": "xxcoin"
}
]
]

0 comments on commit 9a6df19

Please sign in to comment.