resource

package
v0.0.0-...-798156f Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2018 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package resource contains the type definitions for all of frontier response resources.

Index

Constants

This section is empty.

Variables

View Source
var KeyTypeNames = map[strkey.VersionByte]string{
	strkey.VersionByteAccountID: "ed25519_public_key",
	strkey.VersionByteSeed:      "ed25519_secret_seed",
	strkey.VersionByteHashX:     "sha256_hash",
	strkey.VersionByteHashTx:    "preauth_tx",
}

KeyTypeNames maps from strkey version bytes into json string values to use in frontier responses.

Functions

func KeyTypeFromAddress

func KeyTypeFromAddress(address string) (string, error)

KeyTypeFromAddress converts the version byte of the provided strkey encoded value (for example an account id or a signer key) and returns the appropriate frontier-specific type name.

func MustKeyTypeFromAddress

func MustKeyTypeFromAddress(address string) string

MustKeyTypeFromAddress is the panicking variant of KeyTypeFromAddress.

func NewEffect

func NewEffect(
	ctx context.Context,
	row history.Effect,
) (result hal.Pageable, err error)

NewEffect returns a resource of the appropriate sub-type for the provided effect record.

func NewOperation

func NewOperation(
	ctx context.Context,
	row history.Operation,
	ledger history.Ledger,
) (result hal.Pageable, err error)

NewOperation returns a resource of the appropriate sub-type for the provided operation record.

Types

type Account

type Account struct {
	Links struct {
		Self         hal.Link `json:"self"`
		Transactions hal.Link `json:"transactions"`
		Operations   hal.Link `json:"operations"`
		Payments     hal.Link `json:"payments"`
		Effects      hal.Link `json:"effects"`
		Offers       hal.Link `json:"offers"`
		Trades       hal.Link `json:"trades"`
		Data         hal.Link `json:"data"`
	} `json:"_links"`

	HistoryAccount
	Sequence             string            `json:"sequence"`
	SubentryCount        int32             `json:"subentry_count"`
	InflationDestination string            `json:"inflation_destination,omitempty"`
	HomeDomain           string            `json:"home_domain,omitempty"`
	Thresholds           AccountThresholds `json:"thresholds"`
	Flags                AccountFlags      `json:"flags"`
	Balances             []Balance         `json:"balances"`
	Signers              []Signer          `json:"signers"`
	Data                 map[string]string `json:"data"`
}

Account is the summary of an account

func (*Account) GetData

func (this *Account) GetData(key string) ([]byte, error)

GetData returns decoded value for a given key. If the key does not exist, empty slice will be returned.

func (*Account) MustGetData

func (this *Account) MustGetData(key string) []byte

MustGetData returns decoded value for a given key. If the key does not exist, empty slice will be returned. If there is an error decoding a value, it will panic.

func (*Account) Populate

func (this *Account) Populate(
	ctx context.Context,
	ca core.Account,
	cd []core.AccountData,
	cs []core.Signer,
	ct []core.Trustline,
	ha history.Account,
) (err error)

Populate fills out the resource's fields

type AccountFlags

type AccountFlags struct {
	AuthRequired  bool `json:"auth_required"`
	AuthRevocable bool `json:"auth_revocable"`
}

AccountFlags represents the state of an account's flags

func (*AccountFlags) Populate

func (this *AccountFlags) Populate(row core.Account)

type AccountThresholds

type AccountThresholds struct {
	LowThreshold  byte `json:"low_threshold"`
	MedThreshold  byte `json:"med_threshold"`
	HighThreshold byte `json:"high_threshold"`
}

AccountThresholds represents an accounts "thresholds", the numerical values needed to satisfy the authorization of a given operation.

func (*AccountThresholds) Populate

func (this *AccountThresholds) Populate(row core.Account)

type Asset

type Asset base.Asset

Asset represents a single asset

func (*Asset) Populate

func (this *Asset) Populate(ctx context.Context, asset xdr.Asset) error

type AssetStat

type AssetStat struct {
	Links struct {
		Toml hal.Link `json:"toml"`
	} `json:"_links"`

	base.Asset
	PT          string       `json:"paging_token"`
	Amount      string       `json:"amount"`
	NumAccounts int32        `json:"num_accounts"`
	Flags       AccountFlags `json:"flags"`
}

AssetStat represents the statistics for a single Asset

func (AssetStat) PagingToken

func (res AssetStat) PagingToken() string

PagingToken implementation for hal.Pageable

func (*AssetStat) Populate

func (res *AssetStat) Populate(
	ctx context.Context,
	row assets.AssetStatsR,
) (err error)

Populate fills out the details

type Balance

type Balance struct {
	Balance string `json:"balance"`
	Limit   string `json:"limit,omitempty"`
	base.Asset
}

Balance represents an account's holdings for a single currency type

func (*Balance) Populate

func (this *Balance) Populate(ctx context.Context, row core.Trustline) (err error)

func (*Balance) PopulateNative

func (this *Balance) PopulateNative(stroops xdr.Int64) (err error)

type HistoryAccount

type HistoryAccount struct {
	ID        string `json:"id"`
	PT        string `json:"paging_token"`
	AccountID string `json:"account_id"`
}

HistoryAccount is a simple resource, used for the account collection actions. It provides only the "TotalOrderID" of the account and its account id.

func (*HistoryAccount) Populate

func (this *HistoryAccount) Populate(ctx context.Context, row history.Account)

type Ledger

type Ledger struct {
	Links struct {
		Self         hal.Link `json:"self"`
		Transactions hal.Link `json:"transactions"`
		Operations   hal.Link `json:"operations"`
		Payments     hal.Link `json:"payments"`
		Effects      hal.Link `json:"effects"`
	} `json:"_links"`
	ID               string    `json:"id"`
	PT               string    `json:"paging_token"`
	Hash             string    `json:"hash"`
	PrevHash         string    `json:"prev_hash,omitempty"`
	Sequence         int32     `json:"sequence"`
	TransactionCount int32     `json:"transaction_count"`
	OperationCount   int32     `json:"operation_count"`
	ClosedAt         time.Time `json:"closed_at"`
	TotalCoins       string    `json:"total_coins"`
	FeePool          string    `json:"fee_pool"`
	BaseFee          int32     `json:"base_fee_in_stroops"`
	BaseReserve      int32     `json:"base_reserve_in_stroops"`
	MaxTxSetSize     int32     `json:"max_tx_set_size"`
	ProtocolVersion  int32     `json:"protocol_version"`
	HeaderXDR        string    `json:"header_xdr"`
}

Ledger represents a single closed ledger

func (Ledger) PagingToken

func (this Ledger) PagingToken() string

func (*Ledger) Populate

func (this *Ledger) Populate(ctx context.Context, row history.Ledger)

type Offer

type Offer struct {
	Links struct {
		Self       hal.Link `json:"self"`
		OfferMaker hal.Link `json:"offer_maker"`
	} `json:"_links"`

	ID      int64  `json:"id"`
	PT      string `json:"paging_token"`
	Seller  string `json:"seller"`
	Selling Asset  `json:"selling"`
	Buying  Asset  `json:"buying"`
	Amount  string `json:"amount"`
	PriceR  Price  `json:"price_r"`
	Price   string `json:"price"`
}

Offer is the display form of an offer to trade currency.

func (Offer) PagingToken

func (this Offer) PagingToken() string

func (*Offer) Populate

func (this *Offer) Populate(ctx context.Context, row core.Offer)

type OrderBookSummary

type OrderBookSummary struct {
	Bids    []PriceLevel `json:"bids"`
	Asks    []PriceLevel `json:"asks"`
	Selling Asset        `json:"base"`
	Buying  Asset        `json:"counter"`
}

OrderBookSummary represents a snapshot summary of a given order book

func (*OrderBookSummary) Populate

func (this *OrderBookSummary) Populate(
	ctx context.Context,
	selling xdr.Asset,
	buying xdr.Asset,
	row core.OrderBookSummary,
) error

type Path

type Path struct {
	SourceAssetType        string  `json:"source_asset_type"`
	SourceAssetCode        string  `json:"source_asset_code,omitempty"`
	SourceAssetIssuer      string  `json:"source_asset_issuer,omitempty"`
	SourceAmount           string  `json:"source_amount"`
	DestinationAssetType   string  `json:"destination_asset_type"`
	DestinationAssetCode   string  `json:"destination_asset_code,omitempty"`
	DestinationAssetIssuer string  `json:"destination_asset_issuer,omitempty"`
	DestinationAmount      string  `json:"destination_amount"`
	Path                   []Asset `json:"path"`
}

Path represents a single payment path.

func (Path) PagingToken

func (this Path) PagingToken() string

stub implementation to satisfy pageable interface

func (*Path) Populate

func (this *Path) Populate(ctx context.Context, q paths.Query, p paths.Path) (err error)

type Price

type Price base.Price

Price represents a price

type PriceLevel

type PriceLevel struct {
	PriceR Price  `json:"price_r"`
	Price  string `json:"price"`
	Amount string `json:"amount"`
}

PriceLevel represents an aggregation of offers that share a given price

type Root

type Root struct {
	Links struct {
		Account             hal.Link `json:"account"`
		AccountTransactions hal.Link `json:"account_transactions"`
		Assets              hal.Link `json:"assets"`
		Friendbot           hal.Link `json:"friendbot"`
		Metrics             hal.Link `json:"metrics"`
		OrderBook           hal.Link `json:"order_book"`
		Self                hal.Link `json:"self"`
		Transaction         hal.Link `json:"transaction"`
		Transactions        hal.Link `json:"transactions"`
	} `json:"_links"`

	HorizonVersion       string `json:"horizon_version"`
	StellarCoreVersion   string `json:"core_version"`
	HorizonSequence      int32  `json:"history_latest_ledger"`
	HistoryElderSequence int32  `json:"history_elder_ledger"`
	CoreSequence         int32  `json:"core_latest_ledger"`
	NetworkPassphrase    string `json:"network_passphrase"`
	ProtocolVersion      int32  `json:"protocol_version"`
}

Root is the initial map of links into the api.

func (*Root) Populate

func (res *Root) Populate(
	ctx context.Context,
	ledgerState ledger.State,
	hVersion, cVersion string,
	passphrase string,
	pVersion int32,
)

Populate fills in the details

type Signer

type Signer struct {
	PublicKey string `json:"public_key"`
	Weight    int32  `json:"weight"`
	Key       string `json:"key"`
	Type      string `json:"type"`
}

Signer represents one of an account's signers.

func (*Signer) Populate

func (this *Signer) Populate(ctx context.Context, row core.Signer)

Populate fills out the fields of the signer, using one of an account's secondary signers.

func (*Signer) PopulateMaster

func (this *Signer) PopulateMaster(row core.Account)

PopulateMaster fills out the fields of the signer, using a digitalbits account to provide the data.

type Trade

type Trade struct {
	Links struct {
		Self      hal.Link `json:"self"`
		Base      hal.Link `json:"base"`
		Counter   hal.Link `json:"counter"`
		Operation hal.Link `json:"operation"`
	} `json:"_links"`

	ID                 string    `json:"id"`
	PT                 string    `json:"paging_token"`
	LedgerCloseTime    time.Time `json:"ledger_close_time"`
	OfferID            string    `json:"offer_id"`
	BaseAccount        string    `json:"base_account"`
	BaseAmount         string    `json:"base_amount"`
	BaseAssetType      string    `json:"base_asset_type"`
	BaseAssetCode      string    `json:"base_asset_code,omitempty"`
	BaseAssetIssuer    string    `json:"base_asset_issuer,omitempty"`
	CounterAccount     string    `json:"counter_account"`
	CounterAmount      string    `json:"counter_amount"`
	CounterAssetType   string    `json:"counter_asset_type"`
	CounterAssetCode   string    `json:"counter_asset_code,omitempty"`
	CounterAssetIssuer string    `json:"counter_asset_issuer,omitempty"`
	BaseIsSeller       bool      `json:"base_is_seller"`
	Price              xdr.Price `json:"price"`
}

Trade represents a frontier digested trade

func (Trade) PagingToken

func (res Trade) PagingToken() string

PagingToken implementation for hal.Pageable

func (*Trade) Populate

func (res *Trade) Populate(
	ctx context.Context,
	row history.Trade,
) (err error)

Populate fills out the details of a trade using a row from the history_trades table.

type TradeAggregation

type TradeAggregation struct {
	Timestamp     int64     `json:"timestamp"`
	TradeCount    int64     `json:"trade_count"`
	BaseVolume    string    `json:"base_volume"`
	CounterVolume string    `json:"counter_volume"`
	Average       string    `json:"avg"`
	High          string    `json:"high"`
	HighR         xdr.Price `json:"high_r"`
	Low           string    `json:"low"`
	LowR          xdr.Price `json:"low_r"`
	Open          string    `json:"open"`
	OpenR         xdr.Price `json:"open_r"`
	Close         string    `json:"close"`
	CloseR        xdr.Price `json:"close_r"`
}

Transaction represents trade data aggregation over a period of time

func (TradeAggregation) PagingToken

func (res TradeAggregation) PagingToken() string

PagingToken implementation for hal.Pageable. Not actually used

func (*TradeAggregation) Populate

func (res *TradeAggregation) Populate(
	ctx context.Context,
	row history.TradeAggregation,
) (err error)

Populate fills out the details of a trade using a row from the history_trades table.

type TradeEffect

type TradeEffect struct {
	Links struct {
		Self      hal.Link `json:"self"`
		Seller    hal.Link `json:"seller"`
		Buyer     hal.Link `json:"buyer"`
		Operation hal.Link `json:"operation"`
	} `json:"_links"`

	ID                string    `json:"id"`
	PT                string    `json:"paging_token"`
	OfferID           string    `json:"offer_id"`
	Seller            string    `json:"seller"`
	SoldAmount        string    `json:"sold_amount"`
	SoldAssetType     string    `json:"sold_asset_type"`
	SoldAssetCode     string    `json:"sold_asset_code,omitempty"`
	SoldAssetIssuer   string    `json:"sold_asset_issuer,omitempty"`
	Buyer             string    `json:"buyer"`
	BoughtAmount      string    `json:"bought_amount"`
	BoughtAssetType   string    `json:"bought_asset_type"`
	BoughtAssetCode   string    `json:"bought_asset_code,omitempty"`
	BoughtAssetIssuer string    `json:"bought_asset_issuer,omitempty"`
	LedgerCloseTime   time.Time `json:"created_at"`
}

TradeEffect represents a trade effect resource. NOTE (scott, 2017-12-08): this resource is being added back in temporarily to deal with a deploy snafu. I didn't properly message the community that we were changing the response format, and so we're adding this back in to allow transition.

func (TradeEffect) PagingToken

func (res TradeEffect) PagingToken() string

PagingToken implementation for hal.Pageable

func (*TradeEffect) PopulateFromEffect

func (res *TradeEffect) PopulateFromEffect(
	ctx context.Context,
	row history.Effect,
	ledger history.Ledger,
) (err error)

PopulateFromEffect fills out the details of a trade resource from a history.Effect row.

type Transaction

type Transaction struct {
	Links struct {
		Self       hal.Link `json:"self"`
		Account    hal.Link `json:"account"`
		Ledger     hal.Link `json:"ledger"`
		Operations hal.Link `json:"operations"`
		Effects    hal.Link `json:"effects"`
		Precedes   hal.Link `json:"precedes"`
		Succeeds   hal.Link `json:"succeeds"`
	} `json:"_links"`
	ID              string    `json:"id"`
	PT              string    `json:"paging_token"`
	Hash            string    `json:"hash"`
	Ledger          int32     `json:"ledger"`
	LedgerCloseTime time.Time `json:"created_at"`
	Account         string    `json:"source_account"`
	AccountSequence string    `json:"source_account_sequence"`
	FeePaid         int32     `json:"fee_paid"`
	OperationCount  int32     `json:"operation_count"`
	EnvelopeXdr     string    `json:"envelope_xdr"`
	ResultXdr       string    `json:"result_xdr"`
	ResultMetaXdr   string    `json:"result_meta_xdr"`
	FeeMetaXdr      string    `json:"fee_meta_xdr"`
	MemoType        string    `json:"memo_type"`
	Memo            string    `json:"memo,omitempty"`
	Signatures      []string  `json:"signatures"`
	ValidAfter      string    `json:"valid_after,omitempty"`
	ValidBefore     string    `json:"valid_before,omitempty"`
}

Transaction represents a single, successful transaction

func (Transaction) PagingToken

func (res Transaction) PagingToken() string

PagingToken implementation for hal.Pageable

func (*Transaction) Populate

func (res *Transaction) Populate(
	ctx context.Context,
	row history.Transaction,
) (err error)

Populate fills out the details

type TransactionResultCodes

type TransactionResultCodes struct {
	TransactionCode string   `json:"transaction"`
	OperationCodes  []string `json:"operations,omitempty"`
}

TransactionResultCodes represent a summary of result codes returned from a single xdr TransactionResult

func (*TransactionResultCodes) Populate

func (res *TransactionResultCodes) Populate(ctx context.Context,
	fail *txsub.FailedTransactionError,
) (err error)

Populate fills out the details

type TransactionSuccess

type TransactionSuccess struct {
	Links struct {
		Transaction hal.Link `json:"transaction"`
	} `json:"_links"`
	Hash   string `json:"hash"`
	Ledger int32  `json:"ledger"`
	Env    string `json:"envelope_xdr"`
	Result string `json:"result_xdr"`
	Meta   string `json:"result_meta_xdr"`
}

TransactionSuccess represents the result of a successful transaction submission.

func (*TransactionSuccess) Populate

func (res *TransactionSuccess) Populate(ctx context.Context, result txsub.Result)

Populate fills out the details

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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