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 CheckFeeLimit(input TxInput, chainConfig *ChainConfig) error
- func SameTxInputTypes[T TxInput](as T, inputs ...TxInput) bool
- type AdditionalNativeAsset
- type Address
- type AddressBuilder
- type AddressType
- type AmountBlockchain
- func MultiplyByFloat(amount AmountBlockchain, multiplier float64) AmountBlockchain
- func NewAmountBlockchainFromInt64(i64 int64) (AmountBlockchain, bool)
- func NewAmountBlockchainFromStr(str string) AmountBlockchain
- func NewAmountBlockchainFromUint64(u64 uint64) AmountBlockchain
- func NewAmountBlockchainToMaskFloat64(f64 float64) AmountBlockchain
- func (amount *AmountBlockchain) Abs() AmountBlockchain
- func (amount *AmountBlockchain) Add(x *AmountBlockchain) AmountBlockchain
- func (amount AmountBlockchain) ApplyGasPriceMultiplier(chain *ChainClientConfig) AmountBlockchain
- func (amount AmountBlockchain) Bytes() []byte
- 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) IsZero() bool
- func (b AmountHumanReadable) MarshalJSON() ([]byte, error)
- func (b AmountHumanReadable) MarshalYAML() (interface{}, error)
- func (amount AmountHumanReadable) String() string
- func (amount AmountHumanReadable) ToBlockchain(decimals int32) AmountBlockchain
- func (b *AmountHumanReadable) UnmarshalJSON(p []byte) error
- func (b *AmountHumanReadable) UnmarshalYAML(node *yaml.Node) error
- type ChainBaseConfig
- type ChainClientConfig
- type ChainConfig
- func (chain *ChainConfig) Base() *ChainBaseConfig
- func (chain *ChainConfig) Client() *ChainClientConfig
- func (native *ChainConfig) ClientURL() (string, Driver)
- func (chain *ChainConfig) Configure()
- func (native *ChainConfig) GetAssetSymbol() string
- func (asset *ChainConfig) GetChain() *ChainConfig
- func (native *ChainConfig) GetContract() string
- func (asset *ChainConfig) GetDecimals() int32
- func (native *ChainConfig) IsChain(contract ContractAddress) bool
- func (c ChainConfig) String() string
- func (chain *ChainConfig) WithAuth(auth config.Secret) *ChainConfig
- func (chain *ChainConfig) WithChainCoin(chainCoin string) *ChainConfig
- func (chain *ChainConfig) WithChainID(chainID string) *ChainConfig
- func (chain *ChainConfig) WithChainPrefix(chainPrefix string) *ChainConfig
- func (chain *ChainConfig) WithDecimals(decimals int32) *ChainConfig
- func (chain *ChainConfig) WithDriver(driver Driver) *ChainConfig
- func (chain *ChainConfig) WithFeeLimit(feeLimit AmountHumanReadable) *ChainConfig
- func (chain *ChainConfig) WithGasBudgetDefault(gasBudgetDefault AmountHumanReadable) *ChainConfig
- func (chain *ChainConfig) WithGasPriceMultiplier(multiplier float64) *ChainConfig
- func (chain *ChainConfig) WithIndexer(indexerType string, url string) *ChainConfig
- func (chain *ChainConfig) WithMaxGasPrice(maxGasPrice float64) *ChainConfig
- func (chain *ChainConfig) WithMinGasPrice(minGasPrice float64) *ChainConfig
- func (chain *ChainConfig) WithNet(net string) *ChainConfig
- func (chain *ChainConfig) WithProvider(provider string) *ChainConfig
- func (chain *ChainConfig) WithTransactionActiveTime(transactionActiveTime time.Duration) *ChainConfig
- func (chain *ChainConfig) WithUrl(url string) *ChainConfig
- type ClientConfig
- type ContractAddress
- type CrosschainClientConfig
- type Driver
- type ExplorerUrls
- type External
- type GasFeePriority
- type ITask
- type NativeAsset
- type NetworkSelector
- type PossibleAddress
- type PublicKeyFormat
- type SignatureRequest
- type SignatureResponse
- type SignatureType
- type StakeTxInput
- type StakingConfig
- type StakingProvider
- type StringOrInt
- type Tx
- type TxDataToSign
- type TxHash
- type TxInput
- type TxInputConflicts
- type TxInputEnvelope
- type TxInputGasFeeMultiplier
- type TxInputGetMaxPossibleFee
- type TxInputWithAmount
- type TxInputWithMemo
- type TxInputWithPublicKey
- type TxInputWithUnix
- type TxSignature
- type TxStatus
- type TxVariantInput
- type TxVariantInputType
- type UnstakeTxInput
- type WithdrawTxInput
Constants ¶
const ( K256Keccak = SignatureType("k256-keccak") K256Sha256 = SignatureType("k256-sha256") Ed255 = SignatureType("ed255") Schnorr = SignatureType("schnorr") Bls12_381G2Blake2 = SignatureType("bls12-381-g2-blake2") )
const ( ACA = NativeAsset("ACA") // Acala AKT = NativeAsset("AKT") // Akash APTOS = NativeAsset("APTOS") // APTOS ArbETH = NativeAsset("ArbETH") // Arbitrum ASTR = NativeAsset("ASTR") // Astar ATOM = NativeAsset("ATOM") // Cosmos AurETH = NativeAsset("AurETH") // Aurora AVAX = NativeAsset("AVAX") // Avalanche BAND = NativeAsset("BAND") // Band BASE = NativeAsset("BASE") // BASE BABY = NativeAsset("BABY") // Babylon 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 DUSK = NativeAsset("DUSK") // Dusk ENJ = NativeAsset("ENJ") // Enjin ETC = NativeAsset("ETC") // Ethereum Classic ETH = NativeAsset("ETH") // Ethereum ETHW = NativeAsset("ETHW") // Ethereum PoW FIL = NativeAsset("FIL") // Filecoin 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 MON = NativeAsset("MON") // MONAD NOBLE = NativeAsset("NOBLE") // Noble Chain 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 SeiEVM = NativeAsset("SeiEVM") // SeiEVM XRP = NativeAsset("XRP") // XRP XLM = NativeAsset("XLM") // XLM ZETA = NativeAsset("ZETA") // ZetaChain NIL = NativeAsset("NIL") // Nillion )
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") DriverDusk = Driver("dusk") DriverEVM = Driver("evm") DriverEVMLegacy = Driver("evm-legacy") DriverFilecoin = Driver("filecoin") DriverSubstrate = Driver("substrate") DriverSolana = Driver("solana") DriverSui = Driver("sui") DriverTron = Driver("tron") DriverTon = Driver("ton") DriverXrp = Driver("xrp") DriverXlm = Driver("xlm") // Crosschain is a client-only driver DriverCrosschain = Driver("crosschain") )
List of supported Driver
const FLOAT_PRECISION = 6
Variables ¶
var NativeAssetList []NativeAsset = []NativeAsset{ AKT, BAND, BCH, BTC, DOGE, LTC, ACA, APTOS, ArbETH, ASTR, ATOM, AurETH, AVAX, BERA, BNB, CELO, CHZ, CHZ2, DOT, DUSK, ENJ, ETC, ETH, ETHW, FIL, FTM, INJ, HASH, LUNA, LUNC, KAR, KLAY, KSM, XDC, MATIC, MON, OAS, OptETH, EmROSE, SOL, SUI, XPLA, TAO, TIA, TON, TRX, SEI, SeiEVM, XRP, BASE, NOBLE, XLM, ZETA, NIL, }
var SupportedDrivers = []Driver{ DriverAptos, DriverBitcoin, DriverBitcoinCash, DriverBitcoinLegacy, DriverCosmos, DriverCosmosEvmos, DriverEVM, DriverEVMLegacy, DriverFilecoin, DriverSubstrate, DriverSolana, DriverSui, DriverTron, DriverTon, DriverXrp, DriverXlm, }
var SupportedStakingProviders = []StakingProvider{ Native, Kiln, Figment, Twinstake, }
Functions ¶
func CheckFeeLimit ¶
func CheckFeeLimit(input TxInput, chainConfig *ChainConfig) error
Check against the max-fee defaults in the configuration. Custody products should have a way to override max-fee limits.
func SameTxInputTypes ¶
Types ¶
type AdditionalNativeAsset ¶
type AdditionalNativeAsset struct { // The asset ID of the asset to use AssetId string `yaml:"asset_id,omitempty"` // The on-chain contract ID of the asset ContractId ContractAddress `yaml:"contract_id,omitempty"` // Decimals for the asset Decimals int32 `yaml:"decimals,omitempty"` // Maximum fee limit FeeLimit AmountHumanReadable `yaml:"fee_limit"` }
func NewAdditionalNativeAsset ¶
func NewAdditionalNativeAsset(assetId string, contractId ContractAddress, decimals int32, feeLimit AmountHumanReadable) *AdditionalNativeAsset
type Address ¶
type Address string
Address is an address on the blockchain, either sender or recipient
type AddressBuilder ¶
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 AmountBlockchain ¶
AmountBlockchain is a big integer amount as blockchain expects it for tx.
func MultiplyByFloat ¶
func MultiplyByFloat(amount AmountBlockchain, multiplier float64) AmountBlockchain
func NewAmountBlockchainFromInt64 ¶
func NewAmountBlockchainFromInt64(i64 int64) (AmountBlockchain, bool)
NewAmountBlockchainFromUint64 creates a new AmountBlockchain from a uint64
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 *ChainClientConfig) AmountBlockchain
func (AmountBlockchain) Bytes ¶
func (amount AmountBlockchain) Bytes() []byte
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 NewAmountHumanReadableFromFloat ¶
func NewAmountHumanReadableFromFloat(float float64) AmountHumanReadable
NewAmountHumanReadableFromFloat creates a new AmountHumanReadable from a float
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) IsZero ¶
func (b AmountHumanReadable) IsZero() bool
func (AmountHumanReadable) MarshalJSON ¶
func (b AmountHumanReadable) MarshalJSON() ([]byte, error)
func (AmountHumanReadable) MarshalYAML ¶
func (b AmountHumanReadable) MarshalYAML() (interface{}, 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
func (*AmountHumanReadable) UnmarshalYAML ¶
func (b *AmountHumanReadable) UnmarshalYAML(node *yaml.Node) error
type ChainBaseConfig ¶
type ChainBaseConfig struct { // The crosschain symbol of the chain Chain NativeAsset `yaml:"chain,omitempty"` // The driver to use for the chain Driver Driver `yaml:"driver,omitempty"` // The network selector, if necessary (e.g. select mainnet, testnet, or devnet for bitcoin chains) Network string `yaml:"net,omitempty"` // Decimals for the chain's native asset (if it has one). Decimals int32 `yaml:"decimals,omitempty"` // The ChainID of the chain, either in integer or string format ChainID StringOrInt `yaml:"chain_id,omitempty"` // Human readable name of the chain, e.g. "Bitcoin" ChainName string `yaml:"chain_name,omitempty"` // Does the chain use a special prefix for it's address? // E.g. most cosmos chains do this. ChainPrefix string `yaml:"chain_prefix,omitempty"` // If the chain has a native asset, and it has an actual contract address, it should be set here. // This is also referred to as the "ContractID". // E.g. // - APTOS has 0x1::aptos_coin::AptosCoin // - INJ has inj // - HASH has nhash // - LUNA has uluna ChainCoin string `yaml:"chain_coin,omitempty"` // Additional native assets that may be used to pay fees on the chain. NativeAssets []*AdditionalNativeAsset `yaml:"native_assets,omitempty"` // If true, then the `.Chain` does not represent any native asset (i.e. no chain-coin, no decimals). NoNativeAsset bool `yaml:"no_native_asset,omitempty"` // If necessary, specific which asset to use to spend for gas. GasCoin string `yaml:"gas_coin,omitempty"` // Indicate if this chain should not be included. Disabled *bool `yaml:"disabled,omitempty"` // Staking configuration Staking StakingConfig `yaml:"staking,omitempty"` // Maximum total fee limit: required for caller to make use of with `TxInput.GetFeeLimit()` FeeLimit AmountHumanReadable `yaml:"fee_limit,omitempty"` // Transfer tax is percentage that the network takes from every transfer .. only used so far for Terra Classic ChainTransferTax float64 `yaml:"chain_transfer_tax,omitempty"` // Used only for deriving private keys from mnemonic phrases in local testing ChainCoinHDPath uint32 `yaml:"chain_coin_hd_path,omitempty"` // Should use `ChainID` instead XChainIDStr string `yaml:"chain_id_str,omitempty"` }
type ChainClientConfig ¶
type ChainClientConfig struct { URL string `yaml:"url,omitempty"` // Set a secret reference, see config/secret.go. Used for setting an API keys. Auth2 config.Secret `yaml:"auth,omitempty"` // Optional configuration of the Driver. Some chains support different kinds of RPC. Provider string `yaml:"provider,omitempty"` CrosschainClient CrosschainClientConfig `yaml:"crosschain_client"` // Does the chain rely on an indexer in addition to RPC? If so, the URL and type // may be set here. IndexerUrl string `yaml:"indexer_url,omitempty"` IndexerType string `yaml:"indexer_type,omitempty"` // Maximun depth to scan for transaction, if there is no index to use (substrate...) MaxScanDepth int `yaml:"max_scan_depth,omitempty"` NoGasFees bool `yaml:"no_gas_fees,omitempty"` // Default gas budget to use for client gas estimation GasBudgetDefault AmountHumanReadable `yaml:"gas_budget_default,omitempty"` // Gas budget that cannot be exceeded below GasBudgetMinimum AmountHumanReadable `yaml:"gas_budget_min,omitempty"` // A default for clients to gas price if there's not better way to estimate. ChainGasPriceDefault float64 `yaml:"chain_gas_price_default,omitempty"` // A local multiplier for client to apply to gas estimation, if it's important/needed. ChainGasMultiplier float64 `yaml:"chain_gas_multiplier,omitempty"` // for gas estimation of gas limit, for somechains the simulation may be flaky and need a multiplier ChainGasLimitMultiplier float64 `yaml:"chain_gas_limit_multiplier,omitempty"` // The max/min prices can be set to provide sanity limits for what a gas price (per gas or per byte) should be. // This should be in the blockchain amount. ChainMaxGasPrice float64 `yaml:"chain_max_gas_price,omitempty"` ChainMinGasPrice float64 `yaml:"chain_min_gas_price,omitempty"` // Default gas limit for transactions GasLimitDefault int `yaml:"gas_limit_default,omitempty"` // TransactionActiveTime specifies the duration for which a transaction remains valid after being submitted. // The value is represented as a `time.Duration` string. // This field is currently used only by the Stellar network. // // Example format: "30s" (30 seconds), "2m" (2 minutes), "1h" (1 hour). TransactionActiveTime time.Duration `yaml:"transaction_active_time,omitempty"` // How many confirmations is considered "final" for this chain? ConfirmationsFinal int `yaml:"confirmations_final,omitempty"` // Rate limit setting on RPC requests for client, in requests/second. RateLimit rate.Limit `yaml:"rate_limit,omitempty"` // Period between requests (alternative to `rate_limit`) PeriodLimit time.Duration `yaml:"period_limit,omitempty"` // Number of requests to permit in burst Burst int `yaml:"burst,omitempty"` // Rate limiter configured from `rate_limit`, `period_limit`, `burst` (requires calling .Configure after loading from config) Limiter *rate.Limiter `yaml:"-" mapstructure:"-"` // Additional metadata. Not Used in crosschain itself, but helpful to enrich API endpoints. External External `yaml:"external,omitempty"` // Informational URLs for the chain explorers. ExplorerUrls ExplorerUrls `yaml:"explorer_urls,omitempty"` }
func (*ChainClientConfig) Configure ¶
func (chain *ChainClientConfig) Configure()
func (*ChainClientConfig) NewClientLimiter ¶
func (chain *ChainClientConfig) NewClientLimiter() *rate.Limiter
type ChainConfig ¶
type ChainConfig struct { *ChainBaseConfig `yaml:",inline"` *ChainClientConfig `yaml:",inline"` }
func NewChainConfig ¶
func NewChainConfig(nativeAsset NativeAsset, driverMaybe ...Driver) *ChainConfig
func (*ChainConfig) Base ¶
func (chain *ChainConfig) Base() *ChainBaseConfig
func (*ChainConfig) Client ¶
func (chain *ChainConfig) Client() *ChainClientConfig
func (*ChainConfig) ClientURL ¶
func (native *ChainConfig) ClientURL() (string, Driver)
Returns URL and driver used for the client. This will either Be the chain driver, or the 'special' crosschain driver.
func (*ChainConfig) Configure ¶
func (chain *ChainConfig) Configure()
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) IsChain ¶
func (native *ChainConfig) IsChain(contract ContractAddress) bool
func (ChainConfig) String ¶
func (c ChainConfig) String() string
func (*ChainConfig) WithAuth ¶
func (chain *ChainConfig) WithAuth(auth config.Secret) *ChainConfig
func (*ChainConfig) WithChainCoin ¶
func (chain *ChainConfig) WithChainCoin(chainCoin string) *ChainConfig
func (*ChainConfig) WithChainID ¶
func (chain *ChainConfig) WithChainID(chainID string) *ChainConfig
func (*ChainConfig) WithChainPrefix ¶
func (chain *ChainConfig) WithChainPrefix(chainPrefix string) *ChainConfig
func (*ChainConfig) WithDecimals ¶
func (chain *ChainConfig) WithDecimals(decimals int32) *ChainConfig
func (*ChainConfig) WithDriver ¶
func (chain *ChainConfig) WithDriver(driver Driver) *ChainConfig
func (*ChainConfig) WithFeeLimit ¶
func (chain *ChainConfig) WithFeeLimit(feeLimit AmountHumanReadable) *ChainConfig
func (*ChainConfig) WithGasBudgetDefault ¶
func (chain *ChainConfig) WithGasBudgetDefault(gasBudgetDefault AmountHumanReadable) *ChainConfig
func (*ChainConfig) WithGasPriceMultiplier ¶
func (chain *ChainConfig) WithGasPriceMultiplier(multiplier float64) *ChainConfig
func (*ChainConfig) WithIndexer ¶
func (chain *ChainConfig) WithIndexer(indexerType string, url string) *ChainConfig
func (*ChainConfig) WithMaxGasPrice ¶
func (chain *ChainConfig) WithMaxGasPrice(maxGasPrice float64) *ChainConfig
func (*ChainConfig) WithMinGasPrice ¶
func (chain *ChainConfig) WithMinGasPrice(minGasPrice float64) *ChainConfig
func (*ChainConfig) WithNet ¶
func (chain *ChainConfig) WithNet(net string) *ChainConfig
func (*ChainConfig) WithProvider ¶
func (chain *ChainConfig) WithProvider(provider string) *ChainConfig
func (*ChainConfig) WithTransactionActiveTime ¶
func (chain *ChainConfig) WithTransactionActiveTime(transactionActiveTime time.Duration) *ChainConfig
func (*ChainConfig) WithUrl ¶
func (chain *ChainConfig) WithUrl(url string) *ChainConfig
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 CrosschainClientConfig ¶
type CrosschainClientConfig struct { Url string `yaml:"url"` Network NetworkSelector `yaml:"network,omitempty"` }
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 External ¶
type External struct { Dti string `yaml:"dti,omitempty"` CoinMarketCap struct { // CoinMarketCap's ID for the chain ChainId string `yaml:"chain_id,omitempty"` // CoinMarketCap's ID for the chain's native asset, also called "UCID" AssetId string `yaml:"asset_id,omitempty"` } `yaml:"coin_market_cap,omitempty"` CoinGecko struct { // TODO: is there a chain ID for coingecko? ChainId string `yaml:"chain_id,omitempty"` // Coingecko's asset ID, if relevant AssetId string `yaml:"asset_id,omitempty"` } `yaml:"coin_gecko,omitempty"` IndexingCo struct { ChainId string `yaml:"chain_id,omitempty"` } `yaml:"indexing_co,omitempty"` }
External ID's used by other vendors for the given chain
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 { GetChain() *ChainConfig GetDecimals() int32 // Informational / debugging String() string }
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 (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 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 SignatureRequest ¶
type SignatureRequest struct { // Required: The payload to sign Payload []byte // May be optionally set, if different from the from-address. Signer Address }
func NewSignatureRequest ¶
func NewSignatureRequest(payload []byte, signerMaybe ...Address) *SignatureRequest
type SignatureResponse ¶
type SignatureResponse struct { // Signaure of the payload Signature TxSignature // Address + public key of the signer PublicKey []byte Address Address }
type SignatureType ¶
type SignatureType 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 StringOrInt ¶
type StringOrInt string
func (StringOrInt) AsInt ¶
func (s StringOrInt) AsInt() (uint64, bool)
func (StringOrInt) AsString ¶
func (s StringOrInt) AsString() string
type Tx ¶
type Tx interface { Hash() TxHash Sighashes() ([]*SignatureRequest, error) AddSignatures(...*SignatureResponse) error // only needed for RPC endpoints that require signatures in separate fields GetSignatures() []TxSignature Serialize() ([]byte, error) }
Tx is a transaction
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 TxInputGetMaxPossibleFee }
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 TxInputGetMaxPossibleFee ¶
type TxInputGetMaxPossibleFee interface { // Get the maximum possible fee that could occur for this transaction. // This is used to guard against "griefing" attacks where a user is charged way more than they intended. // The contract address may be "" when the fee is for the native asset, as is often the case.. // // Note: The caller/user should check this after TxInput has been populated with all other fields, as they can influence // what the ultimate max fee is. GetFeeLimit() (AmountBlockchain, ContractAddress) }
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 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 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/exchange/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
cosmos/types/InjectiveLabs/injective-core/injective-chain/modules/insurance/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/permissions/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/evmos/v20/x/evm/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
cosmos/types/evmos/evmos/v20/x/feemarket/types
Package types is a reverse proxy.
|
Package types is a reverse proxy. |
cmd
|
|
examples
|
|
testutil
|
|