Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release bifrost/hydration #37

Merged
merged 2 commits into from
Sep 25, 2024
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
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
Loading