Skip to content

Commit

Permalink
Merge branch 'production-hotfix'
Browse files Browse the repository at this point in the history
  • Loading branch information
uiii committed Nov 8, 2023
2 parents b8c3807 + 6497326 commit d88dc35
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jobs:
deploy:
name: Deploy / Production
needs: test
if: github.ref_name == 'master'
if: github.ref_name == 'master' || github.ref_name == 'production-hotfix'
environment:
name: production
url: ${{ steps.pages.outputs.url }}
Expand Down
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
32 changes: 4 additions & 28 deletions src/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,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 @@ -120,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 @@ -156,7 +137,6 @@
"name": "gmordie",
"displayName": "GM",
"icon": "/assets/network-icons/gmordie.png",
"color": "#f47b36",
"website": "https://gmordie.com/",
"parachainId": 2123,
"relayChain": "kusama",
Expand Down Expand Up @@ -199,16 +179,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 Down Expand Up @@ -423,7 +401,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 @@ -515,7 +492,6 @@
"name": "statemine",
"displayName": "Statemine",
"icon": "/assets/network-icons/statemine.png",
"color": "#113911",
"website": "https://www.parity.io/",
"parachainId": 1000,
"relayChain": "kusama",
Expand All @@ -542,8 +518,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 @@ -553,6 +528,7 @@
"icon": "/assets/network-icons/subsocial.png",
"color": "#69058c",
"website": "http://subsocial.network/",
"relayChain": "polkadot",
"prefix": 28,
"decimals": 10,
"symbol": "SUB",
Expand Down

0 comments on commit d88dc35

Please sign in to comment.