Documentation ¶
Overview ¶
Package crosschain is a Go library to interact with multiple blockchains.
Crosschain main design principle is to isolate network Client, Signer and tx Builder. This way you can build applications or micro services using just what you need and with the convenience of a unified interface.
Index ¶
- Constants
- Variables
- func SameTxInputTypes[T TxInput](as T, inputs ...TxInput) bool
- type Address
- type AddressBuilder
- type AddressType
- type AllowEntry
- type AmountBlockchain
- func (amount *AmountBlockchain) Abs() AmountBlockchain
- func (amount *AmountBlockchain) Add(x *AmountBlockchain) AmountBlockchain
- func (amount AmountBlockchain) ApplyGasPriceMultiplier(chain *ChainConfig) AmountBlockchain
- func (amount *AmountBlockchain) Cmp(other *AmountBlockchain) int
- func (amount *AmountBlockchain) Div(x *AmountBlockchain) AmountBlockchain
- func (amount AmountBlockchain) Int() *big.Int
- func (amount *AmountBlockchain) IsZero() bool
- func (b AmountBlockchain) MarshalJSON() ([]byte, error)
- func (amount *AmountBlockchain) Mul(x *AmountBlockchain) AmountBlockchain
- func (amount AmountBlockchain) Sign() int
- func (amount AmountBlockchain) String() string
- func (amount *AmountBlockchain) Sub(x *AmountBlockchain) AmountBlockchain
- func (amount *AmountBlockchain) ToHuman(decimals int32) AmountHumanReadable
- func (amount AmountBlockchain) Uint64() uint64
- func (b *AmountBlockchain) UnmarshalJSON(p []byte) error
- func (amount AmountBlockchain) UnmaskFloat64() float64
- type AmountHumanReadable
- func (amount AmountHumanReadable) Decimal() decimal.Decimal
- func (amount AmountHumanReadable) Div(x AmountHumanReadable) AmountHumanReadable
- func (b AmountHumanReadable) MarshalJSON() ([]byte, error)
- func (amount AmountHumanReadable) String() string
- func (amount AmountHumanReadable) ToBlockchain(decimals int32) AmountBlockchain
- func (b *AmountHumanReadable) UnmarshalJSON(p []byte) error
- type AssetID
- type ChainConfig
- func (asset ChainConfig) GetAllClients() []*ClientConfig
- func (native *ChainConfig) GetAssetSymbol() string
- func (asset *ChainConfig) GetChain() *ChainConfig
- func (native *ChainConfig) GetContract() string
- func (asset *ChainConfig) GetDecimals() int32
- func (asset ChainConfig) GetNativeClients() []*ClientConfig
- func (asset *ChainConfig) ID() AssetID
- func (c ChainConfig) String() string
- type ClientConfig
- type ContractAddress
- type Driver
- type ExplorerUrls
- type GasFeePriority
- type ITask
- type LegacyTxInfo
- type LegacyTxInfoEndpoint
- type NativeAsset
- type NetworkSelector
- type PipelineConfig
- type PossibleAddress
- type PublicKeyFormat
- type SignatureType
- type StakeEvent
- type StakeTxInput
- type StakingConfig
- type StakingProvider
- type Task
- type TaskConfig
- func (task *TaskConfig) GetAssetSymbol() string
- func (task TaskConfig) GetChain() *ChainConfig
- func (task *TaskConfig) GetContract() string
- func (task *TaskConfig) GetDecimals() int32
- func (task TaskConfig) GetTask() *TaskConfig
- func (task *TaskConfig) ID() AssetID
- func (task TaskConfig) String() string
- type TaskConfigOperation
- type TaskConfigOperationParam
- type TaskConfigOperationParamDefaults
- type TokenAssetConfig
- type Tx
- type TxBuilder
- type TxDataToSign
- type TxHash
- type TxInput
- type TxInputConflicts
- type TxInputEnvelope
- type TxInputGasFeeMultiplier
- type TxInputWithAmount
- type TxInputWithMemo
- type TxInputWithPublicKey
- type TxInputWithUnix
- type TxSignature
- type TxStatus
- type TxTokenBuilder
- type TxVariantInput
- type TxVariantInputType
- type TxXTransferBuilder
- type UnstakeTxInput
- type WithdrawTxInput
Constants ¶
const ( K256Keccak = SignatureType("k256-keccak") K256Sha256 = SignatureType("k256-sha256") Ed255 = SignatureType("ed255") Schnorr = SignatureType("schnorr") )
const ( ACA = NativeAsset("ACA") // Acala APTOS = NativeAsset("APTOS") // APTOS ArbETH = NativeAsset("ArbETH") // Arbitrum ATOM = NativeAsset("ATOM") // Cosmos AurETH = NativeAsset("AurETH") // Aurora AVAX = NativeAsset("AVAX") // Avalanche BERA = NativeAsset("BERA") // Berachain BCH = NativeAsset("BCH") // Bitcoin Cash BNB = NativeAsset("BNB") // Binance Coin BTC = NativeAsset("BTC") // Bitcoin CELO = NativeAsset("CELO") // Celo CHZ = NativeAsset("CHZ") // Chiliz CHZ2 = NativeAsset("CHZ2") // Chiliz 2.0 DOGE = NativeAsset("DOGE") // Dogecoin DOT = NativeAsset("DOT") // Polkadot ETC = NativeAsset("ETC") // Ethereum Classic ETH = NativeAsset("ETH") // Ethereum ETHW = NativeAsset("ETHW") // Ethereum PoW FTM = NativeAsset("FTM") // Fantom HASH = NativeAsset("HASH") // Provenance INJ = NativeAsset("INJ") // Injective LTC = NativeAsset("LTC") // Litecoin LUNA = NativeAsset("LUNA") // Terra V2 LUNC = NativeAsset("LUNC") // Terra Classic KAR = NativeAsset("KAR") // Karura KLAY = NativeAsset("KLAY") // Klaytn KSM = NativeAsset("KSM") // Kusama XDC = NativeAsset("XDC") // XinFin MATIC = NativeAsset("MATIC") // Polygon OAS = NativeAsset("OAS") // Oasys (not Oasis!) OptETH = NativeAsset("OptETH") // Optimism EmROSE = NativeAsset("EmROSE") // Rose (Oasis EVM-compat "Emerald" parachain) SOL = NativeAsset("SOL") // Solana SUI = NativeAsset("SUI") // SUI XPLA = NativeAsset("XPLA") // XPLA TAO = NativeAsset("TAO") // Bittensor TIA = NativeAsset("TIA") // celestia TON = NativeAsset("TON") // TON TRX = NativeAsset("TRX") // TRON SEI = NativeAsset("SEI") // Sei XRP = NativeAsset("XRP") // XRP )
List of supported NativeAsset
const ( DriverAptos = Driver("aptos") DriverBitcoin = Driver("bitcoin") DriverBitcoinCash = Driver("bitcoin-cash") DriverBitcoinLegacy = Driver("bitcoin-legacy") DriverCosmos = Driver("cosmos") DriverCosmosEvmos = Driver("evmos") DriverEVM = Driver("evm") DriverEVMLegacy = Driver("evm-legacy") DriverSubstrate = Driver("substrate") DriverSolana = Driver("solana") DriverSui = Driver("sui") DriverTron = Driver("tron") DriverTon = Driver("ton") DriverXrp = Driver("xrp") // Crosschain is a client-only driver DriverCrosschain = Driver("crosschain") )
List of supported Driver
const FLOAT_PRECISION = 6
Variables ¶
var NativeAssetList []NativeAsset = []NativeAsset{ BCH, BTC, DOGE, LTC, ACA, APTOS, ArbETH, ATOM, AurETH, AVAX, BERA, BNB, CELO, CHZ, CHZ2, DOT, ETC, ETH, ETHW, FTM, INJ, HASH, LUNA, LUNC, KAR, KLAY, KSM, XDC, MATIC, OAS, OptETH, EmROSE, SOL, SUI, XPLA, TAO, TIA, TON, TRX, SEI, XRP, }
var SupportedDrivers = []Driver{ DriverAptos, DriverBitcoin, DriverBitcoinCash, DriverBitcoinLegacy, DriverCosmos, DriverCosmosEvmos, DriverEVM, DriverEVMLegacy, DriverSubstrate, DriverSolana, DriverSui, DriverTron, DriverTon, DriverXrp, }
var SupportedStakingProviders = []StakingProvider{ Native, Kiln, Figment, Twinstake, }
Functions ¶
func SameTxInputTypes ¶
Types ¶
type Address ¶
type Address string
Address is an address on the blockchain, either sender or recipient
type AddressBuilder ¶
type AddressBuilder interface { GetAddressFromPublicKey(publicKeyBytes []byte) (Address, error) GetAllPossibleAddressesFromPublicKey(publicKeyBytes []byte) ([]PossibleAddress, error) }
AddressBuilder is the interface for building addresses
type AddressType ¶
type AddressType string
AddressType represents the type of an address, for discovery purposes
const ( AddressTypeSegwit AddressType = AddressType("Segwit") AddressTypeP2SH AddressType = AddressType("P2SH") AddressTypeP2PKH AddressType = AddressType("P2PKH") AddressTypeP2WPKH AddressType = AddressType("P2WPKH") AddressTypeP2TR AddressType = AddressType("P2TR") AddressTypeETHKeccak AddressType = AddressType("ETHKeccak") AddressTypeDefault AddressType = AddressType("Default") )
List of known AddressType
type AllowEntry ¶
type AmountBlockchain ¶
AmountBlockchain is a big integer amount as blockchain expects it for tx.
func MultiplyByFloat ¶
func MultiplyByFloat(amount AmountBlockchain, multiplier float64) AmountBlockchain
func NewAmountBlockchainFromStr ¶
func NewAmountBlockchainFromStr(str string) AmountBlockchain
NewAmountBlockchainFromStr creates a new AmountBlockchain from a string
func NewAmountBlockchainFromUint64 ¶
func NewAmountBlockchainFromUint64(u64 uint64) AmountBlockchain
NewAmountBlockchainFromUint64 creates a new AmountBlockchain from a uint64
func NewAmountBlockchainToMaskFloat64 ¶
func NewAmountBlockchainToMaskFloat64(f64 float64) AmountBlockchain
NewAmountBlockchainToMaskFloat64 creates a new AmountBlockchain as a float64 times 10^FLOAT_PRECISION
func (*AmountBlockchain) Abs ¶
func (amount *AmountBlockchain) Abs() AmountBlockchain
func (*AmountBlockchain) Add ¶
func (amount *AmountBlockchain) Add(x *AmountBlockchain) AmountBlockchain
Use the underlying big.Int.Add()
func (AmountBlockchain) ApplyGasPriceMultiplier ¶
func (amount AmountBlockchain) ApplyGasPriceMultiplier(chain *ChainConfig) AmountBlockchain
func (*AmountBlockchain) Cmp ¶
func (amount *AmountBlockchain) Cmp(other *AmountBlockchain) int
Use the underlying big.Int.Cmp()
func (*AmountBlockchain) Div ¶
func (amount *AmountBlockchain) Div(x *AmountBlockchain) AmountBlockchain
Use the underlying big.Int.Div()
func (AmountBlockchain) Int ¶
func (amount AmountBlockchain) Int() *big.Int
Int converts an AmountBlockchain into *bit.Int
func (*AmountBlockchain) IsZero ¶
func (amount *AmountBlockchain) IsZero() bool
func (AmountBlockchain) MarshalJSON ¶
func (b AmountBlockchain) MarshalJSON() ([]byte, error)
func (*AmountBlockchain) Mul ¶
func (amount *AmountBlockchain) Mul(x *AmountBlockchain) AmountBlockchain
Use the underlying big.Int.Mul()
func (AmountBlockchain) Sign ¶
func (amount AmountBlockchain) Sign() int
func (AmountBlockchain) String ¶
func (amount AmountBlockchain) String() string
func (*AmountBlockchain) Sub ¶
func (amount *AmountBlockchain) Sub(x *AmountBlockchain) AmountBlockchain
Use the underlying big.Int.Sub()
func (*AmountBlockchain) ToHuman ¶
func (amount *AmountBlockchain) ToHuman(decimals int32) AmountHumanReadable
func (AmountBlockchain) Uint64 ¶
func (amount AmountBlockchain) Uint64() uint64
Uint64 converts an AmountBlockchain into uint64
func (*AmountBlockchain) UnmarshalJSON ¶
func (b *AmountBlockchain) UnmarshalJSON(p []byte) error
func (AmountBlockchain) UnmaskFloat64 ¶
func (amount AmountBlockchain) UnmaskFloat64() float64
UnmaskFloat64 converts an AmountBlockchain into float64 given the number of decimals
type AmountHumanReadable ¶
AmountHumanReadable is a decimal amount as a human expects it for readability.
func NewAmountHumanReadableFromStr ¶
func NewAmountHumanReadableFromStr(str string) (AmountHumanReadable, error)
NewAmountHumanReadableFromStr creates a new AmountHumanReadable from a string
func (AmountHumanReadable) Decimal ¶
func (amount AmountHumanReadable) Decimal() decimal.Decimal
func (AmountHumanReadable) Div ¶
func (amount AmountHumanReadable) Div(x AmountHumanReadable) AmountHumanReadable
func (AmountHumanReadable) MarshalJSON ¶
func (b AmountHumanReadable) MarshalJSON() ([]byte, error)
func (AmountHumanReadable) String ¶
func (amount AmountHumanReadable) String() string
func (AmountHumanReadable) ToBlockchain ¶
func (amount AmountHumanReadable) ToBlockchain(decimals int32) AmountBlockchain
func (*AmountHumanReadable) UnmarshalJSON ¶
func (b *AmountHumanReadable) UnmarshalJSON(p []byte) error
type AssetID ¶
type AssetID string
AssetID is an internal identifier for each asset (legacy/deprecated) Examples: ETH, USDC, USDC.SOL - see tests for details
func GetAssetIDFromAsset ¶
func GetAssetIDFromAsset(asset string, nativeAsset NativeAsset) AssetID
GetAssetIDFromAsset return the canonical AssetID given two input strings asset, nativeAsset. Input can come from user input. Examples: - GetAssetIDFromAsset("USDC", "") -> "USDC.ETH" - GetAssetIDFromAsset("USDC", "ETH") -> "USDC.ETH" - GetAssetIDFromAsset("USDC", "SOL") -> "USDC.SOL" - GetAssetIDFromAsset("USDC.SOL", "") -> "USDC.SOL" See tests for more examples.
type ChainConfig ¶
type ChainConfig struct { Chain NativeAsset `yaml:"chain,omitempty"` XAssetDeprecated NativeAsset `yaml:"asset,omitempty"` // deprecated Driver Driver `yaml:"driver,omitempty"` Net string `yaml:"net,omitempty"` Clients []*ClientConfig `yaml:"clients,omitempty"` URL string `yaml:"url,omitempty"` FcdURL string `yaml:"fcd_url,omitempty"` Auth string `yaml:"auth,omitempty"` Provider string `yaml:"provider,omitempty"` ChainID int64 `yaml:"chain_id,omitempty"` ChainIDStr string `yaml:"chain_id_str,omitempty"` ChainName string `yaml:"chain_name,omitempty"` ChainPrefix string `yaml:"chain_prefix,omitempty"` ChainCoin string `yaml:"chain_coin,omitempty"` GasCoin string `yaml:"gas_coin,omitempty"` ChainCoinHDPath uint32 `yaml:"chain_coin_hd_path,omitempty"` ChainGasPriceDefault float64 `yaml:"chain_gas_price_default,omitempty"` ChainGasMultiplier float64 `yaml:"chain_gas_multiplier,omitempty"` ChainGasTip uint64 `yaml:"chain_gas_tip,omitempty"` ChainMaxGasPrice float64 `yaml:"chain_max_gas_price,omitempty"` ChainMinGasPrice float64 `yaml:"chain_min_gas_price,omitempty"` ChainTransferTax float64 `yaml:"chain_transfer_tax,omitempty"` ExplorerURL string `yaml:"explorer_url,omitempty"` Decimals int32 `yaml:"decimals,omitempty"` IndexerUrl string `yaml:"indexer_url,omitempty"` IndexerType string `yaml:"indexer_type,omitempty"` IndexerSymbol string `yaml:"indexer_symbol,omitempty"` PollingPeriod string `yaml:"polling_period,omitempty"` NoGasFees bool `yaml:"no_gas_fees,omitempty"` Disabled *bool `yaml:"disabled,omitempty"` ExplorerUrls ExplorerUrls `yaml:"explorer_urls"` CoinGeckoId string `yaml:"coingecko_id,omitempty"` CoinMarketCapId string `yaml:"coinmarketcap_id,omitempty"` Dti string `yaml:"dti,omitempty"` ConfirmationsFinal int `yaml:"confirmations_final,omitempty"` Staking StakingConfig `yaml:"staking,omitempty"` // Internal // dereferenced api token if used AuthSecret string `yaml:"-"` }
AssetConfig is the model used to represent an asset read from config file or db
func (ChainConfig) GetAllClients ¶
func (asset ChainConfig) GetAllClients() []*ClientConfig
Return list of clients with the "default" client added if it's not already there
func (*ChainConfig) GetAssetSymbol ¶
func (native *ChainConfig) GetAssetSymbol() string
func (*ChainConfig) GetChain ¶
func (asset *ChainConfig) GetChain() *ChainConfig
func (*ChainConfig) GetContract ¶
func (native *ChainConfig) GetContract() string
func (*ChainConfig) GetDecimals ¶
func (asset *ChainConfig) GetDecimals() int32
func (ChainConfig) GetNativeClients ¶
func (asset ChainConfig) GetNativeClients() []*ClientConfig
Return all clients that are not crosschain driver
func (*ChainConfig) ID ¶
func (asset *ChainConfig) ID() AssetID
func (ChainConfig) String ¶
func (c ChainConfig) String() string
type ClientConfig ¶
type ClientConfig struct { Driver Driver `yaml:"driver"` URL string `yaml:"url,omitempty"` Auth string `yaml:"auth,omitempty"` Provider string `yaml:"provider,omitempty"` Network NetworkSelector `yaml:"network,omitempty"` }
ClientConfig is the model used to represent a client inside an AssetConfig
type Driver ¶
type Driver string
Driver is the type of a chain
func (Driver) PublicKeyFormat ¶
func (driver Driver) PublicKeyFormat() PublicKeyFormat
func (Driver) SignatureAlgorithm ¶
func (driver Driver) SignatureAlgorithm() SignatureType
type ExplorerUrls ¶
type GasFeePriority ¶
type GasFeePriority string
var Aggressive GasFeePriority = "aggressive"
var Low GasFeePriority = "low"
var Market GasFeePriority = "market"
var VeryAggressive GasFeePriority = "very-aggressive"
func NewPriority ¶
func NewPriority(input string) (GasFeePriority, error)
func (GasFeePriority) GetDefault ¶
func (p GasFeePriority) GetDefault() (decimal.Decimal, error)
func (GasFeePriority) IsEnum ¶
func (p GasFeePriority) IsEnum() bool
type ITask ¶
type ITask interface { // unique identifier used within crosschain, typically a combination of asset.chain ID() AssetID GetChain() *ChainConfig // Get associated asset decimals if it exists GetDecimals() int32 // Get associated contract if it exists GetContract() string // Informational / debugging String() string // Get asset symbol (e.g. 'USDC') if it exists. Does not include the chain. Informational. GetAssetSymbol() string }
type LegacyTxInfo ¶
type LegacyTxInfo struct { BlockHash string `json:"block_hash"` TxID string `json:"tx_id"` ExplorerURL string `json:"explorer_url"` From Address `json:"from"` To Address `json:"to"` ToAlt Address `json:"to_alt,omitempty"` ContractAddress ContractAddress `json:"contract,omitempty"` Amount AmountBlockchain `json:"amount"` Fee AmountBlockchain `json:"fee"` FeeContract ContractAddress `json:"fee_contract,omitempty"` BlockIndex int64 `json:"block_index,omitempty"` BlockTime int64 `json:"block_time,omitempty"` Confirmations int64 `json:"confirmations,omitempty"` Status TxStatus `json:"status"` Sources []*LegacyTxInfoEndpoint `json:"sources,omitempty"` Destinations []*LegacyTxInfoEndpoint `json:"destinations,omitempty"` Time int64 `json:"time,omitempty"` TimeReceived int64 `json:"time_received,omitempty"` // If this transaction failed, this is the reason why. Error string `json:"error,omitempty"` // contains filtered or unexported fields }
LegacyTxInfo is a unified view of common tx info across multiple blockchains. Use it as an example to build your own.
func (*LegacyTxInfo) AddDroppedDestination ¶
func (info *LegacyTxInfo) AddDroppedDestination(dest *LegacyTxInfoEndpoint)
func (*LegacyTxInfo) AddStakeEvent ¶
func (info *LegacyTxInfo) AddStakeEvent(ev StakeEvent)
func (*LegacyTxInfo) GetDroppedBtcDestinations ¶
func (info *LegacyTxInfo) GetDroppedBtcDestinations() []*LegacyTxInfoEndpoint
func (*LegacyTxInfo) GetStakeEvents ¶
func (info *LegacyTxInfo) GetStakeEvents() []StakeEvent
type LegacyTxInfoEndpoint ¶
type LegacyTxInfoEndpoint struct { Address Address `json:"address"` ContractAddress ContractAddress `json:"contract,omitempty"` Amount AmountBlockchain `json:"amount"` NativeAsset NativeAsset `json:"chain"` Asset string `json:"asset,omitempty"` Memo string `json:"memo,omitempty"` // Set only when there's a contract ID for native asset (and conflicts with our chosen identifier) ContractId ContractAddress `json:"contract_id,omitempty"` }
LegacyTxInfoEndpoint is a unified view of an endpoint (source or destination) in a TxInfo.
type NativeAsset ¶
type NativeAsset string
NativeAsset is an asset on a blockchain used to pay gas fees. In Crosschain, for simplicity, a NativeAsset represents a chain.
func LegacyParseAssetAndNativeAsset ¶
func LegacyParseAssetAndNativeAsset(asset string, nativeAsset string) (string, NativeAsset)
func (NativeAsset) Driver ¶
func (native NativeAsset) Driver() Driver
func (NativeAsset) IsValid ¶
func (native NativeAsset) IsValid() bool
type NetworkSelector ¶
type NetworkSelector string
Network selector is used by crosschain client to select which network of a blockchain to select.
const Mainnets NetworkSelector = ""
const NotMainnets NetworkSelector = "!mainnet"
type PipelineConfig ¶
type PipelineConfig struct { Name string `yaml:"name"` Allow []string `yaml:"allow"` Tasks []string `yaml:"tasks"` // internal AllowList []*AllowEntry `yaml:"-"` }
PipelineConfig is the model used to represent a pipeline (list of tasks) read from config file or db
func (PipelineConfig) ID ¶
func (p PipelineConfig) ID() AssetID
func (PipelineConfig) String ¶
func (p PipelineConfig) String() string
type PossibleAddress ¶
type PossibleAddress struct { Address Address Type AddressType }
PossibleAddress is a pair of (Address, AddressType) used to derive all possible addresses from a public key
type PublicKeyFormat ¶
type PublicKeyFormat string
var Compressed PublicKeyFormat = "compressed"
var Raw PublicKeyFormat = "raw"
var Uncompressed PublicKeyFormat = "uncompressed"
type SignatureType ¶
type SignatureType string
type StakeEvent ¶
type StakeEvent interface {
GetValidator() string
}
type StakeTxInput ¶
type StakeTxInput interface { TxVariantInput Staking() }
Markers for each type of Variant Tx
type StakingConfig ¶
type StakingConfig struct { // the contract used for staking, if relevant StakeContract string `yaml:"stake_contract,omitempty"` // the contract used for unstaking, if relevant UnstakeContract string `yaml:"unstake_contract,omitempty"` // Compatible providers for staking Providers []StakingProvider `yaml:"providers,omitempty"` }
func (*StakingConfig) Enabled ¶
func (staking *StakingConfig) Enabled() bool
type StakingProvider ¶
type StakingProvider string
const Figment StakingProvider = "figment"
const Kiln StakingProvider = "kiln"
const Native StakingProvider = "native"
const Twinstake StakingProvider = "twinstake"
func (StakingProvider) Valid ¶
func (stakingProvider StakingProvider) Valid() bool
type Task ¶
type Task string
Task represents a tx, e.g. smart contract function call, on a blockchain.
type TaskConfig ¶
type TaskConfig struct { Name string `yaml:"name"` Code string `yaml:"code"` Allow []string `yaml:"allow"` Chain string `yaml:"chain"` DefaultParams map[string]interface{} `yaml:"default_params"` Operations []TaskConfigOperation `yaml:"operations"` // internal AllowList []*AllowEntry `yaml:"-"` SrcAsset ITask `yaml:"-"` DstAsset ITask `yaml:"-"` }
TaskConfig is the model used to represent a task read from config file or db
func (*TaskConfig) GetAssetSymbol ¶
func (task *TaskConfig) GetAssetSymbol() string
func (TaskConfig) GetChain ¶
func (task TaskConfig) GetChain() *ChainConfig
func (*TaskConfig) GetContract ¶
func (task *TaskConfig) GetContract() string
func (*TaskConfig) GetDecimals ¶
func (task *TaskConfig) GetDecimals() int32
func (TaskConfig) GetTask ¶
func (task TaskConfig) GetTask() *TaskConfig
func (*TaskConfig) ID ¶
func (task *TaskConfig) ID() AssetID
func (TaskConfig) String ¶
func (task TaskConfig) String() string
type TaskConfigOperation ¶
type TaskConfigOperation struct { Function string `yaml:"function"` Signature string `yaml:"signature"` Contract interface{} `yaml:"contract"` // string or map[string]string Payable bool `yaml:"payable"` Params []TaskConfigOperationParam `yaml:"params"` }
type TaskConfigOperationParam ¶
type TaskConfigOperationParam struct { Name string `yaml:"name"` Type string `yaml:"type"` Bind string `yaml:"bind"` Match string `yaml:"match"` Value interface{} `yaml:"value"` // string or map[string]string // Defaults []TaskConfigOperationParamDefaults `yaml:"defaults"` Fields []TaskConfigOperationParam `yaml:"fields"` }
type TokenAssetConfig ¶
type TokenAssetConfig struct { Asset string `yaml:"asset,omitempty"` Chain NativeAsset `yaml:"chain,omitempty"` Decimals int32 `yaml:"decimals,omitempty"` Contract string `yaml:"contract,omitempty"` // Token configs are joined with a chain config upon loading. // If there is no matching native asset config, there will be a loading error. ChainConfig *ChainConfig `yaml:"-"` }
func (*TokenAssetConfig) GetAssetSymbol ¶
func (token *TokenAssetConfig) GetAssetSymbol() string
func (*TokenAssetConfig) GetChain ¶
func (asset *TokenAssetConfig) GetChain() *ChainConfig
func (*TokenAssetConfig) GetContract ¶
func (token *TokenAssetConfig) GetContract() string
func (*TokenAssetConfig) GetDecimals ¶
func (asset *TokenAssetConfig) GetDecimals() int32
func (asset *TokenAssetConfig) GetDriver() Driver { return Driver(asset.GetNativeAsset().Driver) }
func (*TokenAssetConfig) ID ¶
func (asset *TokenAssetConfig) ID() AssetID
func (*TokenAssetConfig) String ¶
func (c *TokenAssetConfig) String() string
type Tx ¶
type Tx interface { Hash() TxHash Sighashes() ([]TxDataToSign, error) AddSignatures(...TxSignature) error // only needed for RPC endpoints that require signatures in separate fields GetSignatures() []TxSignature Serialize() ([]byte, error) }
Tx is a transaction
type TxBuilder ¶
type TxBuilder interface {
NewTransfer(from Address, to Address, amount AmountBlockchain, input TxInput) (Tx, error)
}
TxBuilder is a Builder that can transfer assets
type TxDataToSign ¶
type TxDataToSign []byte
TxDataToSign is the payload that Signer needs to sign, when "signing a tx". It's sometimes called a sighash.
func (TxDataToSign) String ¶
func (data TxDataToSign) String() string
type TxInput ¶
type TxInput interface { GetDriver() Driver TxInputConflicts TxInputGasFeeMultiplier }
TxInput is input data to a tx. Depending on the blockchain it can include nonce, recent block hash, account id, ...
type TxInputConflicts ¶
type TxInputConflicts interface { // Test independence of two tx-inputs, assuming the same address is used. // Examples: // - using the same nonce or sequence is NOT independent // - spending the same resources or utxo's is NOT independent // - solana (using recent_block_hash) is pretty much always independent // This is used to determine if a transaction needs to be queued or if it can be immediately signed & broadcasted. IndependentOf(other TxInput) (independent bool) // Test if tx-input could possibly result in a "double-send" given the history of past attempts. // A double send is a user re-signing their transaction (to overcome a timeout or use new fees), but then risk multiple transactions // landing on chain. A valid re-sign should only occur if it's only possible for one transaction to land out of the total set of attempts. // Examples: // - Solana typically has no conflicts, but need to ensure (a) new blockhash is used, and (b) sufficient time has passed // to be sure a double send won't occur (return `true`). // - If tx-inputs are not independent (spending same resources), then typically double-sends are impossible (and should return `true` here). // - If there exists tx-inputs that are fully independent (and not timed out), then a double-send is possible and this should return false. SafeFromDoubleSend(previousAttempts ...TxInput) (safe bool) }
This interface determines whether if different tx inputs conflict with one another.
type TxInputEnvelope ¶
type TxInputEnvelope struct {
Type Driver `json:"type"`
}
func NewTxInputEnvelope ¶
func NewTxInputEnvelope(envType Driver) *TxInputEnvelope
type TxInputGasFeeMultiplier ¶
type TxInputGasFeeMultiplier interface {
SetGasFeePriority(priority GasFeePriority) error
}
type TxInputWithAmount ¶
type TxInputWithAmount interface {
SetAmount(AmountBlockchain)
}
TxInputWithAmount for chains that can optimize the tx input if they know the amount being transferred.
type TxInputWithMemo ¶
type TxInputWithMemo interface {
SetMemo(string)
}
For chains/transactions that leverage memo field
type TxInputWithPublicKey ¶
type TxInputWithPublicKey interface { TxInput SetPublicKey([]byte) error SetPublicKeyFromStr(string) error }
TxInputWithPublicKey is input data to a tx for chains that need to explicitly set the public key, e.g. Cosmos
type TxInputWithUnix ¶
type TxInputWithUnix interface {
SetUnix(int64)
}
For chains/transactions that can benefit from knowing the timestamp
type TxSignature ¶
type TxSignature []byte
TxSignature is a tx signature
func NewTxSignatures ¶
func NewTxSignatures(data [][]byte) []TxSignature
NewTxSignatures creates a new array of TxSignature, useful to cast [][]byte into []TxSignature
type TxStatus ¶
type TxStatus uint8
TxStatus is the status of a tx on chain, currently success or failure.
type TxTokenBuilder ¶
type TxTokenBuilder interface { TxBuilder NewNativeTransfer(from Address, to Address, amount AmountBlockchain, input TxInput) (Tx, error) NewTokenTransfer(from Address, to Address, amount AmountBlockchain, input TxInput) (Tx, error) }
TxTokenBuilder is a Builder that can transfer token assets, in addition to native assets This interface is soon being removed.
type TxVariantInput ¶
type TxVariantInput interface { TxInput GetVariant() TxVariantInputType }
type TxVariantInputType ¶
type TxVariantInputType string
func NewStakingInputType ¶
func NewStakingInputType(driver Driver, variant string) TxVariantInputType
func NewUnstakingInputType ¶
func NewUnstakingInputType(driver Driver, variant string) TxVariantInputType
func NewWithdrawingInputType ¶
func NewWithdrawingInputType(driver Driver, variant string) TxVariantInputType
func (TxVariantInputType) Driver ¶
func (variant TxVariantInputType) Driver() Driver
func (TxVariantInputType) Validate ¶
func (variant TxVariantInputType) Validate() error
func (TxVariantInputType) Variant ¶
func (variant TxVariantInputType) Variant() string
type TxXTransferBuilder ¶
type TxXTransferBuilder interface { TxBuilder NewTask(from Address, to Address, amount AmountBlockchain, input TxInput) (Tx, error) }
TxXTransferBuilder is a Builder that can mutate an asset into another asset This interface is soon being removed.
type UnstakeTxInput ¶
type UnstakeTxInput interface { TxVariantInput Unstaking() }
type WithdrawTxInput ¶
type WithdrawTxInput interface { TxVariantInput Withdrawing() }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
chain
|
|
cosmos/types/CosmWasm/wasmd/x/wasm/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/auction/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/ocr/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/oracle/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/peggy/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/tokenfactory/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/wasmx/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
cosmos/types/evmos/ethermint/x/evm/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
cosmos/types/evmos/ethermint/x/feemarket/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
cmd
|
|
examples
|
|
testutil
|
|