Documentation ¶
Index ¶
- type AddressName
- type AssetName
- type Balance
- type BalanceChange
- type Block
- type Client
- type ClientV2
- type ClientWithDecimals
- type FullClient
- type LegacyBalances
- type LegacyTxInfoMappingType
- type ManualUnstakingClient
- type Movement
- type Stake
- type StakeEvent
- type StakeState
- type StakedBalance
- type StakedBalanceArgs
- type StakedBalanceOption
- type StakedBalanceState
- type StakingClient
- type State
- type TransactionName
- type TransferSource
- type TxInfo
- func (info *TxInfo) AddFee(from xc.Address, contract xc.ContractAddress, balance xc.AmountBlockchain, ...)
- func (info *TxInfo) AddMovement(transfer *Movement)
- func (info *TxInfo) AddSimpleTransfer(from xc.Address, to xc.Address, contract xc.ContractAddress, ...)
- func (info *TxInfo) CalculateFees() []*Balance
- func (info *TxInfo) Coalesece()
- func (tx *TxInfo) SetContractIdForNativeAsset(contractId xc.ContractAddress)
- func (tx *TxInfo) SyncDeprecatedFields()
- type Unstake
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressName ¶
type AddressName string
func NewAddressName ¶
func NewAddressName(chain xc.NativeAsset, address string) AddressName
type AssetName ¶
type AssetName string
func NewAssetName ¶
func NewAssetName(chain xc.NativeAsset, contractOrNativeAsset string) AssetName
type Balance ¶
type Balance struct { Asset AssetName `json:"asset"` Contract xc.ContractAddress `json:"contract"` Balance xc.AmountBlockchain `json:"balance"` Amount *xc.AmountHumanReadable `json:"amount,omitempty"` }
func NewBalance ¶
func NewBalance(chain xc.NativeAsset, contract xc.ContractAddress, balance xc.AmountBlockchain, decimals *int) *Balance
type BalanceChange ¶
type BalanceChange struct { Balance xc.AmountBlockchain `json:"balance"` Amount *xc.AmountHumanReadable `json:"amount,omitempty"` XAddress AddressName `json:"address"` // deprecated AddressId xc.Address `json:"address_id"` // replaces address }
func NewBalanceChange ¶
func NewBalanceChange(chain xc.NativeAsset, addressId xc.Address, balance xc.AmountBlockchain, decimals *int) *BalanceChange
type Block ¶
type Block struct { Chain xc.NativeAsset `json:"chain"` // required: set the blockheight of the transaction Height uint64 `json:"height"` // required: set the hash of the block of the transaction Hash string `json:"hash"` // required: set the time of the block of the transaction Time time.Time `json:"time"` }
type Client ¶
type Client interface { // Fetch the basic transaction input for any new transaction FetchLegacyTxInput(ctx context.Context, from xc.Address, to xc.Address) (xc.TxInput, error) // Broadcast a signed transaction to the chain SubmitTx(ctx context.Context, tx xc.Tx) error // Fetching transaction info - legacy endpoint FetchLegacyTxInfo(ctx context.Context, txHash xc.TxHash) (xc.LegacyTxInfo, error) // Fetching transaction info FetchTxInfo(ctx context.Context, txHash xc.TxHash) (TxInfo, error) // Fetch the balance of the given asset that the client is configured with FetchBalance(ctx context.Context, address xc.Address) (xc.AmountBlockchain, error) // Fetch the native balance for the chain on an address FetchNativeBalance(ctx context.Context, address xc.Address) (xc.AmountBlockchain, error) // Fetch the precision (or "decimals") associated with the target asset FetchDecimals(ctx context.Context, contract xc.ContractAddress) (int, error) }
Client is a client that can fetch data and submit tx to a public blockchain
type ClientWithDecimals ¶
type FullClient ¶
type LegacyBalances ¶
type LegacyBalances map[AssetName]xc.AmountBlockchain
type LegacyTxInfoMappingType ¶
type LegacyTxInfoMappingType string
var Account LegacyTxInfoMappingType = "account"
var Utxo LegacyTxInfoMappingType = "utxo"
type ManualUnstakingClient ¶
type ManualUnstakingClient interface {
CompleteManualUnstaking(ctx context.Context, unstake *Unstake) error
}
Special 3rd-party interface for Ethereum as ethereum doesn't understand delegated staking
type Movement ¶
type Movement struct { XAsset AssetName `json:"asset"` // deprecated XContract xc.ContractAddress `json:"contract"` // deprecated AssetId xc.ContractAddress `json:"asset_id"` // replaces contract // ContractId is set only when there is an alternative contract // identifier used by the chain for the native asset. It should be blank otherwise. ContractId xc.ContractAddress `json:"contract_id,omitempty"` // required: source debits From []*BalanceChange `json:"from"` // required: destination credits To []*BalanceChange `json:"to"` Memo string `json:"memo,omitempty"` // contains filtered or unexported fields }
func NewMovement ¶
func NewMovement(chain xc.NativeAsset, contract xc.ContractAddress) *Movement
func (*Movement) AddDestination ¶
type Stake ¶
type Stake struct { Balance xc.AmountBlockchain `json:"balance"` Validator string `json:"validator"` Account string `json:"account"` Address string `json:"address"` }
func (*Stake) GetValidator ¶
type StakeEvent ¶
type StakeEvent interface {
GetValidator() string
}
type StakeState ¶
type StakeState string
var Activating StakeState = "activating"
var Active StakeState = "active"
var Deactivating StakeState = "deactivating"
var Inactive StakeState = "inactive"
type StakedBalance ¶
type StakedBalance struct { // the validator that the stake is delegated to Validator string `json:"validator"` // Optional; the account that the stake is associated with Account string `json:"account,omitempty"` // The states balance of the balance in the validator [+account] Balance StakedBalanceState `json:"balance"` }
func NewStakedBalance ¶
func NewStakedBalance(balance xc.AmountBlockchain, state StakeState, validator, account string) *StakedBalance
func NewStakedBalances ¶
func NewStakedBalances(balances StakedBalanceState, validator, account string) *StakedBalance
type StakedBalanceArgs ¶
type StakedBalanceArgs struct {
// contains filtered or unexported fields
}
func NewStakeBalanceArgs ¶
func NewStakeBalanceArgs(from xc.Address, options ...StakedBalanceOption) (StakedBalanceArgs, error)
func (*StakedBalanceArgs) GetAccount ¶
func (opts *StakedBalanceArgs) GetAccount() (string, bool)
func (*StakedBalanceArgs) GetFrom ¶
func (opts *StakedBalanceArgs) GetFrom() xc.Address
func (*StakedBalanceArgs) GetValidator ¶
func (opts *StakedBalanceArgs) GetValidator() (string, bool)
type StakedBalanceOption ¶
type StakedBalanceOption func(opts *StakedBalanceArgs) error
func StakeBalanceOptionAccount ¶
func StakeBalanceOptionAccount(account string) StakedBalanceOption
func StakeBalanceOptionValidator ¶
func StakeBalanceOptionValidator(validator string) StakedBalanceOption
type StakedBalanceState ¶
type StakedBalanceState struct { Active xc.AmountBlockchain `json:"active,omitempty"` Activating xc.AmountBlockchain `json:"activating,omitempty"` Deactivating xc.AmountBlockchain `json:"deactivating,omitempty"` Inactive xc.AmountBlockchain `json:"inactive,omitempty"` }
type StakingClient ¶
type StakingClient interface { // Fetch staked balances accross different possible states FetchStakeBalance(ctx context.Context, args StakedBalanceArgs) ([]*StakedBalance, error) // Fetch inputs required for a staking transaction FetchStakingInput(ctx context.Context, args builder.StakeArgs) (xc.StakeTxInput, error) // Fetch inputs required for a unstaking transaction FetchUnstakingInput(ctx context.Context, args builder.StakeArgs) (xc.UnstakeTxInput, error) // Fetch input for a withdraw transaction -- not all chains use this as they combine it with unstake FetchWithdrawInput(ctx context.Context, args builder.StakeArgs) (xc.WithdrawTxInput, error) }
type State ¶
type State string
const Failed State = "failed"
const Mining State = "mining"
const Succeeded State = "succeeded"
type TransactionName ¶
type TransactionName string
func NewTransactionName ¶
func NewTransactionName(chain xc.NativeAsset, txHash string) TransactionName
func (TransactionName) Chain ¶
func (name TransactionName) Chain() string
type TransferSource ¶
type TransferSource struct { From AddressName `json:"from"` Asset AssetName `json:"asset"` Amount xc.AmountBlockchain `json:"amount"` }
type TxInfo ¶
type TxInfo struct { Name TransactionName `json:"name"` // required: set the transaction hash/id Hash string `json:"hash"` // required: set the chain XChain xc.NativeAsset `json:"chain"` //deprecated State State `json:"state"` Final bool `json:"final"` // required: set the block info Block *Block `json:"block"` // required: set any movements Movements []*Movement `json:"movements"` // output-only: calculate via .CalcuateFees() method Fees []*Balance `json:"fees"` // Native staking events Stakes []*Stake `json:"stakes,omitempty"` Unstakes []*Unstake `json:"unstakes,omitempty"` // required: set the confirmations at time of querying the info Confirmations uint64 `json:"confirmations"` // optional: set the error of the transaction if there was an error Error *string `json:"error,omitempty"` }
This should roughly match stoplight
func TxInfoFromLegacy ¶
func TxInfoFromLegacy(chainCfg *xc.ChainConfig, legacyTx xc.LegacyTxInfo, mappingType LegacyTxInfoMappingType) TxInfo
func (*TxInfo) AddFee ¶
func (info *TxInfo) AddFee(from xc.Address, contract xc.ContractAddress, balance xc.AmountBlockchain, decimals *int)
func (*TxInfo) AddMovement ¶
func (*TxInfo) AddSimpleTransfer ¶
func (*TxInfo) CalculateFees ¶
func (*TxInfo) Coalesece ¶
func (info *TxInfo) Coalesece()
Merge together movements that have the same asset. This may not always be the right thing to do, depends on the chain.
- UXTO chains, where there's not always a distinct from/to, should be coalesced.
- Account based chains, where there's always distinct from/to, should NOT be coalesced, as this would make it more confusing who is sending to who.
Generally if it's very clear who is sending to who, we don't coalesce. If it's not clear who is sending to who, we should coalesce to simplify.
func (*TxInfo) SetContractIdForNativeAsset ¶
func (tx *TxInfo) SetContractIdForNativeAsset(contractId xc.ContractAddress)
func (*TxInfo) SyncDeprecatedFields ¶
func (tx *TxInfo) SyncDeprecatedFields()
Click to show internal directories.
Click to hide internal directories.