Documentation
¶
Overview ¶
Package bridge implements optional Wayfinder bridge operations for Canton.
It provides deposit/withdrawal flows and bridge-related event queries. The bridge client is optional.
Index ¶
- type Bridge
- type Client
- func (c *Client) CompleteWithdrawal(ctx context.Context, req CompleteWithdrawalRequest) error
- func (c *Client) CreatePendingDeposit(ctx context.Context, req CreatePendingDepositRequest) (*PendingDeposit, error)
- func (c *Client) GetLatestLedgerOffset(ctx context.Context) (int64, error)
- func (c *Client) GetWayfinderBridgeConfigCID(ctx context.Context) (string, error)
- func (c *Client) InitiateWithdrawal(ctx context.Context, req InitiateWithdrawalRequest) (string, error)
- func (c *Client) IsDepositProcessed(ctx context.Context, evmTxHash string) (bool, error)
- func (c *Client) ProcessDepositAndMint(ctx context.Context, req ProcessDepositRequest) (*ProcessedDeposit, error)
- func (c *Client) ProcessWithdrawal(ctx context.Context, withdrawalRequestCID string) (string, error)
- func (c *Client) StreamWithdrawalEvents(ctx context.Context, offset string) <-chan *WithdrawalEvent
- type CompleteWithdrawalRequest
- type Config
- type CreatePendingDepositRequest
- type InitiateWithdrawalRequest
- type Option
- type PendingDeposit
- type ProcessDepositRequest
- type ProcessedDeposit
- type WithdrawalEvent
- type WithdrawalRequest
- type WithdrawalStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bridge ¶
type Bridge interface {
// IsDepositProcessed returns true if a deposit with the given EVM tx hash already exists as an active
// PendingDeposit or DepositReceipt contract.
IsDepositProcessed(ctx context.Context, evmTxHash string) (bool, error)
// GetWayfinderBridgeConfigCID returns the active WayfinderBridgeConfig contract id.
GetWayfinderBridgeConfigCID(ctx context.Context) (string, error)
// CreatePendingDeposit creates a PendingDeposit on Canton from an EVM deposit event.
CreatePendingDeposit(ctx context.Context, req CreatePendingDepositRequest) (*PendingDeposit, error)
// ProcessDepositAndMint processes a PendingDeposit and mints tokens (choice on WayfinderBridgeConfig).
ProcessDepositAndMint(ctx context.Context, req ProcessDepositRequest) (*ProcessedDeposit, error)
// InitiateWithdrawal creates a WithdrawalRequest for a user (choice on WayfinderBridgeConfig).
InitiateWithdrawal(ctx context.Context, req InitiateWithdrawalRequest) (string, error)
// ProcessWithdrawal exercises the ProcessWithdrawal choice on a WithdrawalRequest contract,
// burning tokens on Canton and creating a WithdrawalEvent. Returns the WithdrawalEvent CID.
ProcessWithdrawal(ctx context.Context, withdrawalRequestCID string) (string, error)
// CompleteWithdrawal marks a WithdrawalEvent as completed after the EVM release is finalized.
CompleteWithdrawal(ctx context.Context, req CompleteWithdrawalRequest) error
// StreamWithdrawalEvents streams WithdrawalEvent contracts with automatic reconnection.
StreamWithdrawalEvents(ctx context.Context, offset string) <-chan *WithdrawalEvent
// GetLatestLedgerOffset returns the ledger end
GetLatestLedgerOffset(ctx context.Context) (int64, error)
}
Bridge defines bridge operations.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements bridge operations.
func (*Client) CompleteWithdrawal ¶
func (c *Client) CompleteWithdrawal(ctx context.Context, req CompleteWithdrawalRequest) error
func (*Client) CreatePendingDeposit ¶
func (c *Client) CreatePendingDeposit(ctx context.Context, req CreatePendingDepositRequest) (*PendingDeposit, error)
func (*Client) GetLatestLedgerOffset ¶
func (*Client) GetWayfinderBridgeConfigCID ¶
func (*Client) InitiateWithdrawal ¶
func (*Client) IsDepositProcessed ¶
func (*Client) ProcessDepositAndMint ¶
func (c *Client) ProcessDepositAndMint(ctx context.Context, req ProcessDepositRequest) (*ProcessedDeposit, error)
func (*Client) ProcessWithdrawal ¶
func (*Client) StreamWithdrawalEvents ¶
func (c *Client) StreamWithdrawalEvents(ctx context.Context, offset string) <-chan *WithdrawalEvent
type CompleteWithdrawalRequest ¶
CompleteWithdrawalRequest contains inputs to mark a withdrawal as completed.
type Config ¶
type Config struct {
// DomainID is the Canton synchronizer/domain ID to submit commands against.
DomainID string `yaml:"domain_id"`
// UserID is the Canton user id (JWT subject) used for command submission.
UserID string `yaml:"user_id"`
// OperatorParty is the party that controls WayfinderBridgeConfig (the bridge operator).
OperatorParty string `yaml:"operator_party"`
// PackageID is the package id that contains Wayfinder.Bridge templates/choices.
PackageID string `yaml:"package_id" validate:"required"`
// CorePackageID is the package id for Bridge.Contracts (bridge-core package).
// WithdrawalRequest and WithdrawalEvent live here, separate from PackageID.
CorePackageID string `yaml:"core_package_id" validate:"required"`
// Module is the DAML module name that contains WayfinderBridgeConfig template.
Module string `yaml:"module" validate:"required"`
}
Config contains bridge-client configuration.
type CreatePendingDepositRequest ¶
CreatePendingDepositRequest contains inputs to create a PendingDeposit from an EVM deposit event.
type InitiateWithdrawalRequest ¶
type InitiateWithdrawalRequest struct {
MappingCID string
HoldingCID string
Amount string
EvmDestination string
}
InitiateWithdrawalRequest contains inputs to initiate a withdrawal.
type PendingDeposit ¶
type PendingDeposit struct {
ContractID string
MappingCID string
Fingerprint string
CreatedAt time.Time
}
PendingDeposit describes a created pending deposit.
type ProcessDepositRequest ¶
ProcessDepositRequest contains inputs to process a PendingDeposit and mint tokens.
type ProcessedDeposit ¶
type ProcessedDeposit struct {
ContractID string
}
type WithdrawalEvent ¶
type WithdrawalEvent struct {
ContractID string
EventID string
TransactionID string
Issuer string
UserParty string
EvmDestination string
Amount string
Fingerprint string
Status WithdrawalStatus
}
WithdrawalEvent represents a withdrawal ready for EVM processing
type WithdrawalRequest ¶
type WithdrawalRequest struct {
ContractID string
Amount string
EvmDestination string
UserFingerprint string
CreatedAt time.Time
}
WithdrawalRequest describes a created withdrawal request.
type WithdrawalStatus ¶
type WithdrawalStatus string
WithdrawalStatus represents the state of a withdrawal
const ( WithdrawalStatusPending WithdrawalStatus = "Pending" WithdrawalStatusCompleted WithdrawalStatus = "Completed" WithdrawalStatusFailed WithdrawalStatus = "Failed" )