types

package
v1.109.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

Please put all the test related function to here

Index

Constants

View Source
const (
	// ModuleName name of BASEChain module
	ModuleName = "mayachain"
	// DefaultCodespace is the same as ModuleName
	DefaultCodespace = ModuleName
	// ReserveName the module account name to keep reserve
	ReserveName = "reserve"
	// AsgardName the module account name to keep asgard fund
	AsgardName = "asgard"
	// BondName the name of account used to store bond
	BondName = "bond"
	// MayaFund the module account name to keep the maya fund
	MayaFund = "maya_fund"

	// StoreKey to be used when creating the KVStore
	StoreKey = ModuleName
	// RouterKey used in the RPC query
	RouterKey = ModuleName // this was defined in your key.go file
)
View Source
const (
	AddLiquidityEventType      = "add_liquidity"
	BondEventType              = "bond"
	DonateEventType            = "donate"
	ErrataEventType            = "errata"
	FeeEventType               = "fee"
	GasEventType               = "gas"
	OutboundEventType          = "outbound"
	PendingLiquidity           = "pending_liquidity"
	PoolBalanceChangeEventType = "pool_balance_change"
	PoolEventType              = "pool"
	RefundEventType            = "refund"
	ReserveEventType           = "reserve"
	RewardEventType            = "rewards"
	ScheduledOutboundEventType = "scheduled_outbound"
	SecurityEventType          = "security"
	SetMimirEventType          = "set_mimir"
	SetNodeMimirEventType      = "set_node_mimir"
	SlashEventType             = "slash"
	SlashLiquidityEventType    = "slash_liquidity"
	SlashPointEventType        = "slash_points"
	SwapEventType              = "swap"
	SwitchEventType            = "switch"
	MAYANameEventType          = "mayaname"
	TSSKeygenMetricEventType   = "tss_keygen"
	TSSKeysignMetricEventType  = "tss_keysign"
	WithdrawEventType          = "withdraw"
)

all event types support by BASEChain

View Source
const (
	// SuperMajorityFactor - super majority 2/3
	SuperMajorityFactor = 3
	// SimpleMajorityFactor - simple majority 1/2
	SimpleMajorityFactor = 2
)
View Source
const DefaultIndex uint64 = 1

DefaultIndex is the default capability global index

View Source
const MaxAffiliateFeeBasisPoints = 1_000

MaxAffiliateFeeBasisPoints basis points for withdrawals

View Source
const MaxWithdrawBasisPoints = 10_000

MaxWithdrawBasisPoints basis points for withdrawals

Variables

View Source
var (
	ModuleCdc = codec.NewAminoCodec(amino)
)

Functions

func GetCurrentVersion

func GetCurrentVersion() semver.Version

GetCurrentVersion - intended for unit tests, fetches the current version of THORNode via `version` file #nosec G304 this is a method only used for test purpose

func GetLiquidityPools added in v1.104.1

func GetLiquidityPools(version semver.Version) common.Assets

func GetRandomAZTECAddress

func GetRandomAZTECAddress() common.Address

GetRandomAZTECAddress will just create a random aztec address used for test purpose

func GetRandomBCHAddress

func GetRandomBCHAddress() common.Address

func GetRandomBNBAddress

func GetRandomBNBAddress() common.Address

GetRandomBNBAddress will just create a random bnb address used for test purpose

func GetRandomBTCAddress

func GetRandomBTCAddress() common.Address

func GetRandomBaseAddress

func GetRandomBaseAddress() common.Address

GetRandomBaseAddress will just create a random base address used for test purpose

func GetRandomBech32Addr

func GetRandomBech32Addr() cosmos.AccAddress

GetRandomBech32Addr is an account address used for test

func GetRandomBech32ConsensusPubKey

func GetRandomBech32ConsensusPubKey() string

func GetRandomDASHAddress added in v1.104.1

func GetRandomDASHAddress() common.Address

func GetRandomDOGEAddress

func GetRandomDOGEAddress() common.Address

func GetRandomETHAddress

func GetRandomETHAddress() common.Address

GetRandomETHAddress get a random ETH address for test purpose

func GetRandomGAIAAddress

func GetRandomGAIAAddress() common.Address

GetRandomGAIAAddress will just create a random terra address used for test purpose

func GetRandomKUJIAddress added in v1.107.0

func GetRandomKUJIAddress() common.Address

GetRandomKUJIAddress will just create a random terra address used for test purpose

func GetRandomLTCAddress

func GetRandomLTCAddress() common.Address

func GetRandomPubKey

func GetRandomPubKey() common.PubKey

func GetRandomPubKeySet

func GetRandomPubKeySet() common.PubKeySet

GetRandomPubKeySet return a random common.PubKeySet for test purpose

func GetRandomTx

func GetRandomTx() common.Tx

GetRandomTx

func GetRandomTxHash

func GetRandomTxHash() common.TxID

GetRandomTxHash create a random txHash used for test purpose

func GetThreshold

func GetThreshold(value int) (int, error)

GetThreshold calculate threshold

func HasMinority

func HasMinority(signers, total int) bool

HasMinority return true when it has more than 1/3

func HasSimpleMajority

func HasSimpleMajority(signers, total int) bool

HasSimpleMajority return true when it has more than 1/2 this method replace HasSimpleMajority, which is not correct

func HasSuperMajority

func HasSuperMajority(signers, total int) bool

HasSuperMajority return true when it has 2/3 majority

func MakeTestCodec

func MakeTestCodec() *codec.LegacyAmino

nolint: deadcode unused create a codec used only for testing

func RegisterCodec

func RegisterCodec(cdc *codec.LegacyAmino)

RegisterCodec register the msg types for amino

func RegisterInterfaces

func RegisterInterfaces(registry cdctypes.InterfaceRegistry)

RegisterInterfaces register the types

func SetupConfigForTest

func SetupConfigForTest()

SetupConfigForTest used for test purpose

Types

type LiquidityAuctionTiers

type LiquidityAuctionTiers []LiquidityAuctionTier

LiquidityAuctionTiers a list of liquidity providers

type LiquidityProviders

type LiquidityProviders []LiquidityProvider

LiquidityProviders a list of liquidity providers

func (LiquidityProviders) SetNodeAccount deprecated

func (lps LiquidityProviders) SetNodeAccount(na cosmos.AccAddress)

Deprecated: do not use

type NodeAccounts

type NodeAccounts []NodeAccount

NodeAccounts just a list of NodeAccount

func (NodeAccounts) Contains

func (nas NodeAccounts) Contains(na NodeAccount) bool

Contains will check whether the given node account is in the list

func (NodeAccounts) GetNodeAddresses

func (nas NodeAccounts) GetNodeAddresses() []cosmos.AccAddress

func (NodeAccounts) IsEmpty

func (nas NodeAccounts) IsEmpty() bool

IsEmpty to check whether the NodeAccounts is empty

func (NodeAccounts) IsNodeKeys

func (nas NodeAccounts) IsNodeKeys(addr cosmos.AccAddress) bool

IsNodeKeys validate whether the given account address belongs to an currently active validator

func (NodeAccounts) Len

func (nas NodeAccounts) Len() int

Len return the number of accounts in it

func (NodeAccounts) Less

func (nas NodeAccounts) Less(i, j int) bool

Less sort interface , it will sort by StatusSince field, and then by SignerBNBAddress

func (NodeAccounts) Swap

func (nas NodeAccounts) Swap(i, j int)

Swap node account

type ObservedTxVoters

type ObservedTxVoters []ObservedTxVoter

ObservedTxVoters a list of observed tx voter

type ObservedTxs

type ObservedTxs []ObservedTx

ObservedTxs a list of ObservedTx

func (ObservedTxs) Contains

func (txs ObservedTxs) Contains(tx ObservedTx) bool

type PoolMods

type PoolMods []PoolMod

PoolMods a list of pool modifications

type Pools

type Pools []Pool

Pools represent a list of pools

func (Pools) Get

func (m Pools) Get(asset common.Asset) (Pool, bool)

func (Pools) Set

func (m Pools) Set(pool Pool) Pools

type QueryBlockResponse added in v1.109.0

type QueryBlockResponse struct {
	openapi.BlockResponse
	Txs []QueryBlockTx `json:"txs"`
}

QueryBlockResponse overrides the openapi type with a custom Txs field for marshaling.

func (QueryBlockResponse) MarshalJSON added in v1.109.0

func (q QueryBlockResponse) MarshalJSON() ([]byte, error)

MarshalJSON custom marshalling to add the custom Tx field.

type QueryBlockTx added in v1.109.0

type QueryBlockTx struct {
	openapi.BlockTx
	Tx json.RawMessage `json:"tx,omitempty"`
}

QueryBlockTx overrides the openapi type with a custom Tx field for marshaling.

func (QueryBlockTx) MarshalJSON added in v1.109.0

func (q QueryBlockTx) MarshalJSON() ([]byte, error)

type QueryChainAddress

type QueryChainAddress struct {
	Chain   common.Chain   `json:"chain"`
	Address common.Address `json:"address"`
}

type QueryChainHeight

type QueryChainHeight struct {
	Chain  common.Chain `json:"chain"`
	Height int64        `json:"height"`
}

QueryChainHeight chain height

type QueryKeygenBlock

type QueryKeygenBlock struct {
	KeygenBlock KeygenBlock `json:"keygen_block"`
	Signature   string      `json:"signature"`
}

QueryKeygenBlock query keygen, displays signed keygen requests

func (QueryKeygenBlock) String

func (n QueryKeygenBlock) String() string

String implement fmt.Stringer

type QueryKeysign

type QueryKeysign struct {
	Keysign   TxOut  `json:"keysign"`
	Signature string `json:"signature"`
}

QueryKeysign query keysign result

type QueryLiquidityProvider added in v1.108.0

type QueryLiquidityProvider struct {
	Asset              common.Asset   `json:"asset"`
	CacaoAddress       common.Address `json:"cacao_address,omitempty"`
	AssetAddress       common.Address `json:"asset_address,omitempty"`
	LastAddHeight      int64          `json:"last_add_height,omitempty"`
	LastWithdrawHeight int64          `json:"last_withdraw_height,omitempty"`
	Units              cosmos.Uint    `json:"units"`
	PendingCacao       cosmos.Uint    `json:"pending_cacao"`
	PendingAsset       cosmos.Uint    `json:"pending_asset"`
	PendingTxId        string         `json:"pending_tx_id,omitempty"`
	CacaoDepositValue  cosmos.Uint    `json:"cacao_deposit_value"`
	AssetDepositValue  cosmos.Uint    `json:"asset_deposit_value"`
	// Deprecated
	NodeBondAddress           *string        `json:"node_bond_address,omitempty"`
	WithdrawCounter           string         `json:"withdraw_counter"`
	LastWithdrawCounterHeight *int64         `json:"last_withdraw_counter_height,omitempty"`
	BondedNodes               []LPBondedNode `json:"bonded_nodes"`
	CacaoRedeemValue          cosmos.Uint    `json:"cacao_redeem_value"`
	AssetRedeemValue          cosmos.Uint    `json:"asset_redeem_value"`
	LuviDepositValue          cosmos.Uint    `json:"luvi_deposit_value"`
	LuviRedeemValue           cosmos.Uint    `json:"luvi_redeem_value"`
	LuviGrowthPct             cosmos.Dec     `json:"luvi_growth_pct"`
}

QueryLiquidityProvider holds all the information related to a liquidity provider

func NewQueryLiquidityProvider added in v1.108.0

func NewQueryLiquidityProvider(lp LiquidityProvider, pool Pool, synthSupply cosmos.Uint, version semver.Version) QueryLiquidityProvider

NewQueryLiquidityProvider creates a new QueryLiquidityProvider based on the given liquidity provider and pool

type QueryNodeAccount

type QueryNodeAccount struct {
	NodeAddress         cosmos.AccAddress              `json:"node_address"`
	Status              NodeStatus                     `json:"status"`
	PubKeySet           common.PubKeySet               `json:"pub_key_set"`
	AztecAddress        common.Address                 `json:"aztec_address"`
	ValidatorConsPubKey string                         `json:"validator_cons_pub_key"`
	PeerID              string                         `json:"peer_id"`
	Bond                cosmos.Uint                    `json:"bond"`
	Reward              cosmos.Uint                    `json:"reward"`
	ActiveBlockHeight   int64                          `json:"active_block_height"`
	BondAddress         common.Address                 `json:"bond_address"`
	StatusSince         int64                          `json:"status_since"`
	SignerMembership    common.PubKeys                 `json:"signer_membership"`
	RequestedToLeave    bool                           `json:"requested_to_leave"`
	ForcedToLeave       bool                           `json:"forced_to_leave"`
	LeaveScore          uint64                         `json:"leave_height"`
	IPAddress           string                         `json:"ip_address"`
	Version             semver.Version                 `json:"version"`
	SlashPoints         int64                          `json:"slash_points"`
	Jail                Jail                           `json:"jail"`
	ObserveChains       []QueryChainHeight             `json:"observe_chains"`
	PreflightStatus     QueryNodeAccountPreflightCheck `json:"preflight_status"`
	BondProviders       BondProviders                  `json:"bond_providers"`
}

QueryNodeAccount hold all the information related to node account

func NewQueryNodeAccount

func NewQueryNodeAccount(na NodeAccount, naBond cosmos.Uint) QueryNodeAccount

NewQueryNodeAccount create a new QueryNodeAccount based on the given node account parameter

type QueryNodeAccountPreflightCheck

type QueryNodeAccountPreflightCheck struct {
	Status      NodeStatus `json:"status"`
	Description string     `json:"reason"`
	Code        int        `json:"code"`
}

QueryNodeAccountPreflightCheck is structure to hold all the information need to return to client include current node status , and whether it might get churned in next

func (QueryNodeAccountPreflightCheck) String

String implement fmt.Stringer

type QueryQueue

type QueryQueue struct {
	Swap                   int64       `json:"swap"`
	Outbound               int64       `json:"outbound"`
	Internal               int64       `json:"internal"`
	ScheduledOutboundValue cosmos.Uint `json:"scheduled_outbound_value"`
}

QueryQueue a struct store the total outstanding out items

func (QueryQueue) String

func (h QueryQueue) String() string

String implement fmt.Stringer

type QueryResLastBlockHeights

type QueryResLastBlockHeights struct {
	Chain            common.Chain `json:"chain"`
	LastChainHeight  int64        `json:"last_observed_in"`
	LastSignedHeight int64        `json:"last_signed_out"`
	Mayachain        int64        `json:"mayachain"`
}

QueryResLastBlockHeights used to return the block height query

func (QueryResLastBlockHeights) String

func (h QueryResLastBlockHeights) String() string

String implement fmt.Stringer return a string representation of QueryResLastBlockHeights

type QuerySaver added in v1.108.0

type QuerySaver struct {
	Asset              common.Asset   `json:"asset"`
	AssetAddress       common.Address `json:"asset_address"`
	LastAddHeight      int64          `json:"last_add_height,omitempty"`
	LastWithdrawHeight int64          `json:"last_withdraw_height,omitempty"`
	Units              cosmos.Uint    `json:"units"`
	AssetDepositValue  cosmos.Uint    `json:"asset_deposit_value"`
	AssetRedeemValue   cosmos.Uint    `json:"asset_redeem_value"`
	GrowthPct          cosmos.Dec     `json:"growth_pct"`
}

QuerySaver holds all the information related to a saver

func NewQuerySaver added in v1.108.0

func NewQuerySaver(lp LiquidityProvider, pool Pool) QuerySaver

NewQuerySaver creates a new QuerySaver based on the given liquidity provider parameters and pool

type QueryTxOutItem

type QueryTxOutItem struct {
	Chain       common.Chain   `json:"chain"`
	ToAddress   common.Address `json:"to_address"`
	VaultPubKey common.PubKey  `json:"vault_pub_key,omitempty"`
	Coin        common.Coin    `json:"coin"`
	Memo        string         `json:"memo,omitempty"`
	MaxGas      common.Gas     `json:"max_gas"`
	GasRate     int64          `json:"gas_rate,omitempty"`
	InHash      common.TxID    `json:"in_hash,omitempty"`
	OutHash     common.TxID    `json:"out_hash,omitempty"`
	Height      int64          `json:"height"`
}

func NewQueryTxOutItem

func NewQueryTxOutItem(toi TxOutItem, height int64) QueryTxOutItem

NewQueryTxOutItem create a new QueryTxOutItem based on the given txout item parameter

type QueryVaultPubKeyContract

type QueryVaultPubKeyContract struct {
	PubKey  common.PubKey   `json:"pub_key"`
	Routers []ChainContract `json:"routers"`
}

QueryVaultPubKeyContract is a type to combine PubKey and it's related contract

type QueryVaultResp

type QueryVaultResp struct {
	BlockHeight           int64                                       `json:"block_height,omitempty"`
	PubKey                gitlab_com_thorchain_thornode_common.PubKey `json:"pub_key,omitempty"`
	Coins                 gitlab_com_thorchain_thornode_common.Coins  `json:"coins"`
	Type                  VaultType                                   `json:"type,omitempty"`
	Status                VaultStatus                                 `json:"status,omitempty"`
	StatusSince           int64                                       `json:"status_since,omitempty"`
	Membership            []string                                    `json:"membership,omitempty"`
	Chains                []string                                    `json:"chains,omitempty"`
	InboundTxCount        int64                                       `json:"inbound_tx_count,omitempty"`
	OutboundTxCount       int64                                       `json:"outbound_tx_count,omitempty"`
	PendingTxBlockHeights []int64                                     `json:"pending_tx_block_heights,omitempty"`
	Routers               []ChainContract                             `json:"routers"`
	Addresses             []QueryChainAddress                         `json:"addresses"`
	Frozen                []string                                    `json:"frozen,omitempty"`
}

QueryVaultResp used represent the informat return to client for query asgard

type QueryVaultsPubKeys

type QueryVaultsPubKeys struct {
	Asgard    []QueryVaultPubKeyContract `json:"asgard"`
	Yggdrasil []QueryVaultPubKeyContract `json:"yggdrasil"`
}

QueryVaultsPubKeys represent the result for query vaults pubkeys

type QueryVersion

type QueryVersion struct {
	Current semver.Version `json:"current"`
	Next    semver.Version `json:"next"`
	Querier semver.Version `json:"querier"`
}

type QueryYggdrasilVaults

type QueryYggdrasilVaults struct {
	BlockHeight           int64                                       `json:"block_height,omitempty"`
	PubKey                gitlab_com_thorchain_thornode_common.PubKey `json:"pub_key,omitempty"`
	Coins                 gitlab_com_thorchain_thornode_common.Coins  `json:"coins"`
	Type                  VaultType                                   `json:"type,omitempty"`
	StatusSince           int64                                       `json:"status_since,omitempty"`
	Membership            []string                                    `json:"membership,omitempty"`
	Chains                []string                                    `json:"chains,omitempty"`
	InboundTxCount        int64                                       `json:"inbound_tx_count,omitempty"`
	OutboundTxCount       int64                                       `json:"outbound_tx_count,omitempty"`
	PendingTxBlockHeights []int64                                     `json:"pending_tx_block_heights,omitempty"`
	Routers               []ChainContract                             `json:"routers"`
	Status                NodeStatus                                  `json:"status"`
	Bond                  cosmos.Uint                                 `json:"bond"`
	TotalValue            cosmos.Uint                                 `json:"total_value"`
	Addresses             []QueryChainAddress                         `json:"addresses"`
}

QueryYggdrasilVaults query yggdrasil vault result

type ReserveContributors

type ReserveContributors []ReserveContributor

ReserveContributors a list of reserve contributors

func (ReserveContributors) Add

func (reses ReserveContributors) Add(res ReserveContributor) ReserveContributors

Add the given reserve contributor to list

type Vaults

type Vaults []Vault

Vaults a list of vault

func (Vaults) Has

func (vs Vaults) Has(target common.Coin) Vaults

Has return vaults that have that amount of coins in it

func (Vaults) HasAddress

func (vs Vaults) HasAddress(chain common.Chain, address common.Address) (bool, error)

HasAddress will go through the vaults to determinate whether any of the vault match the given address on the given chain

func (Vaults) SelectByMaxCoin

func (vs Vaults) SelectByMaxCoin(asset common.Asset) (vault Vault)

SelectByMaxCoin return the vault that has most of given asset

func (Vaults) SelectByMinCoin

func (vs Vaults) SelectByMinCoin(asset common.Asset) (vault Vault)

SelectByMinCoin return the vault that has least of given asset

func (Vaults) SortBy

func (vs Vaults) SortBy(sortBy common.Asset) Vaults

SortBy order coins by the given asset

Jump to

Keyboard shortcuts

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