Skip to content

Commit

Permalink
refactor: move parentChainIsArbitrum to separate file (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
spsjvc authored and chrstph-dvx committed Jun 10, 2024
1 parent 3f073a3 commit 1b0deb9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 31 deletions.
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

0 comments on commit 1b0deb9

Please sign in to comment.