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

Add Bob and Mode chains #277

Merged
merged 1 commit into from
Nov 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
28 changes: 25 additions & 3 deletions app/utils/chains/configs.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import { Chain } from 'utils/types/chain';
import { OptimismIcon, BaseIcon } from './icons';
import { OptimismIcon, BaseIcon, ModeIcon, BobIcon } from './icons';

export type CHAIN = 'optimism' | 'base';
export type CHAIN = 'optimism' | 'base' | 'mode' | 'bob';

let opDispatcher = process.env.DISPATCHER_ADDRESS_OPTIMISM!;
let baseDispatcher = process.env.DISPATCHER_ADDRESS_BASE!;
let modeDispatcher = process.env.DISPATCHER_ADDRESS_MODE!;
let bobDispatcher = process.env.DISPATCHER_ADDRESS_BOB!;
Comment on lines +8 to +9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding runtime validation for environment variables

The non-null assertions (!) could lead to runtime errors if environment variables are not properly set. Consider adding validation with meaningful error messages.

Here's a suggested implementation:

-let modeDispatcher = process.env.DISPATCHER_ADDRESS_MODE!;
-let bobDispatcher = process.env.DISPATCHER_ADDRESS_BOB!;
-let modeClientName = process.env.MODE_CLIENT_NAME!;
-let bobClientName = process.env.BOB_CLIENT_NAME!;
-let modeRPC = process.env.MODE_RPC!;
-let bobRPC = process.env.BOB_RPC!;
+const getEnvVar = (name: string): string => {
+  const value = process.env[name];
+  if (!value) {
+    throw new Error(`Missing required environment variable: ${name}`);
+  }
+  return value;
+};
+
+let modeDispatcher = getEnvVar('DISPATCHER_ADDRESS_MODE');
+let bobDispatcher = getEnvVar('DISPATCHER_ADDRESS_BOB');
+let modeClientName = getEnvVar('MODE_CLIENT_NAME');
+let bobClientName = getEnvVar('BOB_CLIENT_NAME');
+let modeRPC = getEnvVar('MODE_RPC');
+let bobRPC = getEnvVar('BOB_RPC');

Also applies to: 13-14, 18-19


let opClientName = process.env.OPTIMISM_CLIENT_NAME!;
let baseClientName = process.env.BASE_CLIENT_NAME!;
let modeClientName = process.env.MODE_CLIENT_NAME!;
let bobClientName = process.env.BOB_CLIENT_NAME!;

let optimismRPC = process.env.OPTIMISM_RPC!;
let baseRPC = process.env.BASE_RPC!;
let modeRPC = process.env.MODE_RPC!;
let bobRPC = process.env.BOB_RPC!;

export const CHAIN_CONFIGS: {
[key in CHAIN]: Chain;
Expand All @@ -30,7 +36,23 @@ export const CHAIN_CONFIGS: {
clients: [baseClientName],
blockTime: 2,
icon: BaseIcon,
}
},
mode: {
display: 'Mode',
rpc: modeRPC,
dispatchers: [modeDispatcher],
clients: [modeClientName],
blockTime: 2,
icon: ModeIcon,
},
bob: {
display: 'Bob',
rpc: bobRPC,
dispatchers: [bobDispatcher],
clients: [bobClientName],
blockTime: 2,
icon: BobIcon,
},
};

export function clientToDisplay(client: string) {
Expand Down
47 changes: 44 additions & 3 deletions app/utils/chains/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ import React from 'react';
export const OptimismIcon = (size?: number): JSX.Element => {
return (
<svg width={size || 32} height={size || 32} viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M17.814 32.19C17.016 32.19 16.275 32.0823 15.591 31.867C14.907 31.6517 14.3307 31.3287 13.862 30.898C13.3933 30.4673 13.0577 29.929 12.855 29.283C12.665 28.637 12.6397 27.8833 12.779 27.022C12.8803 26.4773 12.988 25.9327 13.102 25.388C13.2287 24.8433 13.3553 24.2923 13.482 23.735C13.9 22.025 14.6537 20.7267 15.743 19.84C16.8323 18.9533 18.3017 18.51 20.151 18.51C20.949 18.51 21.6837 18.624 22.355 18.852C23.039 19.0673 23.6153 19.3967 24.084 19.84C24.5653 20.2833 24.901 20.828 25.091 21.474C25.2937 22.12 25.319 22.8737 25.167 23.735C25.0783 24.2923 24.9707 24.8433 24.844 25.388C24.73 25.9327 24.6097 26.4773 24.483 27.022C24.0523 28.7573 23.2923 30.0557 22.203 30.917C21.1137 31.7657 19.6507 32.19 17.814 32.19ZM18.061 29.454C18.745 29.454 19.3467 29.2513 19.866 28.846C20.3853 28.4407 20.7527 27.7947 20.968 26.908C21.1073 26.3507 21.2277 25.825 21.329 25.331C21.443 24.837 21.5443 24.324 21.633 23.792C21.7977 22.9053 21.7217 22.2593 21.405 21.854C21.0883 21.4487 20.588 21.246 19.904 21.246C19.22 21.246 18.6183 21.4487 18.099 21.854C17.5923 22.2593 17.2313 22.9053 17.016 23.792C16.8767 24.324 16.75 24.837 16.636 25.331C16.5347 25.825 16.4333 26.3507 16.332 26.908C16.18 27.7947 16.256 28.4407 16.56 28.846C16.864 29.2513 17.3643 29.454 18.061 29.454ZM25.9444 32C25.8177 32 25.7164 31.9557 25.6404 31.867C25.5644 31.7783 25.539 31.6643 25.5644 31.525L28.1864 19.175C28.2117 19.0357 28.2814 18.9217 28.3954 18.833C28.5094 18.7443 28.6297 18.7 28.7564 18.7H33.8104C34.583 18.7 35.2797 18.7887 35.9004 18.966C36.5337 19.1433 37.0594 19.4157 37.4774 19.783C37.8954 20.1503 38.1867 20.6127 38.3514 21.17C38.516 21.7147 38.5224 22.3543 38.3704 23.089C38.0537 24.5457 37.4077 25.6223 36.4324 26.319C35.4697 27.0157 34.1714 27.364 32.5374 27.364H29.9724L29.0984 31.525C29.073 31.6643 29.0034 31.7783 28.8894 31.867C28.788 31.9557 28.6677 32 28.5284 32H25.9444ZM30.4664 24.742H32.6514C33.1707 24.742 33.633 24.6027 34.0384 24.324C34.4564 24.0453 34.7287 23.621 34.8554 23.051C34.9187 22.7217 34.9314 22.4303 34.8934 22.177C34.8554 21.9237 34.7224 21.721 34.4944 21.569C34.279 21.417 33.9434 21.341 33.4874 21.341H31.2074L30.4664 24.742Z" fill="#FF0420"/>
<path fillRule="evenodd" clipRule="evenodd" d="M25 50C38.8071 50 50 38.8071 50 25C50 11.1929 38.8071 0 25 0C11.1929 0 0 11.1929 0 25C0 38.8071 11.1929 50 25 50ZM15.591 31.867C16.275 32.0823 17.016 32.19 17.814 32.19C19.6507 32.19 21.1137 31.7657 22.203 30.917C23.2923 30.0557 24.0523 28.7573 24.483 27.022C24.6097 26.4773 24.73 25.9327 24.844 25.388C24.9707 24.8433 25.0783 24.2923 25.167 23.735C25.319 22.8737 25.2937 22.12 25.091 21.474C24.901 20.828 24.5653 20.2833 24.084 19.84C23.6153 19.3967 23.039 19.0673 22.355 18.852C21.6837 18.624 20.949 18.51 20.151 18.51C18.3017 18.51 16.8323 18.9533 15.743 19.84C14.6537 20.7267 13.9 22.025 13.482 23.735C13.3553 24.2923 13.2287 24.8433 13.102 25.388C12.988 25.9327 12.8803 26.4773 12.779 27.022C12.6397 27.8833 12.665 28.637 12.855 29.283C13.0577 29.929 13.3933 30.4673 13.862 30.898C14.3307 31.3287 14.907 31.6517 15.591 31.867ZM19.866 28.846C19.3467 29.2513 18.745 29.454 18.061 29.454C17.3643 29.454 16.864 29.2513 16.56 28.846C16.256 28.4407 16.18 27.7947 16.332 26.908C16.4333 26.3507 16.5347 25.825 16.636 25.331C16.75 24.837 16.8767 24.324 17.016 23.792C17.2313 22.9053 17.5923 22.2593 18.099 21.854C18.6183 21.4487 19.22 21.246 19.904 21.246C20.588 21.246 21.0883 21.4487 21.405 21.854C21.7217 22.2593 21.7977 22.9053 21.633 23.792C21.5443 24.324 21.443 24.837 21.329 25.331C21.2277 25.825 21.1073 26.3507 20.968 26.908C20.7527 27.7947 20.3853 28.4407 19.866 28.846ZM25.6404 31.867C25.7164 31.9557 25.8177 32 25.9444 32H28.5284C28.6677 32 28.788 31.9557 28.8894 31.867C29.0034 31.7783 29.073 31.6643 29.0984 31.525L29.9724 27.364H32.5374C34.1714 27.364 35.4697 27.0157 36.4324 26.319C37.4077 25.6223 38.0537 24.5457 38.3704 23.089C38.5224 22.3543 38.516 21.7147 38.3514 21.17C38.1867 20.6127 37.8954 20.1503 37.4774 19.783C37.0594 19.4157 36.5337 19.1433 35.9004 18.966C35.2797 18.7887 34.583 18.7 33.8104 18.7H28.7564C28.6297 18.7 28.5094 18.7443 28.3954 18.833C28.2814 18.9217 28.2117 19.0357 28.1864 19.175L25.5644 31.525C25.539 31.6643 25.5644 31.7783 25.6404 31.867ZM32.6514 24.742H30.4664L31.2074 21.341H33.4874C33.9434 21.341 34.279 21.417 34.4944 21.569C34.7224 21.721 34.8554 21.9237 34.8934 22.177C34.9314 22.4303 34.9187 22.7217 34.8554 23.051C34.7287 23.621 34.4564 24.0453 34.0384 24.324C33.633 24.6027 33.1707 24.742 32.6514 24.742Z" fill="white"/>
<path
d="M17.814 32.19C17.016 32.19 16.275 32.0823 15.591 31.867C14.907 31.6517 14.3307 31.3287 13.862 30.898C13.3933 30.4673 13.0577 29.929 12.855 29.283C12.665 28.637 12.6397 27.8833 12.779 27.022C12.8803 26.4773 12.988 25.9327 13.102 25.388C13.2287 24.8433 13.3553 24.2923 13.482 23.735C13.9 22.025 14.6537 20.7267 15.743 19.84C16.8323 18.9533 18.3017 18.51 20.151 18.51C20.949 18.51 21.6837 18.624 22.355 18.852C23.039 19.0673 23.6153 19.3967 24.084 19.84C24.5653 20.2833 24.901 20.828 25.091 21.474C25.2937 22.12 25.319 22.8737 25.167 23.735C25.0783 24.2923 24.9707 24.8433 24.844 25.388C24.73 25.9327 24.6097 26.4773 24.483 27.022C24.0523 28.7573 23.2923 30.0557 22.203 30.917C21.1137 31.7657 19.6507 32.19 17.814 32.19ZM18.061 29.454C18.745 29.454 19.3467 29.2513 19.866 28.846C20.3853 28.4407 20.7527 27.7947 20.968 26.908C21.1073 26.3507 21.2277 25.825 21.329 25.331C21.443 24.837 21.5443 24.324 21.633 23.792C21.7977 22.9053 21.7217 22.2593 21.405 21.854C21.0883 21.4487 20.588 21.246 19.904 21.246C19.22 21.246 18.6183 21.4487 18.099 21.854C17.5923 22.2593 17.2313 22.9053 17.016 23.792C16.8767 24.324 16.75 24.837 16.636 25.331C16.5347 25.825 16.4333 26.3507 16.332 26.908C16.18 27.7947 16.256 28.4407 16.56 28.846C16.864 29.2513 17.3643 29.454 18.061 29.454ZM25.9444 32C25.8177 32 25.7164 31.9557 25.6404 31.867C25.5644 31.7783 25.539 31.6643 25.5644 31.525L28.1864 19.175C28.2117 19.0357 28.2814 18.9217 28.3954 18.833C28.5094 18.7443 28.6297 18.7 28.7564 18.7H33.8104C34.583 18.7 35.2797 18.7887 35.9004 18.966C36.5337 19.1433 37.0594 19.4157 37.4774 19.783C37.8954 20.1503 38.1867 20.6127 38.3514 21.17C38.516 21.7147 38.5224 22.3543 38.3704 23.089C38.0537 24.5457 37.4077 25.6223 36.4324 26.319C35.4697 27.0157 34.1714 27.364 32.5374 27.364H29.9724L29.0984 31.525C29.073 31.6643 29.0034 31.7783 28.8894 31.867C28.788 31.9557 28.6677 32 28.5284 32H25.9444ZM30.4664 24.742H32.6514C33.1707 24.742 33.633 24.6027 34.0384 24.324C34.4564 24.0453 34.7287 23.621 34.8554 23.051C34.9187 22.7217 34.9314 22.4303 34.8934 22.177C34.8554 21.9237 34.7224 21.721 34.4944 21.569C34.279 21.417 33.9434 21.341 33.4874 21.341H31.2074L30.4664 24.742Z"
fill="#FF0420" />
<path fillRule="evenodd" clipRule="evenodd"
d="M25 50C38.8071 50 50 38.8071 50 25C50 11.1929 38.8071 0 25 0C11.1929 0 0 11.1929 0 25C0 38.8071 11.1929 50 25 50ZM15.591 31.867C16.275 32.0823 17.016 32.19 17.814 32.19C19.6507 32.19 21.1137 31.7657 22.203 30.917C23.2923 30.0557 24.0523 28.7573 24.483 27.022C24.6097 26.4773 24.73 25.9327 24.844 25.388C24.9707 24.8433 25.0783 24.2923 25.167 23.735C25.319 22.8737 25.2937 22.12 25.091 21.474C24.901 20.828 24.5653 20.2833 24.084 19.84C23.6153 19.3967 23.039 19.0673 22.355 18.852C21.6837 18.624 20.949 18.51 20.151 18.51C18.3017 18.51 16.8323 18.9533 15.743 19.84C14.6537 20.7267 13.9 22.025 13.482 23.735C13.3553 24.2923 13.2287 24.8433 13.102 25.388C12.988 25.9327 12.8803 26.4773 12.779 27.022C12.6397 27.8833 12.665 28.637 12.855 29.283C13.0577 29.929 13.3933 30.4673 13.862 30.898C14.3307 31.3287 14.907 31.6517 15.591 31.867ZM19.866 28.846C19.3467 29.2513 18.745 29.454 18.061 29.454C17.3643 29.454 16.864 29.2513 16.56 28.846C16.256 28.4407 16.18 27.7947 16.332 26.908C16.4333 26.3507 16.5347 25.825 16.636 25.331C16.75 24.837 16.8767 24.324 17.016 23.792C17.2313 22.9053 17.5923 22.2593 18.099 21.854C18.6183 21.4487 19.22 21.246 19.904 21.246C20.588 21.246 21.0883 21.4487 21.405 21.854C21.7217 22.2593 21.7977 22.9053 21.633 23.792C21.5443 24.324 21.443 24.837 21.329 25.331C21.2277 25.825 21.1073 26.3507 20.968 26.908C20.7527 27.7947 20.3853 28.4407 19.866 28.846ZM25.6404 31.867C25.7164 31.9557 25.8177 32 25.9444 32H28.5284C28.6677 32 28.788 31.9557 28.8894 31.867C29.0034 31.7783 29.073 31.6643 29.0984 31.525L29.9724 27.364H32.5374C34.1714 27.364 35.4697 27.0157 36.4324 26.319C37.4077 25.6223 38.0537 24.5457 38.3704 23.089C38.5224 22.3543 38.516 21.7147 38.3514 21.17C38.1867 20.6127 37.8954 20.1503 37.4774 19.783C37.0594 19.4157 36.5337 19.1433 35.9004 18.966C35.2797 18.7887 34.583 18.7 33.8104 18.7H28.7564C28.6297 18.7 28.5094 18.7443 28.3954 18.833C28.2814 18.9217 28.2117 19.0357 28.1864 19.175L25.5644 31.525C25.539 31.6643 25.5644 31.7783 25.6404 31.867ZM32.6514 24.742H30.4664L31.2074 21.341H33.4874C33.9434 21.341 34.279 21.417 34.4944 21.569C34.7224 21.721 34.8554 21.9237 34.8934 22.177C34.9314 22.4303 34.9187 22.7217 34.8554 23.051C34.7287 23.621 34.4564 24.0453 34.0384 24.324C33.633 24.6027 33.1707 24.742 32.6514 24.742Z"
fill="white" />
</svg>
);
};
Expand All @@ -14,7 +18,44 @@ export const BaseIcon = (size?: number): JSX.Element => {
<svg width={size || 32} height={size || 32} viewBox="0 0 111 111" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M54.921 110.034C85.359 110.034 110.034 85.402 110.034 55.017C110.034 24.6319 85.359 0 54.921 0C26.0432 0 2.35281 22.1714 0 50.3923H72.8467V59.6416H3.9565e-07C2.35281 87.8625 26.0432 110.034 54.921 110.034Z"
fill="#0052FF"/>
fill="#0052FF" />
</svg>
);
};

export const ModeIcon = (size?: number): JSX.Element => {
return (
<svg width={size || 32} height={size || 32} viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="128" cy="128" r="128" fill="#DFFE00" />
<path
d="M203.881 195.4H174.232V128.11L186.104 89.7348L177.692 86.7415L139.215 195.4H116.666L78.1884 86.7415L69.7771 89.7348L81.6484 128.11V195.4H52V60.4H96.1444L123.526 137.688V160.378H132.474V137.688L159.856 60.4H204V195.4H203.881Z"
fill="black" />
</svg>
);
};

export const BobIcon = (size?: number): JSX.Element => {
return (
<svg width={size || 32} height={size || 32} viewBox="0 0 513 513" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M256.954 512.454C398.339 512.454 512.954 397.839 512.954 256.454C512.954 115.069 398.339 0.453613 256.954 0.453613C115.569 0.453613 0.953613 115.069 0.953613 256.454C0.953613 397.839 115.569 512.454 256.954 512.454Z"
fill="#F25D00" />
<path
d="M160.763 203.097V281.151C160.763 283.837 162.94 286.015 165.627 286.015H243.681C246.367 286.015 248.545 283.837 248.545 281.151V203.097C248.545 200.41 246.367 198.233 243.681 198.233H165.627C162.94 198.233 160.763 200.41 160.763 203.097Z"
fill="white" />
<path
d="M160.792 312.791V390.845C160.792 393.532 162.97 395.709 165.657 395.709H243.711C246.397 395.709 248.575 393.532 248.575 390.845V312.791C248.575 310.105 246.397 307.927 243.711 307.927H165.657C162.97 307.927 160.792 310.105 160.792 312.791Z"
fill="white" />
<path
d="M270.476 312.798V390.853C270.476 393.539 272.653 395.717 275.34 395.717H353.394C356.08 395.717 358.258 393.539 358.258 390.853V312.798C358.258 310.112 356.08 307.934 353.394 307.934H275.34C272.653 307.934 270.476 310.112 270.476 312.798Z"
fill="white" />
<path
d="M270.476 203.071V281.126C270.476 283.812 272.653 285.99 275.34 285.99H353.394C356.08 285.99 358.258 283.812 358.258 281.126V203.071C358.258 200.385 356.08 198.207 353.394 198.207H275.34C272.653 198.207 270.476 200.385 270.476 203.071Z"
fill="white" />
<path
d="M243.681 88.5151H165.627C162.94 88.5151 160.763 90.6929 160.763 93.3792V171.434C160.763 174.12 162.94 176.298 165.627 176.298H243.681C246.367 176.298 248.545 174.12 248.545 171.434V93.3792C248.545 90.6929 246.367 88.5151 243.681 88.5151Z"
fill="white" />
</svg>

);
};
16 changes: 10 additions & 6 deletions app/utils/chains/id-maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@ export const getChainId = (chainName: string, env: string): number => {
}

return chainMap[chainName as ChainName];
}
};

export type ChainName = 'optimism' | 'base';
export type ChainName = 'optimism' | 'base' | 'mode' | 'bob';

export const mainnetIdMap: Record<ChainName, number> = {
'optimism': 10,
'base': 8453,
}
'optimism': 10,
'base': 8453,
'mode': 34443,
'bob': 60808
};

export const sepoliaIdMap: Record<ChainName, number> = {
'optimism': 11155420,
'base': 84532,
}
'mode': 919,
'bob': 808813
};
Loading