Last active
September 27, 2023 14:27
-
-
Save wilsoncusack/ae6116b530591c3505b9fe2580d3c95d to your computer and use it in GitHub Desktop.
possible opstack configs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { Chain, Address, ChainContract } from 'viem' | |
export enum OpStackL1Contract { | |
L1CrossDomainMessenger = 'l1CrossDomainMessenger', | |
L1Erc721Bridge = 'l1Erc721Bridge', | |
L1StandardBridge = 'l1StandardBridge', | |
L2OutputOracle = 'l2OutputOracle', | |
OptimismPortal = 'optimismPortal', | |
} | |
//// 1 //// | |
export type OpStackConfig = { | |
l1: { // could also call it like `daChain` or something else. But `l1` is probably the smooth brain right choice. | |
chainId: number | |
contracts: { | |
[key in OpStackL1Contract]: ChainContract | |
} | |
} | |
/// add other fields eventually | |
} | |
// usage, can typcheck base.l1.chainId matches client.chainId | |
writeDepositTransaction(client, portal: base.l1.contracts.optimismPortal, ...) | |
//// 2 //// | |
type Contract<ChainId = number> = { address: Address, chainId: ChainId } | |
export type OpStackConfig = { | |
[key: string]: Contract | |
// more explicit, but then chainId in the Contract type seems redudant? Maybe not if we add more later | |
[key in OpStackL1Contract]: Contract | |
} | |
// usage, can typcheck base.portal.chainId matches client.chainId | |
writeDepositTransaction(client, portal: base.portal, ...) | |
//// 3 //// | |
??? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment