rpc

package
v0.3.0-beta3-tmp-bridge Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: Apache-2.0, MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPageSize is the default number of records to be fetched
	DefaultPageSize = 20
	// MaxPageSize is the maximum number of records to be fetched
	MaxPageSize = 200
	// DefaultPage is the default page number to be used when fetching records
	DefaultPage = 1
)
View Source
const (
	// BRIDGE is the namespace of the bridge service
	BRIDGE = "bridge"
)

Variables

View Source
var (
	ErrNotOnL1Info = errors.New("this bridge has not been included on the L1 Info Tree yet")
)

Functions

This section is empty.

Types

type BridgeEndpoints

type BridgeEndpoints struct {
	// contains filtered or unexported fields
}

BridgeEndpoints contains implementations for the "bridge" RPC endpoints

func NewBridgeEndpoints

func NewBridgeEndpoints(
	logger *log.Logger,
	writeTimeout time.Duration,
	readTimeout time.Duration,
	networkID uint32,
	sponsor ClaimSponsorer,
	l1InfoTree L1InfoTreer,
	injectedGERs LastGERer,
	bridgeL1 Bridger,
	bridgeL2 Bridger,
) *BridgeEndpoints

NewBridgeEndpoints returns BridgeEndpoints

func (*BridgeEndpoints) ClaimProof

func (b *BridgeEndpoints) ClaimProof(
	networkID uint32, depositCount uint32, l1InfoTreeIndex uint32,
) (interface{}, rpc.Error)

ClaimProof returns the proofs needed to claim a bridge. NetworkID and depositCount refere to the bridge origin while globalExitRoot should be already injected on the destination network. This call needs to be done to a client of the same network were the bridge tx was sent

func (*BridgeEndpoints) GetBridges

func (b *BridgeEndpoints) GetBridges(networkID uint32, pageNumber, pageSize *uint32,
	depositCount *uint64, networkIDs []uint32) (interface{}, rpc.Error)

GetBridges returns the bridges for the given network and the total count of bridges. If networkID is 0, it returns the bridges for the L1 network. If networkID is the same as the client, it returns the bridges for the L2 network. The result is paginated.

func (*BridgeEndpoints) GetClaims

func (b *BridgeEndpoints) GetClaims(networkID uint32, pageNumber,
	pageSize *uint32, networkIDs []uint32) (interface{}, rpc.Error)

GetClaims returns the claims for the given network. If networkID is 0, it returns the claims for the L1 network. If networkID is the same as the client, it returns the claims for the L2 network. The result is paginated.

func (*BridgeEndpoints) GetLastReorgEvent

func (b *BridgeEndpoints) GetLastReorgEvent(networkID uint32) (interface{}, rpc.Error)

func (*BridgeEndpoints) GetLegacyTokenMigrations

func (b *BridgeEndpoints) GetLegacyTokenMigrations(
	networkID uint32, pageNumber, pageSize *uint32) (interface{}, rpc.Error)

GetLegacyTokenMigrations returns the legacy token migrations for the given network. If networkID is 0, it returns the legacy token migrations for the L1 network. If networkID is the same as the client, it returns the legacy token migrations for the L2 network. The result is paginated.

func (*BridgeEndpoints) GetSponsoredClaimStatus

func (b *BridgeEndpoints) GetSponsoredClaimStatus(globalIndex *big.Int) (interface{}, rpc.Error)

GetSponsoredClaimStatus returns the status of a claim that has been previously requested to be sponsored. This call needs to be done to the same client were it was requested to be sponsored

func (*BridgeEndpoints) GetTokenMappings

func (b *BridgeEndpoints) GetTokenMappings(networkID uint32, pageNumber, pageSize *uint32) (interface{}, rpc.Error)

GetTokenMappings returns the token mappings for the given network. If networkID is 0, it returns the token mappings for the L1 network. If networkID is the same as the client, it returns the token mappings for the L2 network. The result is paginated.

func (*BridgeEndpoints) InjectedInfoAfterIndex

func (b *BridgeEndpoints) InjectedInfoAfterIndex(networkID uint32, l1InfoTreeIndex uint32) (interface{}, rpc.Error)

InjectedInfoAfterIndex return the first GER injected onto the network that is linked to the given index or greater. This call is useful to understand when a bridge is ready to be claimed on its destination network

func (*BridgeEndpoints) L1InfoTreeIndexForBridge

func (b *BridgeEndpoints) L1InfoTreeIndexForBridge(networkID uint32, depositCount uint32) (interface{}, rpc.Error)

L1InfoTreeIndexForBridge returns the first L1 Info Tree index in which the bridge was included. networkID represents the origin network. This call needs to be done to a client of the same network were the bridge tx was sent

func (*BridgeEndpoints) SponsorClaim

func (b *BridgeEndpoints) SponsorClaim(claim claimsponsor.Claim) (interface{}, rpc.Error)

SponsorClaim sends a claim tx on behalf of the user. This call needs to be done to a client of the same network were the claim is going to be sent (bridge destination)

type Bridger

type Bridger interface {
	GetProof(ctx context.Context, depositCount uint32, localExitRoot common.Hash) (tree.Proof, error)
	GetRootByLER(ctx context.Context, ler common.Hash) (*tree.Root, error)
	GetBridgesPaged(ctx context.Context, pageNumber, pageSize uint32,
		depositCount *uint64, networkIDs []uint32) ([]*bridgesync.BridgeResponse, int, error)
	GetTokenMappings(ctx context.Context, pageNumber, pageSize uint32) ([]*bridgesync.TokenMapping, int, error)
	GetLegacyTokenMigrations(ctx context.Context,
		pageNumber, pageSize uint32) ([]*bridgesync.LegacyTokenMigration, int, error)
	GetClaimsPaged(ctx context.Context, page, pageSize uint32,
		networkIDs []uint32) ([]*bridgesync.ClaimResponse, int, error)
	GetLastReorgEvent(ctx context.Context) (*bridgesync.LastReorg, error)
}

type BridgesResult

type BridgesResult struct {
	Bridges []*bridgesync.BridgeResponse `json:"bridges"`
	Count   int                          `json:"count"`
}

BridgesResult contains the bridges and the total count of bridges

type ClaimSponsorer

type ClaimSponsorer interface {
	AddClaimToQueue(claim *claimsponsor.Claim) error
	GetClaim(globalIndex *big.Int) (*claimsponsor.Claim, error)
}

type ClaimsResult

type ClaimsResult struct {
	Claims []*bridgesync.ClaimResponse `json:"claims"`
	Count  int                         `json:"count"`
}

ClaimsResult contains the claims and the total count of claims

type L1InfoTreer

type L1InfoTreer interface {
	GetInfoByIndex(ctx context.Context, index uint32) (*l1infotreesync.L1InfoTreeLeaf, error)
	GetRollupExitTreeMerkleProof(ctx context.Context, networkID uint32, root common.Hash) (tree.Proof, error)
	GetLocalExitRoot(ctx context.Context, networkID uint32, rollupExitRoot common.Hash) (common.Hash, error)
	GetLastInfo() (*l1infotreesync.L1InfoTreeLeaf, error)
	GetFirstInfo() (*l1infotreesync.L1InfoTreeLeaf, error)
	GetFirstInfoAfterBlock(blockNum uint64) (*l1infotreesync.L1InfoTreeLeaf, error)
	GetLastVerifiedBatches(rollupID uint32) (*l1infotreesync.VerifyBatches, error)
	GetFirstVerifiedBatches(rollupID uint32) (*l1infotreesync.VerifyBatches, error)
	GetFirstVerifiedBatchesAfterBlock(rollupID uint32, blockNum uint64) (*l1infotreesync.VerifyBatches, error)
	GetFirstL1InfoWithRollupExitRoot(rollupExitRoot common.Hash) (*l1infotreesync.L1InfoTreeLeaf, error)
}

type LastGERer

type LastGERer interface {
	GetFirstGERAfterL1InfoTreeIndex(
		ctx context.Context, atOrAfterL1InfoTreeIndex uint32,
	) (lastgersync.GlobalExitRootInfo, error)
}

type LegacyTokenMigrationsResult

type LegacyTokenMigrationsResult struct {
	TokenMigrations []*bridgesync.LegacyTokenMigration `json:"legacyTokenMigrations"`
	Count           int                                `json:"count"`
}

LegacyTokenMigrationsResult contains the legacy token migrations and the total count of such migrations

type TokenMappingsResult

type TokenMappingsResult struct {
	TokenMappings []*bridgesync.TokenMapping `json:"tokenMappings"`
	Count         int                        `json:"count"`
}

TokenMappingsResult contains the token mappings and the total count of token mappings

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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