Documentation ¶
Index ¶
- Variables
- func HandlerFor(name EndPtName) func(http.ResponseWriter, *http.Request)
- func ValidateAmount(ctx context.Context, amount string) (*big.Int, error)
- func ValidateAsset(ctx context.Context, asset string) (*mint.AssetResource, error)
- func ValidateAssetPair(ctx context.Context, pair string) ([]mint.AssetResource, error)
- func ValidateCreatedBefore(ctx context.Context, createdBefore string) (*time.Time, error)
- func ValidateHop(ctx context.Context, hop string) (*int8, error)
- func ValidateID(ctx context.Context, id string) (*string, *string, *string, error)
- func ValidateLimit(ctx context.Context, limit string) (*uint, error)
- func ValidatePath(ctx context.Context, path []string) ([]string, error)
- func ValidatePrice(ctx context.Context, price string) (*big.Int, *big.Int, error)
- func ValidatePropagation(ctx context.Context, propagation string) (*mint.PgType, error)
- func ValidateSecret(ctx context.Context, secret string) (*string, error)
- type CancelTransaction
- func (e *CancelTransaction) Cancel(ctx context.Context) error
- func (e *CancelTransaction) Execute(ctx context.Context) (*int, *svc.Resp, error)
- func (e *CancelTransaction) ExecuteAuthenticated(ctx context.Context) (*int, *svc.Resp, error)
- func (e *CancelTransaction) ExecutePropagated(ctx context.Context) (*int, *svc.Resp, error)
- func (e *CancelTransaction) Propagate(ctx context.Context) error
- func (e *CancelTransaction) Validate(r *http.Request) error
- type CloseOffer
- type CreateAsset
- type CreateOffer
- type CreateTransaction
- func (e *CreateTransaction) Execute(ctx context.Context) (*int, *svc.Resp, error)
- func (e *CreateTransaction) ExecuteCanonical(ctx context.Context) (*int, *svc.Resp, error)
- func (e *CreateTransaction) ExecutePlan(ctx context.Context) error
- func (e *CreateTransaction) ExecutePropagated(ctx context.Context) (*int, *svc.Resp, error)
- func (e *CreateTransaction) Propagate(ctx context.Context) (*mint.TransactionResource, error)
- func (e *CreateTransaction) Validate(r *http.Request) error
- type EndPtName
- type Endpoint
- func NewCancelTransaction(r *http.Request) (Endpoint, error)
- func NewCloseOffer(r *http.Request) (Endpoint, error)
- func NewCreateAsset(r *http.Request) (Endpoint, error)
- func NewCreateOffer(r *http.Request) (Endpoint, error)
- func NewCreateTransaction(r *http.Request) (Endpoint, error)
- func NewListAssetBalances(r *http.Request) (Endpoint, error)
- func NewListAssetOffers(r *http.Request) (Endpoint, error)
- func NewListAssets(r *http.Request) (Endpoint, error)
- func NewListBalances(r *http.Request) (Endpoint, error)
- func NewPropagateBalance(r *http.Request) (Endpoint, error)
- func NewPropagateOffer(r *http.Request) (Endpoint, error)
- func NewPropagateOperation(r *http.Request) (Endpoint, error)
- func NewRetrieveAsset(r *http.Request) (Endpoint, error)
- func NewRetrieveBalance(r *http.Request) (Endpoint, error)
- func NewRetrieveOffer(r *http.Request) (Endpoint, error)
- func NewRetrieveOperation(r *http.Request) (Endpoint, error)
- func NewRetrieveTransaction(r *http.Request) (Endpoint, error)
- func NewSettleTransaction(r *http.Request) (Endpoint, error)
- type ListAssetBalances
- type ListAssetOffers
- type ListAssets
- type ListBalances
- type ListEndpoint
- type PropagateBalance
- type PropagateOffer
- type PropagateOperation
- type RetrieveAsset
- type RetrieveBalance
- type RetrieveOffer
- type RetrieveOperation
- type RetrieveTransaction
- type SettleTransaction
- func (e *SettleTransaction) Execute(ctx context.Context) (*int, *svc.Resp, error)
- func (e *SettleTransaction) ExecuteCanonical(ctx context.Context) (*int, *svc.Resp, error)
- func (e *SettleTransaction) ExecutePropagated(ctx context.Context) (*int, *svc.Resp, error)
- func (e *SettleTransaction) Propagate(ctx context.Context) error
- func (e *SettleTransaction) Settle(ctx context.Context) error
- func (e *SettleTransaction) Validate(r *http.Request) error
Constants ¶
This section is empty.
Variables ¶
var PriceRegexp = regexp.MustCompile(
"^([0-9]+)\\/([0-9]+)$")
PriceRegexp is used to validate and parse a transaction price.
Functions ¶
func HandlerFor ¶
func HandlerFor( name EndPtName, ) func( http.ResponseWriter, *http.Request, )
HandlerFor returns an handler for the given endpoint name.
func ValidateAmount ¶
ValidateAmount validates the amount of an asset.
func ValidateAsset ¶
ValidateAsset vlaidates an asset name.
func ValidateAssetPair ¶
ValidateAssetPair validates an asset pair.
func ValidateCreatedBefore ¶
ValidateCreatedBefore validates a paging created_before.
func ValidateHop ¶
ValidateHop validates a hop.
func ValidateID ¶
ValidateID validates the ID of an object
func ValidateLimit ¶
ValidateLimit validates a paging limit.
func ValidatePath ¶
ValidatePath validates a path of offers.
func ValidatePrice ¶
ValidatePrice validates a price (pB/pQ).
func ValidatePropagation ¶
ValidatePropagation validates a propagation type.
Types ¶
type CancelTransaction ¶
type CancelTransaction struct { Client *mint.Client // Parameters Hop int8 ID string Token string Owner string // State Tx *model.Transaction Plan *plan.TxPlan }
CancelTransaction creates a new transaction.
func (*CancelTransaction) Cancel ¶
func (e *CancelTransaction) Cancel( ctx context.Context, ) error
Cancel cancels idempotently the underlying operations and crossings at the current hop.
func (*CancelTransaction) ExecuteAuthenticated ¶
ExecuteAuthenticated executes the authenticated cancellation of a transaction.
func (*CancelTransaction) ExecutePropagated ¶
ExecutePropagated executes the settlement of a propagated transaction (involved mint).
type CloseOffer ¶
CloseOffer closes an offer, making it unusable by transactions
type CreateAsset ¶
CreateAsset controls the creation of new assets.
type CreateOffer ¶
type CreateOffer struct { Client *mint.Client ID string // propagation Token string // propagation Owner string Pair []mint.AssetResource BasePrice big.Int QuotePrice big.Int Amount big.Int }
CreateOffer creates a new canonical offer and triggers its propagation to all the mints involved. Offer are represented as asks: base asset (left) is offered in exchange for quote asset (right) for specified amount (of quote asset) at specified price.
type CreateTransaction ¶
type CreateTransaction struct { Client *mint.Client // Parameters Hop int8 ID string Owner string BaseAsset string QuoteAsset string Amount big.Int Destination string Path []string // State Tx *model.Transaction Plan *plan.TxPlan }
CreateTransaction creates a new transaction.
func (*CreateTransaction) ExecuteCanonical ¶
ExecuteCanonical executes the creation of a canonical transaction (owner mint).
func (*CreateTransaction) ExecutePlan ¶
func (e *CreateTransaction) ExecutePlan( ctx context.Context, ) error
ExecutePlan executes the Hop locally, performing the operation and the crossing action if applicable. ExecutePlan is executed in the context of a DB transaction and is idempotent (attempts to retrieve operations for that hop and transaction before executing them).
func (*CreateTransaction) ExecutePropagated ¶
ExecutePropagated executes the creation of a propagated transaction (involved mint).
func (*CreateTransaction) Propagate ¶
func (e *CreateTransaction) Propagate( ctx context.Context, ) (*mint.TransactionResource, error)
Propagate recursively propagates to the next mint in the chain of mint involved in a transaction.
type EndPtName ¶
type EndPtName string
EndPtName reprensents an endpoint name.
const ( // EndPtCancelTransaction cancels a reserved transaction. EndPtCancelTransaction EndPtName = "CancelTransaction" )
const ( // EndPtCloseOffer creates a new offer. EndPtCloseOffer EndPtName = "CloseOffer" )
const ( // EndPtCreateAsset creates a new assset. EndPtCreateAsset EndPtName = "CreateAsset" )
const ( // EndPtCreateOffer creates a new offer. EndPtCreateOffer EndPtName = "CreateOffer" )
const ( // EndPtCreateTransaction creates a new transaction. EndPtCreateTransaction EndPtName = "CreateTransaction" )
const ( // EndPtListAssetBalances creates a new assset. EndPtListAssetBalances EndPtName = "ListAssetBalances" )
const ( // EndPtListAssetOffers creates a new assset. EndPtListAssetOffers EndPtName = "ListAssetOffers" )
const ( // EndPtListAssets creates a new assset. EndPtListAssets EndPtName = "ListAssets" )
const ( // EndPtListBalances creates a new assset. EndPtListBalances EndPtName = "ListBalances" )
const ( // EndPtPropagateBalance creates a new balance. EndPtPropagateBalance EndPtName = "PropagateBalance" )
const ( // EndPtPropagateOffer creates a new offer. EndPtPropagateOffer EndPtName = "PropagateOffer" )
const ( // EndPtPropagateOperation creates a new operation. EndPtPropagateOperation EndPtName = "PropagateOperation" )
const ( // EndPtRetrieveAsset creates a new assset. EndPtRetrieveAsset EndPtName = "RetrieveAsset" )
const ( // EndPtRetrieveBalance creates a new assset. EndPtRetrieveBalance EndPtName = "RetrieveBalance" )
const ( // EndPtRetrieveOffer creates a new assset. EndPtRetrieveOffer EndPtName = "RetrieveOffer" )
const ( // EndPtRetrieveOperation creates a new assset. EndPtRetrieveOperation EndPtName = "RetrieveOperation" )
const ( // EndPtRetrieveTransaction creates a new assset. EndPtRetrieveTransaction EndPtName = "RetrieveTransaction" )
const ( // EndPtSettleTransaction settles a reserved transaction. EndPtSettleTransaction EndPtName = "SettleTransaction" )
type Endpoint ¶
type Endpoint interface { Validate( r *http.Request, ) error Execute( ctx context.Context, ) (*int, *svc.Resp, error) }
Endpoint is the interface that endpoints need to implement.
func NewCancelTransaction ¶
NewCancelTransaction constructs and initialiezes the endpoint.
func NewCloseOffer ¶
NewCloseOffer constructs and initialiezes the endpoint.
func NewCreateAsset ¶
NewCreateAsset constructs and initialiezes the endpoint.
func NewCreateOffer ¶
NewCreateOffer constructs and initialiezes the endpoint.
func NewCreateTransaction ¶
NewCreateTransaction constructs and initialiezes the endpoint.
func NewListAssetBalances ¶
NewListAssetBalances constructs and initialiezes the endpoint.
func NewListAssetOffers ¶
NewListAssetOffers constructs and initialiezes the endpoint.
func NewListAssets ¶
NewListAssets constructs and initialiezes the endpoint.
func NewListBalances ¶
NewListBalances constructs and initialiezes the endpoint.
func NewPropagateBalance ¶
NewPropagateBalance constructs and initialiezes the endpoint.
func NewPropagateOffer ¶
NewPropagateOffer constructs and initialiezes the endpoint.
func NewPropagateOperation ¶
NewPropagateOperation constructs and initialiezes the endpoint.
func NewRetrieveAsset ¶
NewRetrieveAsset constructs and initialiezes the endpoint.
func NewRetrieveBalance ¶
NewRetrieveBalance constructs and initialiezes the endpoint.
func NewRetrieveOffer ¶
NewRetrieveOffer constructs and initialiezes the endpoint.
func NewRetrieveOperation ¶
NewRetrieveOperation constructs and initialiezes the endpoint.
func NewRetrieveTransaction ¶
NewRetrieveTransaction constructs and initialiezes the endpoint.
type ListAssetBalances ¶
type ListAssetBalances struct { ListEndpoint Owner string Asset mint.AssetResource }
ListAssetBalances returns a list of balances.
type ListAssetOffers ¶
type ListAssetOffers struct { ListEndpoint Asset mint.AssetResource Propagation mint.PgType }
ListAssetOffers returns a list of offers.
type ListAssets ¶
type ListAssets struct { ListEndpoint Owner string }
ListAssets returns a list of assets.
type ListBalances ¶
type ListBalances struct { ListEndpoint Holder string }
ListBalances returns a list of balances.
type ListEndpoint ¶
ListEndpoint is an helper object to implement list endpoints.
type PropagateBalance ¶
PropagateBalance fetches the balance propagated and creates a local propagated copy of it.
type PropagateOffer ¶
type PropagateOffer struct { Client *mint.Client ID string // propagation Token string // propagation Owner string }
PropagateOffer retrieves a canonical offer and creates a local propagated copy of it.
type PropagateOperation ¶
PropagateOperation retrieves a canonical operation and creates a local propagated copy of it.
func (*PropagateOperation) ExecutePropagated ¶
ExecutePropagated executes the propagation of an operation (involved mint).
type RetrieveAsset ¶
type RetrieveAsset struct {
Asset mint.AssetResource
}
RetrieveAsset retrieves an asset based on its name. It is not authenticated and is used to verify the existence of an asset.
type RetrieveBalance ¶
RetrieveBalance retrieves an balance based on its id. It is not authenticated and is used to verify balances when they get propagated.
type RetrieveOffer ¶
RetrieveOffer retrieves an offer based on its id. It is not authenticated and is used to verify offers when they get propagated.
type RetrieveOperation ¶
RetrieveOperation retrieves an operation based on its id. It is not authenticated and is used to verify operations when they get propagated.
type RetrieveTransaction ¶
RetrieveTransaction retrieves a transaction based on its id. It is not authenticated and is used to propagate transactions.
type SettleTransaction ¶
type SettleTransaction struct { Client *mint.Client // Parameters Hop int8 ID string Token string Owner string Secret string // State Tx *model.Transaction Plan *plan.TxPlan }
SettleTransaction creates a new transaction.
func (*SettleTransaction) ExecuteCanonical ¶
ExecuteCanonical executes the canonical settlement of a transaction (owner mint).
func (*SettleTransaction) ExecutePropagated ¶
ExecutePropagated executes the settlement of a propagated transaction (involved mint).
func (*SettleTransaction) Propagate ¶
func (e *SettleTransaction) Propagate( ctx context.Context, ) error
Propagate the lock for settlement. Current hop settlement is already performed.
Source Files ¶
- cancel_transaction.go
- close_offer.go
- create_asset.go
- create_offer.go
- create_transaction.go
- endpoint.go
- list_asset_balances.go
- list_asset_offers.go
- list_assets.go
- list_balances.go
- list_endpoint.go
- propagate_balance.go
- propagate_offer.go
- propagate_operation.go
- retrieve_asset.go
- retrieve_balance.go
- retrieve_offer.go
- retrieve_operation.go
- retrieve_transaction.go
- settle_transaction.go
- validations.go