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

refactor: move parentChainIsArbitrum to separate file #116

Merged
merged 1 commit into from
Jun 6, 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
21 changes: 21 additions & 0 deletions src/parentChainIsArbitrum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as chains from './chains';
import { ParentChainId } from './types/ParentChain';

export function parentChainIsArbitrum(parentChainId: ParentChainId): boolean {
// doing switch here to make sure it's exhaustive when checking against `ParentChainId`
switch (parentChainId) {
case chains.mainnet.id:
case chains.base.id:
case chains.sepolia.id:
case chains.holesky.id:
case chains.baseSepolia.id:
case chains.nitroTestnodeL1.id:
return false;

case chains.arbitrumOne.id:
case chains.arbitrumNova.id:
case chains.arbitrumSepolia.id:
case chains.nitroTestnodeL2.id:
return true;
}
}
32 changes: 1 addition & 31 deletions src/prepareNodeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,8 @@ import {
import { ChainConfig } from './types/ChainConfig';
import { CoreContracts } from './types/CoreContracts';
import { ParentChainId, validateParentChain } from './types/ParentChain';
import {
mainnet,
arbitrumOne,
arbitrumNova,
base,
sepolia,
holesky,
arbitrumSepolia,
baseSepolia,
nitroTestnodeL1,
nitroTestnodeL2,
} from './chains';
import { getParentChainLayer } from './utils';
import { parentChainIsArbitrum } from './parentChainIsArbitrum';

// this is different from `sanitizePrivateKey` from utils, as this removes the 0x prefix
function sanitizePrivateKey(privateKey: string) {
Expand All @@ -35,25 +24,6 @@ function stringifyBackendsJson(
return JSON.stringify(backendsJson);
}

function parentChainIsArbitrum(parentChainId: ParentChainId): boolean {
// doing switch here to make sure it's exhaustive when checking against `ParentChainId`
switch (parentChainId) {
case mainnet.id:
case base.id:
case sepolia.id:
case holesky.id:
case baseSepolia.id:
case nitroTestnodeL1.id:
return false;

case arbitrumOne.id:
case arbitrumNova.id:
case arbitrumSepolia.id:
case nitroTestnodeL2.id:
return true;
}
}

export type PrepareNodeConfigParams = {
chainName: string;
chainConfig: ChainConfig;
Expand Down
Loading