Skip to content

Commit

Permalink
Started working on package inclusions
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicF96 committed May 8, 2024
1 parent a06da8a commit 1360f76
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 17 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as data from './dist/data';
import * as data from './dist/types';
import * as utils from './src/utils';

export default { data, utils };
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pinax/chains",
"version": "2.0.1-rc1",
"version": "2.0.2-rc1",
"description": "Single-source-of-truth for the metadata of chains supported by Pinax.",
"keywords": [
"chains",
Expand All @@ -13,7 +13,8 @@
"files": [
"dist/data.json",
"dist/data.d.ts",
"types/**.ts"
"src/types/**.ts",
"src/utils/**/**.ts"
],
"scripts": {
"fetch-graph-ids": "bun ./scripts/fetchGraphIDs.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/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 5/8/2024, 4:18:45 PM.
// Last generation on 5/8/2024, 4:35:33 PM.
export type GraphID =
| 'arbitrum-one'
| 'arbitrum-sepolia'
Expand Down
2 changes: 1 addition & 1 deletion src/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 5/8/2024, 4:18:45 PM.
// Last generation on 5/8/2024, 4:35:33 PM.
export type PinaxID =
| 'arbgoerli'
| 'arbsepolia'
Expand Down
48 changes: 36 additions & 12 deletions src/utils/chains.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,71 @@
import { ChainBase } from '../types/chain.types';
import { Chain, ConsensusLayer, Testnet } from '../types/chain.types';

const isFirehoseSupported = (chain: ChainBase): boolean => {
const isFirehoseSupported = (
chain: Chain | Testnet | ConsensusLayer,
): boolean => {
return (
chain?.supported_services?.firehose?.released_at !== null &&
chain?.supported_services?.firehose?.deprecated_at === null
);
};

const isSubstreamsSupported = (chain: ChainBase): boolean => {
const isSubstreamsSupported = (
chain: Chain | Testnet | ConsensusLayer,
): boolean => {
return (
chain?.supported_services?.substreams?.released_at !== null &&
chain?.supported_services?.substreams?.deprecated_at === null
);
};

const isRpcSupported = (chain: ChainBase): boolean => {
const isRpcSupported = (chain: Chain | Testnet | ConsensusLayer): boolean => {
// Can take a Consensus Layer as parameter but will always return false.
const castedChain = chain as any;
if (castedChain.supported_services.rpc === undefined) {
return false;
}

return (
chain?.supported_services?.rpc?.released_at !== null &&
chain?.supported_services?.rpc?.deprecated_at === null
castedChain?.supported_services?.rpc?.released_at !== null &&
castedChain?.supported_services?.rpc?.deprecated_at === null
);
};

const isChainSupported = (chain: ChainBase): boolean => {
const isChainSupported = (chain: Chain | Testnet | ConsensusLayer): boolean => {
return (
isFirehoseSupported(chain) ||
isSubstreamsSupported(chain) ||
isRpcSupported(chain)
);
};

const wasFirehoseOnceSupported = (chain: ChainBase): boolean => {
const wasFirehoseOnceSupported = (
chain: Chain | Testnet | ConsensusLayer,
): boolean => {
return chain?.supported_services?.firehose?.released_at !== null;
};

const wasSubstreamsOnceSupported = (chain: ChainBase): boolean => {
const wasSubstreamsOnceSupported = (
chain: Chain | Testnet | ConsensusLayer,
): boolean => {
return chain?.supported_services?.substreams?.released_at !== null;
};

const wasRpcOnceSupported = (chain: ChainBase): boolean => {
return chain?.supported_services?.rpc?.released_at !== null;
const wasRpcOnceSupported = (
chain: Chain | Testnet | ConsensusLayer,
): boolean => {
// Can take a Consensus Layer as parameter but will always return false.
const castedChain = chain as any;
if (castedChain.supported_services.rpc === undefined) {
return false;
}

return castedChain?.supported_services?.rpc?.released_at !== null;
};

const wasChainOnceSupported = (chain: ChainBase): boolean => {
const wasChainOnceSupported = (
chain: Chain | Testnet | ConsensusLayer,
): boolean => {
return (
wasFirehoseOnceSupported(chain) ||
wasSubstreamsOnceSupported(chain) ||
Expand Down

0 comments on commit 1360f76

Please sign in to comment.