common

package
v1.131.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 43 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NoAddress   = Address("")
	NoopAddress = Address("noop")
)
View Source
const (
	EmptyChain = Chain("")
	BNBChain   = Chain("BNB")
	BSCChain   = Chain("BSC")
	ETHChain   = Chain("ETH")
	BTCChain   = Chain("BTC")
	LTCChain   = Chain("LTC")
	BCHChain   = Chain("BCH")
	DOGEChain  = Chain("DOGE")
	THORChain  = Chain("THOR")
	TERRAChain = Chain("TERRA")
	GAIAChain  = Chain("GAIA")
	AVAXChain  = Chain("AVAX")

	SigningAlgoSecp256k1 = SigningAlgo("secp256k1")
	SigningAlgoEd25519   = SigningAlgo("ed25519")
)
View Source
const (
	// BNBSymbol BNB
	BNBSymbol = Symbol("BNB")
	// Rune67CSymbol RUNE on binance testnet
	Rune67CSymbol = Symbol("RUNE-67C")
	// RuneB1ASymbol RUNE on binance mainnet
	RuneB1ASymbol = Symbol("RUNE-B1A")
)
View Source
const CurrentChainNetwork = MainNet
View Source
const One = 100000000

One is useful type so THORNode doesn't need to manage 8 zeroes all the time

View Source
const THORChainDecimals = 8

THORChainDecimals indicate the number of decimal points used in THORChain

Variables

View Source
var (
	// EmptyAsset empty asset, not valid
	EmptyAsset = Asset{Chain: EmptyChain, Symbol: "", Ticker: "", Synth: false}
	// LUNAAsset LUNA
	LUNAAsset = Asset{Chain: TERRAChain, Symbol: "LUNA", Ticker: "LUNA", Synth: false}
	// ATOMAsset ATOM
	ATOMAsset = Asset{Chain: GAIAChain, Symbol: "ATOM", Ticker: "ATOM", Synth: false}
	// BNBAsset BNB
	BNBAsset = Asset{Chain: BNBChain, Symbol: "BNB", Ticker: "BNB", Synth: false}
	// BNBBEP20Asset BNB
	BNBBEP20Asset = Asset{Chain: BSCChain, Symbol: "BNB", Ticker: "BNB", Synth: false}
	// BTCAsset BTC
	BTCAsset = Asset{Chain: BTCChain, Symbol: "BTC", Ticker: "BTC", Synth: false}
	// LTCAsset BTC
	LTCAsset = Asset{Chain: LTCChain, Symbol: "LTC", Ticker: "LTC", Synth: false}
	// BCHAsset BCH
	BCHAsset = Asset{Chain: BCHChain, Symbol: "BCH", Ticker: "BCH", Synth: false}
	// DOGEAsset DOGE
	DOGEAsset = Asset{Chain: DOGEChain, Symbol: "DOGE", Ticker: "DOGE", Synth: false}
	// ETHAsset ETH
	ETHAsset = Asset{Chain: ETHChain, Symbol: "ETH", Ticker: "ETH", Synth: false}
	// AVAXAsset AVAX
	AVAXAsset = Asset{Chain: AVAXChain, Symbol: "AVAX", Ticker: "AVAX", Synth: false}
	// Rune67CAsset RUNE on Binance test net
	Rune67CAsset = Asset{Chain: BNBChain, Symbol: "RUNE-67C", Ticker: "RUNE", Synth: false} // mocknet asset on binance ganges
	// RuneB1AAsset RUNE on Binance main net
	RuneB1AAsset = Asset{Chain: BNBChain, Symbol: "RUNE-B1A", Ticker: "RUNE", Synth: false} // mainnet
	// RuneNative RUNE on thorchain
	RuneNative            = Asset{Chain: THORChain, Symbol: "RUNE", Ticker: "RUNE", Synth: false}
	RuneERC20Asset        = Asset{Chain: ETHChain, Symbol: "RUNE-0x3155ba85d5f96b2d030a4966af206230e46849cb", Ticker: "RUNE", Synth: false}
	RuneERC20MocknetAsset = Asset{Chain: ETHChain, Symbol: "RUNE-0xd601c6A3a36721320573885A8d8420746dA3d7A0", Ticker: "RUNE", Synth: false}
	TOR                   = Asset{Chain: THORChain, Symbol: "TOR", Ticker: "TOR", Synth: false}
	THORBTC               = Asset{Chain: THORChain, Symbol: "BTC", Ticker: "BTC", Synth: false}
)
View Source
var (
	ErrInvalidLengthCommon        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowCommon          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupCommon = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	EmptyPubKey    PubKey
	EmptyPubKeySet PubKeySet
)
View Source
var BNBGasFeeMulti = Gas{
	{Asset: BNBAsset, Amount: bnbMultiTxFee},
}

BNBGasFeeMulti gas fee for multi send

View Source
var BNBGasFeeSingleton = Gas{
	{Asset: BNBAsset, Amount: bnbSingleTxFee},
}

BNBGasFeeSingleton fee charged by Binance for transfer with a single coin

View Source
var BlankTxID = TxID("0000000000000000000000000000000000000000000000000000000000000000")

BlankTxID represent blank

View Source
var LatestVersion semver.Version = semver.MustParse("999.0.0")
View Source
var NoCoin = Coin{
	Asset:  EmptyAsset,
	Amount: cosmos.ZeroUint(),
}

NoCoin is empty Coin

Functions

func ConvertAndEncode

func ConvertAndEncode(hrp string, data []byte) (string, error)

ConvertAndEncode converts from a base64 encoded byte string to hex or base32 encoded byte string and then to bech32

func CosmosPrivateKeyToTMPrivateKey added in v0.41.0

func CosmosPrivateKeyToTMPrivateKey(privateKey cryptotypes.PrivKey) crypto.PrivKey

CosmosPrivateKeyToTMPrivateKey convert cosmos implementation of private key to tendermint private key

func Entropy added in v1.106.0

func Entropy(b []byte) float64

func GetMedianInt64 added in v1.121.0

func GetMedianInt64(vals []int64) int64

func GetMedianUint added in v1.112.0

func GetMedianUint(vals []cosmos.Uint) cosmos.Uint

func GetSafeShare added in v0.63.0

func GetSafeShare(part, total, allocation cosmos.Uint) cosmos.Uint

GetSafeShare does the same as GetUncappedShare , but GetSafeShare will guarantee the result will not more than total. The first two arguments should always have the same units (cancelling out to represent a unitless ratio applied to the allocation).

func GetUncappedShare added in v1.93.0

func GetUncappedShare(part, total, allocation cosmos.Uint) (share cosmos.Uint)

GetUncappedShare this method will panic if any of the input parameter can't be convert to cosmos.Dec which shouldn't happen. The first two arguments should always have the same units (cancelling out to represent a unitless ratio applied to the allocation).

func RandHexString added in v1.124.0

func RandHexString(n int) string

RandHexString generates random hex string used for test purpose

func RoundSignificantFigures added in v1.116.0

func RoundSignificantFigures(number uint64, significantDigits int64) uint64

RoundSignificantFigures rounds an unsigned 64-bit integer to the specified number of significant digits. It takes the number and significant digits as arguments.

func SafeSub

func SafeSub(input1, input2 cosmos.Uint) cosmos.Uint

SafeSub subtract input2 from input1, given cosmos.Uint can't be negative , otherwise it will panic thus in this method,when input2 is larger than input 1, it will just return cosmos.ZeroUint

func Sign added in v1.92.0

func Sign(buf []byte) ([]byte, []byte, error)

Sign an array of bytes. Returns (signature, pubkey, error)

func SignBase64 added in v1.92.0

func SignBase64(buf []byte) (string, string, error)

Types

type Account

type Account struct {
	Sequence      int64
	AccountNumber int64
	Coins         Coins
	HasMemoFlag   bool
}

Account define a struct to hold account information across all chain

func NewAccount

func NewAccount(sequence, accountNumber int64, coins Coins, hasMemoFlag bool) Account

NewAccount create a new instance of Account

type Address

type Address string

func ConvertToNewBCHAddressFormat added in v0.54.0

func ConvertToNewBCHAddressFormat(addr Address) (Address, error)

ConvertToNewBCHAddressFormat convert the given BCH to new address format

func ConvertToNewBCHAddressFormatV83 added in v1.83.0

func ConvertToNewBCHAddressFormatV83(addr Address) (Address, error)

ConvertToNewBCHAddressFormatV83 convert the given BCH to new address format

func NewAddress

func NewAddress(address string) (Address, error)

NewAddress create a new Address. Supports Binance, Bitcoin, and Ethereum

func (Address) AccAddress added in v0.41.0

func (addr Address) AccAddress() (cosmos.AccAddress, error)

func (Address) Equals

func (addr Address) Equals(addr2 Address) bool

func (Address) GetChain added in v0.41.0

func (addr Address) GetChain() Chain

Note that this will always return ETHChain for an AVAXChain address, so perhaps only use it when determining a network (e.g. mainnet/testnet).

func (Address) GetNetwork added in v0.54.0

func (addr Address) GetNetwork(ver semver.Version, chain Chain) ChainNetwork

func (Address) IsChain

func (addr Address) IsChain(chain Chain) bool

Note that this can have false positives, such as being unable to distinguish between ETH and AVAX.

func (Address) IsEmpty

func (addr Address) IsEmpty() bool

func (Address) IsNoop added in v1.93.0

func (addr Address) IsNoop() bool

func (Address) IsValidBCHAddress added in v0.54.0

func (addr Address) IsValidBCHAddress() bool

IsValidBCHAddress determinate whether the address is a valid new BCH address format

func (Address) String

func (addr Address) String() string

type AddressSuite added in v1.105.0

type AddressSuite struct{}

func (*AddressSuite) TestAddress added in v1.105.0

func (s *AddressSuite) TestAddress(c *C)

func (*AddressSuite) TestConvertToNewBCHAddressFormat added in v1.105.0

func (s *AddressSuite) TestConvertToNewBCHAddressFormat(c *C)

type Asset

type Asset struct {
	Chain  Chain  `protobuf:"bytes,1,opt,name=chain,proto3,casttype=Chain" json:"chain,omitempty"`
	Symbol Symbol `protobuf:"bytes,2,opt,name=symbol,proto3,casttype=Symbol" json:"symbol,omitempty"`
	Ticker Ticker `protobuf:"bytes,3,opt,name=ticker,proto3,casttype=Ticker" json:"ticker,omitempty"`
	Synth  bool   `protobuf:"varint,4,opt,name=synth,proto3" json:"synth,omitempty"`
	Trade  bool   `protobuf:"varint,5,opt,name=trade,proto3" json:"trade,omitempty"`
}

func BEP2RuneAsset

func BEP2RuneAsset() Asset

BEP2RuneAsset is RUNE on BEP2

func ERC20RuneAsset added in v0.63.0

func ERC20RuneAsset() Asset

ERC20RuneAsset is RUNE on ETH

func NewAsset

func NewAsset(input string) (Asset, error)

NewAsset parse the given input into Asset object

func NewAssetWithShortCodes added in v1.115.0

func NewAssetWithShortCodes(version semver.Version, input string) (Asset, error)

func NewAssetWithShortCodesV115 added in v1.124.0

func NewAssetWithShortCodesV115(input string) (Asset, error)

func NewAssetWithShortCodesV124 added in v1.124.0

func NewAssetWithShortCodesV124(input string) (Asset, error)

func RuneAsset

func RuneAsset() Asset

RuneAsset return RUNE Asset depends on different environment

func (*Asset) Descriptor added in v0.41.0

func (*Asset) Descriptor() ([]byte, []int)

func (Asset) Equals

func (a Asset) Equals(a2 Asset) bool

Equals determinate whether two assets are equivalent

func (Asset) GetChain added in v0.41.0

func (a Asset) GetChain() Chain

func (Asset) GetDerivedAsset added in v1.121.0

func (a Asset) GetDerivedAsset() Asset

Get derived asset of asset

func (Asset) GetLayer1Asset added in v0.41.0

func (a Asset) GetLayer1Asset() Asset

Get layer1 asset version

func (Asset) GetSyntheticAsset added in v0.41.0

func (a Asset) GetSyntheticAsset() Asset

Get synthetic asset of asset

func (Asset) GetTradeAsset added in v1.128.0

func (a Asset) GetTradeAsset() Asset

Get trade asset of asset

func (Asset) IsBNB

func (a Asset) IsBNB() bool

IsBNB is a helper function, return true only when the asset represent BNB

func (Asset) IsDerivedAsset added in v1.121.0

func (a Asset) IsDerivedAsset() bool

Check if asset is a derived asset

func (Asset) IsEmpty

func (a Asset) IsEmpty() bool

IsEmpty will be true when any of the field is empty, chain,symbol or ticker

func (Asset) IsGasAsset added in v0.41.0

func (a Asset) IsGasAsset() bool

IsGasAsset check whether asset is base asset used to pay for gas

func (Asset) IsNative added in v1.121.0

func (a Asset) IsNative() bool

IsNative is a helper function, returns true when the asset is a native asset to THORChain (ie rune, a synth, etc)

func (Asset) IsNativeRune added in v0.41.0

func (a Asset) IsNativeRune() bool

IsNativeRune is a helper function, return true only when the asset represent NATIVE RUNE

func (Asset) IsRune

func (a Asset) IsRune() bool

IsRune is a helper function ,return true only when the asset represent RUNE

func (Asset) IsSyntheticAsset added in v0.41.0

func (a Asset) IsSyntheticAsset() bool

Check if asset is a pegged asset

func (Asset) IsTradeAsset added in v1.128.0

func (a Asset) IsTradeAsset() bool

func (Asset) IsVaultAsset added in v1.121.0

func (a Asset) IsVaultAsset() bool

func (*Asset) Marshal added in v0.41.0

func (m *Asset) Marshal() (dAtA []byte, err error)

func (Asset) MarshalJSON

func (a Asset) MarshalJSON() ([]byte, error)

MarshalJSON implement Marshaler interface

func (Asset) MarshalJSONPB added in v0.41.0

func (a Asset) MarshalJSONPB(*jsonpb.Marshaler) ([]byte, error)

MarshalJSONPB implement jsonpb.Marshaler

func (*Asset) MarshalTo added in v0.41.0

func (m *Asset) MarshalTo(dAtA []byte) (int, error)

func (*Asset) MarshalToSizedBuffer added in v0.41.0

func (m *Asset) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (Asset) MimirString added in v1.121.0

func (a Asset) MimirString() string

Replace pool name "." with a "-" for Mimir key checking.

func (Asset) Native

func (a Asset) Native() string

Native return native asset, only relevant on THORChain

func (*Asset) ProtoMessage added in v0.41.0

func (*Asset) ProtoMessage()

func (*Asset) Reset added in v0.41.0

func (m *Asset) Reset()

func (Asset) ShortCode added in v1.121.0

func (a Asset) ShortCode() string

ShortCode returns the short code for the asset.

func (*Asset) Size added in v0.41.0

func (m *Asset) Size() (n int)

func (Asset) String

func (a Asset) String() string

String implement fmt.Stringer , return the string representation of Asset

func (*Asset) Unmarshal added in v0.41.0

func (m *Asset) Unmarshal(dAtA []byte) error

func (*Asset) UnmarshalJSON

func (a *Asset) UnmarshalJSON(data []byte) error

UnmarshalJSON implement Unmarshaler interface

func (*Asset) UnmarshalJSONPB added in v0.41.0

func (a *Asset) UnmarshalJSONPB(unmarshal *jsonpb.Unmarshaler, content []byte) error

UnmarshalJSONPB implement jsonpb.Unmarshaler

func (*Asset) XXX_DiscardUnknown added in v0.41.0

func (m *Asset) XXX_DiscardUnknown()

func (*Asset) XXX_Marshal added in v0.41.0

func (m *Asset) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Asset) XXX_Merge added in v0.41.0

func (m *Asset) XXX_Merge(src proto.Message)

func (*Asset) XXX_Size added in v0.41.0

func (m *Asset) XXX_Size() int

func (*Asset) XXX_Unmarshal added in v0.41.0

func (m *Asset) XXX_Unmarshal(b []byte) error

type Chain

type Chain string

func GetEVMChains added in v1.95.0

func GetEVMChains() []Chain

GetEVMChains returns all "EVM" chains connected to THORChain "EVM" is defined, in thornode's context, as a chain that: - uses 0x as an address prefix - has a "Router" Smart Contract

func GetUTXOChains added in v1.113.1

func GetUTXOChains() []Chain

GetUTXOChains returns all "UTXO" chains connected to THORChain.

func NewChain

func NewChain(chainID string) (Chain, error)

NewChain create a new Chain and default the siging_algo to Secp256k1

func (Chain) AddressPrefix

func (c Chain) AddressPrefix(cn ChainNetwork) string

AddressPrefix return the address prefix used by the given network (mocknet/mainnet)

func (Chain) ApproximateBlockMilliseconds added in v1.99.0

func (c Chain) ApproximateBlockMilliseconds() int64

func (Chain) DefaultCoinbase added in v1.99.0

func (c Chain) DefaultCoinbase() float64

DefaultCoinbase returns the default coinbase address for each chain, returns 0 if no coinbase emission is used. This is used used at the time of writing as a fallback value in Bifrost, and for inbound confirmation count estimates in the quote APIs.

func (Chain) DustThreshold added in v1.99.0

func (c Chain) DustThreshold() cosmos.Uint

DustThreshold returns the min dust threshold for each chain The min dust threshold defines the lower end of the withdraw range of memoless savers txs The native coin value provided in a memoless tx defines a basis points amount of Withdraw or Add to a savers position as follows: Withdraw range: (dust_threshold + 1) -> (dust_threshold + 10_000) Add range: dust_threshold -> Inf NOTE: these should all be in 8 decimal places

func (Chain) Equals

func (c Chain) Equals(c2 Chain) bool

Equals compare two chain to see whether they represent the same chain

func (Chain) GetGasAsset

func (c Chain) GetGasAsset() Asset

GetGasAsset chain's base asset

func (Chain) GetGasAssetDecimal added in v0.80.0

func (c Chain) GetGasAssetDecimal() int64

GetGasAssetDecimal for the gas asset of given chain , what kind of precision it is using TERRA and GAIA are using 1E6, all other gas asset so far using 1E8 THORChain is using 1E8, if an external chain's gas asset is larger than 1E8, just return cosmos.DefaultCoinDecimals

func (Chain) GetGasUnits added in v1.97.0

func (c Chain) GetGasUnits() string

GetGasUnits returns name of the gas unit for each chain

func (Chain) GetSigningAlgo

func (c Chain) GetSigningAlgo() SigningAlgo

GetSigningAlgo get the signing algorithm for the given chain

func (Chain) InboundNotes added in v1.103.0

func (c Chain) InboundNotes() string

func (Chain) IsBNB

func (c Chain) IsBNB() bool

IsBNB determinate whether it is BNBChain

func (Chain) IsBSCChain added in v1.124.0

func (c Chain) IsBSCChain() bool

func (Chain) IsEVM added in v1.95.0

func (c Chain) IsEVM() bool

IsEVM returns true if given chain is an EVM chain. See working definition of an "EVM" chain in the `GetEVMChains` function description

func (Chain) IsEmpty

func (c Chain) IsEmpty() bool

IsEmpty is to determinate whether the chain is empty

func (Chain) IsTHORChain added in v0.41.0

func (c Chain) IsTHORChain() bool

func (Chain) IsUTXO added in v1.113.1

func (c Chain) IsUTXO() bool

IsUTXO returns true if given chain is a UTXO chain.

func (Chain) IsValidAddress added in v0.54.0

func (c Chain) IsValidAddress(addr Address) bool

IsValidAddress make sure the address is correct for the chain And this also make sure mocknet doesn't use mainnet address vice versa

func (Chain) MaxMemoLength added in v1.99.0

func (c Chain) MaxMemoLength() int

MaxMemoLength returns the max memo length for each chain.

func (Chain) String

func (c Chain) String() string

String implement fmt.Stringer

func (Chain) Validate

func (c Chain) Validate() error

Validate validates chain format, should consist only of uppercase letters

type ChainNetwork

type ChainNetwork uint8

ChainNetwork is to indicate which chain environment THORNode are working with

const (
	// TestNet network for test - DO NOT USE
	// TODO: remove on hard fork
	TestNet ChainNetwork = iota
	// MainNet network for mainnet
	MainNet
	// MockNet network for mocknet
	MockNet
	// Stagenet network for stagenet
	StageNet
)

func (ChainNetwork) SoftEquals added in v0.54.0

func (net ChainNetwork) SoftEquals(net2 ChainNetwork) bool

Soft Equals check is mainnet == mainet, or mocknet == mocknet

type ChainPoolInfo

type ChainPoolInfo struct {
	Chain       Chain   `json:"chain"`
	PubKey      PubKey  `json:"pub_key"`
	PoolAddress Address `json:"pool_address"`
}

ChainPoolInfo represent the pool address specific for a chain

var EmptyChainPoolInfo ChainPoolInfo

EmptyChainPoolInfo everything is empty

func NewChainPoolInfo

func NewChainPoolInfo(chain Chain, pubKey PubKey) (ChainPoolInfo, error)

NewChainPoolInfo create a new instance of ChainPoolInfo

func (ChainPoolInfo) IsEmpty

func (cpi ChainPoolInfo) IsEmpty() bool

IsEmpty whether the struct is empty

type Chains

type Chains []Chain

Chains represent a slice of Chain

func NewChains added in v1.109.0

func NewChains(raw []string) (Chains, error)

func (Chains) Distinct

func (chains Chains) Distinct() Chains

Distinct return a distinct set of chains, no duplicates

func (Chains) Has

func (chains Chains) Has(c Chain) bool

Has check whether chain c is in the list

func (Chains) Strings added in v0.41.0

func (chains Chains) Strings() []string

type Coin

type Coin struct {
	Asset    Asset                                   `protobuf:"bytes,1,opt,name=asset,proto3" json:"asset"`
	Amount   github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,2,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"amount"`
	Decimals int64                                   `protobuf:"varint,3,opt,name=decimals,proto3" json:"decimals,omitempty"`
}

func NewCoin

func NewCoin(asset Asset, amount cosmos.Uint) Coin

NewCoin return a new instance of Coin

func ParseCoin added in v1.105.0

func ParseCoin(coinStr string) (Coin, error)

ParseCoin parses a coin string and panics if it is invalid.

func (*Coin) Descriptor added in v0.41.0

func (*Coin) Descriptor() ([]byte, []int)

func (Coin) Equals

func (c Coin) Equals(cc Coin) bool

Equals compare two coins to see whether they represent the same information

func (Coin) IsEmpty

func (c Coin) IsEmpty() bool

IsEmpty check whether asset is empty or amount is zero

func (Coin) IsNative

func (c Coin) IsNative() bool

IsNative check whether the coin is native on THORChain

func (*Coin) Marshal added in v0.41.0

func (m *Coin) Marshal() (dAtA []byte, err error)

func (*Coin) MarshalTo added in v0.41.0

func (m *Coin) MarshalTo(dAtA []byte) (int, error)

func (*Coin) MarshalToSizedBuffer added in v0.41.0

func (m *Coin) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (Coin) Native

func (c Coin) Native() (cosmos.Coin, error)

Native create a new instance of cosmos.Coin

func (*Coin) ProtoMessage added in v0.41.0

func (*Coin) ProtoMessage()

func (*Coin) Reset added in v0.41.0

func (m *Coin) Reset()

func (*Coin) Size added in v0.41.0

func (m *Coin) Size() (n int)

func (Coin) String

func (c Coin) String() string

String implement fmt.Stringer

func (*Coin) Unmarshal added in v0.41.0

func (m *Coin) Unmarshal(dAtA []byte) error

func (Coin) Valid

func (c Coin) Valid() error

Valid return an error if the coin is not correct

func (Coin) WithDecimals added in v0.41.0

func (c Coin) WithDecimals(decimal int64) Coin

WithDecimals update coin with a decimal

func (*Coin) XXX_DiscardUnknown added in v0.41.0

func (m *Coin) XXX_DiscardUnknown()

func (*Coin) XXX_Marshal added in v0.41.0

func (m *Coin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Coin) XXX_Merge added in v0.41.0

func (m *Coin) XXX_Merge(src proto.Message)

func (*Coin) XXX_Size added in v0.41.0

func (m *Coin) XXX_Size() int

func (*Coin) XXX_Unmarshal added in v0.41.0

func (m *Coin) XXX_Unmarshal(b []byte) error

type Coins

type Coins []Coin

Coins represent a slice of Coin

func NewCoins added in v0.41.0

func NewCoins(coins ...Coin) Coins

NewCoins create a new Coins structure

func (Coins) Add added in v0.41.0

func (oldCoins Coins) Add(addCoins ...Coin) Coins

func (Coins) Add_deprecated added in v1.129.0

func (cs Coins) Add_deprecated(coin Coin) Coins

This overwrites cs by changing its slice-referenced values (when and only when there is a shared Asset), so it is recommended to use destination := NewCoins(source...) first. NOTE: **DEPRECATED** - do not use. TODO: remove usage of this on hard fork.

func (Coins) Adds_deprecated added in v1.121.0

func (cs Coins) Adds_deprecated(coins Coins) Coins

This overwrites cs by changing its slice-referenced values, so it is recommended to use destination := NewCoins(source...) first. NOTE: **DEPRECATED** - do not use. TODO: remove usage of this on hard fork.

func (Coins) Contains

func (cs Coins) Contains(c Coin) bool

Contains check whether the given coin is in the list

func (Coins) Copy added in v1.118.0

func (cs Coins) Copy() Coins

Copy returns a new copy of Coins.

func (Coins) Distinct added in v0.41.0

func (cs Coins) Distinct() Coins

Distinct return a new Coins ,which duplicated coins had been removed

func (Coins) EqualsEx added in v0.65.0

func (cs Coins) EqualsEx(cs2 Coins) bool

EqualsEx Check if two lists of coins are equal to each other. This method will make a copy of cs1 & cs2 , thus the original coins order will not be changed

func (Coins) Equals_deprecated added in v1.121.0

func (cs Coins) Equals_deprecated(cs2 Coins) bool

Equals checks if two lists of coins are equal to each other - order does not matter. This method has a side effect of sorting the input parameters. Since this is already used, it cannot be changed without causing consensus failure. TODO: Deprecated, remove on hard fork.

func (Coins) GetCoin

func (cs Coins) GetCoin(asset Asset) Coin

GetCoin gets a specific coin by asset. Assumes there is only one of this coin in the list.

func (Coins) HasNoneNativeRune added in v0.41.0

func (cs Coins) HasNoneNativeRune() bool

HasNoneNativeRune check whether the coins contains NoneNativeRUNE

At the moment, there are BEP2 RUNE, ERC20 RUNE and Native RUNE

func (Coins) HasSynthetic added in v0.55.0

func (cs Coins) HasSynthetic() bool

HasSynthetic check whether the coins contains synth coin

func (Coins) IsEmpty

func (cs Coins) IsEmpty() bool

func (Coins) Native

func (cs Coins) Native() (cosmos.Coins, error)

func (Coins) NoneEmpty added in v0.54.0

func (cs Coins) NoneEmpty() Coins

NoneEmpty return a new Coins , which ignore the coin that is empty either Coin asset is empty or amount is empty

func (Coins) SafeSub added in v1.115.0

func (oldCoins Coins) SafeSub(subCoins ...Coin) Coins

func (Coins) SafeSub_deprecated added in v1.129.0

func (cs Coins) SafeSub_deprecated(coin Coin) Coins

This overwrites cs by changing its slice-referenced values, so it is recommended to use destination := NewCoins(source...) first. NOTE: **DEPRECATED** - do not use. TODO: remove usage of this on hard fork.

func (Coins) String

func (cs Coins) String() string

String implement fmt.Stringer

func (Coins) Valid

func (cs Coins) Valid() error

Valid check whether all the coins are valid , if not , then return an error

type Fee

type Fee struct {
	Coins      Coins                                   `protobuf:"bytes,1,rep,name=coins,proto3,castrepeated=Coins" json:"coins"`
	PoolDeduct github_com_cosmos_cosmos_sdk_types.Uint `` /* 132-byte string literal not displayed */
}

func NewFee

func NewFee(coins Coins, poolDeduct cosmos.Uint) Fee

NewFee return a new instance of Fee

func (*Fee) Descriptor added in v0.41.0

func (*Fee) Descriptor() ([]byte, []int)

func (*Fee) Marshal added in v0.41.0

func (m *Fee) Marshal() (dAtA []byte, err error)

func (*Fee) MarshalTo added in v0.41.0

func (m *Fee) MarshalTo(dAtA []byte) (int, error)

func (*Fee) MarshalToSizedBuffer added in v0.41.0

func (m *Fee) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Fee) ProtoMessage added in v0.41.0

func (*Fee) ProtoMessage()

func (*Fee) Reset added in v0.41.0

func (m *Fee) Reset()

func (*Fee) Size added in v0.41.0

func (m *Fee) Size() (n int)

func (Fee) String added in v0.41.0

func (f Fee) String() string

func (*Fee) Unmarshal added in v0.41.0

func (m *Fee) Unmarshal(dAtA []byte) error

func (*Fee) XXX_DiscardUnknown added in v0.41.0

func (m *Fee) XXX_DiscardUnknown()

func (*Fee) XXX_Marshal added in v0.41.0

func (m *Fee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Fee) XXX_Merge added in v0.41.0

func (m *Fee) XXX_Merge(src proto.Message)

func (*Fee) XXX_Size added in v0.41.0

func (m *Fee) XXX_Size() int

func (*Fee) XXX_Unmarshal added in v0.41.0

func (m *Fee) XXX_Unmarshal(b []byte) error

type Gas

type Gas Coins

Gas coins

func CalcBinanceGasPrice

func CalcBinanceGasPrice(tx Tx, asset Asset, units []cosmos.Uint) Gas

CalcBinanceGasPrice calculate gas price for Binance chain

func GetEVMGasFee added in v1.111.0

func GetEVMGasFee(chain Chain, gasPrice *big.Int, msgLen uint64) Gas

func MakeEVMGas added in v1.111.0

func MakeEVMGas(chain Chain, gasPrice *big.Int, gas uint64) Gas

func (Gas) Add

func (gas Gas) Add(addCoins ...Coin) Gas

Coins Add for Gas.

func (Gas) Adds_deprecated added in v1.129.0

func (g Gas) Adds_deprecated(g2 Gas) Gas

Add combines two gas objects into one, adding amounts where needed or appending new coins. **WARNING**: dangerous, returns self-reference and also self-modifies

func (Gas) Equals

func (g Gas) Equals(gas2 Gas) bool

Equals Check if two lists of coins are equal to each other. Order does not matter

func (Gas) IsEmpty

func (g Gas) IsEmpty() bool

IsEmpty return true as long as there is one coin in it that is not empty

func (Gas) NoneEmpty added in v1.122.0

func (g Gas) NoneEmpty() Gas

NoneEmpty returns a new Gas which ignores any coin which is empty either Coin asset is empty or amount is empty

func (Gas) SafeSub added in v1.129.0

func (gas Gas) SafeSub(subCoins ...Coin) Gas

Coins SafeSub for Gas.

func (Gas) ToCoins

func (g Gas) ToCoins() Coins

ToCoins convert the gas to Coins

func (Gas) Valid

func (g Gas) Valid() error

Valid return nil when it is valid, otherwise return an error

type Invariant added in v1.117.0

type Invariant func(ctx cosmos.Context) (msg []string, broken bool)

An Invariant is a function which tests a particular invariant. The invariant returns a descriptive message about what happened and a boolean indicating whether the invariant has been broken.

type InvariantRoute added in v1.117.0

type InvariantRoute struct {
	Route     string
	Invariant Invariant
}

invariant route

func NewInvariantRoute added in v1.117.0

func NewInvariantRoute(route string, invariant Invariant) InvariantRoute

NewInvariantRoute - create an InvariantRoute object

type ProtoUint added in v1.121.0

type ProtoUint struct {
	Value github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,1,opt,name=value,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"value"`
}

func (*ProtoUint) Descriptor added in v1.121.0

func (*ProtoUint) Descriptor() ([]byte, []int)

func (*ProtoUint) Marshal added in v1.121.0

func (m *ProtoUint) Marshal() (dAtA []byte, err error)

func (*ProtoUint) MarshalTo added in v1.121.0

func (m *ProtoUint) MarshalTo(dAtA []byte) (int, error)

func (*ProtoUint) MarshalToSizedBuffer added in v1.121.0

func (m *ProtoUint) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ProtoUint) ProtoMessage added in v1.121.0

func (*ProtoUint) ProtoMessage()

func (*ProtoUint) Reset added in v1.121.0

func (m *ProtoUint) Reset()

func (*ProtoUint) Size added in v1.121.0

func (m *ProtoUint) Size() (n int)

func (*ProtoUint) String added in v1.121.0

func (this *ProtoUint) String() string

func (*ProtoUint) Unmarshal added in v1.121.0

func (m *ProtoUint) Unmarshal(dAtA []byte) error

func (*ProtoUint) XXX_DiscardUnknown added in v1.121.0

func (m *ProtoUint) XXX_DiscardUnknown()

func (*ProtoUint) XXX_Marshal added in v1.121.0

func (m *ProtoUint) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ProtoUint) XXX_Merge added in v1.121.0

func (m *ProtoUint) XXX_Merge(src proto.Message)

func (*ProtoUint) XXX_Size added in v1.121.0

func (m *ProtoUint) XXX_Size() int

func (*ProtoUint) XXX_Unmarshal added in v1.121.0

func (m *ProtoUint) XXX_Unmarshal(b []byte) error

type PubKey

type PubKey string

PubKey used in thorchain, it should be bech32 encoded string thus it will be something like tthorpub1addwnpepqt7qug8vk9r3saw8n4r803ydj2g3dqwx0mvq5akhnze86fc536xcycgtrnv tthorpub1addwnpepqdqvd4r84lq9m54m5kk9sf4k6kdgavvch723pcgadulxd6ey9u70k6zq8qe

func NewPubKey

func NewPubKey(key string) (PubKey, error)

NewPubKey create a new instance of PubKey key is bech32 encoded string

func NewPubKeyFromCrypto

func NewPubKeyFromCrypto(pk crypto.PubKey) (PubKey, error)

NewPubKeyFromCrypto

func (PubKey) EVMPubkeyToAddress added in v1.95.0

func (pubKey PubKey) EVMPubkeyToAddress() (Address, error)

EVMPubkeyToAddress converts a pubkey of an EVM chain to the corresponding address

func (PubKey) Equals

func (pubKey PubKey) Equals(pubKey1 PubKey) bool

Equals check whether two are the same

func (PubKey) GetAddress

func (pubKey PubKey) GetAddress(chain Chain) (Address, error)

GetAddress will return an address for the given chain

func (PubKey) GetThorAddress

func (pubKey PubKey) GetThorAddress() (cosmos.AccAddress, error)

func (PubKey) IsEmpty

func (pubKey PubKey) IsEmpty() bool

IsEmpty to check whether it is empty

func (PubKey) MarshalJSON

func (pubKey PubKey) MarshalJSON() ([]byte, error)

MarshalJSON to Marshals to JSON using Bech32

func (PubKey) String

func (pubKey PubKey) String() string

String stringer implementation

func (*PubKey) UnmarshalJSON

func (pubKey *PubKey) UnmarshalJSON(data []byte) error

UnmarshalJSON to Unmarshal from JSON assuming Bech32 encoding

type PubKeySet

type PubKeySet struct {
	Secp256k1 PubKey `protobuf:"bytes,1,opt,name=secp256k1,proto3,casttype=PubKey" json:"secp256k1,omitempty"`
	Ed25519   PubKey `protobuf:"bytes,2,opt,name=ed25519,proto3,casttype=PubKey" json:"ed25519,omitempty"`
}

PubKeySet contains two pub keys , secp256k1 and ed25519

func NewPubKeySet

func NewPubKeySet(secp256k1, ed25519 PubKey) PubKeySet

NewPubKeySet create a new instance of PubKeySet , which contains two keys

func (PubKeySet) Contains

func (pks PubKeySet) Contains(pk PubKey) bool

func (*PubKeySet) Descriptor added in v0.41.0

func (*PubKeySet) Descriptor() ([]byte, []int)

func (PubKeySet) Equals

func (pks PubKeySet) Equals(pks1 PubKeySet) bool

Equals check whether two PubKeySet are the same

func (PubKeySet) GetAddress

func (pks PubKeySet) GetAddress(chain Chain) (Address, error)

GetAddress

func (PubKeySet) IsEmpty

func (pks PubKeySet) IsEmpty() bool

IsEmpty will determinate whether PubKeySet is an empty

func (*PubKeySet) Marshal added in v0.41.0

func (m *PubKeySet) Marshal() (dAtA []byte, err error)

func (*PubKeySet) MarshalTo added in v0.41.0

func (m *PubKeySet) MarshalTo(dAtA []byte) (int, error)

func (*PubKeySet) MarshalToSizedBuffer added in v0.41.0

func (m *PubKeySet) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PubKeySet) ProtoMessage added in v0.41.0

func (*PubKeySet) ProtoMessage()

func (*PubKeySet) Reset added in v0.41.0

func (m *PubKeySet) Reset()

func (*PubKeySet) Size added in v0.41.0

func (m *PubKeySet) Size() (n int)

func (PubKeySet) String

func (pks PubKeySet) String() string

String implement fmt.Stinger

func (*PubKeySet) Unmarshal added in v0.41.0

func (m *PubKeySet) Unmarshal(dAtA []byte) error

func (*PubKeySet) XXX_DiscardUnknown added in v0.41.0

func (m *PubKeySet) XXX_DiscardUnknown()

func (*PubKeySet) XXX_Marshal added in v0.41.0

func (m *PubKeySet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PubKeySet) XXX_Merge added in v0.41.0

func (m *PubKeySet) XXX_Merge(src proto.Message)

func (*PubKeySet) XXX_Size added in v0.41.0

func (m *PubKeySet) XXX_Size() int

func (*PubKeySet) XXX_Unmarshal added in v0.41.0

func (m *PubKeySet) XXX_Unmarshal(b []byte) error

type PubKeys

type PubKeys []PubKey

PubKey used in thorchain, it should be bech32 encoded string thus it will be something like tthorpub1addwnpepqt7qug8vk9r3saw8n4r803ydj2g3dqwx0mvq5akhnze86fc536xcycgtrnv tthorpub1addwnpepqdqvd4r84lq9m54m5kk9sf4k6kdgavvch723pcgadulxd6ey9u70k6zq8qe

func (PubKeys) Addresses added in v1.120.0

func (pks PubKeys) Addresses() ([]cosmos.AccAddress, error)

func (PubKeys) Contains

func (pks PubKeys) Contains(pk PubKey) bool

func (PubKeys) Equals added in v0.68.0

func (pks PubKeys) Equals(newPks PubKeys) bool

Equals check whether two pub keys are identical

func (PubKeys) String

func (pks PubKeys) String() string

String implement stringer interface

func (PubKeys) Strings added in v0.41.0

func (pks PubKeys) Strings() []string

func (PubKeys) Valid

func (pks PubKeys) Valid() error

type SigningAlgo added in v1.83.0

type SigningAlgo string

type Symbol

type Symbol string

Symbol represent an asset

func NewSymbol

func NewSymbol(input string) (Symbol, error)

NewSymbol parse the input as symbol

func (Symbol) Equals

func (s Symbol) Equals(s2 Symbol) bool

Equals check whether two symbol are the same

func (Symbol) IsEmpty

func (s Symbol) IsEmpty() bool

IsEmpty return true when symbol is just empty string

func (Symbol) IsMiniToken

func (s Symbol) IsMiniToken() bool

IsMiniToken is to determine whether it is a mini token on binance chain

func (Symbol) String

func (s Symbol) String() string

String implement fmt.Stringer

func (Symbol) Ticker

func (s Symbol) Ticker() Ticker

Ticker return the ticker part of symbol

type Ticker

type Ticker string

Ticker The trading 'symbol' or shortened name (typically in capital letters) that refer to a coin on a trading platform. For example: BNB

func NewTicker

func NewTicker(ticker string) (Ticker, error)

NewTicker parse the given string as ticker, return error if it is not legitimate ticker

func (Ticker) Equals

func (t Ticker) Equals(t2 Ticker) bool

Equals compare whether two ticker is the same

func (Ticker) IsEmpty

func (t Ticker) IsEmpty() bool

IsEmpty return true when the ticker is an empty string

func (Ticker) String

func (t Ticker) String() string

String implement fmt.Stringer

type Tickers

type Tickers []Ticker

Tickers a list of ticker

type Tx

type Tx struct {
	ID          TxID    `protobuf:"bytes,1,opt,name=id,proto3,casttype=TxID" json:"id,omitempty"`
	Chain       Chain   `protobuf:"bytes,2,opt,name=chain,proto3,casttype=Chain" json:"chain,omitempty"`
	FromAddress Address `protobuf:"bytes,3,opt,name=from_address,json=fromAddress,proto3,casttype=Address" json:"from_address,omitempty"`
	ToAddress   Address `protobuf:"bytes,4,opt,name=to_address,json=toAddress,proto3,casttype=Address" json:"to_address,omitempty"`
	Coins       Coins   `protobuf:"bytes,5,rep,name=coins,proto3,castrepeated=Coins" json:"coins"`
	Gas         Gas     `protobuf:"bytes,6,rep,name=gas,proto3,castrepeated=Gas" json:"gas"`
	Memo        string  `protobuf:"bytes,7,opt,name=memo,proto3" json:"memo,omitempty"`
}

func GetRagnarokTx

func GetRagnarokTx(chain Chain, fromAddr, toAddr Address) Tx

GetRagnarokTx return a tx used for ragnarok

func NewTx

func NewTx(txID TxID, from, to Address, coins Coins, gas Gas, memo string) Tx

NewTx create a new instance of Tx based on the input information

func (*Tx) Descriptor added in v0.41.0

func (*Tx) Descriptor() ([]byte, []int)

func (Tx) Equals

func (tx Tx) Equals(tx2 Tx) bool

Equals compares two Txs to see whether they represent the same Tx. This method has a side effect of sorting the input parameters. Since this is already used, it cannot be changed without causing consensus failure. TODO: Deprecated, remove on hard fork.

func (Tx) EqualsEx added in v0.65.0

func (tx Tx) EqualsEx(tx2 Tx) bool

EqualsEx compare two Tx to see whether they represent the same Tx This method will not change the original tx & tx2

func (Tx) Hash_deprecated added in v1.131.0

func (tx Tx) Hash_deprecated() string

Hash_deprecated calculates a hash only based on from address and to address

func (Tx) IsEmpty

func (tx Tx) IsEmpty() bool

IsEmpty check whether the ID field is empty or not

func (*Tx) Marshal added in v0.41.0

func (m *Tx) Marshal() (dAtA []byte, err error)

func (*Tx) MarshalTo added in v0.41.0

func (m *Tx) MarshalTo(dAtA []byte) (int, error)

func (*Tx) MarshalToSizedBuffer added in v0.41.0

func (m *Tx) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*Tx) ProtoMessage added in v0.41.0

func (*Tx) ProtoMessage()

func (*Tx) Reset added in v0.41.0

func (m *Tx) Reset()

func (*Tx) Size added in v0.41.0

func (m *Tx) Size() (n int)

func (Tx) String

func (tx Tx) String() string

String implement fmt.Stringer return a string representation of the tx

func (Tx) ToAttributes

func (tx Tx) ToAttributes() []cosmos.Attribute

ToAttributes push all the tx fields into a slice of cosmos Attribute(key value pairs)

func (*Tx) Unmarshal added in v0.41.0

func (m *Tx) Unmarshal(dAtA []byte) error

func (Tx) Valid

func (tx Tx) Valid() error

Valid do some data sanity check , if the tx contains invalid information it will return an none nil error

func (*Tx) XXX_DiscardUnknown added in v0.41.0

func (m *Tx) XXX_DiscardUnknown()

func (*Tx) XXX_Marshal added in v0.41.0

func (m *Tx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Tx) XXX_Merge added in v0.41.0

func (m *Tx) XXX_Merge(src proto.Message)

func (*Tx) XXX_Size added in v0.41.0

func (m *Tx) XXX_Size() int

func (*Tx) XXX_Unmarshal added in v0.41.0

func (m *Tx) XXX_Unmarshal(b []byte) error

type TxID

type TxID string

TxID is a string that can uniquely represent a transaction on different block chain

func NewTxID

func NewTxID(hash string) (TxID, error)

NewTxID parse the input hash as TxID

func (TxID) Equals

func (tx TxID) Equals(tx2 TxID) bool

Equals check whether two TxID are the same

func (TxID) Int64 added in v1.124.0

func (tx TxID) Int64() int64

func (TxID) IsBlank added in v1.116.0

func (tx TxID) IsBlank() bool

func (TxID) IsEmpty

func (tx TxID) IsEmpty() bool

IsEmpty return true when the tx represent empty string

func (TxID) Reverse added in v1.107.0

func (tx TxID) Reverse() TxID

Reverse returns a reversed version of the TxID

func (TxID) String

func (tx TxID) String() string

String implement fmt.Stringer

type TxIDs

type TxIDs []TxID

TxIDs is a slice of TxID

type Txs

type Txs []Tx

Txs a list of Tx

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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