Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) GetBridgeByDepositCount(ctx context.Context, networkID uint32, depositCount uint32) (*types.BridgeResponse, error)
- func (c *Client) GetBridges(ctx context.Context, params GetBridgesParams) (*types.BridgesResult, error)
- func (c *Client) GetBridgesByContent(ctx context.Context, params GetBridgesByContentParams) (*types.BridgesByContentResult, error)
- func (c *Client) GetClaimProof(ctx context.Context, networkID, leafIndex, depositCount uint32) (*types.ClaimProof, error)
- func (c *Client) GetClaims(ctx context.Context, params GetClaimsParams) (*types.ClaimsResult, error)
- func (c *Client) GetClaimsByGER(ctx context.Context, networkID uint32, ger string) (*types.ClaimsByGERResult, error)
- func (c *Client) GetInjectedL1InfoLeaf(ctx context.Context, networkID, leafIndex int) (*types.L1InfoTreeLeafResponse, error)
- func (c *Client) GetL1InfoTreeIndex(ctx context.Context, networkID, depositCount int) (uint32, error)
- func (c *Client) GetLastReorgEvent(ctx context.Context, networkID int) (*bridgesync.LastReorg, error)
- func (c *Client) GetLegacyTokenMigrations(ctx context.Context, params GetLegacyTokenMigrationsParams) (*types.LegacyTokenMigrationsResult, error)
- func (c *Client) GetRemoveGEREvents(ctx context.Context, params GetRemoveGEREventsParams) (*types.RemoveGEREventsResult, error)
- func (c *Client) GetSetClaims(ctx context.Context, params GetSetClaimsParams) (*types.SetClaimsResult, error)
- func (c *Client) GetSyncStatus(ctx context.Context) (*types.SyncStatus, error)
- func (c *Client) GetTokenMappings(ctx context.Context, params GetTokenMappingsParams) (*types.TokenMappingsResult, error)
- func (c *Client) GetUnsetClaims(ctx context.Context, params GetUnsetClaimsParams) (*types.UnsetClaimsResult, error)
- func (c *Client) HealthCheck(ctx context.Context) (*types.HealthCheckResponse, error)
- type Config
- type GetBridgesByContentParams
- type GetBridgesParams
- type GetClaimsParams
- type GetLegacyTokenMigrationsParams
- type GetRemoveGEREventsParams
- type GetSetClaimsParams
- type GetTokenMappingsParams
- type GetUnsetClaimsParams
Examples ¶
- Client.GetBridges
- Client.GetClaimProof
- Client.GetClaims
- Client.GetInjectedL1InfoLeaf
- Client.GetL1InfoTreeIndex
- Client.GetLastReorgEvent
- Client.GetLegacyTokenMigrations
- Client.GetRemoveGEREvents
- Client.GetSetClaims
- Client.GetSyncStatus
- Client.GetTokenMappings
- Client.GetUnsetClaims
- Client.HealthCheck
- New
Constants ¶
const ( // DefaultTimeout is the default HTTP client timeout DefaultTimeout = 30 * time.Second )
Variables ¶
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when a resource is not found (HTTP 404)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for the bridgeservice REST API
func New ¶
New creates a new bridgeservice client
Example ¶
package main
import (
"fmt"
"time"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
// Create a client with default timeout (30 seconds)
_ = client.New(client.Config{
BaseURL: "http://localhost:8080",
})
fmt.Printf("Client created with base URL: %s\n", "http://localhost:8080")
// Create a client with custom timeout
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
Timeout: 10 * time.Second,
})
_ = c
}
Output:
func (*Client) GetBridgeByDepositCount ¶
func (c *Client) GetBridgeByDepositCount( ctx context.Context, networkID uint32, depositCount uint32, ) (*types.BridgeResponse, error)
GetBridgeByDepositCount retrieves the bridge for the given network and deposit count. Returns ErrNotFound if the bridge does not exist in bridge or bridge_archive.
func (*Client) GetBridges ¶
func (c *Client) GetBridges(ctx context.Context, params GetBridgesParams) (*types.BridgesResult, error)
GetBridges retrieves paginated bridge events
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
})
// Minimal parameters
resp, err := c.GetBridges(context.Background(), client.GetBridgesParams{
NetworkID: 1,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Total bridges: %d\n", resp.Count)
// With optional parameters
pageNum := uint32(1)
pageSize := uint32(20)
depositCount := uint64(10)
fromAddr := "0x1234567890123456789012345678901234567890"
resp, err = c.GetBridges(context.Background(), client.GetBridgesParams{
NetworkID: 1,
PageNumber: &pageNum,
PageSize: &pageSize,
DepositCount: &depositCount,
FromAddress: &fromAddr,
NetworkIDs: []uint32{2, 3},
})
if err != nil {
log.Fatal(err)
}
for _, bridge := range resp.Bridges {
fmt.Printf("Bridge at block %d\n", bridge.BlockNum)
}
}
Output:
func (*Client) GetBridgesByContent ¶
func (c *Client) GetBridgesByContent( ctx context.Context, params GetBridgesByContentParams, ) (*types.BridgesByContentResult, error)
GetBridgesByContent retrieves bridges matching the given content fields for the specified network.
func (*Client) GetClaimProof ¶
func (c *Client) GetClaimProof( ctx context.Context, networkID, leafIndex, depositCount uint32, ) (*types.ClaimProof, error)
GetClaimProof retrieves Merkle proofs for claim verification
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
})
proof, err := c.GetClaimProof(context.Background(), 1, 10, 5)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Claim proof retrieved for L1 Info Tree Index: %d\n", proof.L1InfoTreeLeaf.L1InfoTreeIndex)
}
Output:
func (*Client) GetClaims ¶
func (c *Client) GetClaims(ctx context.Context, params GetClaimsParams) (*types.ClaimsResult, error)
GetClaims retrieves paginated claims
Example ¶
package main
import (
"context"
"fmt"
"log"
"math/big"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
})
includeAll := true
globalIndex := big.NewInt(123)
resp, err := c.GetClaims(context.Background(), client.GetClaimsParams{
NetworkID: 1,
IncludeAllFields: &includeAll,
GlobalIndex: globalIndex,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Total claims: %d\n", resp.Count)
}
Output:
func (*Client) GetClaimsByGER ¶
func (c *Client) GetClaimsByGER(ctx context.Context, networkID uint32, ger string) (*types.ClaimsByGERResult, error)
GetClaimsByGER retrieves all claims matching the given global exit root (0x-prefixed hex hash) for the specified network (0 for L1, L2 network ID otherwise).
func (*Client) GetInjectedL1InfoLeaf ¶
func (c *Client) GetInjectedL1InfoLeaf( ctx context.Context, networkID, leafIndex int, ) (*types.L1InfoTreeLeafResponse, error)
GetInjectedL1InfoLeaf retrieves an injected L1 info tree leaf
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
})
resp, err := c.GetInjectedL1InfoLeaf(context.Background(), 2, 5)
if err != nil {
log.Fatal(err)
}
fmt.Printf("L1 Info Tree Index: %d, Block: %d\n", resp.L1InfoTreeIndex, resp.BlockNumber)
}
Output:
func (*Client) GetL1InfoTreeIndex ¶
func (c *Client) GetL1InfoTreeIndex(ctx context.Context, networkID, depositCount int) (uint32, error)
GetL1InfoTreeIndex retrieves the L1 Info Tree index for a bridge
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
})
index, err := c.GetL1InfoTreeIndex(context.Background(), 1, 10)
if err != nil {
log.Fatal(err)
}
fmt.Printf("L1 Info Tree Index: %d\n", index)
}
Output:
func (*Client) GetLastReorgEvent ¶
func (c *Client) GetLastReorgEvent(ctx context.Context, networkID int) (*bridgesync.LastReorg, error)
GetLastReorgEvent retrieves the last reorganization event
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
})
// For L1 (networkID = 0)
resp, err := c.GetLastReorgEvent(context.Background(), 0)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Last reorg from block %d to block %d\n", resp.FromBlock, resp.ToBlock)
}
Output:
func (*Client) GetLegacyTokenMigrations ¶
func (c *Client) GetLegacyTokenMigrations( ctx context.Context, params GetLegacyTokenMigrationsParams, ) (*types.LegacyTokenMigrationsResult, error)
GetLegacyTokenMigrations retrieves legacy token migrations
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
})
resp, err := c.GetLegacyTokenMigrations(context.Background(), client.GetLegacyTokenMigrationsParams{
NetworkID: 2,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Total legacy token migrations: %d\n", resp.Count)
}
Output:
func (*Client) GetRemoveGEREvents ¶
func (c *Client) GetRemoveGEREvents( ctx context.Context, params GetRemoveGEREventsParams, ) (*types.RemoveGEREventsResult, error)
GetRemoveGEREvents retrieves removed GER (Global Exit Root) events
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
})
ger := "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
limit := 25
resp, err := c.GetRemoveGEREvents(context.Background(), client.GetRemoveGEREventsParams{
GlobalExitRoot: &ger,
Limit: &limit,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Total remove GER events: %d\n", resp.Count)
}
Output:
func (*Client) GetSetClaims ¶
func (c *Client) GetSetClaims(ctx context.Context, params GetSetClaimsParams) (*types.SetClaimsResult, error)
GetSetClaims retrieves set claims (L2 only)
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
})
pageNum := 1
pageSize := 10
resp, err := c.GetSetClaims(context.Background(), client.GetSetClaimsParams{
PageNumber: &pageNum,
PageSize: &pageSize,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Total set claims: %d\n", resp.Count)
}
Output:
func (*Client) GetSyncStatus ¶
GetSyncStatus retrieves the bridge synchronization status
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
})
resp, err := c.GetSyncStatus(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Printf("L1 Synced: %v, L2 Synced: %v\n", resp.L1Info.IsSynced, resp.L2Info.IsSynced)
}
Output:
func (*Client) GetTokenMappings ¶
func (c *Client) GetTokenMappings( ctx context.Context, params GetTokenMappingsParams, ) (*types.TokenMappingsResult, error)
GetTokenMappings retrieves token mappings
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
})
tokenAddr := "0xabcdef0123456789abcdef0123456789abcdef01"
resp, err := c.GetTokenMappings(context.Background(), client.GetTokenMappingsParams{
NetworkID: 1,
OriginTokenAddress: &tokenAddr,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Total token mappings: %d\n", resp.Count)
}
Output:
func (*Client) GetUnsetClaims ¶
func (c *Client) GetUnsetClaims(ctx context.Context, params GetUnsetClaimsParams) (*types.UnsetClaimsResult, error)
GetUnsetClaims retrieves unset claims (L2 only)
Example ¶
package main
import (
"context"
"fmt"
"log"
"math/big"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
})
pageNum := 1
pageSize := 10
globalIndex := big.NewInt(456)
resp, err := c.GetUnsetClaims(context.Background(), client.GetUnsetClaimsParams{
PageNumber: &pageNum,
PageSize: &pageSize,
GlobalIndex: globalIndex,
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Total unset claims: %d\n", resp.Count)
}
Output:
func (*Client) HealthCheck ¶
HealthCheck performs a health check
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/agglayer/aggkit/bridgeservice/client"
)
func main() {
c := client.New(client.Config{
BaseURL: "http://localhost:8080",
})
resp, err := c.HealthCheck(context.Background())
if err != nil {
log.Fatal(err)
}
fmt.Printf("Status: %s\n", resp.Status)
}
Output:
type GetBridgesByContentParams ¶
type GetBridgesByContentParams struct {
NetworkID uint32
LeafType uint8
OriginAddress string
DestinationNetwork uint32
DestinationAddress string
Amount *big.Int
Metadata []byte
}
GetBridgesByContentParams holds the content fields for GetBridgesByContent
type GetBridgesParams ¶
type GetBridgesParams struct {
NetworkID uint32
PageNumber *uint32
PageSize *uint32
DepositCount *uint64
FromAddress *string
NetworkIDs []uint32
}
GetBridgesParams contains parameters for GetBridges
type GetClaimsParams ¶
type GetClaimsParams struct {
NetworkID uint32
PageNumber *uint32
PageSize *uint32
NetworkIDs []uint32
IncludeAllFields *bool
GlobalIndex *big.Int
}
GetClaimsParams contains parameters for GetClaims
type GetLegacyTokenMigrationsParams ¶
GetLegacyTokenMigrationsParams contains parameters for GetLegacyTokenMigrations
type GetRemoveGEREventsParams ¶
GetRemoveGEREventsParams contains parameters for GetRemoveGEREvents
type GetSetClaimsParams ¶
GetSetClaimsParams contains parameters for GetSetClaims