Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
spsjvc committed Oct 9, 2024
1 parent 645889d commit d49fc26
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
15 changes: 7 additions & 8 deletions src/utils/getRollupCreatorAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ export function getRollupCreatorAddress<TChain extends Chain | undefined>(
const { chainId: parentChainId, isCustom: parentChainIsCustom } = validateParentChain(client);

if (parentChainIsCustom) {
const customParentChainRollupCreator = client.chain?.contracts?.rollupCreator as
| ChainContract
| undefined;
const contract = client.chain?.contracts?.rollupCreator as ChainContract | undefined;
const address = contract?.address;

// check if it's a custom parent chain with the factory address provided

if (!customParentChainRollupCreator?.address) {
throw new Error('invalid rollup creator address provided');
if (typeof address === 'undefined') {
throw new Error(
`Address for RollupCreator is missing on custom parent chain with id ${parentChainId}`,
);
}

return customParentChainRollupCreator?.address;
return address;
}

return rollupCreatorAddress[parentChainId];
Expand Down
15 changes: 7 additions & 8 deletions src/utils/getTokenBridgeCreatorAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@ export function getTokenBridgeCreatorAddress<TChain extends Chain | undefined>(
const { chainId: parentChainId, isCustom: parentChainIsCustom } = validateParentChain(client);

if (parentChainIsCustom) {
const customParentChainTokenBridgeCreator = client.chain?.contracts?.tokenBridgeCreator as
| ChainContract
| undefined;
const contract = client.chain?.contracts?.tokenBridgeCreator as ChainContract | undefined;
const address = contract?.address;

// check if it's a custom parent chain with the factory address provided

if (!customParentChainTokenBridgeCreator?.address) {
throw new Error('invalid token bridge creator address provided');
if (typeof address === 'undefined') {
throw new Error(
`Address for TokenBridgeCreator is missing on custom parent chain with id ${parentChainId}`,
);
}

return customParentChainTokenBridgeCreator?.address;
return address;
}

return tokenBridgeCreatorAddress[parentChainId];
Expand Down

0 comments on commit d49fc26

Please sign in to comment.