Skip to content

Commit

Permalink
Merge pull request #37 from tokenguardio/dapp-analytics-dev
Browse files Browse the repository at this point in the history
Release bifrost/hydration
  • Loading branch information
rrozek authored Sep 25, 2024
2 parents 17d4cca + 5650a20 commit c499a3e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
26 changes: 25 additions & 1 deletion src/components/dapp-analytics/dapp-analytics.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ async function checkDockerContainerStatus(dApps) {
async function checkKubernetesPodStatus(dApps) {
const namespace = 'dapp-analytics';
const labelSelector = 'managed-by=dapp-analytics-admin';

// Fetch pods in the dapp-analytics namespace
const pods = await k8sApi.listNamespacedPod(
namespace,
undefined,
Expand All @@ -624,14 +626,36 @@ async function checkKubernetesPodStatus(dApps) {
labelSelector,
);

// Fetch all pods in the subsquid namespace
const subsquidPods = await k8sApi.listNamespacedPod('subsquid');

// Map over dApps to get their statuses
return dApps.map((dApp) => {
// Check for the related pod in dapp-analytics namespace
const relatedPod = pods.body.items.find(
(pod) =>
pod.metadata.labels && pod.metadata.labels['dapp-id'] === dApp.id,
);

const relatedSubsquidPod = subsquidPods.body.items.find(
(pod) =>
pod.metadata.labels &&
pod.metadata.labels['app'].startsWith('wasabi') &&
pod.metadata.labels['app'].includes(
dApp.slug === 'hydration' ? 'hydradx' : dApp.slug,
),
);

// Determine the container status
const containerStatus = relatedPod
? relatedPod.status.phase
: relatedSubsquidPod
? relatedSubsquidPod.status.phase
: 'not found';

return {
...dApp,
containerStatus: relatedPod ? relatedPod.status.phase : 'not found',
containerStatus,
};
});
}
Expand Down
19 changes: 16 additions & 3 deletions src/components/node-api/chainstate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ const rpcEndpoints: { [key: string]: string } = {
kusama: 'wss://kusama-rpc.polkadot.io',
'aleph-zero': 'wss://rpc.azero.dev',
moonbeam: 'wss://moonbeam.api.onfinality.io/public-ws',
'arbitrum-one': 'https://arbitrum.api.onfinality.io/public',
'arbitrum-one': 'https://arb1.arbitrum.io/rpc',
'arbitrum-nova': 'https://nova.arbitrum.io/rpc',
optimism: 'https://optimism.api.onfinality.io/public',
bifrost: 'wss://bifrost-rpc.dwellir.com',
hydration: 'wss://hydradx-rpc.dwellir.com',
};

export async function getCurrentBlock(chain: string): Promise<number> {
Expand All @@ -15,13 +19,22 @@ export async function getCurrentBlock(chain: string): Promise<number> {
throw new Error(`RPC endpoint for chain ${chain} not found`);
}

if (['polkadot', 'kusama', 'aleph-zero', 'moonbeam'].includes(chain)) {
if (
[
'polkadot',
'kusama',
'aleph-zero',
'moonbeam',
'bifrost',
'hydration',
].includes(chain)
) {
// Substrate-based chains
const wsProvider = new WsProvider(endpoint);
const api = await ApiPromise.create({ provider: wsProvider });
const currentBlock = await api.rpc.chain.getHeader();
return currentBlock.number.toNumber();
} else if (['arbitrum-one'].includes(chain)) {
} else if (['arbitrum-one', 'arbitrum-nova', 'optimism'].includes(chain)) {
// Ethereum-compatible chains (e.g., Arbitrum)
const provider = new ethers.JsonRpcProvider(endpoint);
const currentBlockNumber = await provider.getBlockNumber();
Expand Down

0 comments on commit c499a3e

Please sign in to comment.