Skip to content

Commit

Permalink
2.0.17
Browse files Browse the repository at this point in the history
  • Loading branch information
SoA432 committed Aug 29, 2024
1 parent fc8ebea commit 72873e1
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 23 deletions.
2 changes: 1 addition & 1 deletion data/chains/V2/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is auto-generated on pre-commit to avoid maintaining it.
// Do not modify manually as it will be overwritten.
// Last generation on 8/29/2024, 4:29:12 PM.
// Last generation on 8/29/2024, 4:34:59 PM.

export { default as celo } from './celo/meta';
export { default as alfajores } from './celo/testnets/alfajores/meta';
Expand Down
2 changes: 1 addition & 1 deletion data/index.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Chains under ordered were manually placed, to manage the z-index (priority order) of chains.
// Chains under missing are generated from available data, make sure to order them.
// Include deprecated or future chains.
// Last generation on 8/29/2024, 4:29:12 PM.
// Last generation on 8/29/2024, 4:34:59 PM.

export default {
ordered: {
Expand Down
2 changes: 1 addition & 1 deletion types/graph.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is auto-generated on pre-commit to avoid maintaining it.
// Do not modify manually as it will be overwritten.
// Last generation on 8/29/2024, 4:29:12 PM.
// Last generation on 8/29/2024, 4:34:59 PM.
export type GraphID =
| 'arbitrum-nova'
| 'arbitrum-one'
Expand Down
2 changes: 1 addition & 1 deletion types/pinax.types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is auto-generated on pre-commit to avoid maintaining it / circular dependencies.
// Do not modify manually as it will be overwritten.
// Last generation on 8/29/2024, 4:29:13 PM.
// Last generation on 8/29/2024, 4:34:59 PM.
export type PinaxID =
| 'celo'
| 'alfajores'
Expand Down
81 changes: 62 additions & 19 deletions utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,27 @@ import {
*/
const isServiceSupported = (
chain: Chain | Testnet | ConsensusLayer,
service: ConsensusLayerServiceID | ServiceID
service: ConsensusLayerServiceID | ServiceID,
): boolean => {
// Check if supported_services is defined
if (!chain.supported_services) {
return false;
}

// @ts-ignore
const serviceStatusDates = chain.supported_services[service] as ServiceStatusDates | undefined;
const serviceStatusDates = chain.supported_services[service] as
| ServiceStatusDates
| undefined;

// Check if serviceStatusDates is defined
if (!serviceStatusDates) {
return false;
}

return serviceStatusDates.full_released_at !== null && serviceStatusDates.deprecated_at === null;
return (
serviceStatusDates.full_released_at !== null &&
serviceStatusDates.deprecated_at === null
);
};

/**
Expand All @@ -45,9 +50,14 @@ const isServiceSupported = (
*
* @returns boolean
*/
const isServiceBeta = (chain: Chain | Testnet | ConsensusLayer, service: ConsensusLayerServiceID | ServiceID) => {
const isServiceBeta = (
chain: Chain | Testnet | ConsensusLayer,
service: ConsensusLayerServiceID | ServiceID,
) => {
// @ts-ignore
const serviceStatusDates = chain.supported_services[service] as ServiceStatusDates | undefined;
const serviceStatusDates = chain.supported_services[service] as
| ServiceStatusDates
| undefined;
return (
serviceStatusDates &&
serviceStatusDates.beta_released_at !== null &&
Expand All @@ -64,12 +74,18 @@ const isServiceBeta = (chain: Chain | Testnet | ConsensusLayer, service: Consens
*
* @returns boolean
*/
const isServiceDeprecated = (chain: Chain | Testnet | ConsensusLayer, service: ConsensusLayerServiceID | ServiceID) => {
const isServiceDeprecated = (
chain: Chain | Testnet | ConsensusLayer,
service: ConsensusLayerServiceID | ServiceID,
) => {
// @ts-ignore
const serviceStatusDates = chain.supported_services[service] as ServiceStatusDates | undefined;
const serviceStatusDates = chain.supported_services[service] as
| ServiceStatusDates
| undefined;
return (
serviceStatusDates &&
(serviceStatusDates.beta_released_at !== null || serviceStatusDates.full_released_at !== null) &&
(serviceStatusDates.beta_released_at !== null ||
serviceStatusDates.full_released_at !== null) &&
serviceStatusDates.deprecated_at !== null
);
};
Expand All @@ -83,7 +99,9 @@ const isServiceDeprecated = (chain: Chain | Testnet | ConsensusLayer, service: C
*/
const isChainSupported = (chain: Chain | Testnet | ConsensusLayer) => {
return (
isServiceSupported(chain, 'firehose') || isServiceSupported(chain, 'substreams') || isServiceSupported(chain, 'rpc')
isServiceSupported(chain, 'firehose') ||
isServiceSupported(chain, 'substreams') ||
isServiceSupported(chain, 'rpc')
);
};

Expand All @@ -96,7 +114,9 @@ const isChainSupported = (chain: Chain | Testnet | ConsensusLayer) => {
*/
const isChainBeta = (chain: Chain | Testnet | ConsensusLayer) => {
return (
(isServiceBeta(chain, 'firehose') || isServiceBeta(chain, 'substreams') || isServiceBeta(chain, 'rpc')) &&
(isServiceBeta(chain, 'firehose') ||
isServiceBeta(chain, 'substreams') ||
isServiceBeta(chain, 'rpc')) &&
!isServiceSupported(chain, 'firehose') &&
!isServiceSupported(chain, 'substreams') &&
!isServiceSupported(chain, 'rpc')
Expand Down Expand Up @@ -127,7 +147,10 @@ const isChainDeprecated = (chain: Chain | Testnet | ConsensusLayer) => {
*
* @returns Chain, Testnet or ConsensusLayer
*/
const findChainById = (db: Array<Chain>, id: string): Chain | Testnet | ConsensusLayer | EVM | undefined => {
const findChainById = (
db: Array<Chain>,
id: string,
): Chain | Testnet | ConsensusLayer | EVM | undefined => {
for (const chain of db) {
if (chain.id === id) {
return chain;
Expand Down Expand Up @@ -183,7 +206,9 @@ const findSubnetMainnet = (db: Array<Chain>, id: string) => {
*
* @returns boolean
*/
const isChainConsensusLayer = (chain: Chain | Testnet | ConsensusLayer): boolean => {
const isChainConsensusLayer = (
chain: Chain | Testnet | ConsensusLayer,
): boolean => {
return chain.id.slice(-3).includes('-cl');
};

Expand All @@ -194,7 +219,10 @@ const isChainConsensusLayer = (chain: Chain | Testnet | ConsensusLayer): boolean
*
* @returns boolean
*/
const isChainEVM = (db: Array<Chain>, chain: Chain | Testnet | ConsensusLayer): boolean => {
const isChainEVM = (
db: Array<Chain>,
chain: Chain | Testnet | ConsensusLayer,
): boolean => {
let isEVM = false;
const mainnet = findSubnetMainnet(db, chain.id);
if (mainnet) {
Expand All @@ -214,7 +242,10 @@ const isChainEVM = (db: Array<Chain>, chain: Chain | Testnet | ConsensusLayer):
*
* @returns boolean
*/
const isChainTestnet = (db: Array<Chain>, chain: Chain | Testnet | ConsensusLayer): boolean => {
const isChainTestnet = (
db: Array<Chain>,
chain: Chain | Testnet | ConsensusLayer,
): boolean => {
let isTestnet = false;
const mainnet = findSubnetMainnet(db, chain.id);
if (mainnet) {
Expand Down Expand Up @@ -245,7 +276,9 @@ const hasChainFullBlockSupport = (chain: Chain | Testnet | ConsensusLayer) => {
* @param {Array<Chain | Testnet | ConsensusLayer | EVM>} chains - The array of chains to check for support.
* @returns {number} The number of supported chains.
*/
const getNumberOfSupportedChains = (chains: Array<Chain | Testnet | ConsensusLayer | EVM>) => {
const getNumberOfSupportedChains = (
chains: Array<Chain | Testnet | ConsensusLayer | EVM>,
) => {
let supportedChains = 0;
chains
.filter((c: any) => isChainSupported(c))
Expand Down Expand Up @@ -296,18 +329,24 @@ const getChainStatus = (chain: Chain | ConsensusLayer | EVM | Testnet) => {
* @param {Chain | Testnet | ConsensusLayer | EVM} chain - The chain object to check for supported services.
* @returns {Array<[ServiceID, string | null]>} An array of tuples where each tuple contains a service ID and the release date (beta or full) of the service.
*/
const getSupportedServices = (chain: Chain | Testnet | ConsensusLayer | EVM) => {
const getSupportedServices = (
chain: Chain | Testnet | ConsensusLayer | EVM,
) => {
let supServices = [] as Array<[ServiceID, string | null]>;
(['rpc', 'firehose', 'substreams'] as Array<ServiceID>).forEach((service) => {
if (isServiceBeta(chain as any, service as any)) {
supServices.push([
service,
chain.supported_services[service as keyof typeof chain.supported_services]?.beta_released_at,
chain.supported_services[
service as keyof typeof chain.supported_services
]?.beta_released_at,
]);
} else if (isServiceSupported(chain as any, service as any)) {
supServices.push([
service,
chain.supported_services[service as keyof typeof chain.supported_services]?.full_released_at,
chain.supported_services[
service as keyof typeof chain.supported_services
]?.full_released_at,
]);
}
});
Expand All @@ -326,7 +365,11 @@ const getChainSubnets = (chain: Chain) => {
.concat((chain.consensus as Array<any>) || []);
};

const getChainIconUrl = (chainIcon: ChainIcon, theme: 'dark' | 'light', chainId: string) => {
const getChainIconUrl = (
chainIcon: ChainIcon,
theme: 'dark' | 'light',
chainId: string,
) => {
const iconAssetsFolder = '/assets/chains/';

if (chainIcon?.variants && chainIcon.variants?.includes('branded')) {
Expand Down

0 comments on commit 72873e1

Please sign in to comment.