Documentation ¶
Index ¶
- Constants
- Variables
- func FullMintURL(ctx context.Context, host string, path string, query url.Values) *url.URL
- func GetHost(ctx context.Context) string
- func GetPort(ctx context.Context) string
- func Logf(ctx context.Context, format string, v ...interface{})
- func NormalizedAddress(ctx context.Context, address string) (string, error)
- func NormalizedOwnerAndTokenFromID(ctx context.Context, id string) (string, string, error)
- func UsernameAndMintHostFromAddress(ctx context.Context, address string) (string, string, error)
- type AssetResource
- type BalanceResource
- type Client
- func (c *Client) CancelTransaction(ctx context.Context, id string, hop int8, mint string) (*TransactionResource, error)
- func (c *Client) Init(ctx context.Context) error
- func (c *Client) PropagateBalance(ctx context.Context, id string, mint string) (*BalanceResource, error)
- func (c *Client) PropagateOffer(ctx context.Context, id string, mint string) (*OfferResource, error)
- func (c *Client) PropagateOperation(ctx context.Context, id string, mint string) (*OperationResource, error)
- func (c *Client) PropagateTransaction(ctx context.Context, id string, hop int8, mint string) (*TransactionResource, error)
- func (c *Client) RetrieveBalance(ctx context.Context, id string) (*BalanceResource, error)
- func (c *Client) RetrieveOffer(ctx context.Context, id string) (*OfferResource, error)
- func (c *Client) RetrieveOperation(ctx context.Context, id string) (*OperationResource, error)
- func (c *Client) RetrieveTransaction(ctx context.Context, id string, mint *string) (*TransactionResource, error)
- func (c *Client) SettleTransaction(ctx context.Context, id string, hop *int8, secret *string, mint *string) (*TransactionResource, error)
- type CrossingResource
- type ErrMintClient
- type OfStatus
- type OfferResource
- type OperationResource
- type PgType
- type TkName
- type TkStatus
- type TransactionResource
- type TxStatus
Constants ¶
const ( // EnvCfgHost is the env config key for the mint host. EnvCfgHost env.ConfigKey = "host" // EnvCfgPort is the port on which to run the mint. EnvCfgPort env.ConfigKey = "port" // EnvCfgKeyFile is the production certificate key file. EnvCfgKeyFile env.ConfigKey = "key_file" // EnvCfgCrtFile is the production certificate file. EnvCfgCrtFile env.ConfigKey = "crt_file" )
const ( // ProtocolVersion is the current protocol version. ProtocolVersion string = "0" // TimeResolutionNs is the resolution of our time variables in nanoseconds // (aka resolution in milliseconds). TimeResolutionNs int64 = 1000 * 1000 // TransactionExpiryMs is the time it takes to attempt to cancel a // transaction for this mint. Expressed in ms. TransactionExpiryMs int64 = 1000 * 60 * 60 )
Variables ¶
var AddressRegexp = regexp.MustCompile(
"^" + addressRegexpStr + "$",
)
AddressRegexp is used to validate and parse issuer names.
var AssetNameRegexp = regexp.MustCompile(
"^" + addressRegexpStr + "\\[([A-Z0-9-]{1,64})\\.([0-9]{1,2})\\]" + "$",
)
AssetNameRegexp is used to validate and parse asset names.
var DefaultPort = map[env.Environment]int64{ env.Production: 2406, env.QA: 2407, }
DefaultPort is the mint default port by environment.
var DefaultScheme = map[env.Environment]string{ env.Production: "https", env.QA: "http", }
DefaultScheme is the mint default scheme by environment.
var IDRegexp = regexp.MustCompile(
"^(.+)\\[([a-z]+_[a-zA-Z0-9]+)\\]$",
)
IDRegexp is used to validate a full id including issuer and token.
Functions ¶
func FullMintURL ¶
FullMintURL constructs a fully qualified URL to contact a mint defaulting to the correct scheme and port based on the current environment.
func NormalizedAddress ¶
NormalizedAddress returns the address trimmed from the `+...@` part.
func NormalizedOwnerAndTokenFromID ¶
NormalizedOwnerAndTokenFromID returns a normalized address and token from an id.
Types ¶
type AssetResource ¶
type AssetResource struct { ID string `json:"id"` Created int64 `json:"created"` Owner string `json:"owner"` Propagation PgType `json:"propagation"` Name string `json:"name"` Code string `json:"code"` Scale int8 `json:"scale"` }
AssetResource is the representation of an asset in the mint API.
func AssetResourceFromName ¶
func AssetResourceFromName( ctx context.Context, name string, ) (*AssetResource, error)
AssetResourceFromName parses an asset fully qualified name into an AssetResource object (without id or created date, owner is normalized).
func AssetResourcesFromPair ¶
func AssetResourcesFromPair( ctx context.Context, pair string, ) ([]AssetResource, error)
AssetResourcesFromPair parses a pair into an array of AssetResources (without id or created date).
type BalanceResource ¶
type BalanceResource struct { ID string `json:"id"` Created int64 `json:"created"` Owner string `json:"owner"` Propagation PgType `json:"propagation"` Asset string `json:"asset"` Holder string `json:"holder"` Value *big.Int `json:"value"` }
BalanceResource is the representation of an asset balance in the mint API.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client expose an interface to perform queries on remote mints.
func (*Client) CancelTransaction ¶
func (c *Client) CancelTransaction( ctx context.Context, id string, hop int8, mint string, ) (*TransactionResource, error)
CancelTransaction propagates the cancelation of a transaction on the specified mint for the specified hop.
func (*Client) PropagateBalance ¶
func (c *Client) PropagateBalance( ctx context.Context, id string, mint string, ) (*BalanceResource, error)
PropagateBalance propagates an balance to the specified mint.
func (*Client) PropagateOffer ¶
func (c *Client) PropagateOffer( ctx context.Context, id string, mint string, ) (*OfferResource, error)
PropagateOffer propagates an offer to the specified mint.
func (*Client) PropagateOperation ¶
func (c *Client) PropagateOperation( ctx context.Context, id string, mint string, ) (*OperationResource, error)
PropagateOperation propagates an operation to the specified mint.
func (*Client) PropagateTransaction ¶
func (c *Client) PropagateTransaction( ctx context.Context, id string, hop int8, mint string, ) (*TransactionResource, error)
PropagateTransaction propagates a transaction to the specified mint.
func (*Client) RetrieveBalance ¶
RetrieveBalance retrieves an balance given its ID by extracting the mint and retrieving it from there.
func (*Client) RetrieveOffer ¶
RetrieveOffer retrieves an offer given its ID by extracting the mint and retrieving it from there.
func (*Client) RetrieveOperation ¶
RetrieveOperation retrieves an operation given its ID by extracting the mint and retrieving it from there.
func (*Client) RetrieveTransaction ¶
func (c *Client) RetrieveTransaction( ctx context.Context, id string, mint *string, ) (*TransactionResource, error)
RetrieveTransaction retrieves a transaction given its ID by extracting the mint and retrieving it from there. If host is specified, it attempts to retrrieve the transaction from this host instead of the canonical host.
func (*Client) SettleTransaction ¶
func (c *Client) SettleTransaction( ctx context.Context, id string, hop *int8, secret *string, mint *string, ) (*TransactionResource, error)
SettleTransaction settles a transaction. If hop, secret, mint are specified it settles on the specified mint using the specified hop and secret, otherwise it attempts to settle on the canonical mint.
type CrossingResource ¶
type CrossingResource struct { ID string `json:"id"` Created int64 `json:"created"` Owner string `json:"owner"` Propagation PgType `json:"propagation"` Offer string `json:"offer"` Amount *big.Int `json:"amount"` Status TxStatus `json:"status"` Transaction string `json:"transaction"` TransactionHop int8 `json:"transaction_hop"` }
CrossingResource is the representation of a crossing in the mint API.
type ErrMintClient ¶
ErrMintClient is returned by the client when an proper error is returned by the mint it interacted with.
func (ErrMintClient) Error ¶
func (e ErrMintClient) Error() string
type OfferResource ¶
type OfferResource struct { ID string `json:"id"` Created int64 `json:"created"` Owner string `json:"owner"` Propagation PgType `json:"propagation"` Pair string `json:"pair"` Price string `json:"price"` Amount *big.Int `json:"amount"` Status OfStatus `json:"status"` Remainder *big.Int `json:"remainder"` }
OfferResource is the representation of an offer in the mint API.
type OperationResource ¶
type OperationResource struct { ID string `json:"id"` Created int64 `json:"created"` Owner string `json:"owner"` Propagation PgType `json:"propagation"` Asset string `json:"asset"` Source string `json:"source"` Destination string `json:"destination"` Amount *big.Int `json:"amount"` Status TxStatus `json:"status"` Transaction *string `json:"transaction"` TransactionHop *int8 `json:"transaction_hop"` }
OperationResource is the representation of an operation in the mint API.
type TransactionResource ¶
type TransactionResource struct { ID string `json:"id"` Created int64 `json:"created"` Owner string `json:"owner"` Propagation PgType `json:"propagation"` Pair string `json:"pair"` Amount *big.Int `json:"amount"` Destination string `json:"destination"` Path []string `json:"path"` Status TxStatus `json:"status"` Lock string `json:"lock"` Secret *string `json:"secret"` Operations []OperationResource `json:"operations"` Crossings []CrossingResource `json:"crossings"` }
TransactionResource is the representation of a transaction in the mint API.
type TxStatus ¶
type TxStatus string
TxStatus is the status of a transaction, operation or crossing.
const ( // TxStPending is used to mark a transaction as pending (created but not // yet finalized) TxStPending TxStatus = "pending" // TxStReserved is used to mark a transaction or action (operation or // crossing) as reserved. TxStReserved TxStatus = "reserved" // TxStSettled is used to mark a transaction or action (operation or // crossing) as settled. TxStSettled TxStatus = "settled" // TxStCanceled is used to mark a transaction or action (operation or // crossing) as canceled. TxStCanceled TxStatus = "canceled" )