common

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package common contains constants and types used across op-rosetta.

Index

Constants

View Source
const (
	// MintOpType is a [RosettaTypes.Operation] type for an Optimism Deposit or "mint" transaction.
	MintOpType = "MINT"
	// BurnOpType is a [RosettaTypes.Operation] type for an Optimism Withdrawal or "burn" transaction.
	BurnOpType = "BURN"
	// An erroneous STOP Type not defined in rosetta-geth-sdk
	StopOpType = "STOP"
)

Op Types

View Source
const (

	// TransferEvent is emitted when an ERC20 token is transferred.
	//
	// TransferEvent is emitted in two bridging scenarios:
	// 1. When a native token is being sent to a non-native chain, from the sender to the bridge contract.
	//    Think: Transferring USDC on Ethereum Mainnet to the Optimism bridge contract,
	//    you will see a Transfer event from the sender (you) to the bridge contract.
	// 2. When a non-native token is being sent to a native chain, from the bridge to the sender contract.
	// 	  Think: "Withdrawing" USDC from Optimism to Ethereum Mainnet. You will see a Transfer event
	// 	  from the bridge contract to you (the sender) once the withdrawal is finalized on Mainnet.
	TransferEvent = "Transfer(address,address,uint256)"

	// ERC20BridgeInitiatedEvent is the topic for the ERC20BridgeInitiated event.
	// It is emitted on the originating chain where a bridge is initiated.
	ERC20BridgeInitiatedEvent = "ERC20BridgeInitiated(address,address,address,address,uint256,bytes)"

	// ERC20BridgeFinalizedEvent is the topic for the ERC20BridgeFinalized event.
	// It is emitted on the destination chain where a bridge is finalized.
	ERC20BridgeFinalizedEvent = "ERC20BridgeFinalized(address,address,address,address,uint256,bytes)"

	// Burn event is emitted when a non-native token is being sent to a native chain.
	// For example, consider Bob bridged 100 Token A (native to Ethereum Mainnet) from Ethereum Mainnet to Optimism.
	// Bob now has 100 Token A on Optimism. He then bridges 100 Token A from Optimism to Ethereum Mainnet.
	// In this case, Bob is bridging a non-native token (Token A) from Optimism to the token's native chain (Ethereum Mainnet).
	// In this case, an ERC20BridgeInitiated event will be emitted alongside a Burn event FROM the sender.
	BurnEvent = "Burn(address,uint256)"

	// Mint event is emitted when a non-native token is being sent to a native chain.
	// For example, consider Bob is bridging 100 Token A (native to Ethereum Mainnet) from Ethereum Mainnet to Optimism.
	// Bob will see a Mint event on Optimism TO the sender (Bob).
	MintEvent = "Mint(address,uint256)"
)

Event Topics

Variables

View Source
var (
	// The BaseFeeVault predeploy receives the basefees on L2.
	// The basefee is not burnt on L2 like it is on L1.
	// Once the contract has received a certain amount of fees,
	// the ETH can be permissionlessly withdrawn to an immutable address on L1.
	BaseFeeVault = common.HexToAddress("0x4200000000000000000000000000000000000019")

	// The L1FeeVault predeploy receives the L1 portion of the transaction fees.
	// Once the contract has received a certain amount of fees,
	// the ETH can be permissionlessly withdrawn to an immutable address on L1.
	L1FeeVault = common.HexToAddress("0x420000000000000000000000000000000000001a")

	// The L2ToL1MessagePasser stores commitments to withdrawal transactions.
	// When a user is submitting the withdrawing transaction on L1,
	// they provide a proof that the transaction that they withdrew on L2 is in
	// the sentMessages mapping of this contract.
	//
	// Any withdrawn ETH accumulates into this contract on L2 and can be
	// permissionlessly removed from the L2 supply by calling the burn() function.
	L2ToL1MessagePasser = common.HexToAddress("0x4200000000000000000000000000000000000016")

	// The L2StandardBridge predeploy is the contract on L2 used to bridge assets to L1.
	L2StandardBridge = common.HexToAddress("0x4200000000000000000000000000000000000010")
)

Optimism Predeploy Addresses (represented as 0x-prefixed hex string) See PredeployedContracts for more information.

View Source
var (
	// L1StandardBridge is the Ethereum Mainnet Standard Bridge contract deployment.
	//
	L1StandardBridge = common.HexToAddress("0x25ace71c97B33Cc4729CF772ae268934F7ab5fA1")
)

Optimism Deployed Contracts

Functions

func ContainsTopic

func ContainsTopic(log *types.Log, topic string) bool

ContainsTopic tests if a log contains a given topic. It is expected that the topic is encoded as a hex string. To encode a topic string, use the below [EncodeEventString] function.

func HashEvent

func HashEvent(topic string) string

HashEvent encodes an event string into a topic hash.

func Keccak256

func Keccak256(s string) string

Keccak256 computes the keccak256 hash of the given string. Encodes the resulting hash as a hex string with a 0x prefix.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL