github.com/ethereum-optimism/optimism@v1.7.2/packages/sdk/src/interfaces/types.ts (about) 1 import { 2 Provider, 3 TransactionReceipt, 4 TransactionResponse, 5 } from '@ethersproject/abstract-provider' 6 import { Signer } from '@ethersproject/abstract-signer' 7 import { Contract, BigNumber } from 'ethers' 8 9 import { CrossChainMessenger } from '../cross-chain-messenger' 10 import { IBridgeAdapter } from './bridge-adapter' 11 12 /** 13 * L1 network chain IDs 14 */ 15 export enum L1ChainID { 16 MAINNET = 1, 17 GOERLI = 5, 18 SEPOLIA = 11155111, 19 HARDHAT_LOCAL = 31337, 20 BEDROCK_LOCAL_DEVNET = 900, 21 } 22 23 /** 24 * L2 network chain IDs 25 */ 26 export enum L2ChainID { 27 OPTIMISM = 10, 28 OPTIMISM_GOERLI = 420, 29 OPTIMISM_SEPOLIA = 11155420, 30 OPTIMISM_HARDHAT_LOCAL = 31337, 31 OPTIMISM_HARDHAT_DEVNET = 17, 32 OPTIMISM_BEDROCK_ALPHA_TESTNET = 28528, 33 BASE_GOERLI = 84531, 34 BASE_SEPOLIA = 84532, 35 BASE_MAINNET = 8453, 36 ZORA_GOERLI = 999, 37 ZORA_MAINNET = 7777777, 38 } 39 40 /** 41 * L1 contract references. 42 */ 43 export interface OEL1Contracts { 44 AddressManager: Contract 45 L1CrossDomainMessenger: Contract 46 L1StandardBridge: Contract 47 StateCommitmentChain: Contract 48 CanonicalTransactionChain: Contract 49 BondManager: Contract 50 // Bedrock 51 OptimismPortal: Contract 52 L2OutputOracle: Contract 53 // FPAC 54 OptimismPortal2?: Contract 55 DisputeGameFactory?: Contract 56 } 57 58 /** 59 * L2 contract references. 60 */ 61 export interface OEL2Contracts { 62 L2CrossDomainMessenger: Contract 63 L2StandardBridge: Contract 64 L2ToL1MessagePasser: Contract 65 OVM_L1BlockNumber: Contract 66 OVM_L2ToL1MessagePasser: Contract 67 OVM_DeployerWhitelist: Contract 68 OVM_ETH: Contract 69 OVM_GasPriceOracle: Contract 70 OVM_SequencerFeeVault: Contract 71 WETH: Contract 72 BedrockMessagePasser: Contract 73 } 74 75 /** 76 * Represents Optimism contracts, assumed to be connected to their appropriate 77 * providers and addresses. 78 */ 79 export interface OEContracts { 80 l1: OEL1Contracts 81 l2: OEL2Contracts 82 } 83 84 /** 85 * Convenience type for something that looks like the L1 OE contract interface but could be 86 * addresses instead of actual contract objects. 87 */ 88 export type OEL1ContractsLike = { 89 [K in keyof OEL1Contracts]: AddressLike 90 } 91 92 /** 93 * Convenience type for something that looks like the L2 OE contract interface but could be 94 * addresses instead of actual contract objects. 95 */ 96 export type OEL2ContractsLike = { 97 [K in keyof OEL2Contracts]: AddressLike 98 } 99 100 /** 101 * Convenience type for something that looks like the OE contract interface but could be 102 * addresses instead of actual contract objects. 103 */ 104 export interface OEContractsLike { 105 l1: OEL1ContractsLike 106 l2: OEL2ContractsLike 107 } 108 109 /** 110 * Something that looks like the list of custom bridges. 111 */ 112 export interface BridgeAdapterData { 113 [name: string]: { 114 Adapter: new (opts: { 115 messenger: CrossChainMessenger 116 l1Bridge: AddressLike 117 l2Bridge: AddressLike 118 }) => IBridgeAdapter 119 l1Bridge: AddressLike 120 l2Bridge: AddressLike 121 } 122 } 123 124 /** 125 * Something that looks like the list of custom bridges. 126 */ 127 export interface BridgeAdapters { 128 [name: string]: IBridgeAdapter 129 } 130 131 /** 132 * Enum describing the status of a message. 133 */ 134 export enum MessageStatus { 135 /** 136 * Message is an L1 to L2 message and has not been processed by the L2. 137 */ 138 UNCONFIRMED_L1_TO_L2_MESSAGE, 139 140 /** 141 * Message is an L1 to L2 message and the transaction to execute the message failed. 142 * When this status is returned, you will need to resend the L1 to L2 message, probably with a 143 * higher gas limit. 144 */ 145 FAILED_L1_TO_L2_MESSAGE, 146 147 /** 148 * Message is an L2 to L1 message and no state root has been published yet. 149 */ 150 STATE_ROOT_NOT_PUBLISHED, 151 152 /** 153 * Message is ready to be proved on L1 to initiate the challenge period. 154 */ 155 READY_TO_PROVE, 156 157 /** 158 * Message is a proved L2 to L1 message and is undergoing the challenge period. 159 */ 160 IN_CHALLENGE_PERIOD, 161 162 /** 163 * Message is ready to be relayed. 164 */ 165 READY_FOR_RELAY, 166 167 /** 168 * Message has been relayed. 169 */ 170 RELAYED, 171 } 172 173 /** 174 * Enum describing the direction of a message. 175 */ 176 export enum MessageDirection { 177 L1_TO_L2, 178 L2_TO_L1, 179 } 180 181 /** 182 * Partial message that needs to be signed and executed by a specific signer. 183 */ 184 export interface CrossChainMessageRequest { 185 direction: MessageDirection 186 target: string 187 message: string 188 } 189 190 /** 191 * Core components of a cross chain message. 192 */ 193 export interface CoreCrossChainMessage { 194 sender: string 195 target: string 196 message: string 197 messageNonce: BigNumber 198 value: BigNumber 199 minGasLimit: BigNumber 200 } 201 202 /** 203 * Describes a message that is sent between L1 and L2. Direction determines where the message was 204 * sent from and where it's being sent to. 205 */ 206 export interface CrossChainMessage extends CoreCrossChainMessage { 207 direction: MessageDirection 208 logIndex: number 209 blockNumber: number 210 transactionHash: string 211 } 212 213 /** 214 * Describes messages sent inside the L2ToL1MessagePasser on L2. Happens to be the same structure 215 * as the CoreCrossChainMessage so we'll reuse the type for now. 216 */ 217 export type LowLevelMessage = CoreCrossChainMessage 218 219 /** 220 * Describes a token withdrawal or deposit, along with the underlying raw cross chain message 221 * behind the deposit or withdrawal. 222 */ 223 export interface TokenBridgeMessage { 224 direction: MessageDirection 225 from: string 226 to: string 227 l1Token: string 228 l2Token: string 229 amount: BigNumber 230 data: string 231 logIndex: number 232 blockNumber: number 233 transactionHash: string 234 } 235 236 /** 237 * Represents a withdrawal entry within the logs of a L2 to L1 238 * CrossChainMessage 239 */ 240 export interface WithdrawalEntry { 241 MessagePassed: any 242 } 243 244 /** 245 * Enum describing the status of a CrossDomainMessage message receipt. 246 */ 247 export enum MessageReceiptStatus { 248 RELAYED_FAILED, 249 RELAYED_SUCCEEDED, 250 } 251 252 /** 253 * CrossDomainMessage receipt. 254 */ 255 export interface MessageReceipt { 256 receiptStatus: MessageReceiptStatus 257 transactionReceipt: TransactionReceipt 258 } 259 260 /** 261 * ProvenWithdrawal in OptimismPortal 262 */ 263 export interface ProvenWithdrawal { 264 outputRoot: string 265 timestamp: BigNumber 266 l2BlockNumber: BigNumber 267 } 268 269 /** 270 * Header for a state root batch. 271 */ 272 export interface StateRootBatchHeader { 273 batchIndex: BigNumber 274 batchRoot: string 275 batchSize: BigNumber 276 prevTotalElements: BigNumber 277 extraData: string 278 } 279 280 /** 281 * Information about a state root, including header, block number, and root iself. 282 */ 283 export interface StateRoot { 284 stateRoot: string 285 stateRootIndexInBatch: number 286 batch: StateRootBatch 287 } 288 289 /** 290 * Information about a batch of state roots. 291 */ 292 export interface StateRootBatch { 293 blockNumber: number 294 header: StateRootBatchHeader 295 stateRoots: string[] 296 } 297 298 /** 299 * Proof data required to finalize an L2 to L1 message. 300 */ 301 export interface CrossChainMessageProof { 302 stateRoot: string 303 stateRootBatchHeader: StateRootBatchHeader 304 stateRootProof: { 305 index: number 306 siblings: string[] 307 } 308 stateTrieWitness: string 309 storageTrieWitness: string 310 } 311 312 /** 313 * Stuff that can be coerced into a transaction. 314 */ 315 export type TransactionLike = string | TransactionReceipt | TransactionResponse 316 317 /** 318 * Stuff that can be coerced into a CrossChainMessage. 319 */ 320 export type MessageLike = 321 | CrossChainMessage 322 | TransactionLike 323 | TokenBridgeMessage 324 325 /** 326 * Stuff that can be coerced into a CrossChainMessageRequest. 327 */ 328 export type MessageRequestLike = 329 | CrossChainMessageRequest 330 | CrossChainMessage 331 | TransactionLike 332 | TokenBridgeMessage 333 334 /** 335 * Stuff that can be coerced into a provider. 336 */ 337 export type ProviderLike = string | Provider 338 339 /** 340 * Stuff that can be coerced into a signer. 341 */ 342 export type SignerLike = string | Signer 343 344 /** 345 * Stuff that can be coerced into a signer or provider. 346 */ 347 export type SignerOrProviderLike = SignerLike | ProviderLike 348 349 /** 350 * Stuff that can be coerced into an address. 351 */ 352 export type AddressLike = string | Contract 353 354 /** 355 * Stuff that can be coerced into a number. 356 */ 357 export type NumberLike = string | number | BigNumber